DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2105
Version: 1.1.9
It turned out that the problem exists only for gray scale images with alpha
channel: abs(d()) == 2. It is independent of the image format (png). I
changed the summary accordingly.
For the record: There was a bug for Mac OS for the same type of images.
This is fixed for FLTK 1.3 in svn -r 6773. It was only for Quartz and
didn't exist in FLTK 1.1 with Quickdraw. Currently I don't know if it is
possible (and supported) to compile FLTK 1.1 with Quartz drawing - if it
is, then this should also be fixed in FLTK 1.1.
The new test/unittests program (test/unittest_images.cxx) shows the wrong
behavior for FLTK 1.3 for the 4'th image (gray+alpha).
The attached file alpha.cxx can be used for testing with FLTK 1.1.
Link: http://www.fltk.org/str.php?L2105
Version: 1.1.9
//
// Image drawing with alpha channel test and demo.
// This is extracted and modified from test/unittest_images.cxx
//
// compile with:
//
// fltk-config --use-images --compile alpha.cxx
//
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_RGB_Image.H>
#include <FL/Fl_Box.H>
#include <FL/fl_draw.H>
#include <stdlib.h>
class ImageTest : public Fl_Box {
public:
ImageTest(int x, int y, int w, int h, int D) : Fl_Box(x, y, w, h) {
box(FL_NO_BOX);
create(w,h,D);
}
private:
uchar *img_a;
Fl_RGB_Image *img;
void create(int W, int H, int D) {
uchar *dga = (uchar*)malloc(W*W*D);
img_a = dga;
int x,y;
for (y=0; y<H; y++) {
for (x=0; x<W; x++) {
*dga++ = y<<1; // r or gray
if (D==4) {
*dga++ = x<<1; // g
*dga++ = (128-y)<<1; // b
}
*dga++ = 128; // alpha
}
}
img = new Fl_RGB_Image (img_a,W,H,D);
}
void draw() {
// draw box
fl_color(color()); // background color
fl_rectf(x(), y(), w(), h()); // background
fl_color(FL_BLACK); // box color
fl_rect (x(), y(), w(), h()); // box
// fl_draw_image(img_a, x(), y(), w(), h(), img->d());
// fl_draw_image(img_a, x(), y(), w(), h(), img->d()|FL_IMAGE_WITH_ALPHA);
img->draw(x(),y());
}
};
int main (int argc, char **argv)
{
Fl_Window win (300,300);
ImageTest it_a ( 10, 10,128,128,4);
it_a.color(FL_WHITE);
ImageTest it_b (148, 10,128,128,4);
it_b.color(FL_BLACK);
ImageTest it_c ( 10,148,128,128,2);
it_c.color(FL_WHITE);
ImageTest it_d (148,148,128,128,2);
it_d.color(FL_BLACK);
win.end();
win.show(argc,argv);
Fl::run();
}
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs