Revision: 4956 http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4956&view=rev Author: ossman_ Date: 2012-08-17 13:37:42 +0000 (Fri, 17 Aug 2012) Log Message: ----------- A CGImage is read-only, but it just happened to work anyway. Until 10.8 that is. Do it the documented way by having a CGBitmapContext instead.
Modified Paths: -------------- trunk/vncviewer/OSXPixelBuffer.cxx trunk/vncviewer/OSXPixelBuffer.h Modified: trunk/vncviewer/OSXPixelBuffer.cxx =================================================================== --- trunk/vncviewer/OSXPixelBuffer.cxx 2012-08-17 09:04:28 UTC (rev 4955) +++ trunk/vncviewer/OSXPixelBuffer.cxx 2012-08-17 13:37:42 UTC (rev 4956) @@ -40,29 +40,24 @@ ManagedPixelBuffer(rfb::PixelFormat(32, 24, false, true, 255, 255, 255, 16, 8, 0), width, height), - image(NULL) + bitmap(NULL) { CGColorSpaceRef lut; - CGDataProviderRef provider; lut = CGColorSpaceCreateDeviceRGB(); assert(lut); - provider = CGDataProviderCreateWithData(NULL, data, datasize, NULL); - assert(provider); - image = CGImageCreate(width, height, 8, 32, width*4, lut, - kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, - provider, NULL, false, kCGRenderingIntentDefault); - assert(image); + bitmap = CGBitmapContextCreate(data, width, height, 8, width*4, lut, + kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little); + assert(bitmap); - CGDataProviderRelease(provider); CGColorSpaceRelease(lut); } PlatformPixelBuffer::~PlatformPixelBuffer() { - CGImageRelease((CGImageRef)image); + CFRelease((CGContextRef)bitmap); } @@ -71,6 +66,7 @@ CGRect rect; CGContextRef gc; CGAffineTransform at; + CGImageRef image; gc = (CGContextRef)fl_gc; @@ -102,7 +98,9 @@ rect.size.width = width(); rect.size.height = -height(); // Negative height does _not_ flip the image - CGContextDrawImage(gc, rect, (CGImageRef)image); + image = CGBitmapContextCreateImage((CGContextRef)bitmap); + CGContextDrawImage(gc, rect, image); + CGImageRelease(image); CGContextRestoreGState(gc); } Modified: trunk/vncviewer/OSXPixelBuffer.h =================================================================== --- trunk/vncviewer/OSXPixelBuffer.h 2012-08-17 09:04:28 UTC (rev 4955) +++ trunk/vncviewer/OSXPixelBuffer.h 2012-08-17 13:37:42 UTC (rev 4956) @@ -29,8 +29,8 @@ void draw(int src_x, int src_y, int x, int y, int w, int h); protected: - // This is really a CGImageRerf, but Apple headers conflict with FLTK - void *image; + // This is really a CGContextRef, but Apple headers conflict with FLTK + void *bitmap; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Tigervnc-commits mailing list Tigervnc-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tigervnc-commits