Fixed gray-scale images with alpha channel (STR #2105).

Note: Windows needs RGBA Bitmaps (4 bytes) to do alpha blending.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6804 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2009-06-29 07:44:25 +00:00
parent 121138fa93
commit 7e7a74203a
3 changed files with 14 additions and 5 deletions

View File

@ -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)

View File

@ -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();

View File

@ -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: