Sign in to follow this  
metaldev

lodePNG and indexed color + alpha

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this