提交 efe4e5d1 编写于 作者: G Glenn Randers-Pehrson

[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.
上级 d6eb4b71
Libpng 1.6.19beta03 - September 20, 2015
Libpng 1.6.19beta03 - September 24, 2015
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
......@@ -64,7 +64,7 @@ Version 1.6.19beta02 [August 19, 2015]
in ANSI-C (unlike 0x80000000 in the signed case) the checking that
occurs later can catch them (John Bowler).
Version 1.6.19beta03 [September 20, 2015]
Version 1.6.19beta03 [September 24, 2015]
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
Updated libpng16 with all the recent test changes from libpng17,
including changes to pngvalid.c to ensure that the original,
......@@ -83,6 +83,11 @@ Version 1.6.19beta03 [September 20, 2015]
slightly different error limits this simplifies maintenance. The
makepngs.sh script has also been updated to more accurately reflect
current problems in libpng 1.7 (John Bowler).
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.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
......
......@@ -5347,7 +5347,7 @@ Version 1.6.19beta02 [August 19, 2015]
in ANSI-C (unlike 0x80000000 in the signed case) the checking that
occurs later can catch them (John Bowler).
Version 1.6.19beta03 [September 20, 2015]
Version 1.6.19beta03 [September 24, 2015]
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
Updated libpng16 with all the recent test changes from libpng17,
including changes to pngvalid.c to ensure that the original,
......@@ -5366,6 +5366,11 @@ Version 1.6.19beta03 [September 20, 2015]
slightly different error limits this simplifies maintenance. The
makepngs.sh script has also been updated to more accurately reflect
current problems in libpng 1.7 (John Bowler).
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.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
......
/* pngvalid.c - validate libpng by constructing then reading png files.
*
* Last changed in libpng 1.6.18 [(PENDING RELEASE)]
* Last changed in libpng 1.5.24 [(PENDING RELEASE)]
* Copyright (c) 2014-2015 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
......@@ -3578,7 +3578,7 @@ check_interlace_type(int const interlace_type)
#define CAN_WRITE_INTERLACE\
PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
/* Make a standardized image given a an image colour type, bit depth and
/* Make a standardized image given an image colour type, bit depth and
* interlace type. The standard images have a very restricted range of
* rows and heights and are used for testing transforms rather than image
* layout details. See make_size_images below for a way to make images
......@@ -8039,7 +8039,7 @@ image_transform_png_set_filler_set(const image_transform *this,
RANDOMIZE(data.filler);
data.flags = random_choice();
png_set_filler(pp, data.filler, data.flags);
png_set_filler_16(pp, data.filler, data.flags);
/* The standard display handling stuff also needs to know that
* there is a filler, so set that here.
......@@ -8112,7 +8112,7 @@ image_transform_png_set_add_alpha_set(const image_transform *this,
RANDOMIZE(data.filler);
data.flags = random_choice();
png_set_add_alpha(pp, data.filler, data.flags);
png_set_add_alpha_16(pp, data.filler, data.flags);
this->next->set(this->next, that, pp, pi);
}
......
......@@ -522,7 +522,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
png_set_swap(png_ptr);
/* Add filler (or alpha) byte (before/after each RGB triplet) */
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
png_set_filler_16(png_ptr, 0xffff, PNG_FILLER_AFTER);
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Turn on interlace handling. REQUIRED if you are not using
......@@ -958,7 +958,7 @@ void write_png(char *file_name /* , ... other image information ... */)
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
* RGB (4 channels -> 3 channels). The second parameter is not used.
*/
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
png_set_filler_16(png_ptr, 0, PNG_FILLER_BEFORE);
/* Flip BGR pixels to RGB */
png_set_bgr(png_ptr);
......
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.19beta03 - August 19, 2015
libpng version 1.6.19beta03 - September 24, 2015
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2015 Glenn Randers-Pehrson
......@@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.6.19beta03 - August 19, 2015
libpng versions 0.97, January 1998, through 1.6.19beta03 - September 24, 2015
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2015 Glenn Randers-Pehrson
......@@ -1685,17 +1685,21 @@ described below.
Data will be decoded into the supplied row buffers packed into bytes
unless the library has been told to transform it into another format.
For example, 4 bit/pixel paletted or grayscale data will be returned
2 pixels/byte with the leftmost pixel in the high-order bits of the
byte, unless png_set_packing() is called. 8-bit RGB data will be stored
in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
2 pixels/byte with the leftmost pixel in the high-order bits of the byte,
unless png_set_packing() is called. 8-bit RGB data will be stored
in RGB RGB RGB format unless png_set_filler_16() or png_set_add_alpha_16()
is called to insert filler bytes, either before or after each RGB triplet.
16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
byte of the color value first, unless png_set_scale_16() is called to
transform it to regular RGB RGB triplets, or png_set_filler() or
png_set_add alpha() is called to insert filler bytes, either before or
after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can
be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(),
or png_set_scale_16().
transform it to regular RGB RGB triplets, or png_set_filler_16() or
png_set_add alpha_16() is called to insert trwo filler bytes, either before
or after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data
can be modified with png_set_filler_16(), png_set_add_alpha_16(),
png_set_strip_16(), or png_set_scale_16(). Note that png_set_filler_16()
and png_set_add_alpha_16(), which can be used with either 8-bit or 16-bit
images have replaced the png_set_filler() and png_set_add_alpha() functions,
which only work properly with 8-bit data.
The following code transforms grayscale images of less than 8 to 8 bits,
changes paletted images to RGB, and adds a full alpha channel if there is
......@@ -1785,7 +1789,7 @@ Within the matrix,
"-" means the transformation is not supported.
"." means nothing is necessary (a tRNS chunk can just be ignored).
"t" means the transformation is obtained by png_set_tRNS.
"A" means the transformation is obtained by png_set_add_alpha().
"A" means the transformation is obtained by png_set_add_alpha_16().
"X" means the transformation is obtained by png_set_expand().
"1" means the transformation is obtained by
png_set_expand_gray_1_2_4_to_8() (and by png_set_expand()
......@@ -1848,24 +1852,26 @@ PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
into 4 or 8 bytes for windowing systems that need them in this format:
if (color_type == PNG_COLOR_TYPE_RGB)
png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
png_set_filler_16(png_ptr, filler, PNG_FILLER_BEFORE);
where "filler" is the 8 or 16-bit number to fill with, and the location is
either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
where "filler" is the 8-bit or 16-bit number to fill with, and the location
is either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
you want the filler before the RGB or after. This transformation
does not affect images that already have full alpha channels. To add an
opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
opaque alpha channel, use filler=0xffff and PNG_FILLER_AFTER which
will generate RGBA pixels.
Note that png_set_filler() does not change the color type. If you want
Note that png_set_filler_16() does not change the color type. If you want
to do that, you can add a true alpha channel with
if (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_GRAY)
png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
png_set_add_alpha_16(png_ptr, filler, PNG_FILLER_AFTER);
where "filler" contains the alpha value to assign to each pixel.
This function was added in libpng-1.2.7.
The png_set_alpha() function was added in libpng-1.2.7 and the
png_set_alpha_16() function, which can be used for either 8-bit or
16-bit images, was added in libpng-1.5.24.
If you are reading an image with an alpha channel, and you need the
data as ARGB instead of the normal PNG format RGBA:
......@@ -4904,7 +4910,13 @@ limits are now
png_user_chunk_malloc_max 0 (unlimited) 8,000,000
The png_set_option() function (and the "options" member of the png struct) was
added to libpng-1.5.15.
added to libpng-1.5.15, with option PNG_ARM_NEON.
The png_set_filler_16() and png_set_add_alpha_16() functions were added
at libpng-1.5.24 and libpng-1.6.19. These replace the png_set_filler(() and
the png_set_add_alpha() functions, which did not work properly with 16-bit
images. The new functions can be used with either 8-bit or 16-bit images,
while the old functions are still available for use only with 8-bit images.
The library now supports a complete fixed point implementation and can
thus be used on systems that have no floating point support or very
......@@ -5312,7 +5324,7 @@ Other rules can be inferred by inspecting the libpng source.
XVI. Y2K Compliance in libpng
August 19, 2015
September 24, 2015
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
......
.TH LIBPNG 3 "August 19, 2015"
.TH LIBPNG 3 "September 24, 2015"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.19beta03
.SH SYNOPSIS
......@@ -277,6 +277,8 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.19beta03
\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
\fBvoid png_set_add_alpha_16 (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
\fBvoid png_set_alpha_mode (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImode\fP\fB, double \fIoutput_gamma\fP\fB);\fP
\fBvoid png_set_alpha_mode_fixed (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImode\fP\fB, png_fixed_point \fIoutput_gamma\fP\fB);\fP
......@@ -325,6 +327,8 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.19beta03
\fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
\fBvoid png_set_filler_16 (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
\fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP
\fBvoid png_set_filter_heuristics (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_doublep \fP\fIfilter_weights\fP\fB, png_doublep \fIfilter_costs\fP\fB);\fP
......@@ -508,7 +512,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.19beta03 - August 19, 2015
libpng version 1.6.19beta03 - September 24, 2015
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2015 Glenn Randers-Pehrson
......@@ -519,7 +523,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.6.19beta03 - August 19, 2015
libpng versions 0.97, January 1998, through 1.6.19beta03 - September 24, 2015
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2015 Glenn Randers-Pehrson
......@@ -2193,17 +2197,21 @@ described below.
Data will be decoded into the supplied row buffers packed into bytes
unless the library has been told to transform it into another format.
For example, 4 bit/pixel paletted or grayscale data will be returned
2 pixels/byte with the leftmost pixel in the high-order bits of the
byte, unless png_set_packing() is called. 8-bit RGB data will be stored
in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
2 pixels/byte with the leftmost pixel in the high-order bits of the byte,
unless png_set_packing() is called. 8-bit RGB data will be stored
in RGB RGB RGB format unless png_set_filler_16() or png_set_add_alpha_16()
is called to insert filler bytes, either before or after each RGB triplet.
16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
byte of the color value first, unless png_set_scale_16() is called to
transform it to regular RGB RGB triplets, or png_set_filler() or
png_set_add alpha() is called to insert filler bytes, either before or
after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can
be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(),
or png_set_scale_16().
transform it to regular RGB RGB triplets, or png_set_filler_16() or
png_set_add alpha_16() is called to insert trwo filler bytes, either before
or after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data
can be modified with png_set_filler_16(), png_set_add_alpha_16(),
png_set_strip_16(), or png_set_scale_16(). Note that png_set_filler_16()
and png_set_add_alpha_16(), which can be used with either 8-bit or 16-bit
images have replaced the png_set_filler() and png_set_add_alpha() functions,
which only work properly with 8-bit data.
The following code transforms grayscale images of less than 8 to 8 bits,
changes paletted images to RGB, and adds a full alpha channel if there is
......@@ -2293,7 +2301,7 @@ Within the matrix,
"-" means the transformation is not supported.
"." means nothing is necessary (a tRNS chunk can just be ignored).
"t" means the transformation is obtained by png_set_tRNS.
"A" means the transformation is obtained by png_set_add_alpha().
"A" means the transformation is obtained by png_set_add_alpha_16().
"X" means the transformation is obtained by png_set_expand().
"1" means the transformation is obtained by
png_set_expand_gray_1_2_4_to_8() (and by png_set_expand()
......@@ -2356,24 +2364,26 @@ PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
into 4 or 8 bytes for windowing systems that need them in this format:
if (color_type == PNG_COLOR_TYPE_RGB)
png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
png_set_filler_16(png_ptr, filler, PNG_FILLER_BEFORE);
where "filler" is the 8 or 16-bit number to fill with, and the location is
either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
where "filler" is the 8-bit or 16-bit number to fill with, and the location
is either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
you want the filler before the RGB or after. This transformation
does not affect images that already have full alpha channels. To add an
opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
opaque alpha channel, use filler=0xffff and PNG_FILLER_AFTER which
will generate RGBA pixels.
Note that png_set_filler() does not change the color type. If you want
Note that png_set_filler_16() does not change the color type. If you want
to do that, you can add a true alpha channel with
if (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_GRAY)
png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
png_set_add_alpha_16(png_ptr, filler, PNG_FILLER_AFTER);
where "filler" contains the alpha value to assign to each pixel.
This function was added in libpng-1.2.7.
The png_set_alpha() function was added in libpng-1.2.7 and the
png_set_alpha_16() function, which can be used for either 8-bit or
16-bit images, was added in libpng-1.5.24.
If you are reading an image with an alpha channel, and you need the
data as ARGB instead of the normal PNG format RGBA:
......@@ -5412,7 +5422,13 @@ limits are now
png_user_chunk_malloc_max 0 (unlimited) 8,000,000
The png_set_option() function (and the "options" member of the png struct) was
added to libpng-1.5.15.
added to libpng-1.5.15, with option PNG_ARM_NEON.
The png_set_filler_16() and png_set_add_alpha_16() functions were added
at libpng-1.5.24 and libpng-1.6.19. These replace the png_set_filler(() and
the png_set_add_alpha() functions, which did not work properly with 16-bit
images. The new functions can be used with either 8-bit or 16-bit images,
while the old functions are still available for use only with 8-bit images.
The library now supports a complete fixed point implementation and can
thus be used on systems that have no floating point support or very
......@@ -5820,7 +5836,7 @@ Other rules can be inferred by inspecting the libpng source.
.SH XVI. Y2K Compliance in libpng
August 19, 2015
September 24, 2015
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
......@@ -6141,7 +6157,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.6.19beta03 - August 19, 2015:
Libpng version 1.6.19beta03 - September 24, 2015:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
......@@ -6164,7 +6180,7 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000, through 1.6.19beta03, August 19, 2015, are
libpng versions 1.0.7, July 1, 2000, through 1.6.19beta03, September 24, 2015, are
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors:
......@@ -6258,7 +6274,7 @@ the additional disclaimers inserted at version 1.0.7.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
August 19, 2015
September 24, 2015
.\" end of man page
/* png.h - header file for PNG reference library
*
* libpng version 1.6.19beta03, August 19, 2015
* libpng version 1.6.19beta03, September 24, 2015
*
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
......@@ -12,7 +12,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.19beta03, August 19, 2015: Glenn
* libpng versions 0.97, January 1998, through 1.6.19beta03, September 24, 2015: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
......@@ -251,7 +251,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.0.7, July 1, 2000, through 1.6.19beta03, August 19, 2015, are
* libpng versions 1.0.7, July 1, 2000, through 1.6.19beta03, September 24, 2015, are
* Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.0.6
* with the following individuals added to the list of Contributing Authors:
......@@ -360,7 +360,7 @@
* Y2K compliance in libpng:
* =========================
*
* August 19, 2015
* September 24, 2015
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
......@@ -430,7 +430,7 @@
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.19beta03"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.6.19beta03 - August 19, 2015\n"
" libpng version 1.6.19beta03 - September 24, 2015\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
......@@ -1396,12 +1396,18 @@ PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));
/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,
int flags));
/* Add a filler byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
PNG_EXPORT(245, void, png_set_filler_16, (png_structrp png_ptr,
png_uint_32 filler, int flags));
/* The values of the PNG_FILLER_ defines should NOT be changed */
# define PNG_FILLER_BEFORE 0
# define PNG_FILLER_AFTER 1
/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,
png_uint_32 filler, int flags));
/* Add an alpha byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
PNG_EXPORT(246, void, png_set_add_alpha_16, (png_structrp png_ptr,
png_uint_32 filler, int flags));
#endif /* READ_FILLER || WRITE_FILLER */
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
......@@ -3264,7 +3270,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
* one to use is one more than this.)
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
PNG_EXPORT_LAST_ORDINAL(244);
PNG_EXPORT_LAST_ORDINAL(246);
#endif
#ifdef __cplusplus
......
......@@ -599,6 +599,7 @@
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */
#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */
#define PNG_FLAG_FILLER_16 0x800000 /* old filler byte order */
/* 0x800000 unused */
/* 0x1000000 unused */
/* 0x2000000 unused */
......
......@@ -3860,7 +3860,7 @@ png_image_read_direct(png_voidp argument)
# endif
where = PNG_FILLER_AFTER;
png_set_add_alpha(png_ptr, filler, where);
png_set_add_alpha_16(png_ptr, filler, where);
}
/* This stops the (irrelevant) call to swap_alpha below. */
......
......@@ -2660,10 +2660,17 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
png_uint_32 i;
png_uint_32 row_width = row_info->width;
png_byte lo_filler = (png_byte)filler;
#ifdef PNG_READ_16BIT_SUPPORTED
png_byte hi_filler = (png_byte)(filler>>8);
if (((flags & PNG_FLAG_FILLER_16) == 0) && row_info->bit_depth == 16)
{
/* filler bytes were read in the wrong order prior to libpng-1.5.24 */
lo_filler = hi_filler;
hi_filler = (png_byte)filler;
}
#endif
png_byte lo_filler = (png_byte)filler;
png_debug(1, "in png_do_read_filler");
......
......@@ -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;
......
......@@ -1396,11 +1396,11 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
/* Continue if ignored - this is the pre-1.6.10 behavior */
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
png_set_filler_16(png_ptr, 0, PNG_FILLER_AFTER);
}
else if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
png_set_filler_16(png_ptr, 0, PNG_FILLER_BEFORE);
#else
png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_FILLER not supported");
#endif
......
......@@ -249,3 +249,5 @@ EXPORTS
png_set_check_for_invalid_index @242
png_get_palette_max @243
png_set_option @244
png_set_filler_16 @245
png_set_add_alpha_16 @246
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册