[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:
Glenn Randers-Pehrson
2015-09-23 22:08:04 -05:00
parent d6eb4b71ac
commit efe4e5d10d
13 changed files with 141 additions and 65 deletions

View File

@@ -1,4 +1,4 @@
.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