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:
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++)
// set the alpha blend
Of course, I have called PgAlphaOn() before calling PgDrawPhImage().
Please help me! I really want this to work as soon as possible.