diff --git a/CHANGES b/CHANGES index 558fcc444..b92153e2d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ CHANGES IN FLTK 1.3.0 + - Fixed gray-scale images with alpha channel (STR #2105) - Fixed unexpected shortcut behavior for Win32 (STR #2199) - Fixed documentation for Fl_Progress (STR #2209) - Fluid printing used wrong colors under Windows (STR #2195) diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index f9c07cb9a..849d43f90 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -465,7 +465,7 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { CGDataProviderRelease(src); #elif defined(WIN32) id = fl_create_offscreen(w(), h()); - if (d() == 2 || d() == 4 && fl_can_do_alpha_blending()) { + if ((d() == 2 || d() == 4) && fl_can_do_alpha_blending()) { fl_begin_offscreen((Fl_Offscreen)id); fl_draw_image(array, 0, 0, w(), h(), d()|FL_IMAGE_WITH_ALPHA, ld()); fl_end_offscreen(); diff --git a/src/fl_draw_image_win32.cxx b/src/fl_draw_image_win32.cxx index 1d4495b1a..d43f90e6c 100644 --- a/src/fl_draw_image_win32.cxx +++ b/src/fl_draw_image_win32.cxx @@ -153,7 +153,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, bmi.bmiColors[i].rgbBlue = (uchar)i; bmi.bmiColors[i].rgbGreen = (uchar)i; bmi.bmiColors[i].rgbRed = (uchar)i; - bmi.bmiColors[i].rgbReserved = (uchar)i; + bmi.bmiColors[i].rgbReserved = (uchar)0; // must be zero } } bmi.bmiHeader.biWidth = w; @@ -164,6 +164,10 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, bmi.bmiHeader.biBitCount = depth*8; int pixelsize = depth; #endif + if (depth==2) { // special case: gray with alpha + bmi.bmiHeader.biBitCount = 32; + pixelsize = 4; + } int linesize = (pixelsize*w+3)&~3; static U32* buffer; @@ -218,9 +222,13 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, for (i=w; i--; from += delta) *to++ = *from; break; case 2: - for (i=w; i--; from += delta) { - *to++ = *from; - *to++ = *from; + for (i=w; i--; from += delta, to += 4) { + uchar a = from[1]; + uchar gray = (from[0]*a)>>8; + to[0] = gray; + to[1] = gray; + to[2] = gray; + to[3] = a; } break; case 3: