[devel] Fixed buffer bug (both the strip_16 and scale_16 transforms were

being applied.
This commit is contained in:
Glenn Randers-Pehrson 2011-06-18 00:19:54 -05:00
parent 9a1e2232ba
commit aee83b43d6
2 changed files with 21 additions and 18 deletions

View File

@ -1286,25 +1286,27 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
/* -------------- image transformations start here ------------------- */
#ifdef PNG_READ_16_TO_8_SUPPORTED
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
/* Tell libpng to strip 16-bit/color files down to 8 bits per color.
*/
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
if (transforms & PNG_TRANSFORM_SCALE_16)
png_set_scale_16(png_ptr);
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
else
# endif
# endif
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
{
/* Added at libpng-1.5.4. "strip_16" produces the same result that it
* did in earlier versions, while "scale_16" is now more accurate.
*/
png_set_scale_16(png_ptr);
}
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
else
# endif
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
if (transforms & PNG_TRANSFORM_STRIP_16)
png_set_strip_16(png_ptr);
#endif
#endif
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
/* Strip alpha bytes from the input data without combining with

View File

@ -1878,10 +1878,11 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
(info_ptr->bit_depth == 16))
info_ptr->bit_depth = 8;
# else
/* Force chopping 16-bit input down to 8 */
if (info_ptr->bit_depth == 16)
{
if (!(png_ptr->transformations & PNG_SCALE_16_TO_8))
if (!(png_ptr->transformations & PNG_16_TO_8))
# if PNG_READ_STRIP_16_TO_8_SUPPORTED
png_ptr->transformations |=PNG_16_TO_8;
# else
@ -2151,7 +2152,7 @@ png_do_read_transformations(png_structp png_ptr)
#endif
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
if (png_ptr->transformations & PNG_16_TO_8)
if (png_ptr->transformations & PNG_SCALE_16_TO_8)
png_do_scale_16_to_8(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED