Author: manolo
Date: 2010-07-03 03:13:22 -0700 (Sat, 03 Jul 2010)
New Revision: 7665
Log:
Fixed fl_copy_offscreen when output goes to a Quartz printer context.
Output to a PostScript context still needs to be fixed.
Modified:
branches/branch-1.3/src/Fl_Double_Window.cxx
Modified: branches/branch-1.3/src/Fl_Double_Window.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Double_Window.cxx 2010-07-01 16:52:47 UTC
(rev 7664)
+++ branches/branch-1.3/src/Fl_Double_Window.cxx 2010-07-03 10:13:22 UTC
(rev 7665)
@@ -188,6 +188,13 @@
return (Fl_Offscreen)ctx;
}
+static void bmProviderRelease (void *src, const void *data, size_t size)
+{
+ CFIndex count = CFGetRetainCount(src);
+ CFRelease(src);
+ if(count == 1) free((void*)data);
+}
+
void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int
srcy) {
CGContextRef src = (CGContextRef)osrc;
void *data = CGBitmapContextGetData(src);
@@ -195,7 +202,10 @@
int sh = CGBitmapContextGetHeight(src);
CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(src);
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
- CGDataProviderRef src_bytes = CGDataProviderCreateWithData( 0L, data,
sw*sh*4, 0L);
+ // when output goes to a Quartz printercontext, release of the bitmap must be
+ // delayed after the end of the print page
+ CFRetain(src);
+ CGDataProviderRef src_bytes = CGDataProviderCreateWithData( src, data,
sw*sh*4, bmProviderRelease);
CGImageRef img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, alpha,
src_bytes, 0L, false, kCGRenderingIntentDefault);
// fl_push_clip();
@@ -211,9 +221,9 @@
void fl_delete_offscreen(Fl_Offscreen ctx) {
if (!ctx) return;
void *data = CGBitmapContextGetData((CGContextRef)ctx);
+ CFIndex count = CFGetRetainCount(ctx);
CGContextRelease((CGContextRef)ctx);
- if (!data) return;
- free(data);
+ if(count == 1) free(data);
}
const int stack_max = 16;
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit