[devel] Fixed buffer bug (both the strip_16 and scale_16 transforms were
being applied.
This commit is contained in:
parent
9a1e2232ba
commit
aee83b43d6
22
pngread.c
22
pngread.c
@ -1286,24 +1286,26 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
|||||||
|
|
||||||
/* -------------- image transformations start here ------------------- */
|
/* -------------- 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.
|
/* 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)
|
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
|
/* 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.
|
* 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)
|
if (transforms & PNG_TRANSFORM_STRIP_16)
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||||
|
17
pngrtran.c
17
pngrtran.c
@ -1873,23 +1873,24 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||||
#ifdef PNG_READ_16BIT_SUPPORTED
|
# ifdef PNG_READ_16BIT_SUPPORTED
|
||||||
if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) &&
|
if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) &&
|
||||||
(info_ptr->bit_depth == 16))
|
(info_ptr->bit_depth == 16))
|
||||||
info_ptr->bit_depth = 8;
|
info_ptr->bit_depth = 8;
|
||||||
#else
|
# else
|
||||||
|
|
||||||
/* Force chopping 16-bit input down to 8 */
|
/* Force chopping 16-bit input down to 8 */
|
||||||
if (info_ptr->bit_depth == 16)
|
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
|
# if PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||||
png_ptr->transformations |=PNG_16_TO_8;
|
png_ptr->transformations |=PNG_16_TO_8;
|
||||||
#else
|
# else
|
||||||
png_ptr->transformations |=PNG_SCALE_16_TO_8;
|
png_ptr->transformations |=PNG_SCALE_16_TO_8;
|
||||||
#endif
|
# endif
|
||||||
info_ptr->bit_depth = 8;
|
info_ptr->bit_depth = 8;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
@ -2151,7 +2152,7 @@ png_do_read_transformations(png_structp png_ptr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
#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);
|
png_do_scale_16_to_8(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
#endif
|
#endif
|
||||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||||
|
Loading…
Reference in New Issue
Block a user