Author: AlbrechtS
Date: 2009-06-29 00:45:48 -0700 (Mon, 29 Jun 2009)
New Revision: 6805
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.1/CHANGES
branches/branch-1.1/src/Fl_Image.cxx
branches/branch-1.1/src/fl_draw_image_win32.cxx
Modified: branches/branch-1.1/CHANGES
===================================================================
--- branches/branch-1.1/CHANGES 2009-06-29 07:44:25 UTC (rev 6804)
+++ branches/branch-1.1/CHANGES 2009-06-29 07:45:48 UTC (rev 6805)
@@ -1,5 +1,6 @@
CHANGES IN FLTK 1.1.10
+ - Fixed gray-scale images with alpha channel (STR #2105)
- Fixed unexpected shortcut behavior for Win32 (STR #2199)
- Added cast to Fl_Color in all Fluid code (STR #2206)
- Fixed wrong identifier for special keys combined with
Modified: branches/branch-1.1/src/Fl_Image.cxx
===================================================================
--- branches/branch-1.1/src/Fl_Image.cxx 2009-06-29 07:44:25 UTC (rev
6804)
+++ branches/branch-1.1/src/Fl_Image.cxx 2009-06-29 07:45:48 UTC (rev
6805)
@@ -411,7 +411,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.1/src/fl_draw_image_win32.cxx
===================================================================
--- branches/branch-1.1/src/fl_draw_image_win32.cxx 2009-06-29 07:44:25 UTC
(rev 6804)
+++ branches/branch-1.1/src/fl_draw_image_win32.cxx 2009-06-29 07:45:48 UTC
(rev 6805)
@@ -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