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; png_colorp palette;
int palette_size; int palette_size;
png_bytep trans; png_bytep trans = NULL;
int trans_num; int num_trans = 0;
png_color_16p trans_values;
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
@ -998,12 +997,12 @@ static png_bytep *PNG_Read(
// color is present on the image, the palette flag is disabled. // color is present on the image, the palette flag is disabled.
if (usepal) 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; 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 // libpng will transform this image into RGBA even if
// the transparent index does not exist in the image, // the transparent index does not exist in the image,