PNG Alpha blending example

Hi,
I load a png file with an alpha channel using PxLoadImage and I try to
display it using PgDrawImage, but it does not work correctly.

The image is displayed, but where it should be transparent, it is opaque.


When I load the image, is use the PX_LOAD and PX_TRANSPARENT flags.
When I tried to call PgAlphaOn() before displaying the image, all I got was
a black square instead.

Must I call PgSetAlphaBlend??
If so, I do not know how to obtain the PgMap_t * required by
PgSetAlphaBlend (I do not want a global alpha). I wish to use the alpha
values stored in the png, but PxLoadImage returns a PhImage_t* and
PhImage_t contains a PgAlpha_t * but no PgMap_t*…

Thank you in advance for your help.

Raphael Assenat <raphael.assenat@8d.com> wrote:
: Hi,
: I load a png file with an alpha channel using PxLoadImage and I try to
: display it using PgDrawImage, but it does not work correctly.

: The image is displayed, but where it should be transparent, it is opaque.

If your image is in a PhImage_t structure, use PgDrawPhImage() instead of
PgDrawImage(). PgDrawPhImage() looks after transparency, etc. for you.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Steve Reid wrote:
Hi,

I have tried using PgDrawPhImage instead of PgDrawImage, but I still have
the same problem. The alpha channel seems to be ignored.

I was wondering: Is it possible that PxLoadImage ignores the alpha channel
when loading a png?? I tried the same image in .gif format and it works
well. However, I really need to use .png. What can I do?

Can you tell me where I can find a working example of PNG loading and
displaying using the png’s alpha channel in photon? I have tried the
example in the Help page of PxLoadImage, but Png do not load with alpha
channel either.

Thank you/

Raphael Assenat <> raphael.assenat@8d.com> > wrote:
: Hi,
: I load a png file with an alpha channel using PxLoadImage and I try to
: display it using PgDrawImage, but it does not work correctly.

: The image is displayed, but where it should be transparent, it is
: opaque.

If your image is in a PhImage_t structure, use PgDrawPhImage() instead of
PgDrawImage(). PgDrawPhImage() looks after transparency, etc. for you.


Steve Reid > stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems