diff options
| author | Manolo Gouy <Manolo> | 2010-03-14 22:21:43 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2010-03-14 22:21:43 +0000 |
| commit | 5e214c1e1da075f19347ec780836a641176e7022 (patch) | |
| tree | 33a43c8b36e11500e4c3da68b0b9e5fe4d75b65e /src | |
| parent | be17e1ccb642891b0b00a6e26d9c79272aed1d9e (diff) | |
Now compiles from Mac OS 10.3 and above
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7268 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Gl_Printer.cxx | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/Fl_Gl_Printer.cxx b/src/Fl_Gl_Printer.cxx index ddea19aca..2e4f89378 100644 --- a/src/Fl_Gl_Printer.cxx +++ b/src/Fl_Gl_Printer.cxx @@ -9,6 +9,11 @@ #include "FL/fl_draw.H" #endif +static void imgProviderReleaseData (void *info, const void *data, size_t size) +{ + free((void *)data); +} + void Fl_Gl_Printer::print_gl_window(Fl_Gl_Window *glw, int x, int y) { #ifdef WIN32 @@ -51,19 +56,23 @@ void Fl_Gl_Printer::print_gl_window(Fl_Gl_Window *glw, int x, int y) #ifdef WIN32 fl_draw_image(baseAddress + (glw->h() - 1) * mByteWidth, x, y , glw->w(), glw->h(), bytesperpixel, - mByteWidth); #elif defined(__APPLE__) - CGColorSpaceRef cSpace = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB); - CGContextRef bitmap = CGBitmapContextCreate(baseAddress, glw->w(), glw->h(), 8, mByteWidth, cSpace, +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4 +#define kCGBitmapByteOrder32Big 0 +#define CGBitmapInfo CGImageAlphaInfo +#endif + CGColorSpaceRef cSpace = CGColorSpaceCreateDeviceRGB(); + CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, baseAddress, mByteWidth * glw->h(), imgProviderReleaseData); + CGImageRef image = CGImageCreate(glw->w(), glw->h(), 8, 8*bytesperpixel, mByteWidth, cSpace, #if __BIG_ENDIAN__ - kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big /* XRGB Big Endian */); + (CGBitmapInfo)(kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Big) /* XRGB Big Endian */ #else - kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little /* XRGB Little Endian */); + kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little /* XRGB Little Endian */ #endif - if(bitmap == NULL) return; - CFRelease(cSpace); - // Make an image out of our bitmap - CGImageRef image = CGBitmapContextCreateImage(bitmap); + , provider, NULL, false, kCGRenderingIntentDefault); + CGColorSpaceRelease(cSpace); + CGDataProviderRelease(provider); + if(image == NULL) return; - CFRelease(bitmap); CGContextSaveGState(fl_gc); int w, h; this->printable_rect(&w, &h); @@ -78,5 +87,7 @@ void Fl_Gl_Printer::print_gl_window(Fl_Gl_Window *glw, int x, int y) #else // FIXME Linux/Unix fl_draw_image(baseAddress + (glw->h() - 1) * mByteWidth, x, y , glw->w(), glw->h(), bytesperpixel, - mByteWidth); #endif // WIN32 +#ifndef __APPLE__ free(baseAddress); +#endif } |
