Fix crash when loading 24bit+transparency PNG images, such as http://pixeljoint.com/pixelart/51675.htm - This patch discards the transparency data in this case, because interpreting it correctly is a much bigger change: todo sometime later.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1458 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
8887d4ece5
commit
5e972c0659
@ -3421,16 +3421,33 @@ void Load_PNG(T_IO_Context * context)
|
|||||||
// Transparency (tRNS)
|
// Transparency (tRNS)
|
||||||
if (png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &trans_values))
|
if (png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &trans_values))
|
||||||
{
|
{
|
||||||
int i;
|
if (color_type == PNG_COLOR_TYPE_PALETTE && trans!=NULL)
|
||||||
for (i=0; i<num_trans; i++)
|
|
||||||
{
|
{
|
||||||
if (trans[i]==0)
|
int i;
|
||||||
|
for (i=0; i<num_trans; i++)
|
||||||
{
|
{
|
||||||
context->Transparent_color = i;
|
if (trans[i]==0)
|
||||||
context->Background_transparent = 1;
|
{
|
||||||
break;
|
context->Transparent_color = i;
|
||||||
|
context->Background_transparent = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ((color_type == PNG_COLOR_TYPE_GRAY
|
||||||
|
|| color_type == PNG_COLOR_TYPE_RGB) && trans_values!=NULL)
|
||||||
|
{
|
||||||
|
// In this case, num_trans is supposed to be "1",
|
||||||
|
// and trans_values[0] contains the reference color
|
||||||
|
// (RGB triplet) that counts as transparent.
|
||||||
|
|
||||||
|
// Ideally, we should reserve this color in the palette,
|
||||||
|
// (so it's not merged and averaged with a neighbor one)
|
||||||
|
// and after creating the optimized palette, find its
|
||||||
|
// index and mark it transparent.
|
||||||
|
|
||||||
|
// Current implementation: ignore.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context->Width=info_ptr->width;
|
context->Width=info_ptr->width;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user