[libpng15] Bail out of loop over tRNS array once a transparent entry

is found.
This commit is contained in:
Glenn Randers-Pehrson 2013-08-04 13:54:35 -05:00
parent b3b9360373
commit f880e3a735

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* pngrtran.c - transforms the data in a row for PNG readers
* *
* Last changed in libpng 1.5.16 [May 23, 2013] * Last changed in libpng 1.5.18 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -1095,12 +1095,18 @@ png_init_palette_transformations(png_structp png_ptr)
/* Ignore if all the entries are opaque (unlikely!) */ /* Ignore if all the entries are opaque (unlikely!) */
for (i=0; i<png_ptr->num_trans; ++i) for (i=0; i<png_ptr->num_trans; ++i)
{
if (png_ptr->trans_alpha[i] == 255) if (png_ptr->trans_alpha[i] == 255)
continue; continue;
else if (png_ptr->trans_alpha[i] == 0) else if (png_ptr->trans_alpha[i] == 0)
input_has_transparency = 1; input_has_transparency = 1;
else else
{
input_has_transparency = 1;
input_has_alpha = 1; input_has_alpha = 1;
break;
}
}
} }
/* If no alpha we can optimize. */ /* If no alpha we can optimize. */