• Advertisement
Sign in to follow this  

lodePNG and indexed color + alpha

This topic is 2632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am making an application with many png images, and my goal at this time is to reduce the size of the application.

i am using lodePNG which works really well.

my only issue is that there is no way for me to tell an image that is indexed with a transparent color, from a regular indexed png without transparency.


i tried:
decoder.getInfoPng().color.key_defined
and
LodePNG_InfoColor_isAlphaType(&decoder.getInfoPng().color)

but they return 0 for both types of images.

both types also say they are color type 3, with 1 channel, and bpp 8
maybe im using it wrong?
how do i tell a transparent indexed png from a regular indexed png?


thanks for any help!

[Edited by - metaldev on November 9, 2010 1:37:42 PM]

Share this post


Link to post
Share on other sites
Advertisement
ok i figured it out by parsing through the palette myself and checking for alpha = 0.
However i can't help but think i am not doing this the best way.

bpp = decoder.getBpp();
bool hasTransparency = false;
if (bpp == 8 )
{
unsigned int palleteSize = decoder.getInfoPng().color.palettesize;
for (unsigned int i = 0; i < palleteSize; i ++)
{
if ((int)decoder.getInfoPng().color.palette[(i*4) + 3] == 0)
{
std::cout << "a transparent, indexed png.\n ";
hasTransparency = true;
break;
}
}
}

if (!hasTransparency )
{
std::cout << "an indexed png, with no transparency.\n";
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement