Author: AlbrechtS
Date: 2009-06-29 00:44:25 -0700 (Mon, 29 Jun 2009)
New Revision: 6804
Log:
Fixed gray-scale images with alpha channel (STR #2105).
Note: Windows needs RGBA Bitmaps (4 bytes) to do alpha blending.
Modified:
branches/branch-1.3/CHANGES
branches/branch-1.3/src/Fl_Image.cxx
branches/branch-1.3/src/fl_draw_image_win32.cxx
Modified: branches/branch-1.3/CHANGES
===================================================================
--- branches/branch-1.3/CHANGES 2009-06-28 22:25:51 UTC (rev 6803)
+++ branches/branch-1.3/CHANGES 2009-06-29 07:44:25 UTC (rev 6804)
@@ -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)
Modified: branches/branch-1.3/src/Fl_Image.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Image.cxx 2009-06-28 22:25:51 UTC (rev
6803)
+++ branches/branch-1.3/src/Fl_Image.cxx 2009-06-29 07:44:25 UTC (rev
6804)
@@ -465,7 +465,7 @@
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();
Modified: branches/branch-1.3/src/fl_draw_image_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_draw_image_win32.cxx 2009-06-28 22:25:51 UTC
(rev 6803)
+++ branches/branch-1.3/src/fl_draw_image_win32.cxx 2009-06-29 07:44:25 UTC
(rev 6804)
@@ -153,7 +153,7 @@
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 @@
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 @@
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:
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit