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

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Fri, 17 Feb 2012 09:21:44 +0100

Hi,

Am 17.02.2012 01:54, schrieb Andrew Wood:
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.

Others have already answered how to load PNGs into BBitmaps...

On a related note, any rough time frame for when the alpha channel of
rgb_color is likely to be suported?

A graphics API is formed by all sorts of considerations. In most graphics APIs I know, you have to configure some additional properties, to turn on some features which would in some use-cases feel intuitive to be on by default. But they are off for performance reasons and because in the common use-case, you don't need them.

If you change the drawing mode of your BView to B_OP_OVER or B_OP_ALPHA, then the alpha channel in B_RGBA32 BBitmaps and the alpha property of rgb_colors are fully supported. For painting with rgb_colors, additional configuration options are available and again, might have to be changed from their default value to get the effects that you intend. See the documentation for SetBlendingMode() here:

http://haiku-os.org/legacy-docs/bebook/BView.html#BView_Graphics

Best regards,
-Stephan


Other related posts: