From eb70e46d2ad340145e48ae7272edb520e6c0d449 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Tue, 21 Apr 2009 09:25:22 +0000 Subject: Fixed gray scale w/alpha image drawing for Mac OS with Quartz (FLTK 1.1 with Quickdraw worked) in src/Fl_Images.cxx. Changed test/unittest_images.cxx to use Fl_RGB_Image::draw() to draw images with alpha channel, because the current version of fl_draw_image() supports alpha channels only on Mac. Tested on Windows[1], Linux, and Mac. [1] Windows with GDI drawing doesn't work yet for gray+alpha (STR 2105). To do: Check, if fl_draw_image() should support alpha channel images on all platforms or not at all. The current documentation mentions only RGB and gray scale images. IMHO the behavior is undefined for values of abs(d) == 2 and abs(d) > 3. See also fl_draw_image_mono(). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6773 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Image.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index cd0c5ee90..f9c07cb9a 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -452,7 +452,11 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { if (H <= 0) return; if (!id) { #ifdef __APPLE_QUARTZ__ - CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB(); + CGColorSpaceRef lut = 0; + if (d()<=2) + lut = CGColorSpaceCreateDeviceGray(); + else + lut = CGColorSpaceCreateDeviceRGB(); CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, w()*h()*d(), 0L); id = CGImageCreate( w(), h(), 8, d()*8, ld()?ld():w()*d(), lut, (d()&1)?kCGImageAlphaNone:kCGImageAlphaLast, -- cgit v1.2.3