On 16 Mar 2013, at 02:21, Chris Russ wrote:

> 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.


Hi Chris,

I think this pretty much ought to work, at least with fltk-1.3.x.

What version are you using?

Anyway, take a look at the unittests demo from the test folder,one of the tabs 
there is about image blending and such (IIRC the tab is titled "drawing images".

Does that work on your system? ISTR it maybe only works on W32 and OSX, not 
sure about X11...

Anyway, the code for that tab is in the file unittest_images.cxx, so that might 
yeild some clues!





_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to