Compare commits

..

43 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
78bb9dafe1 [devel] Imported from libpng-1.5.4rc01.tar 2011-06-30 19:04:47 -05:00
Glenn Randers-Pehrson
4fca25504e [devel] Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400. 2011-06-27 12:01:01 -05:00
Glenn Randers-Pehrson
9daf91ed5c [devel] Imported from libpng-1.5.4beta08.tar 2011-06-22 23:15:30 -05:00
John Bowler
fcd7c13ffd [devel] Fix pngvalid.c with ACCURATE_SCALE
and update scripts/pnglibconf.h.prebuilt
2011-06-22 23:13:01 -05:00
Glenn Randers-Pehrson
5bcd0a8c14 [devel] Imported from libpng-1.5.4beta07.tar 2011-06-19 07:10:26 -05:00
John Bowler
8d261262d9 [devel] Fixed pngvalid, simplified macros, added checking for 0 in sCAL. 2011-06-18 13:37:11 -05:00
Glenn Randers-Pehrson
c4a8214b77 [devel] Delete chop_16 synopses and add one for png_set_scale_16_to_8() 2011-06-18 00:44:08 -05:00
Glenn Randers-Pehrson
4e47be74e9 [devel] Bump version to libpng-1.5.4beta07 2011-06-18 00:30:16 -05:00
Glenn Randers-Pehrson
314ef3e72b [devel] Imported from libpng-1.5.4beta06.tar 2011-06-18 00:27:49 -05:00
Glenn Randers-Pehrson
aee83b43d6 [devel] Fixed buffer bug (both the strip_16 and scale_16 transforms were
being applied.
2011-06-18 00:19:54 -05:00
Glenn Randers-Pehrson
9a1e2232ba [devel] Fix pngvalid.c to compile when SCALE_16 is disabled. 2011-06-17 23:40:12 -05:00
Glenn Randers-Pehrson
6da2f2d92a [devel] Fix more inconsistencies from the swap of 16_TO_8 APIs.
pngvalid still fails.
2011-06-17 23:07:16 -05:00
Glenn Randers-Pehrson
24145c8869 [devel] Still trying to fix row buffer problem but pngvalid still fails 2011-06-17 22:45:03 -05:00
Glenn Randers-Pehrson
e6a8060a71 [devel] Fixed some errors with 16_TO_8 macros
pngvalid still fails two tests, problem with row buffer.
2011-06-17 22:28:23 -05:00
Glenn Randers-Pehrson
98f053edbd [devel] Fix new bugs in pngvalid.c; it failed to compile. 2011-06-17 21:57:49 -05:00
Glenn Randers-Pehrson
581d29d4c9 [devel] Removed redundant directives from pngminim/*/*dfa. 2011-06-17 21:44:10 -05:00
Glenn Randers-Pehrson
66b942ce16 [devel] Changed a dependence in scripts/pnglibconf.dfa 2011-06-17 21:17:16 -05:00
Glenn Randers-Pehrson
86cf9b2e89 [devel] Bump version to libpng-1.5.4beta06 2011-06-17 21:13:51 -05:00
Glenn Randers-Pehrson
fb29e51dbd [devel] Imported from libpng-1.5.4beta05.tar 2011-06-17 20:42:19 -05:00
Glenn Randers-Pehrson
ab63dd0892 [devel] Renamed png_set_chop_16() to png_set_strip_16(). 2011-06-17 20:41:19 -05:00
Glenn Randers-Pehrson
a7428d443c [devel] Renamed png_set_strip_16() to png_set_scale_16(). 2011-06-17 19:07:04 -05:00
Glenn Randers-Pehrson
857dbbe7cc [devel] Revised example.c to demonstrate png_set_chop_16(). 2011-06-16 09:39:40 -05:00
Glenn Randers-Pehrson
3fb7c07ea5 [devel] Bump version to libpng-1.5.4beta05 2011-06-16 09:32:36 -05:00
Glenn Randers-Pehrson
60d7c022e5 [devel] Imported from libpng-1.5.4beta04.tar 2011-06-16 09:10:57 -05:00
Glenn Randers-Pehrson
850769f787 [devel] Revised contrib/visupng, gregbook, and pngminim
to demonstrate chop_16_to_8
2011-06-16 09:08:53 -05:00
Glenn Randers-Pehrson
5f0b9276ec [devel] Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again.
If this is not enabled, png_set_strip_16() and png_do_scale_16_to_8()
aren't built.
2011-06-16 09:05:40 -05:00
Glenn Randers-Pehrson
733b131545 [devel] Added information about "chop_16" to the manual. 2011-06-15 13:21:01 -05:00
Glenn Randers-Pehrson
ef217b76a3 [devel] Updated comments that mention 1.5.3; changed them to 1.5.4. 2011-06-15 12:58:27 -05:00
Glenn Randers-Pehrson
b0791f75ad [devel] Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms. 2011-06-15 12:07:20 -05:00
Glenn Randers-Pehrson
039ad872fe [devel] Bump version to libpng-1.5.4beta04 2011-06-15 11:51:55 -05:00
Glenn Randers-Pehrson
903c64dce8 [devel] Added "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c 2011-06-15 11:50:23 -05:00
Glenn Randers-Pehrson
8f4edd07be [devel] Imported from libpng-1.5.4beta03.tar 2011-06-15 08:21:56 -05:00
Glenn Randers-Pehrson
be720edba7 [devel] Correction to the expand_16 code; removed extra instance of
png_set_scale_16_to_8 from pngpriv.h
2011-06-15 08:20:37 -05:00
Glenn Randers-Pehrson
140504b11a [devel] Add synopsis for png_set_chop_16() to manual
and fix some other small typos.
2011-06-15 08:10:13 -05:00
John Bowler
cd3b0cc4d9 [devel] Fixed a problem in png_do_expand_palette() exposed by optimization in
1.5.3beta06
  Also removed a spurious (totally unused and confusing) member from png_info.
  The palette expand optimization prevented expansion to an intermediate RGBA
    form if tRNS was present but alpha was marked to be stripped; this exposed
    a check for tRNS in png_do_expand_palette() which is inconsistent with the
    code elsewhere in libpng.
2011-06-14 23:01:07 -05:00
Glenn Randers-Pehrson
06a9684cfa [devel] Bump version to libpng-1.5.4beta03 2011-06-14 11:06:42 -05:00
Glenn Randers-Pehrson
45599ad00f [devel] Imported from libpng-1.5.4beta02.tar 2011-06-14 07:17:29 -05:00
Glenn Randers-Pehrson
677819fe66 [devel] Check for READ_CHOP_16_TO_8 support in pngvalid,
not libpng version for presence of png_set_chop_16_to_8(), in pngvalid.c
2011-06-14 07:10:47 -05:00
Glenn Randers-Pehrson
2232baa41b [devel] Made png_set_chop_16() API removeable
by disabling PNG_CHOP_16_TO_8_SUPPORTED
2011-06-14 06:59:46 -05:00
Glenn Randers-Pehrson
7dffa41643 [devel] Use the old scaling method for background if png_set_chop_16() was
called.
2011-06-14 06:30:12 -05:00
John Bowler
550bab03fb [devel] Removed the ACCURATE and LEGACY options (they are no longer useable)
Fixed some compiliation problems with scaling options.
2011-06-14 06:17:26 -05:00
Glenn Randers-Pehrson
413138a5ca [devel] Added png_set_chop_16() API. 2011-06-13 22:07:37 -05:00
John Bowler
74945f2f04 [devel] Fix and clarify LEGACY 16-to-8 scaling. 2011-06-13 20:50:42 -05:00
47 changed files with 744 additions and 400 deletions

View File

@@ -1,5 +1,5 @@
Libpng 1.5.4beta01 - June 14, 2011
Libpng 1.5.4rc01 - June 30, 2011
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.
@@ -9,20 +9,20 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
1.5.4beta01.tar.xz (LZMA-compressed, recommended)
1.5.4beta01.tar.gz
1.5.4beta01.tar.bz2
1.5.4rc01.tar.xz (LZMA-compressed, recommended)
1.5.4rc01.tar.gz
1.5.4rc01.tar.bz2
Source files with CRLF line endings (for Windows), without the
"configure" script
lp154b01.7z (LZMA-compressed, recommended)
lp154b01.zip
lp154r01.7z (LZMA-compressed, recommended)
lp154r01.zip
Other information:
1.5.4beta01-README.txt
1.5.4beta01-LICENSE.txt
1.5.4rc01-README.txt
1.5.4rc01-LICENSE.txt
Changes since the last public release (1.5.2):
@@ -193,6 +193,56 @@ Version 1.5.4beta01 [June 14, 2011]
outside of an unknown-chunk block in png.h because they are also
needed for other uses.
Version 1.5.4beta02 [June 14, 2011]
Fixed and clarified LEGACY 16-to-8 scaling code.
Added png_set_chop_16() API, to match inaccurate results from previous
libpng versions.
Removed the ACCURATE and LEGACY options (they are no longer useable)
Use the old scaling method for background if png_set_chop_16() was
called.
Made png_set_chop_16() API removeable with PNG_NO_READ_CHOP_16_TO_8_SUPPORTED
Version 1.5.4beta03 [June 15, 2011]
Fixed a problem in png_do_expand_palette() exposed by optimization in
1.5.3beta06
Also removed a spurious and confusing "trans" member ("trans") from png_info.
The palette expand optimization prevented expansion to an intermediate RGBA
form if tRNS was present but alpha was marked to be stripped; this exposed
a check for tRNS in png_do_expand_palette() which is inconsistent with the
code elsewhere in libpng.
Correction to the expand_16 code; removed extra instance of
png_set_scale_16_to_8 from pngpriv.h
Version 1.5.4beta04 [June 16, 2011]
Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c
Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms.
Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again. If this is
not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built.
Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8
Version 1.5.4beta05 [June 16, 2011]
Renamed png_set_strip_16() to png_set_scale_16() and renamed
png_set_chop_16() to png_set_strip(16) in an attempt to minimize the
behavior changes between libpng14 and libpng15.
Version 1.5.4beta06 [June 18, 2011]
Fixed new bug that was causing both strip_16 and scale_16 to be applied.
Version 1.5.4beta07 [June 19, 2011]
Fixed pngvalid, simplified macros, added checking for 0 in sCAL.
The ACCURATE scale macro is no longer defined in 1.5 - call the
png_scale_16_to_8 API. Made sure that PNG_READ_16_TO_8 is still defined
if the png_strip_16_to_8 API is present. png_check_fp_number now
maintains some state so that positive, negative and zero values are
identified. sCAL uses these to be strictly spec conformant.
Version 1.5.4beta08 [June 23, 2011]
Fixed pngvalid if ACCURATE_SCALE is defined.
Updated scripts/pnglibconf.h.prebuilt.
Version 1.5.4rc01 [June 30, 2011]
Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

50
CHANGES
View File

@@ -3456,6 +3456,56 @@ Version 1.5.4beta01 [June 14, 2011]
outside of an unknown-chunk block in png.h because they are also
needed for other uses.
Version 1.5.4beta02 [June 14, 2011]
Fixed and clarified LEGACY 16-to-8 scaling code.
Added png_set_chop_16() API, to match inaccurate results from previous
libpng versions.
Removed the ACCURATE and LEGACY options (they are no longer useable)
Use the old scaling method for background if png_set_chop_16() was
called.
Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
Version 1.5.4beta03 [June 15, 2011]
Fixed a problem in png_do_expand_palette() exposed by optimization in
1.5.3beta06
Also removed a spurious and confusing "trans" member ("trans") from png_info.
The palette expand optimization prevented expansion to an intermediate RGBA
form if tRNS was present but alpha was marked to be stripped; this exposed
a check for tRNS in png_do_expand_palette() which is inconsistent with the
code elsewhere in libpng.
Correction to the expand_16 code; removed extra instance of
png_set_scale_16_to_8 from pngpriv.h
Version 1.5.4beta04 [June 16, 2011]
Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c
Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms.
Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again. If this is
not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built.
Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8
Version 1.5.4beta05 [June 16, 2011]
Renamed png_set_strip_16() to png_set_scale_16() and renamed
png_set_chop_16() to png_set_strip(16) in an attempt to minimize the
behavior changes between libpng14 and libpng15.
Version 1.5.4beta06 [June 18, 2011]
Fixed new bug that was causing both strip_16 and scale_16 to be applied.
Version 1.5.4beta07 [June 19, 2011]
Fixed pngvalid, simplified macros, added checking for 0 in sCAL.
The ACCURATE scale macro is no longer defined in 1.5 - call the
png_scale_16_to_8 API. Made sure that PNG_READ_16_TO_8 is still defined
if the png_strip_16_to_8 API is present. png_check_fp_number now
maintains some state so that positive, negative and zero values are
identified. sCAL uses these to be strictly spec conformant.
Version 1.5.4beta08 [June 23, 2011]
Fixed pngvalid if ACCURATE_SCALE is defined.
Updated scripts/pnglibconf.h.prebuilt.
Version 1.5.4rc01 [June 30, 2011]
Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@@ -260,7 +260,7 @@ install(CODE ${PNG_CONFIG_INSTALL_CODE})
# SET UP LINKS
if(PNG_SHARED)
set_target_properties(${PNG_LIB_NAME} PROPERTIES
# VERSION 15.${PNGLIB_RELEASE}.1.5.4beta01
# VERSION 15.${PNGLIB_RELEASE}.1.5.4rc01
VERSION 15.${PNGLIB_RELEASE}.0
SOVERSION 15
CLEAN_DIRECT_OUTPUT 1)

View File

@@ -10,7 +10,7 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.5.4beta01, June 14, 2011, are
libpng versions 1.2.6, August 15, 2004, through 1.5.4rc01, June 30, 2011, are
Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
June 14, 2011
June 30, 2011

2
README
View File

@@ -1,4 +1,4 @@
README for libpng version 1.5.4beta01 - June 14, 2011 (shared library 15.0)
README for libpng version 1.5.4rc01 - June 30, 2011 (shared library 15.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.

22
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for libpng 1.5.4beta01.
# Generated by GNU Autoconf 2.68 for libpng 1.5.4rc01.
#
# Report bugs to <png-mng-implement@lists.sourceforge.net>.
#
@@ -570,8 +570,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libpng'
PACKAGE_TARNAME='libpng'
PACKAGE_VERSION='1.5.4beta01'
PACKAGE_STRING='libpng 1.5.4beta01'
PACKAGE_VERSION='1.5.4rc01'
PACKAGE_STRING='libpng 1.5.4rc01'
PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net'
PACKAGE_URL=''
@@ -1307,7 +1307,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures libpng 1.5.4beta01 to adapt to many kinds of systems.
\`configure' configures libpng 1.5.4rc01 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1377,7 +1377,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libpng 1.5.4beta01:";;
short | recursive ) echo "Configuration of libpng 1.5.4rc01:";;
esac
cat <<\_ACEOF
@@ -1485,7 +1485,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libpng configure 1.5.4beta01
libpng configure 1.5.4rc01
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1908,7 +1908,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libpng $as_me 1.5.4beta01, which was
It was created by libpng $as_me 1.5.4rc01, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@@ -2723,7 +2723,7 @@ fi
# Define the identity of the package.
PACKAGE='libpng'
VERSION='1.5.4beta01'
VERSION='1.5.4rc01'
cat >>confdefs.h <<_ACEOF
@@ -2787,7 +2787,7 @@ fi
PNGLIB_VERSION=1.5.4beta01
PNGLIB_VERSION=1.5.4rc01
PNGLIB_MAJOR=1
PNGLIB_MINOR=5
PNGLIB_RELEASE=4
@@ -13040,7 +13040,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libpng $as_me 1.5.4beta01, which was
This file was extended by libpng $as_me 1.5.4rc01, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -13106,7 +13106,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
libpng config.status 1.5.4beta01
libpng config.status 1.5.4rc01
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"

View File

@@ -18,12 +18,12 @@ AC_PREREQ(2.59)
dnl Version number stuff here:
AC_INIT([libpng], [1.5.4beta01], [png-mng-implement@lists.sourceforge.net])
AC_INIT([libpng], [1.5.4rc01], [png-mng-implement@lists.sourceforge.net])
AM_INIT_AUTOMAKE
dnl stop configure from automagically running automake
AM_MAINTAINER_MODE
PNGLIB_VERSION=1.5.4beta01
PNGLIB_VERSION=1.5.4rc01
PNGLIB_MAJOR=1
PNGLIB_MINOR=5
PNGLIB_RELEASE=4

View File

@@ -229,8 +229,14 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
png_set_expand(png_ptr);
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_expand(png_ptr);
#ifdef PNG_READ_16_TO_8_SUPPORTED
if (bit_depth == 16)
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
png_set_scale_16(png_ptr);
# else
png_set_strip_16(png_ptr);
# endif
#endif
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);

View File

@@ -311,8 +311,14 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
png_set_expand(png_ptr);
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_expand(png_ptr);
#ifdef PNG_READ_16_TO_8_SUPPORTED
if (bit_depth == 16)
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
png_set_scale_16(png_ptr);
# else
png_set_strip_16(png_ptr);
# endif
#endif
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);

View File

@@ -36,4 +36,4 @@ option FLOATING_ARITHMETIC off
option SETJMP on
option STDIO on
option READ_EXPAND on
option READ_16_TO_8 on
option READ_STRIP_16_TO_8 on

View File

@@ -36,5 +36,5 @@ option STDIO on
option READ_bKGD on
option READ_GAMMA on
option READ_EXPAND on
option READ_16_TO_8 on
option READ_STRIP_16_TO_8 on
option READ_GRAY_TO_RGB on

View File

@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
{
fprintf (stderr, "PNG2PNM\n");
fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n");
fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
exit(1);
}

View File

@@ -175,8 +175,14 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
// expand images of all color-type and bit-depth to 3x8 bit RGB images
// let the library process things like alpha, transparency, background
if (iBitDepth == 16)
png_set_strip_16(png_ptr);
#ifdef PNG_READ_16_TO_8_SUPPORTED
if (iBitDepth == 16)
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
png_set_scale_16(png_ptr);
# else
png_set_strip_16(png_ptr);
# endif
#endif
if (iColorType == PNG_COLOR_TYPE_PALETTE)
png_set_expand(png_ptr);
if (iBitDepth < 8)

View File

@@ -2,7 +2,7 @@
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* This file has been placed in the public domain by the authors.
* Maintained 1998-2011 Glenn Randers-Pehrson
* Maintained 1996, 1997 Andreas Dilger)
@@ -187,8 +187,15 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
* are mutually exclusive.
*/
/* Tell libpng to strip 16 bit/color files down to 8 bits/color */
/* Tell libpng to strip 16 bit/color files down to 8 bits/color.
* Use accurate scaling if it's available, otherwise just chop off the
* low byte.
*/
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
png_set_scale_16(png_ptr);
#else
png_set_strip_16(png_ptr);
#endif
/* Strip alpha bytes from the input data without combining with the
* background (not recommended).

View File

@@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.5.4beta01 - June 14, 2011
libpng version 1.5.4rc01 - June 30, 2011
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2011 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.5.4beta01 - June 14, 2011
libpng versions 0.97, January 1998, through 1.5.4rc01 - June 30, 2011
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2011 Glenn Randers-Pehrson
@@ -647,12 +647,12 @@ If you intend to display the PNG or to incorporate it in other image data you
need to tell libpng information about your display or drawing surface so that
libpng can convert the values in the image to match the display.
From libpng-1.5.3 this information can be set before reading the PNG file
From libpng-1.5.4 this information can be set before reading the PNG file
header. In earlier versions png_set_gamma() existed but behaved incorrectly if
called before the PNG file header had been read and png_set_alpha_mode() did not
exist.
If you need to support versions prior to libpng-1.5.3 test the version number
If you need to support versions prior to libpng-1.5.4 test the version number
and follow the procedures described in the appropriate manual page.
You give libpng the encoding expected by your system expressed as a 'gamma'
@@ -673,7 +673,7 @@ documentation!
Many systems permit the system gamma to be changed via a lookup table in the
display driver, a few systems, including older Macs, change the response by
default. As of 1.5.3 three special values are available to handle common
default. As of 1.5.4 three special values are available to handle common
situations:
PNG_DEFAULT_sRGB: Indicates that the system conforms to the IEC 61966-2-1
@@ -844,11 +844,16 @@ color!)
You set the transforms you need later, either as flags to the high level
interface or libpng API calls for the low level interface. For reference the
settings required are:
settings and API calls required are:
8-bit values:
PNG_TRANSFORM_STRIP_16 | PNG_EXPAND
png_set_expand(png_ptr); png_set_strip_16(png_ptr);
PNG_TRANSFORM_SCALE_16 | PNG_EXPAND
png_set_expand(png_ptr); png_set_scale_16(png_ptr);
If you must get exactly the same inaccurate results
produced by default in versions prior to libpng-1.5.4,
use PNG_TRANSFORM_STRIP_16 and png_set_strip_16(png_ptr)
instead.
16-bit values:
PNG_TRANSFORM_EXPAND_16
@@ -859,9 +864,9 @@ color data you can add PNG_TRANSFORM_GRAY_TO_RGB or png_set_gray_to_rgb(png_ptr)
to the list.
Calling png_set_background before the PNG file header is read will not work
prior to libpng-1.5.3. Because the failure may result in unexpected warnings or
prior to libpng-1.5.4. Because the failure may result in unexpected warnings or
errors it is therefore much safer to call png_set_background after the head has
been read. Unfortunately this means that prior to libpng-1.5.3 it cannot be
been read. Unfortunately this means that prior to libpng-1.5.4 it cannot be
used with the high level interface.
The high-level read interface
@@ -873,8 +878,10 @@ the entire image into memory, and (b) the input transformations
you want to do are limited to the following set:
PNG_TRANSFORM_IDENTITY No transformation
PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to
8-bit
PNG_TRANSFORM_SCALE_16 Strip 16-bit samples to
8-bit accurately
PNG_TRANSFORM_STRIP_16 Chop 16-bit samples to
8-bit less accurately
PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel
PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit
samples to bytes
@@ -968,9 +975,9 @@ for use in later transformations. Important information copied in is:
1) The PNG file gamma from the gAMA chunk. This overwrites the default value
provided by an earlier call to png_set_gamma or png_set_alpha_mode.
2) Prior to libpng-1.5.3 the background color from a bKGd chunk. This
2) Prior to libpng-1.5.4 the background color from a bKGd chunk. This
damages the information provided by an earlier call to png_set_background
resulting in expected behavior. Libpng-1.5.3 no longer does this.
resulting in expected behavior. Libpng-1.5.4 no longer does this.
3) The number of significant bits in each component value. Libpng uses this to
optimize gamma handling by reducing the internal lookup table sizes.
@@ -1399,12 +1406,12 @@ 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()
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_strip_16() is called to
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(), or png_set_strip_16().
be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(),
or png_set_scale_16().
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
@@ -1441,7 +1448,7 @@ PNG can have files with 16 bits per channel. If you only can handle
8 bits per channel, this will strip the pixels down to 8-bit.
if (bit_depth == 16)
png_set_strip_16(png_ptr);
png_set_scale_16(png_ptr);
If you need to process the alpha channel on the image separately from the image
data (for example if you convert it to a bitmap mask) it is possible to have
@@ -1634,7 +1641,7 @@ can be determined.
The png_set_background() function has been described already, it tells libpng to
composite images with alpha or simple transparency against the supplied
background color. For compatibility with versions of libpng earlier than
libpng-1.5.3 it is recommended that you call the function after reading the file
libpng-1.5.4 it is recommended that you call the function after reading the file
header, even if you don't want to use the color in a bKGD chunk, if one exists.
If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
@@ -1671,7 +1678,7 @@ image_background->gray.
If you didn't call png_set_gamma() before reading the file header, for example
if you need your code to remain compatible with older versions of libpng prior
to libpng-1.5.3, this is the place to call it.
to libpng-1.5.4, this is the place to call it.
Do not call it if you called png_set_alpha_mode(); doing so will damage the
settings put in place by png_set_alpha_mode(). (If png_set_alpha_mode() is
@@ -4090,20 +4097,20 @@ PNG_NO_USE_READ_MACROS before including png.h. Notice that this is
only supported from 1.5.0 -defining PNG_NO_USE_READ_MACROS prior to 1.5.0
will lead to a link failure.
Prior to libpng-1.5.3, the zlib compressor used the same set of parameters
Prior to libpng-1.5.4, the zlib compressor used the same set of parameters
when compressing the IDAT data and textual data such as zTXt and iCCP.
In libpng-1.5.3 we reinitialized the zlib stream for each type of data.
In libpng-1.5.4 we reinitialized the zlib stream for each type of data.
We added five png_set_text_*() functions for setting the parameters to
use with textual data.
Prior to libpng-1.5.3, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
Prior to libpng-1.5.4, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
option was off by default, and slightly inaccurate scaling occurred.
This option can no longer be turned off, and 16-to-8 scaling is always
accurate. This change will result in some different results while
reading 16-bit images, with none of the pixels being off-by-one any
longer (see Clause 13.12 of the PNG specification).
This option can no longer be turned off, and the choice of accurate
or inaccurate 16-to-8 scaling is by using the new png_set_scale_16_to_8()
API for accurate scaling or the old png_set_strip_16_to_8() API for simple
chopping.
Prior to libpng-1.5.3, the png_set_user_limits() function could only be
Prior to libpng-1.5.4, the png_set_user_limits() function could only be
used to reduce the width and height limits from the value of
PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said
that it could be used to override them. Now this function will reduce or
@@ -4417,13 +4424,13 @@ Other rules can be inferred by inspecting the libpng source.
XIV. Y2K Compliance in libpng
June 14, 2011
June 30, 2011
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.5.4beta01 are Y2K compliant. It is my belief that earlier
upward through 1.5.4rc01 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that

View File

@@ -1,6 +1,6 @@
.TH LIBPNG 3 "June 14, 2011"
.TH LIBPNG 3 "June 30, 2011"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta01
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4rc01
.SH SYNOPSIS
\fI\fB
@@ -764,6 +764,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta01
\fI\fB
\fBvoid png_set_scale_16 (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP
\fI\fB
@@ -951,7 +955,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.5.4beta01 - June 14, 2011
libpng version 1.5.4rc01 - June 30, 2011
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2011 Glenn Randers-Pehrson
@@ -962,7 +966,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.5.4beta01 - June 14, 2011
libpng versions 0.97, January 1998, through 1.5.4rc01 - June 30, 2011
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2011 Glenn Randers-Pehrson
@@ -1598,12 +1602,12 @@ If you intend to display the PNG or to incorporate it in other image data you
need to tell libpng information about your display or drawing surface so that
libpng can convert the values in the image to match the display.
From libpng-1.5.3 this information can be set before reading the PNG file
From libpng-1.5.4 this information can be set before reading the PNG file
header. In earlier versions png_set_gamma() existed but behaved incorrectly if
called before the PNG file header had been read and png_set_alpha_mode() did not
exist.
If you need to support versions prior to libpng-1.5.3 test the version number
If you need to support versions prior to libpng-1.5.4 test the version number
and follow the procedures described in the appropriate manual page.
You give libpng the encoding expected by your system expressed as a 'gamma'
@@ -1624,7 +1628,7 @@ documentation!
Many systems permit the system gamma to be changed via a lookup table in the
display driver, a few systems, including older Macs, change the response by
default. As of 1.5.3 three special values are available to handle common
default. As of 1.5.4 three special values are available to handle common
situations:
PNG_DEFAULT_sRGB: Indicates that the system conforms to the IEC 61966-2-1
@@ -1795,11 +1799,16 @@ color!)
You set the transforms you need later, either as flags to the high level
interface or libpng API calls for the low level interface. For reference the
settings required are:
settings and API calls required are:
8-bit values:
PNG_TRANSFORM_STRIP_16 | PNG_EXPAND
png_set_expand(png_ptr); png_set_strip_16(png_ptr);
PNG_TRANSFORM_SCALE_16 | PNG_EXPAND
png_set_expand(png_ptr); png_set_scale_16(png_ptr);
If you must get exactly the same inaccurate results
produced by default in versions prior to libpng-1.5.4,
use PNG_TRANSFORM_STRIP_16 and png_set_strip_16(png_ptr)
instead.
16-bit values:
PNG_TRANSFORM_EXPAND_16
@@ -1810,9 +1819,9 @@ color data you can add PNG_TRANSFORM_GRAY_TO_RGB or png_set_gray_to_rgb(png_ptr)
to the list.
Calling png_set_background before the PNG file header is read will not work
prior to libpng-1.5.3. Because the failure may result in unexpected warnings or
prior to libpng-1.5.4. Because the failure may result in unexpected warnings or
errors it is therefore much safer to call png_set_background after the head has
been read. Unfortunately this means that prior to libpng-1.5.3 it cannot be
been read. Unfortunately this means that prior to libpng-1.5.4 it cannot be
used with the high level interface.
.SS The high-level read interface
@@ -1824,8 +1833,10 @@ the entire image into memory, and (b) the input transformations
you want to do are limited to the following set:
PNG_TRANSFORM_IDENTITY No transformation
PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to
8-bit
PNG_TRANSFORM_SCALE_16 Strip 16-bit samples to
8-bit accurately
PNG_TRANSFORM_STRIP_16 Chop 16-bit samples to
8-bit less accurately
PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel
PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit
samples to bytes
@@ -1919,9 +1930,9 @@ for use in later transformations. Important information copied in is:
1) The PNG file gamma from the gAMA chunk. This overwrites the default value
provided by an earlier call to png_set_gamma or png_set_alpha_mode.
2) Prior to libpng-1.5.3 the background color from a bKGd chunk. This
2) Prior to libpng-1.5.4 the background color from a bKGd chunk. This
damages the information provided by an earlier call to png_set_background
resulting in expected behavior. Libpng-1.5.3 no longer does this.
resulting in expected behavior. Libpng-1.5.4 no longer does this.
3) The number of significant bits in each component value. Libpng uses this to
optimize gamma handling by reducing the internal lookup table sizes.
@@ -2350,12 +2361,12 @@ 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()
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_strip_16() is called to
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(), or png_set_strip_16().
be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(),
or png_set_scale_16().
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
@@ -2392,7 +2403,7 @@ PNG can have files with 16 bits per channel. If you only can handle
8 bits per channel, this will strip the pixels down to 8-bit.
if (bit_depth == 16)
png_set_strip_16(png_ptr);
png_set_scale_16(png_ptr);
If you need to process the alpha channel on the image separately from the image
data (for example if you convert it to a bitmap mask) it is possible to have
@@ -2585,7 +2596,7 @@ can be determined.
The png_set_background() function has been described already, it tells libpng to
composite images with alpha or simple transparency against the supplied
background color. For compatibility with versions of libpng earlier than
libpng-1.5.3 it is recommended that you call the function after reading the file
libpng-1.5.4 it is recommended that you call the function after reading the file
header, even if you don't want to use the color in a bKGD chunk, if one exists.
If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
@@ -2622,7 +2633,7 @@ image_background->gray.
If you didn't call png_set_gamma() before reading the file header, for example
if you need your code to remain compatible with older versions of libpng prior
to libpng-1.5.3, this is the place to call it.
to libpng-1.5.4, this is the place to call it.
Do not call it if you called png_set_alpha_mode(); doing so will damage the
settings put in place by png_set_alpha_mode(). (If png_set_alpha_mode() is
@@ -5041,20 +5052,20 @@ PNG_NO_USE_READ_MACROS before including png.h. Notice that this is
only supported from 1.5.0 -defining PNG_NO_USE_READ_MACROS prior to 1.5.0
will lead to a link failure.
Prior to libpng-1.5.3, the zlib compressor used the same set of parameters
Prior to libpng-1.5.4, the zlib compressor used the same set of parameters
when compressing the IDAT data and textual data such as zTXt and iCCP.
In libpng-1.5.3 we reinitialized the zlib stream for each type of data.
In libpng-1.5.4 we reinitialized the zlib stream for each type of data.
We added five png_set_text_*() functions for setting the parameters to
use with textual data.
Prior to libpng-1.5.3, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
Prior to libpng-1.5.4, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
option was off by default, and slightly inaccurate scaling occurred.
This option can no longer be turned off, and 16-to-8 scaling is always
accurate. This change will result in some different results while
reading 16-bit images, with none of the pixels being off-by-one any
longer (see Clause 13.12 of the PNG specification).
This option can no longer be turned off, and the choice of accurate
or inaccurate 16-to-8 scaling is by using the new png_set_scale_16_to_8()
API for accurate scaling or the old png_set_strip_16_to_8() API for simple
chopping.
Prior to libpng-1.5.3, the png_set_user_limits() function could only be
Prior to libpng-1.5.4, the png_set_user_limits() function could only be
used to reduce the width and height limits from the value of
PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said
that it could be used to override them. Now this function will reduce or
@@ -5368,13 +5379,13 @@ Other rules can be inferred by inspecting the libpng source.
.SH XIV. Y2K Compliance in libpng
June 14, 2011
June 30, 2011
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.5.4beta01 are Y2K compliant. It is my belief that earlier
upward through 1.5.4rc01 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that
@@ -5565,8 +5576,10 @@ the first widely used release:
1.5.2 15 10502 15.so.15.2[.0]
1.5.3beta01-10 15 10503 15.so.15.3[.0]
1.5.3rc01-02 15 10503 15.so.15.3[.0]
1.5.3beta11 [no 1.5.3] 15 10503 15.so.15.3[.0]
1.5.4beta01 15 10504 15.so.15.4[.0]
1.5.3beta11 15 10503 15.so.15.3[.0]
1.5.3 [omitted]
1.5.4beta01-08 15 10504 15.so.15.4[.0]
1.5.4rc01 15 10504 15.so.15.4[.0]
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@@ -5623,7 +5636,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.5.4beta01 - June 14, 2011:
Libpng version 1.5.4rc01 - June 30, 2011:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@@ -5646,7 +5659,7 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.5.4beta01, June 14, 2011, are
libpng versions 1.2.6, August 15, 2004, through 1.5.4rc01, June 30, 2011, are
Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@@ -5745,7 +5758,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
June 14, 2011
June 30, 2011
.\" end of man page

View File

@@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "June 14, 2011"
.TH LIBPNGPF 3 "June 30, 2011"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta01
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4rc01
(private functions)
.SH SYNOPSIS
\fB#include \fI"pngpriv.h"

2
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "June 14, 2011"
.TH PNG 5 "June 30, 2011"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION

106
png.c
View File

@@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -14,7 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_5_4beta01 Your_png_h_is_not_version_1_5_4beta01;
typedef png_libpng_version_1_5_4rc01 Your_png_h_is_not_version_1_5_4rc01;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@@ -617,13 +617,13 @@ png_get_copyright(png_const_structp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.5.4beta01 - June 14, 2011" PNG_STRING_NEWLINE \
"libpng version 1.5.4rc01 - June 30, 2011" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
return "libpng version 1.5.4beta01 - June 14, 2011\
return "libpng version 1.5.4rc01 - June 30, 2011\
Copyright (c) 1998-2011 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -946,16 +946,9 @@ png_check_IHDR(png_structp png_ptr,
/* Check an ASCII formated floating point value, see the more detailed
* comments in pngpriv.h
*/
/* The following is used internally to preserve the 'valid' flag */
/* The following is used internally to preserve the sticky flags */
#define png_fp_add(state, flags) ((state) |= (flags))
#define png_fp_set(state, value)\
((state) = (value) | ((state) & PNG_FP_WAS_VALID))
/* Internal type codes: bits above the base state! */
#define PNG_FP_SIGN 0 /* [+-] */
#define PNG_FP_DOT 4 /* . */
#define PNG_FP_DIGIT 8 /* [0123456789] */
#define PNG_FP_E 12 /* [Ee] */
#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY))
int /* PRIVATE */
png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
@@ -968,55 +961,55 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
{
int type;
/* First find the type of the next character */
switch (string[i])
{
char ch = string[i];
if (ch >= 48 && ch <= 57)
type = PNG_FP_DIGIT;
else switch (ch)
{
case 43: case 45: type = PNG_FP_SIGN; break;
case 46: type = PNG_FP_DOT; break;
case 69: case 101: type = PNG_FP_E; break;
default: goto PNG_FP_End;
}
case 43: type = PNG_FP_SAW_SIGN; break;
case 45: type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break;
case 46: type = PNG_FP_SAW_DOT; break;
case 48: type = PNG_FP_SAW_DIGIT; break;
case 49: case 50: case 51: case 52:
case 53: case 54: case 55: case 56:
case 57: type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break;
case 69:
case 101: type = PNG_FP_SAW_E; break;
default: goto PNG_FP_End;
}
/* Now deal with this type according to the current
* state, the type is arranged to not overlap the
* bits of the PNG_FP_STATE.
*/
switch ((state & PNG_FP_STATE) + type)
switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY))
{
case PNG_FP_INTEGER + PNG_FP_SIGN:
case PNG_FP_INTEGER + PNG_FP_SAW_SIGN:
if (state & PNG_FP_SAW_ANY)
goto PNG_FP_End; /* not a part of the number */
png_fp_add(state, PNG_FP_SAW_SIGN);
png_fp_add(state, type);
break;
case PNG_FP_INTEGER + PNG_FP_DOT:
case PNG_FP_INTEGER + PNG_FP_SAW_DOT:
/* Ok as trailer, ok as lead of fraction. */
if (state & PNG_FP_SAW_DOT) /* two dots */
goto PNG_FP_End;
else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */
png_fp_add(state, PNG_FP_SAW_DOT);
png_fp_add(state, type);
else
png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);
png_fp_set(state, PNG_FP_FRACTION | type);
break;
case PNG_FP_INTEGER + PNG_FP_DIGIT:
case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT:
if (state & PNG_FP_SAW_DOT) /* delayed fraction */
png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);
png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID);
png_fp_add(state, type | PNG_FP_WAS_VALID);
break;
case PNG_FP_INTEGER + PNG_FP_E:
case PNG_FP_INTEGER + PNG_FP_SAW_E:
if ((state & PNG_FP_SAW_DIGIT) == 0)
goto PNG_FP_End;
@@ -1024,17 +1017,17 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
break;
/* case PNG_FP_FRACTION + PNG_FP_SIGN:
goto PNG_FP_End; ** no sign in exponent */
/* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN:
goto PNG_FP_End; ** no sign in fraction */
/* case PNG_FP_FRACTION + PNG_FP_DOT:
/* case PNG_FP_FRACTION + PNG_FP_SAW_DOT:
goto PNG_FP_End; ** Because SAW_DOT is always set */
case PNG_FP_FRACTION + PNG_FP_DIGIT:
png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID);
case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT:
png_fp_add(state, type | PNG_FP_WAS_VALID);
break;
case PNG_FP_FRACTION + PNG_FP_E:
case PNG_FP_FRACTION + PNG_FP_SAW_E:
/* This is correct because the trailing '.' on an
* integer is handled above - so we can only get here
* with the sequence ".E" (with no preceding digits).
@@ -1046,7 +1039,7 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
break;
case PNG_FP_EXPONENT + PNG_FP_SIGN:
case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN:
if (state & PNG_FP_SAW_ANY)
goto PNG_FP_End; /* not a part of the number */
@@ -1054,15 +1047,15 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
break;
/* case PNG_FP_EXPONENT + PNG_FP_DOT:
/* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT:
goto PNG_FP_End; */
case PNG_FP_EXPONENT + PNG_FP_DIGIT:
png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID);
case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT:
png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID);
break;
/* case PNG_FP_EXPONEXT + PNG_FP_E:
/* case PNG_FP_EXPONEXT + PNG_FP_SAW_E:
goto PNG_FP_End; */
default: goto PNG_FP_End; /* I.e. break 2 */
@@ -1090,8 +1083,11 @@ png_check_fp_string(png_const_charp string, png_size_t size)
int state=0;
png_size_t char_index=0;
return png_check_fp_number(string, size, &state, &char_index) &&
(char_index == size || string[char_index] == 0);
if (png_check_fp_number(string, size, &state, &char_index) &&
(char_index == size || string[char_index] == 0))
return state /* must be non-zero - see above */;
return 0; /* i.e. fail */
}
#endif /* pCAL or sCAL */
@@ -1845,7 +1841,7 @@ png_8bit_l2[128] =
#endif
};
static png_int_32
PNG_STATIC png_int_32
png_log8bit(unsigned int x)
{
unsigned int lg2 = 0;
@@ -1901,7 +1897,7 @@ png_log8bit(unsigned int x)
* Zero (257): 0
* End (258): 23499
*/
static png_int_32
PNG_STATIC png_int_32
png_log16bit(png_uint_32 x)
{
unsigned int lg2 = 0;
@@ -1995,7 +1991,7 @@ for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"}
0 45425.85339951654943850496
#endif
static png_uint_32
PNG_STATIC png_uint_32
png_exp(png_fixed_point x)
{
if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */
@@ -2043,7 +2039,7 @@ png_exp(png_fixed_point x)
return 0;
}
static png_byte
PNG_STATIC png_byte
png_exp8bit(png_fixed_point lg2)
{
/* Get a 32-bit value: */
@@ -2057,7 +2053,7 @@ png_exp8bit(png_fixed_point lg2)
return (png_byte)((x + 0x7fffffU) >> 24);
}
static png_uint_16
PNG_STATIC png_uint_16
png_exp16bit(png_fixed_point lg2)
{
/* Get a 32-bit value: */
@@ -2369,7 +2365,7 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
else
shift = 0; /* keep all 16 bits */
if (png_ptr->transformations & PNG_16_TO_8)
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))
{
/* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively
* the significant bits in the *input* when the output will
@@ -2385,12 +2381,12 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
png_ptr->gamma_shift = shift;
#ifdef PNG_16BIT_SUPPORTED
/* NOTE: prior to 1.5.3 this test used to include PNG_BACKGROUND (now
/* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
* PNG_COMPOSE). This effectively smashed the background calculation for
* 16-bit output because the 8-bit table assumes the result will be reduced
* to 8 bits.
*/
if (png_ptr->transformations & PNG_16_TO_8)
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))
#endif
png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
png_ptr->screen_gamma > 0 ? png_product2(png_ptr->gamma,

39
png.h
View File

@@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.5.4beta01 - June 14, 2011
* libpng version 1.5.4rc01 - June 30, 2011
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -11,7 +11,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.5.4beta01 - June 14, 2011: Glenn
* libpng versions 0.97, January 1998, through 1.5.4rc01 - June 30, 2011: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@@ -152,8 +152,10 @@
* 1.5.2 15 10502 15.so.15.2[.0]
* 1.5.3beta01-10 15 10503 15.so.15.3[.0]
* 1.5.3rc01-02 15 10503 15.so.15.3[.0]
* 1.5.3beta11 [no 1.5.3] 15 10503 15.so.15.3[.0]
* 1.5.4beta01 15 10504 15.so.15.4[.0]
* 1.5.3beta11 15 10503 15.so.15.3[.0]
* 1.5.3 [omitted]
* 1.5.4beta01-08 15 10504 15.so.15.4[.0]
* 1.5.4rc01 15 10504 15.so.15.4[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -185,7 +187,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.5.4beta01, June 14, 2011, are
* libpng versions 1.2.6, August 15, 2004, through 1.5.4rc01, June 30, 2011, are
* Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
@@ -297,13 +299,13 @@
* Y2K compliance in libpng:
* =========================
*
* June 14, 2011
* June 30, 2011
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.5.4beta01 are Y2K compliant. It is my belief that
* upward through 1.5.4rc01 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant.
*
* Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -358,9 +360,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.5.4beta01"
#define PNG_LIBPNG_VER_STRING "1.5.4rc01"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.5.4beta01 - June 14, 2011\n"
" libpng version 1.5.4rc01 - June 30, 2011\n"
#define PNG_LIBPNG_VER_SONUM 15
#define PNG_LIBPNG_VER_DLLNUM 15
@@ -520,7 +522,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef char* png_libpng_version_1_5_4beta01;
typedef char* png_libpng_version_1_5_4rc01;
/* Three color definitions. The order of the red, green, and blue, (and the
* exact size) is not important, although the size of the fields need to
@@ -597,7 +599,7 @@ typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
* and whether that contents is compressed or not. The "key" field
* points to a regular zero-terminated C string. The "text", "lang", and
* "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
* However, the * structure returned by png_get_text() will always contain
* However, the structure returned by png_get_text() will always contain
* regular zero-terminated C strings (possibly empty), never NULL pointers,
* so they can be safely used in printf() and other string-handling functions.
*/
@@ -899,8 +901,9 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
/* Added to libpng-1.4.0 */
#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
/* Added to libpng-1.5.3 */
/* Added to libpng-1.5.4 */
#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
/* Flags for MNG supported features */
#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
@@ -1403,7 +1406,7 @@ PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr));
#ifdef PNG_READ_BACKGROUND_SUPPORTED
/* Handle alpha and tRNS by replacing with a background color. Prior to
* libpng-1.5.3 this API must not be called before the PNG file header has been
* libpng-1.5.4 this API must not be called before the PNG file header has been
* read. Doing so will result in unexpected behavior and possible warnings or
* errors if the PNG file contains a bKGD chunk.
*/
@@ -1421,7 +1424,13 @@ PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr,
# define PNG_BACKGROUND_GAMMA_UNIQUE 3
#endif
#ifdef PNG_READ_16_TO_8_SUPPORTED
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
/* Scale a 16-bit depth file down to 8-bit, accurately. */
PNG_EXPORT(229, void, png_set_scale_16, (png_structp png_ptr));
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
/* Strip the second byte of information from a 16-bit depth file. */
PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr));
#endif
@@ -2566,7 +2575,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
* scripts/symbols.def as well.
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
PNG_EXPORT_LAST_ORDINAL(228);
PNG_EXPORT_LAST_ORDINAL(229);
#endif
#ifdef __cplusplus

View File

@@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.5.4beta01 - June 14, 2011
* libpng version 1.5.4rc01 - June 30, 2011
*
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -385,7 +385,9 @@
# define PNG_NORETURN __declspec(noreturn)
# endif
# ifndef PNG_ALLOCATED
# define PNG_ALLOCATED __declspec(restrict)
# if (_MSC_VER >= 1400)
# define PNG_ALLOCATED __declspec(restrict)
# endif
# endif
/* This specifically protects structure members that should only be

View File

@@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -507,7 +507,7 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
{
#ifdef PNG_CONSOLE_IO_SUPPORTED
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
/* Check on NULL only added in 1.5.3 */
/* Check on NULL only added in 1.5.4 */
if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
{
/* Strip "#nnnn " from beginning of error message. */

View File

@@ -138,7 +138,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
* single color specified that should be treated as fully transparent.
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
*/
png_bytep trans; /* alpha values for paletted image */
png_bytep trans_alpha; /* alpha values for paletted image */
png_color_16 trans_color; /* transparent color for non-palette image */
#endif

View File

@@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)

View File

@@ -6,7 +6,7 @@
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -115,8 +115,15 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
# define PNG_ZBUF_SIZE 65536L
#endif
/* PNG_STATIC is used to mark internal file scope functions if they need to be
* accessed for implementation tests (see the code in tests/?*).
*/
#ifndef PNG_STATIC
# define PNG_STATIC static
#endif
/* If warnings or errors are turned off the code is disabled or redirected here.
* From 1.5.3 functions have been added to allow very limited formatting of
* From 1.5.4 functions have been added to allow very limited formatting of
* error and warning messages - this code will also be disabled here.
*/
#ifdef PNG_WARNINGS_SUPPORTED
@@ -281,7 +288,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
#define PNG_BACKGROUND_EXPAND 0x0100
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
#define PNG_16_TO_8 0x0400
#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
#define PNG_RGBA 0x0800
#define PNG_EXPAND 0x1000
#define PNG_GAMMA 0x2000
@@ -295,10 +302,10 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
#define PNG_RGB_TO_GRAY_ERR 0x200000L
#define PNG_RGB_TO_GRAY_WARN 0x400000L
#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
#define PNG_ENCODE_ALPHA 0x800000L /* Added to libpng-1.5.3 */
#define PNG_ENCODE_ALPHA 0x800000L /* Added to libpng-1.5.4 */
#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */
/* 0x4000000L unused */
#define PNG_SCALE_16_TO_8 0x4000000L /* Added to libpng-1.5.4 */
/* 0x8000000L unused */
/* 0x10000000L unused */
/* 0x20000000L unused */
@@ -325,9 +332,9 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.3 */
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.3 */
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.3 */
#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L
@@ -338,7 +345,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
/* 0x400000L unused */
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */
#define PNG_FLAG_ZTXT_CUSTOM_STRATEGY 0x1000000L /* 5 lines added */
#define PNG_FLAG_ZTXT_CUSTOM_LEVEL 0x2000000L /* to libpng-1.5.3 */
#define PNG_FLAG_ZTXT_CUSTOM_LEVEL 0x2000000L /* to libpng-1.5.4 */
#define PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL 0x4000000L
#define PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS 0x8000000L
#define PNG_FLAG_ZTXT_CUSTOM_METHOD 0x10000000L
@@ -452,7 +459,7 @@ PNG_EXTERN png_fixed_point png_fixed PNGARG((png_structp png_ptr, double fp,
#define PNG_tRNS PNG_CONST png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
#define PNG_zTXt PNG_CONST png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
/* Gamma values (new at libpng-1.5.3): */
/* Gamma values (new at libpng-1.5.4): */
#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */
#define PNG_GAMMA_MAC_INVERSE 65909
#define PNG_GAMMA_sRGB_INVERSE 45455
@@ -819,7 +826,12 @@ PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info,
png_bytep row));
#endif
#ifdef PNG_READ_16_TO_8_SUPPORTED
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
PNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info,
png_bytep row));
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,
png_bytep row));
#endif
@@ -1128,7 +1140,7 @@ PNG_EXTERN png_charp png_format_number(png_const_charp start, png_charp end,
#endif
#ifdef PNG_WARNINGS_SUPPORTED
/* New defines and members adding in libpng-1.5.3 */
/* New defines and members adding in libpng-1.5.4 */
# define PNG_WARNING_PARAMETER_SIZE 32
# define PNG_WARNING_PARAMETER_COUNT 8
@@ -1221,8 +1233,18 @@ PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr,
#define PNG_FP_SAW_DOT 16 /* Saw a dot in current state */
#define PNG_FP_SAW_E 32 /* Saw an E (or e) in current state */
#define PNG_FP_SAW_ANY 60 /* Saw any of the above 4 */
/* These three values don't affect the parser. They are set but not used.
*/
#define PNG_FP_WAS_VALID 64 /* Preceding substring is a valid fp number */
#define PNG_FP_INVALID 128 /* Available for callers as a distinct value */
#define PNG_FP_NEGATIVE 128 /* A negative number, including "-0" */
#define PNG_FP_NONZERO 256 /* A non-zero value */
#define PNG_FP_STICKY 448 /* The above three flags */
/* This is available for the caller to store in 'state' if required. Do not
* call the parser after setting it (the parser sometimes clears it.)
*/
#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */
/* Result codes for the parser (boolean - true meants ok, false means
* not ok yet.)
@@ -1230,6 +1252,20 @@ PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr,
#define PNG_FP_MAYBE 0 /* The number may be valid in the future */
#define PNG_FP_OK 1 /* The number is valid */
/* Tests on the sticky non-zero and negative flags. To pass these checks
* the state must also indicate that the whole number is valid - this is
* achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this
* is equivalent to PNG_FP_OK above.)
*/
#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)
/* NZ_MASK: the string is valid and a non-zero negative value */
#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)
/* Z MASK: the string is valid and a non-zero value. */
/* PNG_FP_SAW_DIGIT: the string is valid. */
#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)
#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)
#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)
/* The actual parser. This can be called repeatedly, it updates
* the index into the string and the state variable (which must
* be initialzed to 0). It returns a result code, as above. There
@@ -1249,7 +1285,10 @@ PNG_EXTERN int png_check_fp_number PNGARG((png_const_charp string,
png_size_t size, int *statep, png_size_tp whereami));
/* This is the same but it checks a complete string and returns true
* only if it just contains a floating point number.
* only if it just contains a floating point number. As of 1.5.4 this
* function also returns the state at the end of parsing the number if
* it was valid (otherwise it returns 0.) This can be used for testing
* for negative or zero values using the sticky flag.
*/
PNG_EXTERN int png_check_fp_string PNGARG((png_const_charp string,
png_size_t size));

View File

@@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -1286,9 +1286,23 @@ 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.
*/
if (transforms & PNG_TRANSFORM_SCALE_16)
{
/* 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);
}
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
/* If both SCALE and STRIP are required pngrtran will effectively cancel the
* latter by doing SCALE first. This is ok and allows apps not to check for
* which is supported to get the right answer.
*/
if (transforms & PNG_TRANSFORM_STRIP_16)
png_set_strip_16(png_ptr);
#endif
@@ -1387,7 +1401,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
png_set_gray_to_rgb(png_ptr);
#endif
/* Added at libpng-1.5.3 */
/* Added at libpng-1.5.4 */
#ifdef PNG_READ_EXPAND_16_SUPPORTED
if (transforms & PNG_TRANSFORM_EXPAND_16)
png_set_expand_16(png_ptr);

View File

@@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -132,8 +132,25 @@ png_set_background(png_structp png_ptr,
# endif /* FLOATING_POINT */
#endif /* READ_BACKGROUND */
#ifdef PNG_READ_16_TO_8_SUPPORTED
/* Strip 16-bit depth files to 8-bit depth */
/* Scale 16-bit depth files to 8-bit depth. If both of these are set then the
* one that pngrtran does first (scale) happens. This is necessary to allow the
* TRANSFORM and API behavior to be somewhat consistent, and it's simpler.
*/
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
void PNGAPI
png_set_scale_16(png_structp png_ptr)
{
png_debug(1, "in png_set_scale_16");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_SCALE_16_TO_8;
}
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
/* Chop 16-bit depth files to 8-bit depth */
void PNGAPI
png_set_strip_16(png_structp png_ptr)
{
@@ -757,12 +774,12 @@ png_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma,
if (png_ptr == NULL)
return;
/* New in libpng-1.5.3 - reserve particular negative values as flags. */
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);
file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);
#if PNG_LIBPNG_VER >= 10600
/* Checking the gamma values for being >0 was added in 1.5.3 along with the
/* Checking the gamma values for being >0 was added in 1.5.4 along with the
* premultiplied alpha support; this actually hides an undocumented feature
* of the previous implementation which allowed gamma processing to be
* disabled in background handling. There is no evidence (so far) that this
@@ -1137,7 +1154,7 @@ png_init_palette_transformations(png_structp png_ptr)
static void /* PRIVATE */
png_init_rgb_transformations(png_structp png_ptr)
{
/* Added to libpng-1.5.3: check the color type to determine whether there
/* Added to libpng-1.5.4: check the color type to determine whether there
* is any alpha or transparency in the image and simply cancel the
* background and alpha mode stuff if there isn't.
*/
@@ -1242,9 +1259,9 @@ png_init_read_transformations(png_structp png_ptr)
*/
#ifdef PNG_READ_GAMMA_SUPPORTED
/* Prior to 1.5.3 these tests were performed from png_set_gamma, 1.5.3 adds
/* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds
* png_set_alpha_mode and this is another source for a default file gamma so
* the test needs to be performed later - here. In addition prior to 1.5.3
* the test needs to be performed later - here. In addition prior to 1.5.4
* the tests were repeated for the PALETTE color type here - this is no
* longer necessary (and doesn't seem to have been necessary before.)
*/
@@ -1269,7 +1286,7 @@ png_init_read_transformations(png_structp png_ptr)
else if (png_ptr->screen_gamma != 0)
/* The converse - assume the file matches the screen, note that this
* perhaps undesireable default can (from 1.5.3) be changed by calling
* perhaps undesireable default can (from 1.5.4) be changed by calling
* png_set_alpha_mode (even if the alpha handling mode isn't required
* or isn't changed from the default.)
*/
@@ -1279,7 +1296,7 @@ png_init_read_transformations(png_structp png_ptr)
/* Just in case the following prevents any processing - file and screen
* are both assumed to be linear and there is no way to introduce a
* third gamma value other than png_set_background with 'UNIQUE', and,
* prior to 1.5.3
* prior to 1.5.4
*/
png_ptr->screen_gamma = png_ptr->gamma = PNG_FP_1;
@@ -1312,20 +1329,21 @@ png_init_read_transformations(png_structp png_ptr)
* 6) PNG_GAMMA
* 7) PNG_STRIP_ALPHA (if compose)
* 8) PNG_ENCODE_ALPHA
* 9) PNG_16_TO_8 (strip16)
* 10) PNG_QUANTIZE (converts to palette)
* 11) PNG_EXPAND_16
* 12) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY
* 13) PNG_INVERT_MONO
* 14) PNG_SHIFT
* 15) PNG_PACK
* 16) PNG_BGR
* 17) PNG_PACKSWAP
* 18) PNG_FILLER (includes PNG_ADD_ALPHA)
* 19) PNG_INVERT_ALPHA
* 20) PNG_SWAP_ALPHA
* 21) PNG_SWAP_BYTES
* 22) PNG_USER_TRANSFORM [must be last]
* 9) PNG_SCALE_16_TO_8
* 10) PNG_16_TO_8
* 11) PNG_QUANTIZE (converts to palette)
* 12) PNG_EXPAND_16
* 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY
* 14) PNG_INVERT_MONO
* 15) PNG_SHIFT
* 16) PNG_PACK
* 17) PNG_BGR
* 18) PNG_PACKSWAP
* 19) PNG_FILLER (includes PNG_ADD_ALPHA)
* 20) PNG_INVERT_ALPHA
* 21) PNG_SWAP_ALPHA
* 22) PNG_SWAP_BYTES
* 23) PNG_USER_TRANSFORM [must be last]
*/
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
@@ -1340,12 +1358,12 @@ png_init_read_transformations(png_structp png_ptr)
PNG_EXPAND_tRNS);
png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
/* Kill the tRNS chunk itself too. Prior to 1.5.3 this did not happen
/* Kill the tRNS chunk itself too. Prior to 1.5.4 this did not happen
* so transparency information would remain just so long as it wasn't
* expanded. This produces unexpected API changes if the set of things
* that do PNG_EXPAND_tRNS changes (perfectly possible given the
* documentation - which says ask for what you want, accept what you
* get.) This makes the behavior consistent from 1.5.3:
* get.) This makes the behavior consistent from 1.5.4:
*/
png_ptr->num_trans = 0;
}
@@ -1438,25 +1456,24 @@ png_init_read_transformations(png_structp png_ptr)
*
* The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at
* present, so that case is ok (until do_expand_16 is moved.)
*
* NOTE: this discards the low 16 bits of the user supplied background
* color, but until expand_16 works properly there is no choice!
*/
#ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
# define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16))
#else
# define CHOP(x) ((png_uint_16)((2*(png_uint_32)(x) + 257)/514))
#endif
CHOP(png_ptr->background.red);
CHOP(png_ptr->background.green);
CHOP(png_ptr->background.blue);
CHOP(png_ptr->background.gray);
# undef CHOP
}
#endif
#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */
/* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the
* background support (see the comments in scripts/pnglibconf.dfa), this
* allows pre-multiplication of the alpha channel to be implemented as
* compositing on black. This is probably sub-optimal and has been done in
* 1.5.3 betas simply to enable external critique and testing (i.e. to
* 1.5.4 betas simply to enable external critique and testing (i.e. to
* implement the new API quickly, without lots of internal changes.)
*/
@@ -1475,7 +1492,7 @@ png_init_read_transformations(png_structp png_ptr)
* the gamma tables will not be built even if composition is required on a
* gamma encoded value.
*
* In 1.5.3 this is addressed below by an additional check on the individual
* In 1.5.4 this is addressed below by an additional check on the individual
* file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the
* tables.
*/
@@ -1486,9 +1503,11 @@ png_init_read_transformations(png_structp png_ptr)
|| ((png_ptr->transformations & PNG_COMPOSE)
&& (png_gamma_significant(png_ptr->gamma)
|| png_gamma_significant(png_ptr->screen_gamma)
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
&& png_gamma_significant(png_ptr->background_gamma))))
|| ((png_ptr->transformations & PNG_ENCODE_ALPHA)
&& png_gamma_significant(png_ptr->background_gamma))
# endif
)) || ((png_ptr->transformations & PNG_ENCODE_ALPHA)
&& png_gamma_significant(png_ptr->screen_gamma))
)
{
@@ -1841,7 +1860,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
/* The following used to be conditional on PNG_GAMMA (prior to 1.5.3),
/* The following used to be conditional on PNG_GAMMA (prior to 1.5.4),
* however it seems that the code in png_init_read_transformations, which has
* been called before this from png_read_update_info->png_read_start_row
* sometimes does the gamma transform and cancels the flag.
@@ -1849,19 +1868,43 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->gamma = png_ptr->gamma;
#endif
#ifdef PNG_READ_16_TO_8_SUPPORTED
#ifdef PNG_READ_16BIT_SUPPORTED
if ((png_ptr->transformations & PNG_16_TO_8) && (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)
{
png_ptr->transformations |=PNG_16_TO_8;
info_ptr->bit_depth = 8;
# ifdef PNG_READ_16BIT_SUPPORTED
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
if (png_ptr->transformations & PNG_SCALE_16_TO_8)
info_ptr->bit_depth = 8;
# endif
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
if (png_ptr->transformations & PNG_16_TO_8)
info_ptr->bit_depth = 8;
# endif
# else
/* No 16 bit support: force chopping 16-bit input down to 8, in this case
* the app program can chose if both APIs are available by setting the
* correct scaling to use.
*/
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
/* For compatibility with previous versions use the strip method by
* default. This code works because if PNG_SCALE_16_TO_8 is already
* set the code below will do that in preference to the chop.
*/
png_ptr->transformations |= PNG_16_TO_8;
info_ptr->bit_depth = 8;
# else
# if PNG_READ_SCALE_16_TO_8_SUPPORTED
png_ptr->transformations |= PNG_SCALE_16_TO_8;
info_ptr->bit_depth = 8;
# else
CONFIGURATION ERROR: you must enable at least one 16 to 8 method
# endif
# endif
#endif /* !READ_16BIT_SUPPORTED */
}
#endif
#endif
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
@@ -1948,7 +1991,7 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
/* Adding in 1.5.3: cache the above value in png_struct so that we can later
/* Adding in 1.5.4: cache the above value in png_struct so that we can later
* check in png_rowbytes that the user buffer won't get overwritten. Note
* that the field is not always set - if png_read_update_info isn't called
* the application has to either not do any transforms or get the calculation
@@ -1973,15 +2016,15 @@ png_do_read_transformations(png_structp png_ptr)
if (png_ptr->row_buf == NULL)
{
/* Prior to 1.5.3 this output row/pass where the NULL pointer is, but this
/* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this
* error is incredibly rare and incredibly easy to debug without this
* information.
*/
png_error(png_ptr, "NULL row buffer");
}
/* The following is debugging; prior to 1.5.3 the code was never compiled in;
* in 1.5.3 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
/* The following is debugging; prior to 1.5.4 the code was never compiled in;
* in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
* PNG_WARN_UNINITIALIZED_ROW removed. In 1.5 the new flag is set only for
* selected new APIs to ensure that there is no API change.
*/
@@ -1990,7 +2033,7 @@ png_do_read_transformations(png_structp png_ptr)
{
/* Application has failed to call either png_read_start_image() or
* png_read_update_info() after setting transforms that expand pixels.
* This check added to libpng-1.2.19 (but not enabled until 1.5.3).
* This check added to libpng-1.2.19 (but not enabled until 1.5.4).
*/
png_error(png_ptr, "Uninitialized row");
}
@@ -2121,7 +2164,16 @@ png_do_read_transformations(png_structp png_ptr)
png_do_encode_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr);
#endif
#ifdef PNG_READ_16_TO_8_SUPPORTED
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
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
/* There is no harm in doing both of these because only one has any effect,
* by putting the 'scale' option first if the app asks for scale (either by
* calling the API or in a TRANSFORM flag) this is what happens.
*/
if (png_ptr->transformations & PNG_16_TO_8)
png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
@@ -2148,7 +2200,7 @@ png_do_read_transformations(png_structp png_ptr)
#endif
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
/*NOTE: moved here in 1.5.3 (from much later in this list.) */
/*NOTE: moved here in 1.5.4 (from much later in this list.) */
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
@@ -2452,12 +2504,12 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
}
#endif
#ifdef PNG_READ_16_TO_8_SUPPORTED
/* Chop rows of bit depth 16 down to 8 */
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
/* Scale rows of bit depth 16 down to 8 accurately */
void /* PRIVATE */
png_do_chop(png_row_infop row_info, png_bytep row)
png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_chop");
png_debug(1, "in png_do_scale_16_to_8");
if (row_info->bit_depth == 16)
{
@@ -2499,17 +2551,37 @@ png_do_chop(png_row_infop row_info, png_bytep row)
* (V * 255 + 32895) >> 16
*/
#ifdef PNG_LEGACY_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
*dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0);
#else
png_int_32 tmp = *sp++; /* must be signed! */
# ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24;
# else
sp++;
# endif
*dp++ = (png_byte)tmp;
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
row_info->rowbytes = row_info->width * row_info->channels;
}
}
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
void /* PRIVATE */
/* Simply discard the low byte. This was the default behavior prior
* to libpng-1.5.4.
*/
png_do_chop(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_chop");
if (row_info->bit_depth == 16)
{
png_bytep sp = row; /* source */
png_bytep dp = row; /* destinaton */
png_bytep ep = sp + row_info->rowbytes; /* end+1 */
while (sp < ep)
{
*dp++ = *sp;
sp += 2; /* skip low byte */
}
row_info->bit_depth = 8;
@@ -4411,7 +4483,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
if (row_info->bit_depth == 8)
{
{
if (trans_alpha != NULL)
if (num_trans > 0)
{
sp = row + (png_size_t)row_width - 1;
dp = row + (png_size_t)(row_width << 2) - 1;
@@ -4465,7 +4537,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
*/
void /* PRIVATE */
png_do_expand(png_row_infop row_info, png_bytep row,
png_const_color_16p trans_value)
png_const_color_16p trans_color)
{
int shift, value;
png_bytep sp, dp;
@@ -4477,7 +4549,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
{
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
{
png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0);
png_uint_16 gray = (png_uint_16)(trans_color ? trans_color->gray : 0);
if (row_info->bit_depth < 8)
{
@@ -4569,7 +4641,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
row_info->rowbytes = row_width;
}
if (trans_value != NULL)
if (trans_color != NULL)
{
if (row_info->bit_depth == 8)
{
@@ -4621,13 +4693,13 @@ png_do_expand(png_row_infop row_info, png_bytep row,
row_width);
}
}
else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value)
else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color)
{
if (row_info->bit_depth == 8)
{
png_byte red = (png_byte)(trans_value->red & 0xff);
png_byte green = (png_byte)(trans_value->green & 0xff);
png_byte blue = (png_byte)(trans_value->blue & 0xff);
png_byte red = (png_byte)(trans_color->red & 0xff);
png_byte green = (png_byte)(trans_color->green & 0xff);
png_byte blue = (png_byte)(trans_color->blue & 0xff);
sp = row + (png_size_t)row_info->rowbytes - 1;
dp = row + (png_size_t)(row_width << 2) - 1;
for (i = 0; i < row_width; i++)
@@ -4645,12 +4717,12 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
else if (row_info->bit_depth == 16)
{
png_byte red_high = (png_byte)((trans_value->red >> 8) & 0xff);
png_byte green_high = (png_byte)((trans_value->green >> 8) & 0xff);
png_byte blue_high = (png_byte)((trans_value->blue >> 8) & 0xff);
png_byte red_low = (png_byte)(trans_value->red & 0xff);
png_byte green_low = (png_byte)(trans_value->green & 0xff);
png_byte blue_low = (png_byte)(trans_value->blue & 0xff);
png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff);
png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff);
png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff);
png_byte red_low = (png_byte)(trans_color->red & 0xff);
png_byte green_low = (png_byte)(trans_color->green & 0xff);
png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
sp = row + row_info->rowbytes - 1;
dp = row + (png_size_t)(row_width << 3) - 1;
for (i = 0; i < row_width; i++)

View File

@@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -2038,21 +2038,26 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
i = 1;
state = 0;
if (png_ptr->chunkdata[1] == 45 /* negative width */ ||
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
if (!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
i >= slength || png_ptr->chunkdata[i++] != 0)
png_warning(png_ptr, "Invalid sCAL chunk ignored: bad width format");
else if (!PNG_FP_IS_POSITIVE(state))
png_warning(png_ptr, "Invalid sCAL chunk ignored: non-positive width");
else
{
png_size_t heighti = i;
state = 0;
if (png_ptr->chunkdata[i] == 45 /* negative height */ ||
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
if (!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
i != slength)
png_warning(png_ptr, "Invalid sCAL chunk ignored: bad height format");
else if (!PNG_FP_IS_POSITIVE(state))
png_warning(png_ptr,
"Invalid sCAL chunk ignored: non-positive height");
else
/* This is the (only) success case. */
png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0],
@@ -2679,7 +2684,7 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
{
png_debug(1, "in png_combine_row");
/* Added in 1.5.3: the row_info should match the information returned by any
/* Added in 1.5.4: the row_info should match the information returned by any
* call to png_read_update_info at this point. Do not continue if we got
* this wrong.
*/

View File

@@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.5.1 [February 3, 2011]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)

View File

@@ -5,7 +5,7 @@
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -68,7 +68,7 @@ struct png_struct_def
uInt zbuf_size; /* size of zbuf (typically 65536) */
#ifdef PNG_WRITE_SUPPORTED
/* Added in 1.5.3: state to keep track of whether the zstream has been
/* Added in 1.5.4: state to keep track of whether the zstream has been
* initialized and if so whether it is for IDAT or some other chunk.
*/
#define PNG_ZLIB_UNINITIALIZED 0
@@ -78,7 +78,7 @@ struct png_struct_def
#define PNG_ZLIB_IN_USE 4 /* a flag value */
png_uint_32 zlib_state; /* State of zlib initialization */
/* End of material added at libpng 1.5.3 */
/* End of material added at libpng 1.5.4 */
int zlib_level; /* holds zlib compression level */
int zlib_method; /* holds zlib compression method */
@@ -86,7 +86,7 @@ struct png_struct_def
int zlib_mem_level; /* holds zlib compression memory level */
int zlib_strategy; /* holds zlib compression strategy */
#endif
/* Added at libpng 1.5.3 */
/* Added at libpng 1.5.4 */
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
int zlib_text_level; /* holds zlib compression level */
@@ -95,7 +95,7 @@ struct png_struct_def
int zlib_text_mem_level; /* holds zlib compression memory level */
int zlib_text_strategy; /* holds zlib compression strategy */
#endif
/* End of material added at libpng 1.5.3 */
/* End of material added at libpng 1.5.4 */
png_uint_32 width; /* width of image in pixels */
png_uint_32 height; /* height of image in pixels */
@@ -111,7 +111,7 @@ struct png_struct_def
png_bytep avg_row; /* buffer to save "avg" row when filtering */
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
png_row_info row_info; /* used for transformation routines */
png_size_t info_rowbytes; /* Added in 1.5.3: cache of updated row bytes */
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
png_uint_32 idat_size; /* current IDAT size for read */
png_uint_32 crc; /* current chunk CRC value */

View File

@@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -918,7 +918,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
/* Normally one would use Z_DEFAULT_STRATEGY for text compression.
* This is here just to make pngtest replicate the results from libpng
* versions prior to 1.5.3, and to test this new API.
* versions prior to 1.5.4, and to test this new API.
*/
png_set_text_compression_strategy(write_ptr, Z_FILTERED);
#endif
@@ -1794,4 +1794,4 @@ main(int argc, char *argv[])
}
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_5_4beta01 Your_png_h_is_not_version_1_5_4beta01;
typedef png_libpng_version_1_5_4rc01 Your_png_h_is_not_version_1_5_4rc01;

View File

@@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)

View File

@@ -1,7 +1,7 @@
/* pngvalid.c - validate libpng by constructing then reading png files.
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 2011 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
@@ -1571,7 +1571,7 @@ typedef struct png_modifier
unsigned int test_gamma_threshold :1;
unsigned int test_gamma_transform :1; /* main tests */
unsigned int test_gamma_sbit :1;
unsigned int test_gamma_strip16 :1;
unsigned int test_gamma_scale16 :1;
unsigned int test_gamma_background :1;
unsigned int test_gamma_alpha_mode :1;
unsigned int test_gamma_expand16 :1;
@@ -1623,7 +1623,7 @@ modifier_init(png_modifier *pm)
pm->test_gamma_threshold = 0;
pm->test_gamma_transform = 0;
pm->test_gamma_sbit = 0;
pm->test_gamma_strip16 = 0;
pm->test_gamma_scale16 = 0;
pm->test_gamma_background = 0;
pm->test_gamma_alpha_mode = 0;
pm->test_gamma_expand16 = 0;
@@ -3429,7 +3429,7 @@ read_palette(store_palette palette, int *npalette, png_structp pp, png_infop pi)
if ((png_get_tRNS(pp, pi, &trans_alpha, &num, 0) & PNG_INFO_tRNS) != 0 &&
(trans_alpha != NULL || num != 1/*returns 1 for a transparent color*/) &&
/* Oops, if a palette tRNS gets expanded png_read_update_info (at least so
* far as 1.5.3) does not zap the trans_alpha pointer, only num_trans, so
* far as 1.5.4) does not zap the trans_alpha pointer, only num_trans, so
* in the above call we get a success, we get a pointer (who knows what
* to) and we get num_trans == 0:
*/
@@ -5240,7 +5240,50 @@ IT(expand_16);
#define PT ITSTRUCT(expand_16)
#endif /* PNG_READ_EXPAND_16_SUPPORTED */
#ifdef PNG_READ_16_TO_8_SUPPORTED
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* API added in 1.5.4 */
/* png_set_scale_16 */
static void
image_transform_png_set_scale_16_set(PNG_CONST image_transform *this,
transform_display *that, png_structp pp, png_infop pi)
{
png_set_scale_16(pp);
this->next->set(this->next, that, pp, pi);
}
static void
image_transform_png_set_scale_16_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display)
{
if (that->bit_depth == 16)
{
that->sample_depth = that->bit_depth = 8;
if (that->red_sBIT > 8) that->red_sBIT = 8;
if (that->green_sBIT > 8) that->green_sBIT = 8;
if (that->blue_sBIT > 8) that->blue_sBIT = 8;
if (that->alpha_sBIT > 8) that->alpha_sBIT = 8;
}
this->next->mod(this->next, that, pp, display);
}
static int
image_transform_png_set_scale_16_add(image_transform *this,
PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
{
UNUSED(colour_type)
this->next = *that;
*that = this;
return bit_depth > 8;
}
IT(scale_16);
#undef PT
#define PT ITSTRUCT(scale_16)
#endif /* PNG_READ_SCALE_16_TO_8_SUPPORTED (1.5.4 on) */
#ifdef PNG_READ_16_TO_8_SUPPORTED /* the default before 1.5.4 */
/* png_set_strip_16 */
static void
image_transform_png_set_strip_16_set(PNG_CONST image_transform *this,
@@ -5262,9 +5305,19 @@ image_transform_png_set_strip_16_mod(PNG_CONST image_transform *this,
if (that->blue_sBIT > 8) that->blue_sBIT = 8;
if (that->alpha_sBIT > 8) that->alpha_sBIT = 8;
# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
/* Prior to 1.5.4 png_set_strip_16 would use an 'accurate' method if this
* configuration option is set. From 1.5.4 the flag is never set and the
* 'scale' API (above) must be used.
*/
# ifdef PNG_READ_ACCURATE_SCALE_SUPPORTED
# if PNG_LIBPNG_VER >= 10504
# error PNG_READ_ACCURATE_SCALE should not be set
# endif
/* The strip 16 algorithm drops the low 8 bits rather than calculating
* 1/257, so we need to adjust the permitted errors appropriately:
* Notice that this is only relevant prior to the addition of the
* png_set_scale_16 API in 1.5.4 (but 1.5.4+ always defines the above!)
*/
{
PNG_CONST double d = (255-128.5)/65535;
@@ -6001,7 +6054,7 @@ typedef struct gamma_display
png_byte sbit;
int threshold_test;
int use_input_precision;
int strip16;
int scale16;
int expand16;
int do_background;
png_color_16 background_color;
@@ -6017,7 +6070,7 @@ typedef struct gamma_display
static void
gamma_display_init(gamma_display *dp, png_modifier *pm, png_uint_32 id,
double file_gamma, double screen_gamma, png_byte sbit, int threshold_test,
int use_input_precision, int strip16, int expand16,
int use_input_precision, int scale16, int expand16,
int do_background, PNG_CONST png_color_16 *pointer_to_the_background_color,
double background_gamma)
{
@@ -6032,7 +6085,7 @@ gamma_display_init(gamma_display *dp, png_modifier *pm, png_uint_32 id,
dp->sbit = sbit;
dp->threshold_test = threshold_test;
dp->use_input_precision = use_input_precision;
dp->strip16 = strip16;
dp->scale16 = scale16;
dp->expand16 = expand16;
dp->do_background = do_background;
if (do_background && pointer_to_the_background_color != 0)
@@ -6055,11 +6108,16 @@ gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi)
* are interactions with sBIT but, internally, libpng makes sbit at most
* PNG_MAX_GAMMA_8 when doing the following.
*/
if (dp->strip16)
# ifdef PNG_READ_16_TO_8_SUPPORTED
png_set_strip_16(pp);
if (dp->scale16)
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
png_set_scale_16(pp);
# else
png_error(pp, "strip16 (16 to 8 bit conversion) not supported");
/* The following works both in 1.5.4 and earlier versions: */
# ifdef PNG_READ_16_TO_8_SUPPORTED
png_set_strip_16(pp);
# else
png_error(pp, "scale16 (16 to 8 bit conversion) not supported");
# endif
# endif
if (dp->expand16)
@@ -6169,7 +6227,7 @@ typedef struct validate_info
png_byte sbit;
int use_input_precision;
int do_background;
int strip16;
int scale16;
unsigned int sbit_max;
unsigned int isbit_shift;
unsigned int outmax;
@@ -6280,7 +6338,7 @@ init_validate_info(validate_info *vi, gamma_display *dp, png_struct *pp,
if (fabs(vi->file_inverse-1) < PNG_GAMMA_THRESHOLD)
vi->file_inverse = 0;
vi->strip16 = dp->strip16;
vi->scale16 = dp->scale16;
}
/* This function handles composition of a single non-alpha component. The
@@ -6670,47 +6728,52 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi,
* option has been used and 'inaccurate' scaling is used then the
* bit reduction is obtained by simply using the top 8 bits of the
* value.
*
* This is only done for older libpng versions when the 'inaccurate'
* (chop) method of scaling was used.
*/
# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
/* This may be required for other components in the future, but
* at present the presence of gamma correction effectively
* prevents the errors in the component scaling (I don't quite
* understand why, but since it's better this way I care not to
* ask, JB 20110419.)
*/
if (pass == 0 && alpha < 0 && vi->strip16 && vi->sbit > 8 &&
vi->sbit + vi->isbit_shift == 16)
{
tmp = ((id >> 8) - .5)/255;
if (tmp > 0)
# if PNG_LIBPNG_VER < 10504
/* This may be required for other components in the future,
* but at present the presence of gamma correction effectively
* prevents the errors in the component scaling (I don't quite
* understand why, but since it's better this way I care not
* to ask, JB 20110419.)
*/
if (pass == 0 && alpha < 0 && vi->scale16 && vi->sbit > 8 &&
vi->sbit + vi->isbit_shift == 16)
{
is_lo = ceil(outmax * tmp - vi->maxout_total);
if (is_lo < 0) is_lo = 0;
tmp = ((id >> 8) - .5)/255;
if (tmp > 0)
{
is_lo = ceil(outmax * tmp - vi->maxout_total);
if (is_lo < 0) is_lo = 0;
}
else
is_lo = 0;
tmp = ((id >> 8) + .5)/255;
if (tmp < 1)
{
is_hi = floor(outmax * tmp + vi->maxout_total);
if (is_hi > outmax) is_hi = outmax;
}
else
is_hi = outmax;
if (!(od < is_lo || od > is_hi))
{
if (encoded_error < vi->outlog)
return i;
pass = "within 8 bit limits:\n";
}
}
else
is_lo = 0;
tmp = ((id >> 8) + .5)/255;
if (tmp < 1)
{
is_hi = floor(outmax * tmp + vi->maxout_total);
if (is_hi > outmax) is_hi = outmax;
}
else
is_hi = outmax;
if (!(od < is_lo || od > is_hi))
{
if (encoded_error < vi->outlog)
return i;
pass = "within 8 bit limits:\n";
}
}
# endif
# endif
}
else /* !use_input_precision */
@@ -7112,7 +7175,7 @@ gamma_test(png_modifier *pmIn, PNG_CONST png_byte colour_typeIn,
PNG_CONST double file_gammaIn, PNG_CONST double screen_gammaIn,
PNG_CONST png_byte sbitIn, PNG_CONST int threshold_testIn,
PNG_CONST char *name,
PNG_CONST int use_input_precisionIn, PNG_CONST int strip16In,
PNG_CONST int use_input_precisionIn, PNG_CONST int scale16In,
PNG_CONST int expand16In, PNG_CONST int do_backgroundIn,
PNG_CONST png_color_16 *bkgd_colorIn, double bkgd_gammaIn)
{
@@ -7122,7 +7185,7 @@ gamma_test(png_modifier *pmIn, PNG_CONST png_byte colour_typeIn,
gamma_display_init(&d, pmIn, FILEID(colour_typeIn, bit_depthIn,
palette_numberIn, interlace_typeIn, 0, 0, 0),
file_gammaIn, screen_gammaIn, sbitIn,
threshold_testIn, use_input_precisionIn, strip16In,
threshold_testIn, use_input_precisionIn, scale16In,
expand16In, do_backgroundIn, bkgd_colorIn, bkgd_gammaIn);
Try
@@ -7267,7 +7330,7 @@ static void gamma_threshold_test(png_modifier *pm, png_byte colour_type,
(void)gamma_test(pm, colour_type, bit_depth, 0/*palette*/, interlace_type,
file_gamma, screen_gamma, 0/*sBIT*/, 1/*threshold test*/, name,
0 /*no input precision*/,
0 /*no strip16*/, 0 /*no expand16*/, 0 /*no background*/, 0 /*hence*/,
0 /*no scale16*/, 0 /*no expand16*/, 0 /*no background*/, 0 /*hence*/,
0 /*no background gamma*/);
}
@@ -7310,7 +7373,7 @@ static void gamma_transform_test(png_modifier *pm,
PNG_CONST int palette_number,
PNG_CONST int interlace_type, PNG_CONST double file_gamma,
PNG_CONST double screen_gamma, PNG_CONST png_byte sbit,
PNG_CONST int use_input_precision, PNG_CONST int strip16)
PNG_CONST int use_input_precision, PNG_CONST int scale16)
{
size_t pos = 0;
char name[64];
@@ -7325,7 +7388,7 @@ static void gamma_transform_test(png_modifier *pm,
else
pos = safecat(name, sizeof name, pos, "gamma ");
if (strip16)
if (scale16)
pos = safecat(name, sizeof name, pos, "16to8 ");
pos = safecatd(name, sizeof name, pos, file_gamma, 3);
@@ -7334,7 +7397,7 @@ static void gamma_transform_test(png_modifier *pm,
gamma_test(pm, colour_type, bit_depth, palette_number, interlace_type,
file_gamma, screen_gamma, sbit, 0, name, use_input_precision,
strip16, pm->test_gamma_expand16, 0 , 0, 0);
scale16, pm->test_gamma_expand16, 0 , 0, 0);
}
static void perform_gamma_transform_tests(png_modifier *pm)
@@ -7351,7 +7414,7 @@ static void perform_gamma_transform_tests(png_modifier *pm)
{
gamma_transform_test(pm, colour_type, bit_depth, palette_number,
pm->interlace_type, 1/pm->gammas[i], pm->gammas[j], 0/*sBIT*/,
pm->use_input_precision, 0 /*do not strip16*/);
pm->use_input_precision, 0 /*do not scale16*/);
if (fail(pm))
return;
@@ -7390,7 +7453,7 @@ static void perform_gamma_sbit_tests(png_modifier *pm)
{
gamma_transform_test(pm, colour_type, bit_depth, npalette,
pm->interlace_type, 1/pm->gammas[i], pm->gammas[j],
sbit, pm->use_input_precision_sbit, 0 /*strip16*/);
sbit, pm->use_input_precision_sbit, 0 /*scale16*/);
if (fail(pm))
return;
@@ -7405,7 +7468,7 @@ static void perform_gamma_sbit_tests(png_modifier *pm)
* generated if DO_16BIT is defined.
*/
#ifdef DO_16BIT
static void perform_gamma_strip16_tests(png_modifier *pm)
static void perform_gamma_scale16_tests(png_modifier *pm)
{
# ifndef PNG_MAX_GAMMA_8
# define PNG_MAX_GAMMA_8 11
@@ -7428,28 +7491,28 @@ static void perform_gamma_strip16_tests(png_modifier *pm)
{
gamma_transform_test(pm, 0, 16, 0, pm->interlace_type,
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
pm->use_input_precision_16to8, 1 /*strip16*/);
pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm))
return;
gamma_transform_test(pm, 2, 16, 0, pm->interlace_type,
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
pm->use_input_precision_16to8, 1 /*strip16*/);
pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm))
return;
gamma_transform_test(pm, 4, 16, 0, pm->interlace_type,
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
pm->use_input_precision_16to8, 1 /*strip16*/);
pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm))
return;
gamma_transform_test(pm, 6, 16, 0, pm->interlace_type,
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
pm->use_input_precision_16to8, 1 /*strip16*/);
pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm))
return;
@@ -7704,11 +7767,11 @@ perform_gamma_test(png_modifier *pm, int summary)
}
#ifdef DO_16BIT /* Should be READ_16BIT_SUPPORTED */
if (pm->test_gamma_strip16)
if (pm->test_gamma_scale16)
{
/* The 16 to 8 bit strip operations: */
init_gamma_errors(pm);
perform_gamma_strip16_tests(pm);
perform_gamma_scale16_tests(pm);
if (summary)
{
@@ -8261,7 +8324,7 @@ int main(int argc, PNG_CONST char **argv)
pm.test_gamma_threshold = 1;
pm.test_gamma_transform = 1;
pm.test_gamma_sbit = 1;
pm.test_gamma_strip16 = 1;
pm.test_gamma_scale16 = 1;
pm.test_gamma_background = 1;
pm.test_gamma_alpha_mode = 1;
}
@@ -8288,10 +8351,10 @@ int main(int argc, PNG_CONST char **argv)
pm.test_gamma_sbit = 0;
else if (strcmp(*argv, "--gamma-16-to-8") == 0)
pm.ngammas = 2U, pm.test_gamma_strip16 = 1;
pm.ngammas = 2U, pm.test_gamma_scale16 = 1;
else if (strcmp(*argv, "--nogamma-16-to-8") == 0)
pm.test_gamma_strip16 = 0;
pm.test_gamma_scale16 = 0;
else if (strcmp(*argv, "--gamma-background") == 0)
pm.ngammas = 2U, pm.test_gamma_background = 1;
@@ -8417,13 +8480,13 @@ int main(int argc, PNG_CONST char **argv)
if (pm.ngammas > 0 &&
pm.test_gamma_threshold == 0 && pm.test_gamma_transform == 0 &&
pm.test_gamma_sbit == 0 && pm.test_gamma_strip16 == 0 &&
pm.test_gamma_sbit == 0 && pm.test_gamma_scale16 == 0 &&
pm.test_gamma_background == 0 && pm.test_gamma_alpha_mode == 0)
{
pm.test_gamma_threshold = 1;
pm.test_gamma_transform = 1;
pm.test_gamma_sbit = 1;
pm.test_gamma_strip16 = 1;
pm.test_gamma_scale16 = 1;
pm.test_gamma_background = 1;
pm.test_gamma_alpha_mode = 1;
}
@@ -8434,7 +8497,7 @@ int main(int argc, PNG_CONST char **argv)
pm.test_gamma_threshold = 0;
pm.test_gamma_transform = 0;
pm.test_gamma_sbit = 0;
pm.test_gamma_strip16 = 0;
pm.test_gamma_scale16 = 0;
pm.test_gamma_background = 0;
pm.test_gamma_alpha_mode = 0;
}

View File

@@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -1458,7 +1458,7 @@ png_set_compression_method(png_structp png_ptr, int method)
png_ptr->zlib_method = method;
}
/* The following were added to libpng-1.5.3 */
/* The following were added to libpng-1.5.4 */
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
void PNGAPI
png_set_text_compression_level(png_structp png_ptr, int level)
@@ -1539,7 +1539,7 @@ png_set_text_compression_method(png_structp png_ptr, int method)
png_ptr->zlib_text_method = method;
}
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
/* end of API added to libpng-1.5.3 */
/* end of API added to libpng-1.5.4 */
void PNGAPI
png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)

View File

@@ -1,7 +1,7 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)

View File

@@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.5.3 [(PENDING RELEASE)]
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -1017,7 +1017,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
png_write_chunk(png_ptr, png_IDAT, data, length);
png_ptr->mode |= PNG_HAVE_IDAT;
/* Prior to 1.5.3 this code was replicated in every caller (except at the
/* Prior to 1.5.4 this code was replicated in every caller (except at the
* end, where it isn't technically necessary). Since this function has
* flushed the data we can safely reset the zlib output buffer here.
*/

View File

@@ -1,7 +1,7 @@
VisualStudio instructions
libpng version 1.5.4beta01 - June 14, 2011
libpng version 1.5.4rc01 - June 30, 2011
Copyright (c) 1998-2010 Glenn Randers-Pehrson

View File

@@ -2,7 +2,7 @@
<!--
* zlib.props - location of zlib source
*
* libpng version 1.5.4beta01 - June 14, 2011
* libpng version 1.5.4rc01 - June 30, 2011
*
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
*

View File

@@ -1,9 +1,9 @@
Makefiles for libpng version 1.5.4beta01 - June 14, 2011
Makefiles for libpng version 1.5.4rc01 - June 30, 2011
pnglibconf.h.prebuilt => Stores configuration settings
makefile.linux => Linux/ELF makefile
(gcc, creates libpng15.so.15.1.5.4beta01)
(gcc, creates libpng15.so.15.1.5.4rc01)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
@@ -20,7 +20,7 @@ pnglibconf.h.prebuilt => Stores configuration settings
makefile.dec => DEC Alpha UNIX makefile
makefile.dj2 => DJGPP 2 makefile
makefile.elf => Linux/ELF makefile symbol versioning,
(gcc, creates libpng15.so.15.1.5.4beta01)
(gcc, creates libpng15.so.15.1.5.4rc01)
makefile.freebsd => FreeBSD makefile
makefile.gcc => Generic gcc makefile
makefile.hpgcc => HPUX makefile using gcc
@@ -35,12 +35,12 @@ pnglibconf.h.prebuilt => Stores configuration settings
makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.sggcc => Silicon Graphics (gcc,
creates libpng15.so.15.1.5.4beta01)
creates libpng15.so.15.1.5.4rc01)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng15.so.15.1.5.4beta01)
creates libpng15.so.15.1.5.4rc01)
makefile.so9 => Solaris 9 makefile (gcc,
creates libpng15.so.15.1.5.4beta01)
creates libpng15.so.15.1.5.4rc01)
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit makefile
@@ -57,7 +57,7 @@ Other supporting scripts:
libpng-config-body.in => used by several makefiles to create libpng-config
libpng-config-head.in => used by several makefiles to create libpng-config
libpng.pc.in => Used by several makefiles to create libpng.pc
pngwin.rc => Used by the visualc6 and visualc71 projects.
pngwin.rc => Used by the visualc71 project.
pngwin.def => Used by makefile.os2
pngwin.dfn => Used to maintain pngwin.def
SCOPTIONS.ppc => Used with smakefile.ppc

View File

@@ -11,7 +11,7 @@
# Modeled after libxml-config.
version=1.5.4beta01
version=1.5.4rc01
prefix=""
libdir=""
libs=""

View File

@@ -5,6 +5,6 @@ includedir=@includedir@/libpng15
Name: libpng
Description: Loads and saves PNG files
Version: 1.5.4beta01
Version: 1.5.4rc01
Libs: -L${libdir} -lpng15
Cflags: -I${includedir}

View File

@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng15
LIB= png15
SHLIB_MAJOR= 0
SHLIB_MINOR= 1.5.4beta01
SHLIB_MINOR= 1.5.4rc01
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c

View File

@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include
LIB= png
SHLIB_MAJOR= 15
SHLIB_MINOR= 1.5.4beta01
SHLIB_MINOR= 1.5.4rc01
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c

View File

@@ -11,7 +11,7 @@ LIBDIR= ${PREFIX}/lib
MANDIR= ${PREFIX}/man/cat
SHLIB_MAJOR= 15
SHLIB_MINOR= 1.5.4beta01
SHLIB_MINOR= 1.5.4rc01
LIB= png
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \

View File

@@ -293,8 +293,10 @@ option READ enables READ_INTERLACING
# Disabling READ_16BIT does not disable reading 16-bit PNG files, but it
# forces them to be chopped down to 8-bit, and disables any 16-bit
# processing after that has happened. You need to be sure to enable READ_16_TO_8
# when you disable READ_16BIT for this to work properly.
# processing after that has happened. You need to be sure to enable
# READ_SCALE_16_TO_8 or READ_STRIP_16_TO_8 when you disable READ_16BIT for
# this to work properly. You should disable the other option if you need to
# ensure a particular convertion (otherwise the app can chose.)
option READ_16BIT requires READ enables 16BIT
@@ -312,7 +314,8 @@ option READ_SWAP requires READ_TRANSFORMS READ_16BIT
option READ_PACKSWAP requires READ_TRANSFORMS
option READ_INVERT requires READ_TRANSFORMS
option READ_BACKGROUND requires READ_TRANSFORMS enables READ_STRIP_ALPHA
option READ_16_TO_8 requires READ_TRANSFORMS
option READ_STRIP_16_TO_8 requires READ_TRANSFORMS
option READ_SCALE_16_TO_8 requires READ_TRANSFORMS
option READ_FILLER requires READ_TRANSFORMS
option READ_GAMMA requires READ_TRANSFORMS enables READ_gAMA
option READ_GRAY_TO_RGB requires READ_TRANSFORMS
@@ -346,9 +349,6 @@ option INCH_CONVERSIONS
option BUILD_GRAYSCALE_PALETTE
option READ_16_TO_8_ACCURATE_SCALE requires READ
option LEGACY_READ_16_TO_8_ACCURATE_SCALE disabled
# IN DEVELOPMENT
# These are currently experimental features; define them if you want
@@ -553,7 +553,8 @@ option SAVE_INT_32 requires WRITE
# png_save_int_32 is required by the ancillary chunks oFFs and pCAL
# added at libpng-1.5.3
# added at libpng-1.5.4
option WRITE_OPTIMIZE_CMF requires WRITE
option READ_COMPRESSED_TEXT disabled
@@ -571,7 +572,6 @@ option WRITE_iTXt enables WRITE_COMPRESSED_TEXT
option WRITE_zTXt enables WRITE_COMPRESSED_TEXT
option WRITE_COMPRESSED_TEXT enables WRITE_TEXT
# Turn this off to disable png_read_png() and png_write_png() and
# leave the row_pointers member out of the info structure.

View File

@@ -3,7 +3,7 @@
/* pnglibconf.h - library build configuration */
/* libpng version 1.5.0 - last changed on February 11, 2011 */
/* libpng version 1.5.4 - last changed on June 22, 2011 */
/* Copyright (c) 1998-2011 Glenn Randers-Pehrson */
@@ -49,6 +49,7 @@
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_CONVERT_tIME_SUPPORTED
#define PNG_EASY_ACCESS_SUPPORTED
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
#define PNG_ERROR_TEXT_SUPPORTED
#define PNG_FIXED_POINT_SUPPORTED
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
@@ -61,7 +62,6 @@
#define PNG_INFO_IMAGE_SUPPORTED
#define PNG_IO_STATE_SUPPORTED
#define PNG_iTXt_SUPPORTED
/*#undef PNG_LEGACY_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED*/
#define PNG_MNG_FEATURES_SUPPORTED
#define PNG_oFFs_SUPPORTED
#define PNG_pCAL_SUPPORTED
@@ -69,8 +69,6 @@
#define PNG_POINTER_INDEXING_SUPPORTED
#define PNG_PROGRESSIVE_READ_SUPPORTED
#define PNG_READ_16BIT_SUPPORTED
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
#define PNG_READ_16_TO_8_SUPPORTED
#define PNG_READ_ALPHA_MODE_SUPPORTED
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_READ_BACKGROUND_SUPPORTED
@@ -78,6 +76,7 @@
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
#define PNG_READ_EXPAND_16_SUPPORTED
#define PNG_READ_EXPAND_SUPPORTED
#define PNG_READ_FILLER_SUPPORTED
@@ -100,10 +99,12 @@
#define PNG_READ_QUANTIZE_SUPPORTED
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
#define PNG_READ_sBIT_SUPPORTED
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
#define PNG_READ_sCAL_SUPPORTED
#define PNG_READ_SHIFT_SUPPORTED
#define PNG_READ_sPLT_SUPPORTED
#define PNG_READ_sRGB_SUPPORTED
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
#define PNG_READ_STRIP_ALPHA_SUPPORTED
#define PNG_READ_SUPPORTED
#define PNG_READ_SWAP_ALPHA_SUPPORTED
@@ -117,7 +118,6 @@
#define PNG_READ_USER_CHUNKS_SUPPORTED
#define PNG_READ_USER_TRANSFORM_SUPPORTED
#define PNG_READ_zTXt_SUPPORTED
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
#define PNG_SAVE_INT_32_SUPPORTED
#define PNG_sBIT_SUPPORTED
#define PNG_sCAL_SUPPORTED
@@ -146,6 +146,8 @@
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
#define PNG_WRITE_FILLER_SUPPORTED
#define PNG_WRITE_FILTER_SUPPORTED
#define PNG_WRITE_FLUSH_SUPPORTED
@@ -156,7 +158,6 @@
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
#define PNG_WRITE_INVERT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
#define PNG_WRITE_iTXt_SUPPORTED
#define PNG_WRITE_oFFs_SUPPORTED
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
@@ -182,7 +183,5 @@
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_zTXt_SUPPORTED
#define PNG_zTXt_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
/* end of options */
#endif /* PNGLCONF_H */

View File

@@ -5,7 +5,7 @@
LIBRARY
EXPORTS
;Version 1.5.4beta01
;Version 1.5.4rc01
png_access_version_number @1
png_set_sig_bytes @2
png_sig_cmp @3
@@ -234,3 +234,4 @@ EXPORTS
png_set_text_compression_method @226
png_set_alpha_mode @227
png_set_alpha_mode_fixed @228
png_set_scale_16 @229