PgDrawPhImage with per pixel Alpha

Hi,
I am trying to display an image (PhImage_t) with a manually set per pixel
alpha. I tried global alpha value with PgSetAlphaBlend(NULL, 0x7f), and it
works. But when I pass my own PgMap_t as the first argument to
PgSetAlphaBlend, The PgDrawPhImage returns -1.

According to the PgDrawPhImage man page, this means that the draw buffer is
not large enough. So I tried PgSetDrawBufferSize(0xffff), but
PgDrawPhImage still returned -1.

After adding PgSetDrawBufferSize to my code, I noticed that when I removed
the PgSetAlphaBlend call, PgDrawPhImage returned ok (0), but my image did
not display at all! However, the image was displayed when
PgSetDrawBufferSize was not called!

I am now wondering if the problem could be that I do not allocate and fill
my PgMap_t correctly. Here is the code I use:

PgMap_t alphamap;

alphamap.dim.w = pimage->size.w;
alphamap.dim.h = pimage->size.h;
alphamap.bpl = pimage->size.w;
alphamap.map = malloc(pimage->size.w*pimage->size.h);

// and I initialise it to fully opaque
for (i=0; isize.w*pimage->size.h; i++)
alphamap.map_=255;


// set the alpha blend
PgSetAlphaBlend(&alphamap, 0x00);

Of course, I have called PgAlphaOn() before calling PgDrawPhImage().


Please help me! I really want this to work as soon as possible.
Thank you._

Hi Raphael,

sorry about the late response. I spoke with one of the developers and
here is some information for you.

PgDrawPhImage will draw the alpha map provided by the PhImage_t structure.

look at PhImage_t.alpha member (it’s a PgAlpha_t which for some reason
isn’t doc’d, but you can probably figure it out easily enough from
/usr/include/photon/Pg.h). You don’t need to call any PgSetAlpha calls
if you set this member, PgDrawPhImage does all this for you.


Hope this helps
Regards
Brenda

Raphael Assenat wrote:

Hi,
I am trying to display an image (PhImage_t) with a manually set per pixel
alpha. I tried global alpha value with PgSetAlphaBlend(NULL, 0x7f), and it
works. But when I pass my own PgMap_t as the first argument to
PgSetAlphaBlend, The PgDrawPhImage returns -1.

According to the PgDrawPhImage man page, this means that the draw buffer is
not large enough. So I tried PgSetDrawBufferSize(0xffff), but
PgDrawPhImage still returned -1.

After adding PgSetDrawBufferSize to my code, I noticed that when I removed
the PgSetAlphaBlend call, PgDrawPhImage returned ok (0), but my image did
not display at all! However, the image was displayed when
PgSetDrawBufferSize was not called!

I am now wondering if the problem could be that I do not allocate and fill
my PgMap_t correctly. Here is the code I use:

PgMap_t alphamap;

alphamap.dim.w = pimage->size.w;
alphamap.dim.h = pimage->size.h;
alphamap.bpl = pimage->size.w;
alphamap.map = malloc(pimage->size.w*pimage->size.h);

// and I initialise it to fully opaque
for (i=0; isize.w*pimage->size.h; i++)
alphamap.map> =255;


// set the alpha blend
PgSetAlphaBlend(&alphamap, 0x00);

Of course, I have called PgAlphaOn() before calling PgDrawPhImage().


Please help me! I really want this to work as soon as possible.
Thank you.

\