Merge branch 'png-trans-fix' into 'next'

Fix issue with png_get_tRNS

See merge request STJr/SRB2!1606
This commit is contained in:
Tatsuru 2021-09-12 20:30:36 +00:00
commit 59e1706f5c

View file

@ -901,9 +901,8 @@ static png_bytep *PNG_Read(
png_colorp palette;
int palette_size;
png_bytep trans;
int trans_num;
png_color_16p trans_values;
png_bytep trans = NULL;
int num_trans = 0;
#ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD
@ -998,12 +997,12 @@ static png_bytep *PNG_Read(
// color is present on the image, the palette flag is disabled.
if (usepal)
{
png_get_tRNS(png_ptr, png_info_ptr, &trans, &trans_num, &trans_values);
png_uint_32 result = png_get_tRNS(png_ptr, png_info_ptr, &trans, &num_trans, NULL);
if (trans && trans_num > 0)
if ((result & PNG_INFO_tRNS) && num_trans > 0 && trans != NULL)
{
INT32 i;
for (i = 0; i < trans_num; i++)
for (i = 0; i < num_trans; i++)
{
// libpng will transform this image into RGBA even if
// the transparent index does not exist in the image,