I've been working on a widget that can show images zoomed in and out at 
arbitrary percentages, and that part works.  Now, in the middle of my ::draw() 
function I want to overlay some RGBA PNG images -- these have transparency 
where I'd like the underlying image to show up.

I can make the images show up in the right places, but the alpha channel is 
being completely ignored in this little snippet:

void *baseaddr = (void *)(head->image_->data()[0]);
int     imagew = head->image_->w();
int imageh = head->image_->h();
int imaged = head->image_->d();
fl_draw_image((const uchar *)baseaddr, x, y, imagew, imageh, imaged);

head->image_ in this case was an Fl_PNG_Image that should have 4 channels.  It 
has been cast into an Fl_RGB_Image, which should be a compatible type.

But alpha blending isn't happening.  I'm getting white where there should be 
transparency to the pixels previously drawn in the buffer.  Instead, I should 
be getting a blend using the variable opacity in the A channel.

Upon further investigation, the documentation says that the only way to get 
transparency (and 100% transparency at that) is with an Fl_Pixmap (say, a GIF 
file), and that is definitely NOT RGB.  Even so, would that work where this 
fails, albeit without the kinds of shadows I'm trying to cast in the PNGs?

The documentation also points out a function called fl_read_image() where I 
could copy out the area underneath where the PNG is destined to be drawn.  
Therefore I could do the alpha blend myself and then do a regular 
fl_draw_image() to put the blended image in place.  Is this the only way it 
will work?

Please advise.

-Chris

P.S.  I deeply appreciate your help earlier when I needed to split my Photoshop 
plug-in into a stub plug-in and then an .exe.  Works like a champ.
_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to