[haiku-3rdparty-dev] Re: Displaying PNG images and transparency

  • From: Jon Yoder <darkwyrm@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Thu, 16 Feb 2012 20:22:52 -0500

On 02/16/2012 07:54 PM, Andrew Wood wrote:

Im just starting off writing Haiku apps and am wondering how to go about
displaying a PNG image in a BView.

Ive looked into the BBitmap class but I dont think it can directly
support PNGs? Also the PNGs have some transparent areas in them which
I'd like to maintain when displayed.
It's actually the exact thing you're looking for. Haiku is different from other OSes in that you ask the Translation Kit for a BBitmap from a file and it does all the hard work for you. Look at the BTranslationUtils class for the task you've described.

On a related note, any rough time frame for when the alpha channel of
rgb_color is likely to be suported?
It's been quite a while since I did any Haiku coding, but last I knew it was. I *think* it was just a matter of setting a BView's drawing mode to B_OP_ALPHA.

Not to toot my own horn a bunch, but it might serve you well to read Lesson #19 from my "Learning to Program with Haiku" programming lesson series on the Haiku website. It covers a lot of what you're describing in more detail.


Other related posts: