mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Reverted the fix of byte order in png_do_read_filler() with 16-bit
input that was made in version 1.6.17beta01, to preserve legacy behavior even though it was incorrect. Instead, added new API png_set_filter_16() and png_set_add_alpha_16() that set a flag to make png_do_read_filter() interpret the filler bytes properly.
This commit is contained in:
26
pngtrans.c
26
pngtrans.c
@@ -119,7 +119,17 @@ png_set_interlace_handling(png_structrp png_ptr)
|
||||
void PNGAPI
|
||||
png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_filler");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_set_filler_16(png_ptr, filler, filler_loc);
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_16; /* Wrong byte order */
|
||||
}
|
||||
|
||||
/* Added to libpng-1.5.24 */
|
||||
void PNGAPI
|
||||
png_set_filler_16(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_filler_16");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
@@ -139,6 +149,7 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
* confusion in the past.) The filler is only used in the read code.
|
||||
*/
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
png_ptr->flags |= PNG_FLAG_FILLER_16; /* Correct byte order */
|
||||
# else
|
||||
png_app_error(png_ptr, "png_set_filler not supported on read");
|
||||
PNG_UNUSED(filler) /* not used in the write case */
|
||||
@@ -202,13 +213,24 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
/* Added to libpng-1.2.7 */
|
||||
void PNGAPI
|
||||
png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_set_add_alpha_16(png_ptr, filler, filler_loc);
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_16; /* Wrong byte order */
|
||||
}
|
||||
|
||||
/* Added to libpng-1.5.24 */
|
||||
void PNGAPI
|
||||
png_set_add_alpha_16(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_add_alpha");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
png_set_filler_16(png_ptr, filler, filler_loc);
|
||||
/* The above may fail to do anything. */
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
|
||||
Reference in New Issue
Block a user