Derek Leach
03/23/2009 9:16 AM
post24991
|
void PhReleaseImage(PhImage_t *img)
{
PhDrawContext_t *cur_dc=NULL;
if (_Ph_)
cur_dc = _Ph_->draw_context;
if(img)
{
if(img->flags & Ph_RELEASE_IMAGE)
{
FREE(img->image);
img->image = NULL;
}
if(img->flags & Ph_RELEASE_PALETTE)
{
if (cur_dc)
{
if ((CUR_GC->palette.palette == img->palette) || (BUF_GC->palette.palette == img->palette))
PgSetPalette(NULL, 0, 0, -1, Pg_PALSET_SOFT, 0);
}
free(img->palette);
img->palette = NULL;
}
if(img->flags & Ph_RELEASE_TRANSPARENCY_MASK)
{
FREE(img->mask_bm);
img->mask_bm = NULL;
}
if(img->flags & Ph_RELEASE_GHOST_BITMAP)
{
FREE(img->ghost_bitmap);
img->ghost_bitmap = NULL;
}
if((img->flags & Ph_RELEASE_ALPHA) && img->alpha)
{
if (cur_dc)
{
if ((CUR_GC->alpha.src_alpha_map.map == img->alpha->src_alpha_map.map) ||
(BUF_GC->alpha.src_alpha_map.map == img->alpha->src_alpha_map.map))
PgSetAlpha(0, NULL, NULL, 0, 0);
}
FREE(img->alpha->src_alpha_map.map);
/* free(img->alpha->dest_alpha_map.map); */
free(img->alpha);
img->alpha = NULL;
}
}
}
It does release the "image data", it doesn't release the PhImage_t structure. From the docs:
This function doesn't release the image structure itself.
You will notice the FREE() macro, it is defined as:
#define FREE(p) \
{ \
if((p) && PgShmemDestroy(p)) \
free(p); \
}
So if shared memory was used for the image data, via the parameter to PhCreateImage(), it will be released properly.
Regarding PgAlpha_t, you should not have to be responsible for this,
what version of QNX are you using? I have heard rumblings about lack of PNG palettized image support, but no one has
returns answers to me. If you are using QNX SDP 6.4.0, the libpng is used by the codec. Can you post one of these
images?
FYI: There is an actual Foundry27 Graphics project with forums you can post to for Photon, Advanced Graphics, and GLES
among other things.
Regards,
-Derek
|
|
|