Compare commits

...

54 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
69ddffdf2c [libpng17] Use a more generous size limit for IDAT chunks. 2017-09-03 09:20:23 -05:00
Glenn Randers-Pehrson
3e2769b9d7 [libpng17] Bump version to 1.7.0beta90 2017-08-28 18:34:49 -05:00
Glenn Randers-Pehrson
780d38b87d [libpng17]Added PNGMINUS_UNUSED macro to contrib/pngminus/p*.c and added missing
parenthesis in contrib/pngminus/pnm2png.c (bug report by Christian Hesse).
2017-08-28 14:17:52 -05:00
Glenn Randers-Pehrson
031a3815ae [libpng17] Bump version to 1.7.0beta90 2017-08-18 20:23:56 -05:00
Glenn Randers-Pehrson
ef5a5760d4 [libpng17] Imported from libpng-1.7.0beta89.tar 2017-08-18 20:22:58 -05:00
Glenn Randers-Pehrson
0b2b7d8ab5 [libpng17] Imported from libpng-1.7.0beta88.tar 2017-08-18 20:01:40 -05:00
Glenn Randers-Pehrson
1c2e35ab73 [libpng17] Imported from libpng-1.7.0beta88.tar 2017-08-07 09:45:14 -05:00
Glenn Randers-Pehrson
58cd558a43 [libpng17] Added some bad PNGs to the test directory and to the test/pngtest script 2017-08-06 14:16:17 -05:00
Glenn Randers-Pehrson
bdca749e35 [libpng17] Added private png_check_chunk_name() and png_check_chunk_length()
functions.
2017-08-06 14:13:18 -05:00
Glenn Randers-Pehrson
19855cd8b1 [libpng17] Fix URL in documentation. 2017-05-22 17:39:22 -05:00
Glenn Randers-Pehrson
9bda575f69 [libpng17] Change http: urls to https: in libpng.3 2017-04-03 16:58:43 -05:00
Glenn Randers-Pehrson
66def3fb3c [libpng17] Bump version to 1.7.0beta88 2017-04-01 11:29:32 -05:00
Glenn Randers-Pehrson
8f4d83a881 [libpng17] Imported from libpng-1.7.0beta87.tar 2017-04-01 11:29:12 -05:00
Glenn Randers-Pehrson
a9b02399ac [libpng17] Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin).
2017-03-21 20:12:09 -05:00
Glenn Randers-Pehrson
ba42eccb05 [libpng17] Merge contrib/examples/pngtopng.c with libpng-1.6.29beta02 2017-02-24 09:25:27 -06:00
Glenn Randers-Pehrson
7345c50aaa [libpng17] Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna) 2016-12-31 13:02:01 -06:00
Glenn Randers-Pehrson
20be5b5411 [libpng16] Mention CVE-2016-10087 in CHANGES. 2016-12-30 14:00:44 -06:00
Glenn Randers-Pehrson
750a023377 [libpng17] Merge license info from libpng-1.6.27 2016-12-30 12:10:45 -06:00
Glenn Randers-Pehrson
e00c39596a [libpng17] Update license info from libpng-1.6.27 2016-12-30 10:27:53 -06:00
Glenn Randers-Pehrson
448fad2d02 [libpng17] Bump version to 1.7.0beta87 2016-12-30 08:29:13 -06:00
Glenn Randers-Pehrson
76a1f4bb3f [libpng17] Imported from libpng-1.7.0beta86.tar 2016-12-29 07:58:43 -06:00
Glenn Randers-Pehrson
243d4e5f3f [libpng17] Fixed a potential null pointer dereference in png_set_text_2()
(bug report and patch by Patrick Keshishian)
2016-12-29 07:57:58 -06:00
Glenn Randers-Pehrson
48f8ca26e4 [libpng17] Bump version to 1.7.0beta86 2016-12-29 07:56:24 -06:00
Glenn Randers-Pehrson
6c9ecd348d [libpng17] Removed clutter 2016-12-28 06:13:59 -06:00
Glenn Randers-Pehrson
e6470a8876 [libpng17] Ported new ARM support in CMakeLists.txt from libpng16 2016-12-27 11:35:56 -06:00
John Bowler
b14987b483 Merge branch 'libpng17' of ../../libpng into libpng17 2016-12-27 08:24:04 -08:00
Glenn Randers-Pehrson
7ed5c08fad [libpng17] Imported from libpng-1.7.0beta86.tar 2016-12-27 08:24:34 -06:00
John Bowler
5a1f75289e Merge branch 'libpng17' of ../../libpng into libpng17 2016-12-26 18:04:54 -08:00
Glenn Randers-Pehrson
4caddaafbb [libpng17] Update CHANGES and ANNOUNCE 2016-12-26 19:56:53 -06:00
John Bowler
512336676e Remove 'defined' within macro
This eliminates the use of 'defined' within macros that get substituted
on #if lines; see the previous patch for a more detailed discussion.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-12-26 16:46:30 -08:00
John Bowler
0ea7a09ced Remove 'defined' within macro
This removes the use of a macro containing the pre-processor 'defined'
operator.  It is unclear whether this is valid; a macro which
"generates" 'defined' is not permitted, but the use of the work
"generates" within the C90 standard seems to imply more than simple
substitution of an expression itself containing a well-formed defined
operation.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-12-26 16:45:31 -08:00
Glenn Randers-Pehrson
0b02a667cf [libpng17] Fix some indentation in pngrutil.c
(bug report and patch by Patrick Keshishian).
2016-12-26 18:38:13 -06:00
Glenn Randers-Pehrson
e1c7c0402c [libpng17] Quieted warnings from clang-3.8 in pngunknown.c and pngvalid.c. 2016-10-01 20:09:52 -05:00
Glenn Randers-Pehrson
2127ecd0fa [libpng17 Updated the documentation about CRC and ADLER32 handling. 2016-09-26 11:16:08 -05:00
Glenn Randers-Pehrson
1757736115 [libpng17] Bump version to 1.7.0beta85 2016-09-26 08:58:31 -05:00
Glenn Randers-Pehrson
6f9a39848e [libpng17] Imported from libpng-1.7.0beta84.tar 2016-09-26 08:58:23 -05:00
Glenn Randers-Pehrson
517fe770e2 [libpng17] Changed bad CRC from 0x00000000 to 0xabadcc32 and bad ADLER32
from 0x00000000 to 0xabadad32 in badcrc.png and badadler.png, to make
them recognizable in hex dumps.
2016-09-26 08:07:21 -05:00
Glenn Randers-Pehrson
f911c1146a [libpng17] Warn about ADLER32 checksum mismatch instead of issuing png_error().
Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
2016-09-25 22:22:47 -05:00
Glenn Randers-Pehrson
28de8bf6cd [libpng17] Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngrutil.c.
Conditionally compile png_set_benign_errors() in pngtest.c
2016-09-19 17:02:26 -05:00
Glenn Randers-Pehrson
6f39846891 [libpng17] Conditionally compile png_set_benign_errors() in pngread.c 2016-09-11 19:33:34 -05:00
Glenn Randers-Pehrson
07e2cf117f [libpng17] Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
bugfix by John Bowler).
2016-09-01 17:36:36 -05:00
Glenn Randers-Pehrson
f0ada4edee [libpng17] Minor editing of INSTALL, (whitespace, added copyright line) 2016-08-18 18:45:35 -05:00
Glenn Randers-Pehrson
3220f9c5a5 [libpng17] Bump version to 1.7.0beta84 2016-08-07 19:54:00 -05:00
Glenn Randers-Pehrson
5096cac90c [libpng17] Imported from libpng-1.7.0beta83.tar 2016-08-07 19:45:17 -05:00
Glenn Randers-Pehrson
2a2373c1ec [libpng17] Update CHANGES and ANNOUNCE, fix typos in pngrutil.c 2016-07-23 16:41:19 -05:00
John Bowler
4283e2bf66 Fix debug test of output gamma
The test would fire when a gamma transform was eliminated because it was not
significant if other transforms remained.  This is a debug-only change to alter
the test to check for an insignificant mis-match of the actual output gamma from
the requested output gamma.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-07-23 10:03:48 -07:00
Glenn Randers-Pehrson
8ffea2e56b [libpng17] Update CHANGES and ANNOUNCE 2016-07-16 11:37:48 -05:00
John Bowler
99eb6b5d5d Remove/rearrange png_struct fields
Certain fields are only used in reading.  This attempts to do some minor
cleanup/rearrangement.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-07-16 08:26:14 -07:00
Glenn Randers-Pehrson
096dbf8335 [libpng17] Fixed more indentation to comply with our coding style. 2016-07-15 14:43:19 -05:00
Glenn Randers-Pehrson
9743d58bc0 [libpng17] Fix one incorrect indent in pngvalid.c 2016-07-13 17:19:58 -05:00
Glenn Randers-Pehrson
bdb730a593 [libng17] Undo bad indentation change in example.c 2016-07-13 16:30:28 -05:00
Glenn Randers-Pehrson
f1fb09c406 [libpng17] Fixed some indentation to comply with our coding style (synced
with libpng-1.6.24beta05).
2016-07-13 15:27:04 -05:00
Glenn Randers-Pehrson
83ca33b017 [libpng17] Minor update of INSTALL 2016-07-04 20:39:41 -05:00
Glenn Randers-Pehrson
aa78bc36d9 [libpng17] Bump version to 1.7.0beta83 2016-07-04 14:30:59 -05:00
68 changed files with 1580 additions and 1047 deletions

View File

@@ -1,5 +1,5 @@
Libpng 1.7.0beta82 - July 4, 2016
Libpng 1.7.0beta90 - September 3, 2017
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.7.0beta82.tar.xz (LZMA-compressed, recommended)
1.7.0beta82.tar.gz
1.7.0beta90.tar.xz (LZMA-compressed, recommended)
1.7.0beta90.tar.gz
Source files with CRLF line endings (for Windows), without the
"configure" script
/scratch/glennrp/Libpng17/lp170b82.7z (LZMA-compressed, recommended)
/scratch/glennrp/Libpng17/lp170b82.zip
/scratch/glennrp/Libpng17/lp170b90.7z (LZMA-compressed, recommended)
/scratch/glennrp/Libpng17/lp170b90.zip
Other information:
1.7.0beta82-README.txt
1.7.0beta82-LICENSE.txt
libpng-1.7.0beta82-*.asc (armored detached GPG signatures)
1.7.0beta90-README.txt
1.7.0beta90-LICENSE.txt
libpng-1.7.0beta90-*.asc (armored detached GPG signatures)
Changes since the last public release (1.6.0):
@@ -1390,6 +1390,61 @@ Version 1.7.0beta82 [July 4, 2016]
Relocated misplaced #endif in png.c sRGB profile checking.
Fixed two Coverity issues in pngcp.c.
Version 1.7.0beta83 [July 23, 2016]
Fixed some indentation to comply with our coding style.
Removed/rearranged certain png_struct fields that are only used
in reading.
Fixed debug test of output gamma.
Version 1.7.0beta84 [September 26, 2016]
Minor editing of INSTALL, (whitespace, added copyright line)
Don't install pngcp; it conflicts with pngcp in the pngtools package.
Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
bugfix by John Bowler).
Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c
Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngrutil.c.
If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE,
ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs.
Issue png_benign_error() on ADLER32 checksum mismatch instead of png_error().
Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
Version 1.7.0beta85 [December 27, 2016]
Updated the documentation about CRC and ADLER32 handling.
Quieted warnings from clang-3.8 in pngunknown.c and pngvalid.c.
Removed the use of a macro containing the pre-processor 'defined'
operator. It is unclear whether this is valid; a macro that
"generates" 'defined' is not permitted, but the use of the word
"generates" within the C90 standard seems to imply more than simple
substitution of an expression itself containing a well-formed defined
operation.
Version 1.7.0beta86 [December 29, 2016]
Ported CMakeLists.txt from libpng-1.6.27rc01.
Fixed a potential null pointer dereference in png_set_text_2() (bug report
and patch by Patrick Keshishian, CVE-2016-10087).
Version 1.7.0beta87 [April 1, 2017]
Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna).
The contrib/examples/pngtopng.c recovery code was in the wrong "if"
branches; the comments were correct.
Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin).
Merged some recent changes from libpng-1.6.30beta01.
Version 1.7.0beta88 [August 7. 2017]
Added private png_check_chunk_name() and png_check_chunk_length()
functions (Fixes CVE-2017-12652).
Version 1.7.0beta89 [August 19, 2017]
Check for 0 return from png_get_rowbytes() in contrib/pngminus/*.c to stop
some Coverity issues (162705, 162706, and 162707).
Version 1.7.0beta90 [September 3, 2017]
Added PNGMINUS_UNUSED macro to contrib/pngminus/p*.c and added missing
parenthesis in contrib/pngminus/pnm2png.c (bug report by Christian Hesse).
Compute a larger limit on IDAT because some applications write a deflate
buffer for each row (Bug report by Andrew Church).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

56
CHANGES
View File

@@ -5690,6 +5690,62 @@ Version 1.7.0beta82 [July 4, 2016]
Relocated misplaced #endif in png.c sRGB profile checking.
Fixed two Coverity issues in pngcp.c.
Version 1.7.0beta83 [July 23, 2016]
Fixed some indentation to comply with our coding style.
Removed/rearranged certain png_struct fields that are only used
in reading.
Fixed debug test of output gamma.
Version 1.7.0beta84 [September 26, 2016]
Minor editing of INSTALL, (whitespace, added copyright line)
Don't install pngcp; it conflicts with pngcp in the pngtools package.
Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
bugfix by John Bowler).
Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c
Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngrutil.c.
If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE,
ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs.
Issue png_benign_error() on ADLER32 checksum mismatch instead of png_error().
Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
Version 1.7.0beta85 [December 27, 2016]
Updated the documentation about CRC and ADLER32 handling.
Quieted warnings from clang-3.8 in pngunknown.c and pngvalid.c.
Removed the use of a macro containing the pre-processor 'defined'
operator. It is unclear whether this is valid; a macro that
"generates" 'defined' is not permitted, but the use of the word
"generates" within the C90 standard seems to imply more than simple
substitution of an expression itself containing a well-formed defined
operation.
Version 1.7.0beta86 [December 29, 2016]
Ported CMakeLists.txt from libpng-1.6.27rc01.
Fixed a potential null pointer dereference in png_set_text_2() (bug report
and patch by Patrick Keshishian, CVE-2016-10087).
Version 1.7.0beta87 [April 1, 2017]
Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna).
The contrib/examples/pngtopng.c recovery code was in the wrong "if"
branches; the comments were correct.
Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin).
Merged some recent changes from libpng-1.6.30beta01.
Version 1.7.0beta88 [August 7, 2017]
Initialized btoa[] in pngstest.c
Added private png_check_chunk_name() and png_check_chunk_length()
functions (Fixes CVE-2017-12652).
Version 1.7.0beta89 [August 19, 2017]
Check for 0 return from png_get_rowbytes() in contrib/pngminus/*.c to stop
some Coverity issues (162705, 162706, and 162707).
Version 1.7.0beta90 [September 3, 2017]
Added PNGMINUS_UNUSED macro to contrib/pngminus/p*.c and added missing
parenthesis in contrib/pngminus/pnm2png.c (bug report by Christian Hesse).
Compute a larger limit on IDAT because some applications write a deflate
buffer for each row (Bug report by Andrew Church).
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

@@ -5,6 +5,7 @@
# Revised by Roger Lowman, 2009-2010
# Revised by Clifford Yapp, 2011-2012
# Revised by Roger Leigh, 2016
# Revised by Andreas Franek, 2016
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
@@ -69,6 +70,36 @@ option(PNGARG "Disable ANSI-C prototypes" OFF)
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
# set definitions and sources for arm
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm" OR
${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch64")
set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
check: (default) use internal checking code;
off: disable the optimizations;
on: turn on unconditionally.")
set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS
${PNG_ARM_NEON_POSSIBLE_VALUES})
list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
if(index EQUAL -1)
message(FATAL_ERROR
" PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_ARM_NEON} STREQUAL "no")
set(libpng_arm_sources
arm/arm_init.c
arm/filter_neon.S
arm/filter_neon_intrinsics.c)
if(${PNG_ARM_NEON} STREQUAL "on")
add_definitions(-DPNG_ARM_NEON_OPT=2)
elseif(${PNG_ARM_NEON} STREQUAL "check")
add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
endif()
else()
add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
endif()
# SET LIBNAME
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
@@ -360,6 +391,7 @@ set(libpng_sources
pngwrite.c
pngwtran.c
pngwutil.c
${libpng_arm_sources}
)
set(pngtest_sources
pngtest.c
@@ -697,7 +729,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
# SET UP LINKS
if(PNG_SHARED)
set_target_properties(png PROPERTIES
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta82
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta90
VERSION 17.${PNGLIB_RELEASE}.0
SOVERSION 17
CLEAN_DIRECT_OUTPUT 1)

89
INSTALL
View File

@@ -1,25 +1,25 @@
Installing libpng
Installing libpng
Contents
I. Simple installation
II. Rebuilding the configure scripts
III. Using scripts/makefile*
IV. Using cmake
V. Directory structure
VI. Building with project files
VII. Building with makefiles
VIII. Configuring libpng for 16-bit platforms
IX. Configuring for DOS
X. Configuring for Medium Model
XI. Prepending a prefix to exported symbols
XII. Configuring for compiler xxx:
XIII. Removing unwanted object code
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
XV. Setjmp/longjmp issues
XVI. Common linking failures
XVII. Other sources of information about libpng
I. Simple installation
II. Rebuilding the configure scripts
III. Using scripts/makefile*
IV. Using cmake
V. Directory structure
VI. Building with project files
VII. Building with makefiles
VIII. Configuring libpng for 16-bit platforms
IX. Configuring for DOS
X. Configuring for Medium Model
XI. Prepending a prefix to exported symbols
XII. Configuring for compiler xxx:
XIII. Removing unwanted object code
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
XV. Setjmp/longjmp issues
XVI. Common linking failures
XVII. Other sources of information about libpng
I. Simple installation
@@ -79,7 +79,7 @@ Or you can use one of the "projects" in the "projects" directory.
Before installing libpng, you must first install zlib, if it
is not already on your system. zlib can usually be found
wherever you got libpng; otherwise go to http://zlib.net. You can place
zlib in in the same directory as libpng or in another directory.
zlib in the same directory as libpng or in another directory.
If your system already has a preinstalled zlib you will still need
to have access to the zlib.h and zconf.h include files that
@@ -90,22 +90,24 @@ standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
and LD_LIBRARY_PATH in your environment before running "make test"
or "make distcheck":
ZLIBLIB=/path/to/lib export ZLIBLIB
ZLIBINC=/path/to/include export ZLIBINC
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
ZLIBLIB=/path/to/lib export ZLIBLIB
ZLIBINC=/path/to/include export ZLIBINC
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
in your environment and type
make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test
IV. Using cmake
If you want to use "cmake" (see www.cmake.org), type
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
As when using the simple configure method described above, "/path" points to
the installation directory where you want to put the libpng "lib", "include",
@@ -119,8 +121,8 @@ or "zlib128") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
.. (the parent directory)
libpng (this directory)
.. (the parent directory)
libpng (this directory)
INSTALL (this file)
README
*.h, *.c => libpng source files
@@ -163,10 +165,15 @@ VII. Building with makefiles
Copy the file (or files) that you need from the
scripts directory into this directory, for example
MSDOS example: copy scripts\makefile.msc makefile
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
UNIX example: cp scripts/makefile.std makefile
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
MSDOS example:
copy scripts\makefile.msc makefile
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
UNIX example:
cp scripts/makefile.std makefile
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
Read the makefile to see if you need to change any source or
target directories to match your preferences.
@@ -233,7 +240,8 @@ The files in libpng proper only include pngpriv.h and png.h, which
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
As of libpng-1.5.0, pngpriv.h also includes three other private header
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
that previously appeared in the public headers.
that previously appeared in the public headers. As of libpng-1.7.0,
pngchunk.h is also included, and is used privately by pngrutil.c.
XIII. Removing unwanted object code
@@ -242,7 +250,7 @@ libpng are compiled. All the defines end in _SUPPORTED. If you are
never going to use a capability, you can change the #define to #undef
before recompiling libpng and save yourself code and data space, or
you can turn off individual capabilities with defines that begin with
PNG_NO_.
"PNG_NO_".
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
@@ -310,7 +318,7 @@ only png_longjmp_ptr, which must match the C longjmp function.) The new
approach is documented in pngconf.h
Despite these changes, libpng 1.5.0 only supports the native C function
calling standard on those platforms tested so far (__cdecl on Microsoft
calling standard on those platforms tested so far ("__cdecl" on Microsoft
Windows). This is because the support requirements for alternative
calling conventions seem to no longer exist. Developers who find it
necessary to set PNG_API_RULE to 1 should advise the mailing list
@@ -374,7 +382,7 @@ your application is going to be using multiple threads, you should
configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
-DPNG_NO_SETJMP on your compile line, or with
#undef PNG_SETJMP_SUPPORTED
#undef PNG_SETJMP_SUPPORTED
in your pnglibconf.h or pngusr.h.
@@ -400,3 +408,8 @@ XVII. Other sources of information about libpng:
Further information can be found in the README and libpng-manual.txt
files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5.
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
and license in png.h.

34
LICENSE
View File

@@ -10,8 +10,8 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta82, July 4, 2016, are
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
libpng versions 1.0.7, July 1, 2000 through 1.7.0beta90, August 28, 2017 are
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
derived from libpng-1.0.6, and are distributed according to the same
disclaimer and license as libpng-1.0.6 with the following individuals
added to the list of Contributing Authors:
@@ -32,6 +32,10 @@ and with the following additions to the disclaimer:
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
Some files in the "contrib" directory and some configure-generated
files that are distributed with libpng have other copyright owners and
are released under other open source licenses.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
libpng-0.96, and are distributed according to the same disclaimer and
@@ -55,6 +59,9 @@ Contributing Authors:
Greg Roelofs
Tom Tanner
Some files in the "scripts" directory have other copyright owners
but are released under this license.
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -95,18 +102,29 @@ appreciated.
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
TRADEMARK:
printf("%s", png_get_copyright(NULL));
The name "libpng" has not been registered by the Copyright owner
as a trademark in any jurisdiction. However, because libpng has
been distributed and maintained world-wide, continually since 1995,
the Copyright owner claims "common-law trademark protection" in any
jurisdiction where common-law trademark is recognized.
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
OSI CERTIFICATION:
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
a certification mark of the Open Source Initiative. OSI has not addressed
the additional disclaimers inserted at version 1.0.7.
EXPORT CONTROL:
The Copyright owner believes that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because
it is open source, publicly available software, that does not contain
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
734.7(b).
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
July 4, 2016
August 28, 2017

View File

@@ -1,19 +1,24 @@
# Makefile.am:
# Source file for Makefile.in (and hence Makefile)
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
#
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
# Last changed in libpng 1.7.0 [(PENDING RELEASE)]
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
ACLOCAL_AMFLAGS = -I scripts
# test programs - run on make check, make distcheck
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp
if HAVE_CLOCK_GETTIME
check_PROGRAMS += timepng
endif
# Utilities - installed
bin_PROGRAMS= pngcp pngfix png-fix-itxt
bin_PROGRAMS= pngfix png-fix-itxt
# This ensures that pnglibconf.h gets built at the start of 'make all' or
# 'make check', but it does not add dependencies to the individual programs,

12
README
View File

@@ -1,4 +1,4 @@
README for libpng version 1.7.0beta82 - July 4, 2016 (shared library 17.0)
README for libpng version 1.7.0beta90 - August 28, 2017 (shared library 17.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@@ -23,7 +23,7 @@ earlier versions if you are using a shared library. The type of the
png_uint_32, which will affect shared-library applications that use
this function.
To avoid problems with changes to the internals of png info_struct,
To avoid problems with changes to the internals of the png info_struct,
new APIs have been made available in 0.95 to avoid direct application
access to info_ptr. These functions are the png_set_<chunk> and
png_get_<chunk> functions. These functions should be used when
@@ -88,11 +88,11 @@ zlib should be available at the same place that libpng is, or at zlib.net.
You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/documents/
these at http://www.libpng.org/pub/png/pngdocs.html .
This code is currently being archived at libpng.sf.net in the
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
in any of those places, e-mail me, and I'll help you find it.
This code is currently being archived at libpng.sourceforge.io in the
[DOWNLOAD] area, and at ftp://ftp-osl.osuosl.org/pub/libpng/src . If you
can't find it in any of those places, e-mail me, and I'll help you find it.
I am not a lawyer, but I believe that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export

7
TODO
View File

@@ -5,13 +5,14 @@ Final bug fixes.
Better C++ wrapper/full C++ implementation?
Fix problem with C++ and EXTERN "C".
cHRM transformation.
Remove setjmp/longjmp usage in favor of returning error codes.
Remove setjmp/longjmp usage in favor of returning error codes. As a start on
this, minimize the use of png_error(), replacing them with
png_warning(); return(0); or similar.
Palette creation.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Improved dithering.
Multi-lingual error and warning message support.
Complete sRGB transformation (presently it simply uses gamma=0.45455).
Make profile checking optional via a png_set_something() call.
Man pages for function calls.
Better documentation.
Better filter selection
@@ -23,8 +24,8 @@ Use greater precision when changing to linear gamma for compositing against
background and doing rgb-to-gray transformation.
Investigate pre-incremented loop counters and other loop constructions.
Add interpolated method of handling interlacing.
Switch to the simpler zlib (zlib/libpng) license if legally possible.
Extend pngvalid.c to validate more of the libpng transformations.
Refactor preprocessor conditionals to compile entire statements
Quiet compiler warnings (mostly -Wconversion warnings).
*/

View File

@@ -1,5 +1,13 @@
# configure.ac
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
# Last changed in libpng 1.7.0 [(PENDING RELEASE)]
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Minor upgrades (compatible ABI): increment the package version
@@ -18,7 +26,7 @@ AC_PREREQ([2.68])
dnl Version number stuff here:
AC_INIT([libpng],[1.7.0beta82],[png-mng-implement@lists.sourceforge.net])
AC_INIT([libpng],[1.7.0beta90],[png-mng-implement@lists.sourceforge.net])
AC_CONFIG_MACRO_DIR([scripts])
# libpng does not follow GNU file name conventions (hence 'foreign')
@@ -30,7 +38,7 @@ AC_CONFIG_MACRO_DIR([scripts])
# 1.14.1 is required for %reldir% support
AM_INIT_AUTOMAKE([1.15 foreign dist-xz color-tests silent-rules subdir-objects])
# The following line causes --disable-maintainer-mode to be the default to
# configure, this is necessary because libpng distributions cannot rely on the
# configure. This is necessary because libpng distributions cannot rely on the
# time stamps of the autotools generated files being correct
AM_MAINTAINER_MODE
@@ -40,7 +48,7 @@ dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake
PNGLIB_VERSION=1.7.0beta82
PNGLIB_VERSION=1.7.0beta90
PNGLIB_MAJOR=1
PNGLIB_MINOR=7
PNGLIB_RELEASE=0
@@ -178,7 +186,7 @@ then
enable_floating_arithmetic=no])
fi
# Set the relevant defines if required (only if required), this will override
# Set the relevant defines if required (only if required). This will override
# anything on the command line.
if test "$enable_floating_point" != yes
then

View File

@@ -17,7 +17,7 @@
*
* Documentation:
* http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
* http://code.google.com/p/android/issues/detail?id=49065
* https://code.google.com/p/android/issues/detail?id=49065
*
* NOTE: this requires that libpng is built against the Android NDK and linked
* with an implementation of the Android ARM 'cpu-features' library. The code

View File

@@ -1,10 +1,12 @@
/*- pngtopng
*
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
* COPYRIGHT: Written by John Cunningham Bowler, 2011, 2017.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.
*
* Last changed in libpng 1.6.29 [%RDATE%]
*
* Read a PNG and write it out in a fixed format, using the 'simplified API'
* that was introduced in libpng-1.6.0.
*
@@ -59,26 +61,27 @@ int main(int argc, const char **argv)
else
fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
image.message);
free(buffer);
}
else
{
fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
image.message);
/* This is the only place where a 'free' is required; libpng does
* the cleanup on error and success, but in this case we couldn't
* complete the read because of running out of memory.
*/
png_image_free(&image);
}
free(buffer);
}
else
{
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
(unsigned long)PNG_IMAGE_SIZE(image));
/* This is the only place where a 'free' is required; libpng does
* the cleanup on error and success, but in this case we couldn't
* complete the read because of running out of memory and so libpng
* has not got to the point where it can do cleanup.
*/
png_image_free(&image);
}
}
else

View File

@@ -55,7 +55,7 @@ mation and links to the latest version of the source code, and Chapters
13-15 of the book for detailed discussion of the three programs.
Greg Roelofs
http://pobox.com/~newt/greg_contact.html
https://pobox.com/~newt/greg_contact.html
16 March 2008
@@ -63,7 +63,7 @@ BUILD INSTRUCTIONS
- Prerequisites (in order of compilation):
- zlib http://zlib.net/
- zlib https://zlib.net/
- libpng http://www.libpng.org/pub/png/libpng.html
- pngbook http://www.libpng.org/pub/png/book/sources.html

View File

@@ -1,9 +1,8 @@
/*-
* pngstest.c
*
* Copyright (c) 2013-2016 John Cunningham Bowler
*
* Last changed in libpng 1.6.24 [(PENDING RELEASE)]
* Last changed in libpng 1.6.31 [July 27, 2017]
* Copyright (c) 2013-2017 John Cunningham Bowler
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -2611,9 +2610,9 @@ compare_two_images(Image *a, Image *b, int via_linear,
const unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
int alpha_added, alpha_removed;
int bchannels;
int btoa[4];
png_uint_32 y;
Transform tr;
int btoa[4]={0,0,0,0};
/* This should never happen: */
if (width != b->image.width || height != b->image.height)
@@ -2746,22 +2745,27 @@ compare_two_images(Image *a, Image *b, int via_linear,
*/
else if ((a->opts & ACCUMULATE) == 0)
{
# ifdef __GNUC__
# define BYTE_CHARS 20 /* 2^32: GCC sprintf warning */
# else
# define BYTE_CHARS 3 /* 2^8: real maximum value */
# endif
/* Check the original image first,
* TODO: deal with input images with bad pixel values?
*/
if (amax >= a->image.colormap_entries)
{
char pindex[9];
sprintf(pindex, "%d[%lu]", amax,
(unsigned long)a->image.colormap_entries);
char pindex[3+2*BYTE_CHARS];
sprintf(pindex, "%d[%u]", amax,
(png_byte)/*SAFE*/a->image.colormap_entries);
return logerror(a, a->file_name, ": bad pixel index: ", pindex);
}
else if (bmax >= b->image.colormap_entries)
{
char pindex[9];
sprintf(pindex, "%d[%lu]", bmax,
(unsigned long)b->image.colormap_entries);
char pindex[3+2*BYTE_CHARS];
sprintf(pindex, "%d[%u]", bmax,
(png_byte)/*SAFE*/b->image.colormap_entries);
return logerror(b, b->file_name, ": bad pixel index: ", pindex);
}
}
@@ -2881,10 +2885,13 @@ compare_two_images(Image *a, Image *b, int via_linear,
{
case 4:
if (pua[btoa[3]] != pub[3]) break;
/* FALLTHROUGH */
case 3:
if (pua[btoa[2]] != pub[2]) break;
/* FALLTHROUGH */
case 2:
if (pua[btoa[1]] != pub[1]) break;
/* FALLTHROUGH */
case 1:
if (pua[btoa[0]] != pub[0]) break;
if (alpha_added != 4 && pub[alpha_added] != 65535) break;
@@ -2900,10 +2907,13 @@ compare_two_images(Image *a, Image *b, int via_linear,
{
case 4:
if (psa[btoa[3]] != psb[3]) break;
/* FALLTHROUGH */
case 3:
if (psa[btoa[2]] != psb[2]) break;
/* FALLTHROUGH */
case 2:
if (psa[btoa[1]] != psb[1]) break;
/* FALLTHROUGH */
case 1:
if (psa[btoa[0]] != psb[0]) break;
if (alpha_added != 4 && psb[alpha_added] != 255) break;

View File

@@ -1,7 +1,7 @@
/* pngunknown.c - test the read side unknown chunk handling
*
* Last changed in libpng 1.6.22 [May 26, 2016]
* Last changed in libpng 1.6.26 [October 20, 2016]
* Copyright (c) 2015,2016 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
@@ -478,7 +478,7 @@ get_valid(display *d, png_infop info_ptr)
png_textp text;
png_uint_32 ntext = png_get_text(d->png_ptr, info_ptr, &text, NULL);
while (ntext-- > 0) switch (text[ntext].compression)
while (ntext > 0) switch (text[--ntext].compression)
{
case -1:
flags |= PNG_INFO_tEXt;

View File

@@ -1,9 +1,8 @@
/* pngvalid.c - validate libpng by constructing then reading png files.
*
* Last changed in libpng 1.6.24 [(PENDING RELEASE)]
* Copyright (c) 2014-2016 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
* Last changed in libpng 1.6.27 [December 29, 2016]
* Copyright (c) 2014-2016 John Cunningham Bowler
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -1115,7 +1114,7 @@ store_warning(png_structp ppIn, png_const_charp message)
if (!ps->expect_warning)
store_log(ps, pp, message, 0 /* warning */);
else
ps->saw_warning = 1;
ps->saw_warning = 1;
}
/* These somewhat odd functions are used when reading an image to ensure that
@@ -1242,7 +1241,7 @@ store_image_check(const png_store* ps, png_const_structp pp, int iImage)
image += 2; /* skip image first row markers */
while (rows-- > 0)
for (; rows > 0; --rows)
{
if (image[-2] != 190 || image[-1] != 239)
png_error(pp, "row start overwritten");
@@ -4011,8 +4010,11 @@ check_interlace_type(int const interlace_type)
# define do_own_interlace 1
#endif /* WRITE_INTERLACING tests */
#define CAN_WRITE_INTERLACE\
PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
#if PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
# define CAN_WRITE_INTERLACE 1
#else
# define CAN_WRITE_INTERLACE 0
#endif
/* Do the same thing for read interlacing; this controls whether read tests do
* their own de-interlace or use libpng.
@@ -11427,23 +11429,36 @@ perform_interlace_macro_validation(void)
*/
for (v=0;;)
{
/* The first two tests overflow if the pass row or column is outside
* the possible range for a 32-bit result. In fact the values should
* never be outside the range for a 31-bit result, but checking for 32
* bits here ensures that if an app uses a bogus pass row or column
* (just so long as it fits in a 32 bit integer) it won't get a
* possibly dangerous overflow.
*/
/* First the base 0 stuff: */
m = PNG_ROW_FROM_PASS_ROW(v, pass);
f = png_row_from_pass_row(v, pass);
if (m != f)
if (v < png_pass_rows(0xFFFFFFFFU, pass))
{
fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n",
v, pass, m, f);
exit(99);
m = PNG_ROW_FROM_PASS_ROW(v, pass);
f = png_row_from_pass_row(v, pass);
if (m != f)
{
fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n",
v, pass, m, f);
exit(99);
}
}
m = PNG_COL_FROM_PASS_COL(v, pass);
f = png_col_from_pass_col(v, pass);
if (m != f)
if (v < png_pass_cols(0xFFFFFFFFU, pass))
{
fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n",
v, pass, m, f);
exit(99);
m = PNG_COL_FROM_PASS_COL(v, pass);
f = png_col_from_pass_col(v, pass);
if (m != f)
{
fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n",
v, pass, m, f);
exit(99);
}
}
m = PNG_ROW_IN_INTERLACE_PASS(v, pass);

View File

@@ -1,8 +1,12 @@
/*
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
* copyright (C) 1999,2017 by Willem van Schaik <willem at schaik.com>
*
* version 1.0 - 1999.10.15 - First version.
* 1.1 - 2017.04.22 - Add buffer-size check (Glenn Randers-Pehrson)
* 1.2 - 2017.08.24 - Fix potential overflow in buffer-size check
* (Glenn Randers-Pehrson)
* 1.3 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
@@ -41,6 +45,7 @@
#define PNG_DEBUG 0
#endif
#include "png.h"
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
@@ -48,11 +53,20 @@
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#endif
#ifndef PNGMINUS_UNUSED
/* Unused formal parameter warnings are silenced using the following macro
* which is expected to have no bad effects on performance (optimizing
* compilers will probably remove it entirely).
*/
# define PNGMINUS_UNUSED(param) (void)param
#endif
/* function prototypes */
int main (int argc, char *argv[]);
void usage ();
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha);
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw,
BOOL alpha);
/*
* main
@@ -85,7 +99,8 @@ int main(int argc, char *argv[])
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
{
fprintf (stderr, "PNM2PNG\n");
fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]);
fprintf (stderr, "Error: can not create alpha-channel file %s\n",
argv[argi]);
exit (1);
}
break;
@@ -176,9 +191,11 @@ void usage()
fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n");
fprintf (stderr, " or: ... | png2pnm [options]\n");
fprintf (stderr, "Options:\n");
fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
fprintf (stderr,
" -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
fprintf (stderr, " -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
fprintf (stderr,
" -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
fprintf (stderr, " -h | -? print this help-information\n");
}
@@ -186,7 +203,8 @@ void usage()
* png2pnm
*/
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha)
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
volatile BOOL raw, BOOL alpha)
{
png_struct *png_ptr = NULL;
png_info *info_ptr = NULL;
@@ -218,7 +236,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
/* create png and info structures */
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
png_ptr = png_create_read_struct (png_get_libpng_ver(NULL),
NULL, NULL, NULL);
if (!png_ptr)
return FALSE; /* out of memory */
@@ -261,7 +279,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
png_set_expand (png_ptr);
#ifdef NJET
/* downgrade 16-bit images to 8 bit */
/* downgrade 16-bit images to 8-bit */
if (bit_depth == 16)
png_set_strip_16 (png_ptr);
/* transform grayscale images into full-color */
@@ -315,12 +333,21 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
/* row_bytes is the width x number of channels x (bit-depth / 8) */
row_bytes = png_get_rowbytes (png_ptr, info_ptr);
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) {
if ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes))
{
/* too big */
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return FALSE;
}
if ((png_pixels = (png_byte *)
malloc ((size_t)row_bytes * (size_t)height * sizeof (png_byte))) == NULL)
{
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return FALSE;
}
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
if ((row_pointers = (png_byte **)
malloc ((size_t)height * sizeof (png_bytep))) == NULL)
{
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
free (png_pixels);
@@ -329,7 +356,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
}
/* set the individual row_pointers to point at the correct offsets */
for (i = 0; i < (height); i++)
for (i = 0; i < ((int) height); i++)
row_pointers[i] = png_pixels + i * row_bytes;
/* now we can go ahead and just read the whole image */
@@ -372,9 +399,9 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
/* write data to PNM file */
pix_ptr = png_pixels;
for (row = 0; row < height; row++)
for (row = 0; row < (int) height; row++)
{
for (col = 0; col < width; col++)
for (col = 0; col < (int) width; col++)
{
for (i = 0; i < (channels - alpha_present); i++)
{
@@ -401,7 +428,8 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
if (raw)
fputc ((int) *pix_ptr++ , alpha_file);
else
if (bit_depth == 16){
if (bit_depth == 16)
{
dep_16 = (long) *pix_ptr++;
fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
}
@@ -425,6 +453,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
if (png_pixels != (unsigned char*) NULL)
free (png_pixels);
PNGMINUS_UNUSED(raw); /* to quiet a Coverity defect */
return TRUE;
} /* end of source */

View File

@@ -1,9 +1,13 @@
/*
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
* copyright (C) 1999,2015 by Willem van Schaik <willem@schaik.com>
* copyright (C) 1999,2015,2017 by Willem van Schaik <willem at schaik.com>
*
* version 1.0 - 1999.10.15 - First version.
* version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
* version 1.2 - 2017.04.22 - Add buffer-size check
* 1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
* (Glenn Randers-Pehrson)
* 1.4 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
@@ -47,6 +51,15 @@
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
#endif
#ifndef PNGMINUS_UNUSED
/* Unused formal parameter warnings are silenced using the following macro
* which is expected to have no bad effects on performance (optimizing
* compilers will probably remove it entirely).
*/
# define PNGMINUS_UNUSED(param) (void)param
#endif
/* function prototypes */
int main (int argc, char *argv[]);
@@ -370,11 +383,16 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
row_bytes = (width * channels * bit_depth + 7) / 8;
else
#endif
/* row_bytes is the width x number of channels x (bit-depth / 8) */
/* row_bytes is the width x number of channels x (bit-depth / 8) */
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
if ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes))
{
/* too big */
return FALSE;
}
if ((png_pixels = (png_byte *)
malloc (row_bytes * height * sizeof (png_byte))) == NULL)
malloc ((size_t)row_bytes * (size_t)height * sizeof (png_byte))) == NULL)
return FALSE;
/* read data from PNM file */
@@ -383,7 +401,8 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
for (row = 0; row < (int) height; row++)
{
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
if (packed_bitmap) {
if (packed_bitmap)
{
for (i = 0; i < (int) row_bytes; i++)
/* png supports this format natively so no conversion is needed */
*pix_ptr++ = get_data (pnm_file, 8);
@@ -504,6 +523,8 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
if (png_pixels != (unsigned char*) NULL)
free (png_pixels);
PNGMINUS_UNUSED(raw); /* Quiet a Coverity defect */
return TRUE;
} /* end of pnm2png */
@@ -520,7 +541,8 @@ void get_token(FILE *pnm_file, char *token)
do
{
ret = fgetc(pnm_file);
if (ret == '#') {
if (ret == '#')
{
/* the rest of this line is a comment */
do
{

View File

@@ -23,4 +23,5 @@ ORIGINAL AUTHORS
of the people below claim any rights with regard to the contents of this
directory.
John Bowler <jbowler@acm.org>
John Bowler <jbowler at acm.org>
Glenn Randers-Pehrson <glennrp at users.sourceforge.net>

View File

@@ -1,4 +1,11 @@
#!/bin/sh
# chkfmt
#
# COPYRIGHT: Written by John Cunningham Bowler, 2010.
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Check the format of the source files in the current directory - checks for a
# line length of 80 characters max and no tab characters.

View File

@@ -2,7 +2,7 @@
*
* Copyright (c) 2016 John Cunningham Bowler
*
* Last changed in libpng 1.6.24 [(PENDING RELEASE)]
* Last changed in libpng 1.6.24 [August 4, 2016]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer

View File

@@ -2,7 +2,7 @@
*
* Copyright (c) 2014-2016 John Cunningham Bowler
*
* Last changed in libpng 1.6.21 [January 15, 2016]
* Last changed in libpng 1.6.26 [October 20, 2016]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -1824,7 +1824,7 @@ IDAT_init(struct IDAT * const idat, struct file * const file)
}
static png_uint_32
rechunk_length(struct IDAT *idat)
rechunk_length(struct IDAT *idat, int start)
/* Return the length for the next IDAT chunk, taking into account
* rechunking.
*/
@@ -1836,7 +1836,7 @@ rechunk_length(struct IDAT *idat)
const struct IDAT_list *cur;
unsigned int count;
if (idat->idat_index == 0) /* at the new chunk (first time) */
if (start)
return idat->idat_length; /* use the cache */
/* Otherwise rechunk_length is called at the end of a chunk for the length
@@ -1995,7 +1995,7 @@ process_IDAT(struct file *file)
idat->idat_index = 0; /* Index into chunk data */
/* Update the chunk length to the correct value for the IDAT chunk: */
file->chunk->chunk_length = rechunk_length(idat);
file->chunk->chunk_length = rechunk_length(idat, 1/*start*/);
/* Change the state to writing IDAT chunks */
file->state = STATE_IDAT;
@@ -3473,7 +3473,8 @@ read_callback(png_structp png_ptr, png_bytep buffer, size_t count)
/* Write another IDAT chunk. Call rechunk_length to
* calculate the length required.
*/
length = chunk->chunk_length = rechunk_length(file->idat);
length = chunk->chunk_length =
rechunk_length(file->idat, 0/*end*/);
assert(type == png_IDAT);
file->write_count = 0; /* for the new chunk */
--(file->write_count); /* fake out the increment below */

25
contrib/tools/reindent Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
# reindent a libpng C source
# COPYRIGHT: Written by Glenn Randers-Pehrson, 2016.
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
# Usage:
# reindent inputtabsize outputtabsize inputcontinuestring outputcontinuestring
#
# Assumes that continued lines begin with indentation plus one space, and
# that continued comments begin with indentation plus " *".
#
# eg, to change libpng coding style from 3-space indentation with 4-space
# continuations to 4-space indentation with 2-space continuations:
#
# reindent 3 4 "\t " " " < example.c > example.c_4_2
# and to restore the file back to libpng coding style
# reindent 4 3 " " " " < example.c_4_2 > example.c_3_4
unexpand --first-only --t $1 | \
sed -e "/^ *$3[^\*]/{s/$3/$4/}" | \
expand -t $2

View File

@@ -14,7 +14,7 @@
* All routines take and return a floating point value in the range
* 0 to 1.0, doing a calculation according to the sRGB specification
* (in fact the source of the numbers is the wikipedia article at
* http://en.wikipedia.org/wiki/SRGB).
* https://en.wikipedia.org/wiki/SRGB).
*/
static double
sRGB_from_linear(double l)

View File

@@ -97,7 +97,7 @@ int main(int argc, const char **argv)
*/
if (buffer != NULL &&
png_image_finish_read(&image, NULL/*background*/, buffer,
0/*row_stride*/, NULL/*colormap*/) != 0)
0/*row_stride*/, NULL/*colormap*/) != 0)
{
/* Now write the image out to the second argument. In the write
* call 'convert_to_8bit' allows 16-bit data to be squashed down to
@@ -105,7 +105,7 @@ int main(int argc, const char **argv)
* to the 8-bit format.
*/
if (png_image_write_to_file(&image, argv[2], 0/*convert_to_8bit*/,
buffer, 0/*row_stride*/, NULL/*colormap*/) != 0)
buffer, 0/*row_stride*/, NULL/*colormap*/) != 0)
{
/* The image has been written successfully. */
exit(0);
@@ -295,7 +295,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
* was compiled with a compatible version of the library. REQUIRED
*/
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
@@ -375,7 +375,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
* low byte.
*/
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
png_set_scale_16(png_ptr);
png_set_scale_16(png_ptr);
#else
png_set_strip_16(png_ptr);
#endif
@@ -419,10 +419,10 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
if (png_get_bKGD(png_ptr, info_ptr, &image_background) != 0)
png_set_background(png_ptr, image_background,
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
else
png_set_background(png_ptr, &my_background,
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
/* Some suggestions as to how to get a screen gamma value
*
@@ -481,7 +481,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
png_color std_color_cube[MAX_SCREEN_COLORS];
png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
MAX_SCREEN_COLORS, NULL, 0);
MAX_SCREEN_COLORS, NULL, 0);
}
/* This reduces the image to the palette supplied in the file */
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) != 0)
@@ -491,7 +491,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
png_get_hIST(png_ptr, info_ptr, &histogram);
png_set_quantize(png_ptr, palette, num_palette,
max_screen_colors, histogram, 0);
max_screen_colors, histogram, 0);
}
}
#endif /* READ_QUANTIZE */
@@ -522,7 +522,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
png_set_swap(png_ptr);
/* Add filler (or alpha) byte (before/after each RGB triplet) */
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
png_set_filler(png_ptr, 0xffff, PNG_FILLER_AFTER);
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Turn on interlace handling. REQUIRED if you are not using
@@ -532,7 +532,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
number_passes = png_set_interlace_handling(png_ptr);
#else /* !READ_INTERLACING */
number_passes = 1;
#endif /* !READ_INTERLACING */
#endif /* READ_INTERLACING */
/* Optional call to gamma correct and add the background to the palette
@@ -552,7 +552,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
for (row = 0; row < height; row++)
row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
info_ptr));
info_ptr));
/* Now it's time to read the image. One of these methods is REQUIRED */
#ifdef entire /* Read the entire image in one go */
@@ -574,10 +574,10 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
{
#ifdef sparkle /* Read the image using the "sparkle" effect. */
png_read_rows(png_ptr, &row_pointers[y], NULL,
number_of_rows);
number_of_rows);
#else no_sparkle /* Read the image using the "rectangle" effect */
png_read_rows(png_ptr, NULL, &row_pointers[y],
number_of_rows);
number_of_rows);
#endif no_sparkle /* Use only one of these two methods */
}
@@ -614,7 +614,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
* linked libraries.
*/
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (*png_ptr == NULL)
{
@@ -649,14 +649,14 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
* the function png_get_progressive_ptr(png_ptr).
*/
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
info_callback, row_callback, end_callback);
info_callback, row_callback, end_callback);
return (OK);
}
int
process_data(png_structp *png_ptr, png_infop *info_ptr,
png_bytep buffer, png_uint_32 length)
png_bytep buffer, png_uint_32 length)
{
if (setjmp(png_jmpbuf((*png_ptr))))
{
@@ -691,7 +691,7 @@ info_callback(png_structp png_ptr, png_infop info)
}
row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass)
png_uint_32 row_num, int pass)
{
/*
* This function is called for every row in the image. If the
@@ -780,7 +780,7 @@ void write_png(char *file_name /* , ... other image information ... */)
* in case we are using dynamically linked libraries. REQUIRED.
*/
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
@@ -819,7 +819,7 @@ void write_png(char *file_name /* , ... other image information ... */)
* png_init_io() here you would call
*/
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
user_IO_flush_function);
user_IO_flush_function);
/* where user_io_ptr is a structure you want available to the callbacks */
#endif no_streams /* Only use one initialization method */
@@ -842,7 +842,7 @@ void write_png(char *file_name /* , ... other image information ... */)
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
*/
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
/* Set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
@@ -988,11 +988,11 @@ void write_png(char *file_name /* , ... other image information ... */)
png_bytep row_pointers[height];
if (height > PNG_UINT_32_MAX/(sizeof (png_bytep)))
png_error (png_ptr, "Image is too tall to process in memory");
png_error (png_ptr, "Image is too tall to process in memory");
/* Set up pointers into your "image" byte array */
for (k = 0; k < height; k++)
row_pointers[k] = image + k*width*bytes_per_pixel;
row_pointers[k] = image + k*width*bytes_per_pixel;
/* One of the following output methods is REQUIRED */

View File

@@ -1,9 +1,9 @@
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.7.0beta82 - July 4, 2016
libpng version 1.7.0beta90 - August 28, 2017
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2015 Glenn Randers-Pehrson
Copyright (c) 1998-2017 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
@@ -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.7.0beta82 - July 4, 2016
libpng versions 0.97, January 1998, through 1.7.0beta90 - August 28, 2017
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2015 Glenn Randers-Pehrson
@@ -67,17 +67,17 @@ file format in application programs.
The PNG specification (second edition), November 2003, is available as
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
<http://www.w3.org/TR/2003/REC-PNG-20031110/
<https://www.w3.org/TR/2003/REC-PNG-20031110/
The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at
<http://png-mng.sourceforge.net/pub/png/spec/1.2/>.
<https://png-mng.sourceforge.io/pub/png/spec/1.2/>.
It is technically equivalent
to the PNG specification (second edition) but has some additional material.
The PNG-1.0 specification is available as RFC 2083
<http://png-mng.sourceforge.net/pub/png/spec/1.0/> and as a
W3C Recommendation <http://www.w3.org/TR/REC-png-961001>.
The PNG-1.0 specification is available as RFC 2083
<https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
Some additional chunks are described in the special-purpose public chunks
documents at <http://www.libpng.org/pub/png/spec/register/>
@@ -102,7 +102,7 @@ majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can
be found at the zlib home page, <http://zlib.net/>.
be found at the zlib home page, <https://zlib.net/>.
The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details.
@@ -471,8 +471,9 @@ the default, use
The values for png_set_crc_action() say how libpng is to handle CRC errors in
ancillary and critical chunks, and whether to use the data contained
therein. Note that it is impossible to "discard" data in a critical
chunk.
therein. Starting with libpng-1.6.26, this also governs how an ADLER32 error
is handled while reading the IDAT chunk. Note that it is impossible to
"discard" data in a critical chunk.
Choices for (int) crit_action are
PNG_CRC_DEFAULT 0 error/quit
@@ -489,6 +490,9 @@ Choices for (int) ancil_action are
PNG_CRC_QUIET_USE 4 quiet/use data
PNG_CRC_NO_CHANGE 5 use the current value
When the setting for crit_action is PNG_CRC_QUIET_USE, the CRC and ADLER32
checksums are not only ignored, but they are not evaluated.
Setting up callback code
You can set up a callback function to handle any unknown chunks in the
@@ -3833,7 +3837,7 @@ The #defines to be used in png_image::format. Each #define identifies a
particular layout of channel data and, if present, alpha values. There are
separate defines for each of the two channel encodings.
A format is built up using single bit flag values. Not all combinations are
A format is built up using one-bit flag values. Not all combinations are
valid: use the bit flag values below for testing a format returned by the
read APIs, but set formats from the derived values.
@@ -4046,7 +4050,7 @@ READ APIs
When the simplified API needs to convert between sRGB and linear colorspaces,
the actual sRGB transfer curve defined in the sRGB specification (see the
article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
approximation used elsewhere in libpng.
WRITE APIS
@@ -4223,7 +4227,7 @@ However, there are some uncertainties about the status of local variables
after a longjmp, so the user may want to be careful about doing anything
after setjmp returns non-zero besides returning itself. Consult your
compiler documentation for more details. For an alternative approach, you
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net),
may wish to use the "cexcept" facility (see https://cexcept.sourceforge.io/),
which is illustrated in pngvalid.c and in contrib/visupng.
Beginning in libpng-1.4.0, the png_set_benign_errors() API became available.
@@ -4443,7 +4447,7 @@ in a MNG datastream. As a minimum, it must have the MNG 8-byte signature
and the MHDR and MEND chunks. Libpng does not provide support for these
or any other MNG chunks; your application must provide its own support for
them. You may wish to consider using libmng (available at
http://www.libmng.com) instead.
https://www.libmng.com/) instead.
VIII. Changes to Libpng from version 0.88
@@ -5185,27 +5189,33 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files
going back to version 0.70. You can access the git repository (read only)
at
git://git.code.sf.net/p/libpng/code
https://github.com/glennrp/libpng or
https://git.code.sf.net/p/libpng/code.git
or you can browse it with a web browser by selecting the "code" button at
or you can browse it with a web browser at
https://sourceforge.net/projects/libpng
https://github.com/glennrp/libpng or
https://sourceforge.net/p/libpng/code/ci/libpng16/tree/
Patches can be sent to glennrp at users.sourceforge.net or to
png-mng-implement at lists.sourceforge.net or you can upload them to
the libpng bug tracker at
http://libpng.sourceforge.net
https://libpng.sourceforge.io/
or as a "pull request" to
https://github.com/glennrp/libpng/pulls
We also accept patches built from the tar or zip distributions, and
simple verbal discriptions of bug fixes, reported either to the
SourceForge bug tracker, to the png-mng-implement at lists.sf.net
mailing list, or directly to glennrp.
mailing list, as github issues, or directly to glennrp.
XVI. Coding style
Our coding style is similar to the "Allman" style
(See http://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
(See https://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
braces on separate lines:
if (condition)
@@ -5247,6 +5257,19 @@ the statement that follows the comment:
*/
statement;
%17+%Linus Torvalds recomends putting the leading "/*" in multiple-line
%17+%comments on a separate line:
%17+%
%17+% /*
%17+% * This is a multiple-line
%17+% * comment.
%17+% */
%17+% statement;
%17+%
%17+%See
%17+%https://developers.slashdot.org/story/16/07/12/2036201
%17+%/linus-torvalds-in-sweary-rant-about-punctuation-in-kernel-comments
%17+%
Very short comments can be placed after the end of the statement
to which they pertain:
@@ -5306,7 +5329,7 @@ Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as
though it were a function.
Control keywords if, for, while, and switch are always followed by a space
to distinguish them from function calls, which have no trailing space.
to distinguish them from function calls, which have no trailing space.
We put a space after each comma and after each semicolon
in "for" statements, and we put spaces before and after each
@@ -5328,8 +5351,9 @@ with an even number of lower-case hex digits (e.g., 0x00, 0xff, 0x0100).
We prefer to use underscores in variable names rather than camelCase, except
for a few type names that we inherit from zlib.h.
We prefer "if (something != 0)" and "if (something == 0)"
over "if (something)" and if "(!something)", respectively.
We prefer "if (something != 0)" and "if (something == 0)" over
"if (something)" and if "(!something)", respectively, and for pointers
we prefer "if (some_pointer != NULL)" or "if (some_pointer == NULL)".
We do not use the TAB character for indentation in the C sources.
@@ -5343,7 +5367,7 @@ 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.7.0beta82 are Y2K compliant. It is my belief that earlier
upward through 1.7.0beta90 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

137
libpng.3
View File

@@ -1,6 +1,6 @@
.TH LIBPNG 3 "July 4, 2016"
.TH LIBPNG 3 "August 28, 2017"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta82
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta90
.SH SYNOPSIS
\fB
#include <png.h>\fP
@@ -500,10 +500,10 @@ 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.7.0beta82 - July 4, 2016
libpng version 1.7.0beta90 - August 28, 2017
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2015 Glenn Randers-Pehrson
Copyright (c) 1998-2017 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
@@ -511,7 +511,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.7.0beta82 - July 4, 2016
libpng versions 0.97, January 1998, through 1.7.0beta90 - August 28, 2017
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2015 Glenn Randers-Pehrson
@@ -567,17 +567,17 @@ file format in application programs.
The PNG specification (second edition), November 2003, is available as
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
<http://www.w3.org/TR/2003/REC-PNG-20031110/
<https://www.w3.org/TR/2003/REC-PNG-20031110/
The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at
<http://png-mng.sourceforge.net/pub/png/spec/1.2/>.
<https://png-mng.sourceforge.io/pub/png/spec/1.2/>.
It is technically equivalent
to the PNG specification (second edition) but has some additional material.
The PNG-1.0 specification is available as RFC 2083
<http://png-mng.sourceforge.net/pub/png/spec/1.0/> and as a
W3C Recommendation <http://www.w3.org/TR/REC-png-961001>.
The PNG-1.0 specification is available as RFC 2083
<https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
Some additional chunks are described in the special-purpose public chunks
documents at <http://www.libpng.org/pub/png/spec/register/>
@@ -602,7 +602,7 @@ majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can
be found at the zlib home page, <http://zlib.net/>.
be found at the zlib home page, <https://zlib.net/>.
The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details.
@@ -971,8 +971,9 @@ the default, use
The values for png_set_crc_action() say how libpng is to handle CRC errors in
ancillary and critical chunks, and whether to use the data contained
therein. Note that it is impossible to "discard" data in a critical
chunk.
therein. Starting with libpng-1.6.26, this also governs how an ADLER32 error
is handled while reading the IDAT chunk. Note that it is impossible to
"discard" data in a critical chunk.
Choices for (int) crit_action are
PNG_CRC_DEFAULT 0 error/quit
@@ -989,6 +990,9 @@ Choices for (int) ancil_action are
PNG_CRC_QUIET_USE 4 quiet/use data
PNG_CRC_NO_CHANGE 5 use the current value
When the setting for crit_action is PNG_CRC_QUIET_USE, the CRC and ADLER32
checksums are not only ignored, but they are not evaluated.
.SS Setting up callback code
You can set up a callback function to handle any unknown chunks in the
@@ -4333,7 +4337,7 @@ The #defines to be used in png_image::format. Each #define identifies a
particular layout of channel data and, if present, alpha values. There are
separate defines for each of the two channel encodings.
A format is built up using single bit flag values. Not all combinations are
A format is built up using one-bit flag values. Not all combinations are
valid: use the bit flag values below for testing a format returned by the
read APIs, but set formats from the derived values.
@@ -4546,7 +4550,7 @@ READ APIs
When the simplified API needs to convert between sRGB and linear colorspaces,
the actual sRGB transfer curve defined in the sRGB specification (see the
article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
approximation used elsewhere in libpng.
WRITE APIS
@@ -4723,7 +4727,7 @@ However, there are some uncertainties about the status of local variables
after a longjmp, so the user may want to be careful about doing anything
after setjmp returns non-zero besides returning itself. Consult your
compiler documentation for more details. For an alternative approach, you
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net),
may wish to use the "cexcept" facility (see https://cexcept.sourceforge.io/),
which is illustrated in pngvalid.c and in contrib/visupng.
Beginning in libpng-1.4.0, the png_set_benign_errors() API became available.
@@ -4943,7 +4947,7 @@ in a MNG datastream. As a minimum, it must have the MNG 8-byte signature
and the MHDR and MEND chunks. Libpng does not provide support for these
or any other MNG chunks; your application must provide its own support for
them. You may wish to consider using libmng (available at
http://www.libmng.com) instead.
https://www.libmng.com/) instead.
.SH VIII. Changes to Libpng from version 0.88
@@ -5685,27 +5689,33 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files
going back to version 0.70. You can access the git repository (read only)
at
git://git.code.sf.net/p/libpng/code
https://github.com/glennrp/libpng or
https://git.code.sf.net/p/libpng/code.git
or you can browse it with a web browser by selecting the "code" button at
or you can browse it with a web browser at
https://sourceforge.net/projects/libpng
https://github.com/glennrp/libpng or
https://sourceforge.net/p/libpng/code/ci/libpng16/tree/
Patches can be sent to glennrp at users.sourceforge.net or to
png-mng-implement at lists.sourceforge.net or you can upload them to
the libpng bug tracker at
http://libpng.sourceforge.net
https://libpng.sourceforge.io/
or as a "pull request" to
https://github.com/glennrp/libpng/pulls
We also accept patches built from the tar or zip distributions, and
simple verbal discriptions of bug fixes, reported either to the
SourceForge bug tracker, to the png-mng-implement at lists.sf.net
mailing list, or directly to glennrp.
mailing list, as github issues, or directly to glennrp.
.SH XVI. Coding style
Our coding style is similar to the "Allman" style
(See http://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
(See https://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
braces on separate lines:
if (condition)
@@ -5747,6 +5757,19 @@ the statement that follows the comment:
*/
statement;
%17+%Linus Torvalds recomends putting the leading "/*" in multiple-line
%17+%comments on a separate line:
%17+%
%17+% /*
%17+% * This is a multiple-line
%17+% * comment.
%17+% */
%17+% statement;
%17+%
%17+%See
%17+%https://developers.slashdot.org/story/16/07/12/2036201
%17+%/linus-torvalds-in-sweary-rant-about-punctuation-in-kernel-comments
%17+%
Very short comments can be placed after the end of the statement
to which they pertain:
@@ -5806,7 +5829,7 @@ Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as
though it were a function.
Control keywords if, for, while, and switch are always followed by a space
to distinguish them from function calls, which have no trailing space.
to distinguish them from function calls, which have no trailing space.
We put a space after each comma and after each semicolon
in "for" statements, and we put spaces before and after each
@@ -5828,8 +5851,9 @@ with an even number of lower-case hex digits (e.g., 0x00, 0xff, 0x0100).
We prefer to use underscores in variable names rather than camelCase, except
for a few type names that we inherit from zlib.h.
We prefer "if (something != 0)" and "if (something == 0)"
over "if (something)" and if "(!something)", respectively.
We prefer "if (something != 0)" and "if (something == 0)" over
"if (something)" and if "(!something)", respectively, and for pointers
we prefer "if (some_pointer != NULL)" or "if (some_pointer == NULL)".
We do not use the TAB character for indentation in the C sources.
@@ -5843,7 +5867,7 @@ 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.7.0beta82 are Y2K compliant. It is my belief that earlier
upward through 1.7.0beta90 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
@@ -5940,14 +5964,13 @@ the first widely used release:
...
1.0.19 10 10019 10.so.0.19[.0]
...
1.2.56 13 10253 12.so.0.53[.0]
1.2.57 13 10257 12.so.0.56[.0]
...
1.5.27 15 10523 15.so.15.23[.0]
...
1.6.22 16 10622 16.so.16.22[.0]
1.5.28 15 10528 15.so.15.28[.0]
...
1.6.28 16 10628 16.so.16.28[.0]
1.7.0alpha01-10 17 10700 17.so.17.0[.0]
1.7.0beta01-82 17 10700 17.so.17.0[.0]
1.7.0beta01-86 17 10700 17.so.17.0[.0]
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@@ -5964,7 +5987,7 @@ release number plus "betaNN" or "rcNN".
.LP
.IR libpng :
.IP
http://libpng.sourceforge.net (follow the [DOWNLOAD] link)
https://libpng.sourceforge.io/ (follow the [DOWNLOAD] link)
http://www.libpng.org/pub/png
.LP
@@ -5974,7 +5997,7 @@ http://www.libpng.org/pub/png
.I libpng
or at
.br
ftp://ftp.info-zip.org/pub/infozip/zlib
https://zlib.net/
.LP
.IR PNG specification: RFC 2083
@@ -5983,11 +6006,11 @@ ftp://ftp.info-zip.org/pub/infozip/zlib
.I libpng
or at
.br
ftp://ftp.rfc-editor.org:/in-notes/rfc2083.txt
https://www.ietf.org/rfc/rfc2083.txt
.br
or (as a W3C Recommendation) at
.br
http://www.w3.org/TR/REC-png.html
https://www.w3.org/TR/REC-png.html
.LP
In the case of any inconsistency between the PNG specification
@@ -6003,7 +6026,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.7.0beta82 - July 4, 2016:
Libpng version 1.7.0beta90 - August 28, 2017:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@@ -6028,8 +6051,8 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta82, July 4, 2016, are
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
libpng versions 1.0.7, July 1, 2000 through 1.7.0beta90, August 28, 2017 are
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
derived from libpng-1.0.6, and are distributed according to the same
disclaimer and license as libpng-1.0.6 with the following individuals
added to the list of Contributing Authors:
@@ -6050,6 +6073,10 @@ and with the following additions to the disclaimer:
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
Some files in the "contrib" directory and some configure-generated
files that are distributed with libpng have other copyright owners and
are released under other open source licenses.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
libpng-0.96, and are distributed according to the same disclaimer and
@@ -6073,6 +6100,9 @@ Contributing Authors:
Greg Roelofs
Tom Tanner
Some files in the "scripts" directory have other copyright owners
but are released under this license.
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -6113,6 +6143,29 @@ appreciated.
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
TRADEMARK:
The name "libpng" has not been registered by the Copyright owner
as a trademark in any jurisdiction. However, because libpng has
been distributed and maintained world-wide, continually since 1995,
the Copyright owner claims "common-law trademark protection" in any
jurisdiction where common-law trademark is recognized.
OSI CERTIFICATION:
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
a certification mark of the Open Source Initiative. OSI has not addressed
the additional disclaimers inserted at version 1.0.7.
EXPORT CONTROL:
The Copyright owner believes that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because
it is open source, publicly available software, that does not contain
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
734.7(b).
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
@@ -6121,13 +6174,9 @@ boxes and the like:
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
a certification mark of the Open Source Initiative. OSI has not addressed
the additional disclaimers inserted at version 1.0.7.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
July 4, 2016
August 28, 2017
.\" end of man page

View File

@@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "July 4, 2016"
.TH LIBPNGPF 3 "August 28, 2017"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta82
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta90
(private functions)
.SH SYNOPSIS
\fB#include \fI"pngpriv.h"

10
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "July 4, 2016"
.TH PNG 5 "August 28, 2017"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
@@ -23,12 +23,12 @@ platforms.
PNG specification (second edition), November 2003:
.IP
.br
<http://www.w3.org/TR/2003/REC-PNG-20031110/
<https://www.w3.org/TR/2003/REC-PNG-20031110/
.LP
PNG 1.2 specification, July 1999:
.IP
.br
http://png-mng.sourceforge.net/pub/png/spec/1.2/
https://png-mng.sourceforge.io/pub/png/spec/1.2/
.LP
PNG 1.0 specification, October 1996:
.IP
@@ -36,11 +36,11 @@ PNG 1.0 specification, October 1996:
RFC 2083
.IP
.br
http://www.ietf.org/rfc/rfc2083.txt
https://www.ietf.org/rfc/rfc2083.txt
.br
or (as a W3C Recommendation) at
.br
http://www.w3.org/TR/REC-png-961001
https://www.w3.org/TR/REC-png-961001
.SH AUTHORS
This man page: Glenn Randers-Pehrson
.LP

200
png.c
View File

@@ -2,7 +2,7 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* Copyright (c) 1998-2002,2004,2006-2017 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.)
*
@@ -15,7 +15,7 @@
#define PNG_SRC_FILE PNG_SRC_FILE_png
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_7_0beta82 Your_png_h_is_not_version_1_7_0beta82;
typedef png_libpng_version_1_7_0beta90 Your_png_h_is_not_version_1_7_0beta90;
/* 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
@@ -81,7 +81,7 @@ png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)
if (items >= (~(png_alloc_size_t)0)/size)
{
png_warning(png_voidcast(png_structrp, png_ptr),
"Potential overflow in png_zalloc()");
"Potential overflow in png_zalloc()");
return NULL;
}
@@ -310,7 +310,7 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
if (png_user_version_check(&create_struct, user_png_ver) != 0)
{
png_structrp png_ptr = png_voidcast(png_structrp,
png_malloc_warn(&create_struct, (sizeof *png_ptr)));
png_malloc_warn(&create_struct, (sizeof *png_ptr)));
if (png_ptr != NULL)
{
@@ -352,7 +352,7 @@ png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED)
* has always been done in 'example.c'.
*/
info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr,
(sizeof *info_ptr)));
(sizeof *info_ptr)));
if (info_ptr != NULL)
memset(info_ptr, 0, (sizeof *info_ptr));
@@ -399,7 +399,7 @@ png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)
void PNGAPI
png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
int num)
int num)
{
png_debug(1, "in png_free_data");
@@ -427,6 +427,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
png_free(png_ptr, info_ptr->text);
info_ptr->text = NULL;
info_ptr->num_text = 0;
info_ptr->max_text = 0;
}
}
#endif
@@ -704,15 +705,15 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.7.0beta82 - July 4, 2016" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
"libpng version 1.7.0beta90 - August 28, 2017" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2017 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.7.0beta82 - July 4, 2016\
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
return "libpng version 1.7.0beta90 - August 28, 2017\
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
# endif
@@ -933,7 +934,7 @@ png_zstream_error(z_stream *zstream, int ret)
#ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */
static int
png_colorspace_check_gamma(png_const_structrp png_ptr,
png_colorspacerp colorspace, png_fixed_point gAMA, int from)
png_colorspacerp colorspace, png_fixed_point gAMA, int from)
/* This is called to check a new gamma value against an existing one. The
* routine returns false if the new gamma value should not be written.
*
@@ -953,7 +954,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr,
png_fixed_point gtest;
if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
(png_muldiv(&gtest, colorspace->gamma, PNG_FP_1, gAMA) == 0 ||
(png_muldiv(&gtest, colorspace->gamma, PNG_FP_1, gAMA) == 0 ||
gtest < PNG_FP_1 - 1000 || gtest > PNG_FP_1 + 1000))
{
/* Either this is an sRGB image, in which case the calculated gamma
@@ -965,7 +966,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr,
if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2)
{
png_chunk_report(png_ptr, "gamma value does not match sRGB",
PNG_CHUNK_ERROR);
PNG_CHUNK_ERROR);
/* Do not overwrite an sRGB value */
return from == 2;
}
@@ -973,7 +974,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr,
else /* sRGB tag not involved */
{
png_chunk_report(png_ptr, "gamma value does not match libpng estimate",
PNG_CHUNK_WARNING);
PNG_CHUNK_WARNING);
return from == 1;
}
}
@@ -983,7 +984,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr,
void /* PRIVATE */
png_colorspace_set_gamma(png_const_structrp png_ptr,
png_colorspacerp colorspace, png_fixed_point gAMA)
png_colorspacerp colorspace, png_fixed_point gAMA)
{
/* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
* occur. Since the fixed point representation is asymmetrical it is
@@ -996,8 +997,13 @@ png_colorspace_set_gamma(png_const_structrp png_ptr,
* In 1.6.0 this test replaces the ones in pngrutil.c, in the gAMA chunk
* handling code, which only required the value to be >0.
*/
# define ERRMSG (defined PNG_TRANSFORM_MECH_SUPPORTED) &&\
(defined PNG_ERROR_TEXT_SUPPORTED)
# if (defined PNG_TRANSFORM_MECH_SUPPORTED) &&\
(defined PNG_ERROR_TEXT_SUPPORTED)
# define ERRMSG 1
# else
# define ERRMSG 0
# endif
# if ERRMSG
png_const_charp errmsg;
# endif
@@ -1573,8 +1579,8 @@ static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */
static int
png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr,
png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
int preferred)
png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
int preferred)
{
if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
return 0;
@@ -1621,7 +1627,7 @@ png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr,
int /* PRIVATE */
png_colorspace_set_chromaticities(png_const_structrp png_ptr,
png_colorspacerp colorspace, const png_xy *xy, int preferred)
png_colorspacerp colorspace, const png_xy *xy, int preferred)
{
/* We must check the end points to ensure they are reasonable - in the past
* color management systems have crashed as a result of getting bogus
@@ -1635,7 +1641,7 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr,
{
case 0: /* success */
return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ,
preferred);
preferred);
case 1:
/* We can't invert the chromaticities so we can't produce value XYZ
@@ -1659,7 +1665,7 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr,
int /* PRIVATE */
png_colorspace_set_endpoints(png_const_structrp png_ptr,
png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)
png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)
{
png_XYZ XYZ = *XYZ_in;
png_xy xy;
@@ -1668,7 +1674,7 @@ png_colorspace_set_endpoints(png_const_structrp png_ptr,
{
case 0:
return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ,
preferred);
preferred);
case 1:
/* End points are invalid. */
@@ -1726,7 +1732,7 @@ is_ICC_signature(png_alloc_size_t it)
static int
png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
png_const_charp name, png_alloc_size_t value, png_const_charp reason)
png_const_charp name, png_alloc_size_t value, png_const_charp reason)
{
size_t pos;
char message[196]; /* see below for calculation */
@@ -1751,8 +1757,8 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/
pos = png_safecat(message, (sizeof message), pos,
png_format_number(number, number+(sizeof number),
PNG_NUMBER_FORMAT_x, value));
png_format_number(number, number+(sizeof number),
PNG_NUMBER_FORMAT_x, value));
pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/
}
# endif
@@ -1766,7 +1772,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
* application errors the PNG won't be written.)
*/
png_chunk_report(png_ptr, message,
(colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR);
(colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR);
return 0;
}
@@ -1775,7 +1781,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
#ifdef PNG_sRGB_SUPPORTED
int /* PRIVATE */
png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
int intent)
int intent)
{
/* sRGB sets known gamma, end points and (from the chunk) intent. */
/* IMPORTANT: these are not necessarily the values found in an ICC profile
@@ -1812,10 +1818,10 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
*/
if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
(unsigned)intent, "invalid sRGB rendering intent");
(unsigned)intent, "invalid sRGB rendering intent");
if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
colorspace->rendering_intent != intent)
colorspace->rendering_intent != intent)
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
(unsigned)intent, "inconsistent rendering intents");
@@ -1829,8 +1835,8 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
* warn but overwrite the value with the correct one.
*/
if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 &&
!png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy,
100))
!png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy,
100))
png_chunk_report(png_ptr, "cHRM chunk does not match sRGB",
PNG_CHUNK_ERROR);
@@ -1838,7 +1844,7 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
* returns true when the 'from' argument corresponds to sRGB (2).
*/
(void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE,
2/*from sRGB*/);
2/*from sRGB*/);
/* intent: bugs in GCC force 'int' to be used as the parameter type. */
colorspace->rendering_intent = png_check_u16(png_ptr, intent);
@@ -1873,23 +1879,23 @@ static const png_byte D50_nCIEXYZ[12] =
int /* PRIVATE */
png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
png_const_charp name, png_uint_32 profile_length)
png_const_charp name, png_uint_32 profile_length)
{
if (profile_length < 132)
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
"too short");
"too short");
if (profile_length & 3)
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
"invalid length");
"invalid length");
return 1;
}
int /* PRIVATE */
png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
png_const_charp name, png_uint_32 profile_length,
png_const_bytep profile/* first 132 bytes only */, int is_color)
png_const_charp name, png_uint_32 profile_length,
png_const_bytep profile/* first 132 bytes only */, int is_color)
{
png_uint_32 temp;
@@ -1901,13 +1907,13 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
temp = png_get_uint_32(profile);
if (temp != profile_length)
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"length does not match profile");
"length does not match profile");
temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */
if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */
profile_length < 132+12*temp) /* truncated tag table */
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"tag count too large");
"tag count too large");
/* The 'intent' must be valid or we can't store it, ICC limits the intent to
* 16 bits.
@@ -1915,14 +1921,14 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
temp = png_get_uint_32(profile+64);
if (temp >= 0xffff) /* The ICC limit */
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"invalid rendering intent");
"invalid rendering intent");
/* This is just a warning because the profile may be valid in future
* versions.
*/
if (temp >= PNG_sRGB_INTENT_LAST)
(void)png_icc_profile_error(png_ptr, NULL, name, temp,
"intent outside defined range");
"intent outside defined range");
/* At this point the tag table can't be checked because it hasn't necessarily
* been loaded; however, various header fields can be checked. These checks
@@ -1939,7 +1945,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
temp = png_get_uint_32(profile+36); /* signature 'ascp' */
if (temp != 0x61637370)
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"invalid signature");
"invalid signature");
/* Currently the PCS illuminant/adopted white point (the computational
* white point) are required to be D50,
@@ -1950,7 +1956,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
*/
if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0)
(void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/,
"PCS illuminant is not D50");
"PCS illuminant is not D50");
/* The PNG spec requires this:
* "If the iCCP chunk is present, the image samples conform to the colour
@@ -1978,18 +1984,18 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
case 0x52474220: /* 'RGB ' */
if (!is_color)
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"RGB color space not permitted on grayscale PNG");
"RGB color space not permitted on grayscale PNG");
break;
case 0x47524159: /* 'GRAY' */
if (is_color)
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"Gray color space not permitted on RGB PNG");
"Gray color space not permitted on RGB PNG");
break;
default:
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"invalid ICC profile color space");
"invalid ICC profile color space");
}
/* It is up to the application to check that the profile class matches the
@@ -2014,7 +2020,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
case 0x61627374: /* 'abst' */
/* May not be embedded in an image */
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"invalid embedded Abstract ICC profile");
"invalid embedded Abstract ICC profile");
case 0x6C696E6B: /* 'link' */
/* DeviceLink profiles cannot be interpreted in a non-device specific
@@ -2024,7 +2030,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
* PNG.
*/
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"unexpected DeviceLink ICC profile class");
"unexpected DeviceLink ICC profile class");
case 0x6E6D636C: /* 'nmcl' */
/* A NamedColor profile is also device specific, however it doesn't
@@ -2032,7 +2038,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
* certainly it will fail the tests below.
*/
(void)png_icc_profile_error(png_ptr, NULL, name, temp,
"unexpected NamedColor ICC profile class");
"unexpected NamedColor ICC profile class");
break;
default:
@@ -2042,7 +2048,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
* understood profiles.
*/
(void)png_icc_profile_error(png_ptr, NULL, name, temp,
"unrecognized ICC profile class");
"unrecognized ICC profile class");
break;
}
@@ -2058,7 +2064,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
default:
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"unexpected ICC PCS encoding");
"unexpected ICC PCS encoding");
}
return 1;
@@ -2066,8 +2072,8 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
int /* PRIVATE */
png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
png_const_charp name, png_uint_32 profile_length,
png_const_bytep profile /* header plus whole tag table */)
png_const_charp name, png_uint_32 profile_length,
png_const_bytep profile /* header plus whole tag table */)
{
png_uint_32 tag_count = png_get_uint_32(profile+128);
png_uint_32 itag;
@@ -2095,7 +2101,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
* alignment.
*/
(void)png_icc_profile_error(png_ptr, NULL, name, tag_id,
"ICC profile tag start not a multiple of 4");
"ICC profile tag start not a multiple of 4");
}
/* This is a hard error; potentially it can cause read outside the
@@ -2103,7 +2109,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
*/
if (tag_start > profile_length || tag_length > profile_length - tag_start)
return png_icc_profile_error(png_ptr, colorspace, name, tag_id,
"ICC profile tag outside profile");
"ICC profile tag outside profile");
}
return 1; /* success, maybe with warnings */
@@ -2131,22 +2137,22 @@ static const struct
*/
/* adler32, crc32, MD5[4], intent, date, length, file-name */
PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9,
PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,
"2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc")
PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,
"2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc")
/* ICC sRGB v2 perceptual no black-compensation: */
PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21,
PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,
"2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc")
PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,
"2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc")
PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae,
PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,
"2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc")
PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,
"2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc")
/* ICC sRGB v4 perceptual */
PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812,
PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,
"2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc")
PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,
"2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc")
/* The following profiles have no known MD5 checksum. If there is a match
* on the (empty) MD5 the other fields are used to attempt a match and
@@ -2154,8 +2160,8 @@ static const struct
* which suggests that they were also made by Hewlett Packard.
*/
PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce,
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,
"2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc")
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,
"2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc")
/* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not
* match the D50 PCS illuminant in the header (it is in fact the D65 values,
@@ -2165,17 +2171,17 @@ static const struct
* chromaticAdaptationTag.
*/
PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552,
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/,
"1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual")
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/,
"1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual")
PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d,
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/,
"1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative")
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/,
"1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative")
};
static int
png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
png_const_bytep profile, uLong adler)
png_const_bytep profile, uLong adler)
{
/* The quick check is to verify just the MD5 signature and trust the
* rest of the data. Because the profile has already been verified for
@@ -2257,7 +2263,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
* which is made irrelevant by this error.
*/
png_chunk_report(png_ptr, "known incorrect sRGB profile",
PNG_CHUNK_ERROR);
PNG_CHUNK_ERROR);
}
/* Warn that this being done; this isn't even an error since
@@ -2267,8 +2273,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
else if (png_sRGB_checks[i].have_md5 == 0)
{
png_chunk_report(png_ptr,
"out-of-date sRGB profile with no signature",
PNG_CHUNK_WARNING);
"out-of-date sRGB profile with no signature",
PNG_CHUNK_WARNING);
}
return 1+png_sRGB_checks[i].is_broken;
@@ -2294,7 +2300,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
void /* PRIVATE */
png_icc_set_sRGB(png_const_structrp png_ptr,
png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
{
/* Is this profile one of the known ICC sRGB profiles? If it is, just set
* the sRGB information.
@@ -2308,17 +2314,17 @@ png_icc_set_sRGB(png_const_structrp png_ptr,
int /* PRIVATE */
png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,
int is_color)
png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,
int is_color)
{
if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
return 0;
if (png_icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
is_color) != 0 &&
is_color) != 0 &&
png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
profile) != 0)
profile) != 0)
{
# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
/* If no sRGB support, don't try storing sRGB information */
@@ -2471,9 +2477,9 @@ png_copy_row(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
void /* PRIVATE */
png_check_IHDR(png_const_structrp png_ptr,
png_uint_32 width, png_uint_32 height, int bit_depth,
int color_type, int interlace_type, int compression_type,
int filter_type)
png_uint_32 width, png_uint_32 height, int bit_depth,
int color_type, int interlace_type, int compression_type,
int filter_type)
{
int error = 0;
@@ -2629,7 +2635,7 @@ png_check_IHDR(png_const_structrp png_ptr,
int /* PRIVATE */
png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
png_size_tp whereami)
png_size_tp whereami)
{
int state = *statep;
png_size_t i = *whereami;
@@ -2785,7 +2791,7 @@ png_pow10(int power)
if (power < 0)
{
if (power < DBL_MIN_10_EXP) return 0;
recip = 1, power = -power;
recip = 1; power = -power;
}
if (power > 0)
@@ -2863,7 +2869,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
double test = png_pow10(exp_b10+1);
if (test <= DBL_MAX)
++exp_b10, base = test;
{
++exp_b10; base = test;
}
else
break;
@@ -2877,7 +2885,10 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
* test on DBL_MAX above.
*/
fp /= base;
while (fp >= 1) fp /= 10, ++exp_b10;
while (fp >= 1)
{
fp /= 10; ++exp_b10;
}
/* Because of the code above fp may, at this point, be
* less than .1, this is ok because the code below can
@@ -2928,7 +2939,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
/* Rounding up to 10, handle that here. */
if (czero > 0)
{
--czero, d = 1;
--czero; d = 1;
if (cdigits == 0) --clead;
}
else
@@ -2942,7 +2953,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
else if (ch == 46)
{
ch = *--ascii, ++size;
ch = *--ascii; ++size;
/* Advance exp_b10 to '1', so that the
* decimal point happens after the
* previous digit.
@@ -2969,7 +2980,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
int ch = *--ascii;
if (ch == 46)
++size, exp_b10 = 1;
{
++size; exp_b10 = 1;
}
/* Else lost a leading zero, so 'exp_b10' is
* still ok at (-1)
@@ -3060,7 +3073,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*/
size -= cdigits;
*ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision */
*ascii++ = 69; --size; /* 'E': PLUS 1 TOTAL 2+precision */
/* The following use of an unsigned temporary avoids ambiguities in
* the signed arithmetic on exp_b10 and permits GCC at least to do
@@ -3176,7 +3189,10 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
* then ndigits digits to first:
*/
i = 5;
while (ndigits < i) *ascii++ = 48, --i;
while (ndigits < i)
{
*ascii++ = 48; --i;
}
while (ndigits >= first) *ascii++ = digits[--ndigits];
/* Don't output the trailing zeros! */
}
@@ -3480,7 +3496,7 @@ png_setting(png_structrp png_ptr, png_uint_32 setting, png_uint_32 parameter,
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
/* sRGB conversion tables; these are machine generated with the code in
* contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the
* specification (see the article at http://en.wikipedia.org/wiki/SRGB)
* specification (see the article at https://en.wikipedia.org/wiki/SRGB)
* is used, not the gamma=1/2.2 approximation use elsewhere in libpng.
* The sRGB to linear table is exact (to the nearest 16-bit linear fraction).
* The inverse (linear to sRGB) table has accuracies as follows:

79
png.h
View File

@@ -1,9 +1,9 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.7.0beta82, July 4, 2016
* libpng version 1.7.0beta90, August 28, 2017
*
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* Copyright (c) 1998-2002,2004,2006-2017 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.)
*
@@ -12,7 +12,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.7.0beta82, July 4, 2016:
* libpng versions 0.97, January 1998, through 1.7.0beta90, August 28, 2017:
* Glenn Randers-Pehrson.
* See also "Contributing Authors", below.
*/
@@ -25,8 +25,8 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.0.7, July 1, 2000, through 1.7.0beta82, July 4, 2016, are
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
* libpng versions 1.0.7, July 1, 2000 through 1.7.0beta90, August 28, 2017 are
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
* derived from libpng-1.0.6, and are distributed according to the same
* disclaimer and license as libpng-1.0.6 with the following individuals
* added to the list of Contributing Authors:
@@ -47,6 +47,10 @@
* risk of satisfactory quality, performance, accuracy, and effort is with
* the user.
*
* Some files in the "contrib" directory and some configure-generated
* files that are distributed with libpng have other copyright owners and
* are released under other open source licenses.
*
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
* libpng-0.96, and are distributed according to the same disclaimer and
@@ -70,6 +74,9 @@
* Greg Roelofs
* Tom Tanner
*
* Some files in the "scripts" directory have other copyright owners
* but are released under this license.
*
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
*
@@ -109,6 +116,29 @@
* appreciated.
*
* END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
*
* TRADEMARK:
*
* The name "libpng" has not been registered by the Copyright owner
* as a trademark in any jurisdiction. However, because libpng has
* been distributed and maintained world-wide, continually since 1995,
* the Copyright owner claims "common-law trademark protection" in any
* jurisdiction where common-law trademark is recognized.
*
* OSI CERTIFICATION:
*
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
* a certification mark of the Open Source Initiative. OSI has not addressed
* the additional disclaimers inserted at version 1.0.7.
*
* EXPORT CONTROL:
*
* The Copyright owner believes that the Export Control Classification
* Number (ECCN) for libpng is EAR99, which means not subject to export
* controls or International Traffic in Arms Regulations (ITAR) because
* it is open source, publicly available software, that does not contain
* any encryption software. See the EAR, paragraphs 734.3(b)(3) and
* 734.7(b).
*/
/*
@@ -121,12 +151,6 @@
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
*/
/*
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
* a certification mark of the Open Source Initiative. OSI has not addressed
* the additional disclaimers inserted at version 1.0.7.
*/
/*
* The contributing authors would like to thank all those who helped
* with testing, bug fixes, and patience. This wouldn't have been
@@ -189,7 +213,7 @@
* 1.6.22 16 10622 16.so.16.22[.0]
* ...
* 1.7.0alpha01-10 17 10700 17.so.17.0[.0]
* 1.7.0beta01-82 17 10700 17.so.17.0[.0]
* 1.7.0beta01-84 17 10700 17.so.17.0[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -210,20 +234,20 @@
*
* See libpng.txt or libpng.3 for more information. The PNG specification
* is available as a W3C Recommendation and as an ISO Specification,
* <http://www.w3.org/TR/2003/REC-PNG-20031110/
* <https://www.w3.org/TR/2003/REC-PNG-20031110/
*/
/*
* Y2K compliance in libpng:
* =========================
*
* July 4, 2016
* August 28, 2017
*
* 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.7.0beta82 are Y2K compliant. It is my belief that
* upward through 1.7.0beta90 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
@@ -285,9 +309,8 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.7.0beta82"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.7.0beta82 - July 4, 2016\n"
#define PNG_LIBPNG_VER_STRING "1.7.0beta90"
#define PNG_HEADER_VERSION_STRING " libpng version 1.7.0beta90 - August 28, 2017\n"
#define PNG_LIBPNG_VER_SONUM 17
#define PNG_LIBPNG_VER_DLLNUM 17
@@ -301,7 +324,7 @@
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
*/
#define PNG_LIBPNG_VER_BUILD 82
#define PNG_LIBPNG_VER_BUILD 90
/* Release Status */
#define PNG_LIBPNG_BUILD_ALPHA 1
@@ -332,14 +355,14 @@
* the library has been built.
*/
#ifndef PNGLCONF_H
/* If pnglibconf.h is missing, you can
* copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
*/
/* If pnglibconf.h is missing, you can
* copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
*/
# include "pnglibconf.h"
#endif
#ifndef PNG_VERSION_INFO_ONLY
/* Machine specific configuration. */
/* Machine specific configuration. */
# include "pngconf.h"
#endif
@@ -561,7 +584,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_7_0beta82;
typedef char* png_libpng_version_1_7_0beta90;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -3382,7 +3405,7 @@ typedef struct
*
* When the simplified API needs to convert between sRGB and linear colorspaces,
* the actual sRGB transfer curve defined in the sRGB specification (see the
* article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
* article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
* approximation used elsewhere in libpng.
*
* When an alpha channel is present it is expected to denote pixel coverage
@@ -3872,9 +3895,9 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
#define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
(((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
12U+3U*(image).colormap_entries/*PLTE data*/+\
(((image).format&PNG_FORMAT_FLAG_ALPHA)?\
12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
12U+3U*(image).colormap_entries/*PLTE data*/+\
(((image).format&PNG_FORMAT_FLAG_ALPHA)?\
12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
/* A helper for the following macro; if your compiler cannot handle the
* following macro use this one with the result of

View File

@@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.7.0beta82, July 4, 2016
* libpng version 1.7.0beta90, August 28, 2017
*
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -188,27 +188,27 @@
* compatible with GCC or Visual C because of different calling conventions.
*/
# if PNG_API_RULE == 2
/* If this line results in an error, either because __watcall is not
* understood or because of a redefine just below you cannot use *this*
* build of the library with the compiler you are using. *This* build was
* build using Watcom and applications must also be built using Watcom!
*/
/* If this line results in an error, either because __watcall is not
* understood or because of a redefine just below you cannot use *this*
* build of the library with the compiler you are using. *This* build was
* build using Watcom and applications must also be built using Watcom!
*/
# define PNGCAPI __watcall
# endif
# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
# define PNGCAPI __cdecl
# if PNG_API_RULE == 1
/* If this line results in an error __stdcall is not understood and
* PNG_API_RULE should not have been set to '1'.
*/
/* If this line results in an error __stdcall is not understood and
* PNG_API_RULE should not have been set to '1'.
*/
# define PNGAPI __stdcall
# endif
# else
/* An older compiler, or one not detected (erroneously) above,
* if necessary override on the command line to get the correct
* variants for the compiler.
*/
/* An older compiler, or one not detected (erroneously) above,
* if necessary override on the command line to get the correct
* variants for the compiler.
*/
# ifndef PNGCAPI
# define PNGCAPI _cdecl
# endif
@@ -225,10 +225,10 @@
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
(defined(__BORLANDC__) && __BORLANDC__ < 0x500)
/* older Borland and MSC
* compilers used '__export' and required this to be after
* the type.
*/
/* older Borland and MSC
* compilers used '__export' and required this to be after
* the type.
*/
# ifndef PNG_EXPORT_TYPE
# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
# endif
@@ -244,9 +244,9 @@
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
# define PNGAPI _System
# else /* !Windows/x86 && !OS/2 */
/* Use the defaults, or define PNG*API on the command line (but
* this will have to be done for every compile!)
*/
/* Use the defaults, or define PNG*API on the command line (but
* this will have to be done for every compile!)
*/
# endif /* other system, !OS/2 */
#endif /* !Windows/x86 */
@@ -267,7 +267,7 @@
*/
#ifndef PNG_IMPEXP
# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
/* This forces use of a DLL, disallowing static linking */
/* This forces use of a DLL, disallowing static linking */
# define PNG_IMPEXP PNG_DLL_IMPORT
# endif
@@ -340,7 +340,7 @@
* less efficient code.
*/
# if defined(__clang__) && defined(__has_attribute)
/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
# endif

View File

@@ -27,7 +27,7 @@ static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
#ifdef PNG_WARNINGS_SUPPORTED
static void /* PRIVATE */
png_default_warning PNGARG((png_const_structrp png_ptr,
png_const_charp warning_message));
png_const_charp warning_message));
#endif /* WARNINGS */
/* This function is called whenever there is a fatal error. This function
@@ -38,7 +38,7 @@ png_default_warning PNGARG((png_const_structrp png_ptr,
#ifdef PNG_ERROR_TEXT_SUPPORTED
PNG_FUNCTION(void,PNGAPI
png_error,(png_const_structrp png_ptr, png_const_charp error_message),
PNG_NORETURN)
PNG_NORETURN)
{
if (png_ptr != NULL && png_ptr->error_fn != NULL)
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
@@ -71,7 +71,7 @@ png_err,(png_const_structrp png_ptr),PNG_NORETURN)
*/
size_t
png_safecat(png_charp buffer, size_t bufsize, size_t pos,
png_const_charp string)
png_const_charp string)
{
if (buffer != NULL && pos < bufsize)
{
@@ -93,7 +93,7 @@ png_safecat(png_charp buffer, size_t bufsize, size_t pos,
#define PNG_HAVE_FORMAT_NUMBER /* for the code below */
png_charp
png_format_number(png_const_charp start, png_charp end, int format,
png_alloc_size_t number)
png_alloc_size_t number)
{
int count = 0; /* number of digits output */
int mincount = 1; /* minimum number required */
@@ -180,7 +180,7 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
int offset = 0;
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
warning_message + offset);
warning_message + offset);
else
png_default_warning(png_ptr, warning_message + offset);
}
@@ -192,7 +192,7 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
*/
void
png_warning_parameter(png_warning_parameters p, int number,
png_const_charp string)
png_const_charp string)
{
if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)
(void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);
@@ -200,7 +200,7 @@ png_warning_parameter(png_warning_parameters p, int number,
void
png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
png_alloc_size_t value)
png_alloc_size_t value)
{
char buffer[PNG_NUMBER_BUFFER_SIZE];
png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
@@ -208,7 +208,7 @@ png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
void
png_warning_parameter_signed(png_warning_parameters p, int number, int format,
png_int_32 value)
png_int_32 value)
{
png_alloc_size_t u;
png_charp str;
@@ -229,7 +229,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format,
void
png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
png_const_charp message)
png_const_charp message)
{
/* The internal buffer is just 192 bytes - enough for all our messages,
* overflow doesn't happen because this code checks! If someone figures
@@ -433,7 +433,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
PNG_FUNCTION(void,PNGAPI
png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
PNG_NORETURN)
PNG_NORETURN)
{
char msg[18+PNG_MAX_ERROR_TEXT];
if (png_ptr == NULL || png_ptr->chunk_name == 0U)
@@ -596,7 +596,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
else
{
png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
png_malloc_warn(png_ptr, jmp_buf_size));
png_malloc_warn(png_ptr, jmp_buf_size));
if (png_ptr->jmp_buf_ptr == NULL)
return NULL; /* new NULL return on OOM */
@@ -685,7 +685,7 @@ png_free_jmpbuf(png_structrp png_ptr)
*/
static PNG_FUNCTION(void /* PRIVATE */,
png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
PNG_NORETURN)
PNG_NORETURN)
{
#ifdef PNG_CONSOLE_IO_SUPPORTED
{
@@ -789,7 +789,7 @@ png_get_error_ptr(png_const_structrp png_ptr)
*/
PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
PNG_NORETURN)
PNG_NORETURN)
{
const png_const_structrp png_ptr = png_nonconst_ptr;
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
@@ -812,7 +812,7 @@ png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
/* Missing longjmp buffer, the following is to help debugging: */
{
size_t pos = png_safecat(image->message, (sizeof image->message), 0,
"bad longjmp: ");
"bad longjmp: ");
png_safecat(image->message, (sizeof image->message), pos,
error_message);
}

View File

@@ -499,7 +499,7 @@ png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
#ifdef PNG_bKGD_SUPPORTED
png_uint_32 PNGAPI
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
png_color_16p *background)
png_color_16p *background)
{
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_bKGD) != 0 &&
@@ -539,28 +539,28 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
if (white_x != NULL)
*white_x = png_float(png_ptr,
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
if (white_y != NULL)
*white_y = png_float(png_ptr,
info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
if (red_x != NULL)
*red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
"cHRM red X");
"cHRM red X");
if (red_y != NULL)
*red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
"cHRM red Y");
"cHRM red Y");
if (green_x != NULL)
*green_x = png_float(png_ptr,
info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
if (green_y != NULL)
*green_y = png_float(png_ptr,
info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
if (blue_x != NULL)
*blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
"cHRM blue X");
"cHRM blue X");
if (blue_y != NULL)
*blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
"cHRM blue Y");
"cHRM blue Y");
return (PNG_INFO_cHRM);
}
@@ -569,42 +569,42 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_uint_32 PNGAPI
png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *red_X, double *red_Y, double *red_Z, double *green_X,
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
double *blue_Z)
double *red_X, double *red_Y, double *red_Z, double *green_X,
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
double *blue_Z)
{
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
if (red_X != NULL)
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
"cHRM red X");
"cHRM red X");
if (red_Y != NULL)
*red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
"cHRM red Y");
"cHRM red Y");
if (red_Z != NULL)
*red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
"cHRM red Z");
"cHRM red Z");
if (green_X != NULL)
*green_X = png_float(png_ptr,
info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
if (green_Y != NULL)
*green_Y = png_float(png_ptr,
info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
if (green_Z != NULL)
*green_Z = png_float(png_ptr,
info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
if (blue_X != NULL)
*blue_X = png_float(png_ptr,
info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
if (blue_Y != NULL)
*blue_Y = png_float(png_ptr,
info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
if (blue_Z != NULL)
*blue_Z = png_float(png_ptr,
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
return (PNG_INFO_cHRM);
}
@@ -694,8 +694,8 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_debug1(1, "in %s retrieval function", "gAMA");
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
file_gamma != NULL)
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
file_gamma != NULL)
{
*file_gamma = info_ptr->colorspace.gamma;
return (PNG_INFO_gAMA);
@@ -717,7 +717,7 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
file_gamma != NULL)
{
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
"png_get_gAMA");
"png_get_gAMA");
return (PNG_INFO_gAMA);
}
@@ -904,7 +904,7 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
*/
*width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
*height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
"sCAL height");
"sCAL height");
return (PNG_INFO_sCAL);
}

View File

@@ -67,7 +67,7 @@ png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
*/
PNG_FUNCTION(png_voidp /* PRIVATE */,
png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
PNG_ALLOCATED)
PNG_ALLOCATED)
{
/* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
* allocators have also been removed in 1.6.0, so any 16-bit system now has
@@ -112,7 +112,7 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
*/
static png_voidp
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
size_t element_size)
size_t element_size)
{
png_alloc_size_t req = nelements; /* known to be > 0 */
@@ -125,7 +125,7 @@ png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
PNG_FUNCTION(png_voidp /* PRIVATE */,
png_malloc_array,(png_const_structrp png_ptr, int nelements,
size_t element_size),PNG_ALLOCATED)
size_t element_size),PNG_ALLOCATED)
{
affirm(nelements > 0 && element_size > 0);
return png_malloc_array_checked(png_ptr, nelements, element_size);
@@ -133,7 +133,7 @@ png_malloc_array,(png_const_structrp png_ptr, int nelements,
PNG_FUNCTION(png_voidp /* PRIVATE */,
png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
{
/* These are internal errors: */
affirm(add_elements > 0 && element_size > 0 && old_elements >= 0 &&
@@ -145,7 +145,7 @@ png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
if (add_elements <= INT_MAX - old_elements)
{
png_voidp new_array = png_malloc_array_checked(png_ptr,
old_elements+add_elements, element_size);
old_elements+add_elements, element_size);
if (new_array != NULL)
{
@@ -156,7 +156,7 @@ png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
memcpy(new_array, old_array, element_size*(unsigned)old_elements);
memset((char*)new_array + element_size*(unsigned)old_elements, 0,
element_size*(unsigned)add_elements);
element_size*(unsigned)add_elements);
return new_array;
}
@@ -201,7 +201,7 @@ png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
*/
PNG_FUNCTION(png_voidp,PNGAPI
png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),
PNG_ALLOCATED)
PNG_ALLOCATED)
{
if (png_ptr != NULL)
{

View File

@@ -195,7 +195,7 @@ png_process_data_skip(png_structrp png_ptr)
static void
png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,
png_size_t buffer_length)
png_size_t buffer_length)
{
png_ptr->current_buffer_size = buffer_length;
png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size;
@@ -743,6 +743,8 @@ png_push_read_chunk_header(png_structrp png_ptr, png_infop info_ptr)
png_ptr->chunk_length = png_get_uint_31(png_ptr, chunk_header);
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_header+4);
png_reset_crc(png_ptr, chunk_header+4);
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
png_check_chunk_length(png_ptr, png_ptr->chunk_length);
mode = png_ptr->mode;
png_ptr->process_mode = png_check_bits(png_ptr,
png_read_chunk+png_find_chunk_op(png_ptr), 4);

View File

@@ -319,9 +319,13 @@
* is just the affirm code; there's no reason to allow configuration of this
* option.
*/
#define PNG_AFFIRM_TEXT (PNG_RELEASE_BUILD ?\
(defined PNG_ERROR_TEXT_SUPPORTED) :\
(defined PNG_WARNINGS_SUPPORTED) || (defined PNG_CONSOLE_IO_SUPPORTED))
#if PNG_RELEASE_BUILD ?\
(defined PNG_ERROR_TEXT_SUPPORTED) :\
(defined PNG_WARNINGS_SUPPORTED) || (defined PNG_CONSOLE_IO_SUPPORTED)
# define PNG_AFFIRM_TEXT 1
#else
# define PNG_AFFIRM_TEXT 0
#endif /* PNG_AFFIRM_TEXT definition */
#define PNG_SRC_LINE (PNG_SRC_FILE + __LINE__)
@@ -1083,7 +1087,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr,
#ifdef PNG_WRITE_cHRM_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,
const png_xy *xy), PNG_EMPTY);
/* The xy value must have been previously validated */
/* The xy value must have been previously validated */
#endif
#ifdef PNG_WRITE_sRGB_SUPPORTED
@@ -1707,7 +1711,6 @@ PNG_INTERNAL_FUNCTION(int,png_read_finish_IDAT,(png_structrp png_ptr),
* is more IDAT data available the caller should output an
* appropriate (too much IDAT) error message.
*/
#endif /* READ */
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_cache_known_unknown,(png_structrp png_ptr,
@@ -1734,6 +1737,12 @@ PNG_INTERNAL_FUNCTION(png_chunk_op,png_find_chunk_op,(png_structrp png_ptr),
* read state.
*/
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
const png_uint_32 chunk_name),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
const png_uint_32 chunk_length),PNG_EMPTY);
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
png_inforp info_ptr, png_bytep chunk_data),PNG_EMPTY);
@@ -1752,6 +1761,7 @@ PNG_INTERNAL_FUNCTION(void,png_handle_chunk,(png_structrp png_ptr,
* has returned png_chunk_process_all and all the data is available for
* png_handle_chunk (via the libpng read callback.)
*/
#endif /* READ */
PNG_INTERNAL_FUNCTION(void,png_init_row_info,(png_structrp png_ptr),PNG_EMPTY);
/* Set the png_struct::row_ members from the PNG file information, running
@@ -1769,13 +1779,13 @@ PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,
PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,
png_inforp info_ptr), PNG_EMPTY);
/* Synchronize the info 'valid' flags with the colorspace */
/* Synchronize the info 'valid' flags with the colorspace */
PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,
png_inforp info_ptr), PNG_EMPTY);
/* Copy the png_struct colorspace to the info_struct and call the above to
* synchronize the flags. Checks for NULL info_ptr and does nothing.
*/
/* Copy the png_struct colorspace to the info_struct and call the above to
* synchronize the flags. Checks for NULL info_ptr and does nothing.
*/
#endif
/* Added at libpng version 1.4.0 */
@@ -2117,6 +2127,14 @@ PNG_INTERNAL_FUNCTION(unsigned int,png_gamma_nxmbit_correct,
/* In this case the value must have 'n' bits and the output will have 'm'
* bits.
*/
#if !PNG_RELEASE_BUILD
PNG_INTERNAL_FUNCTION(int,png_gamma_check,(png_const_structrp png_ptr,
png_const_transform_controlp tc),PNG_EMPTY);
/* Debugging only routine to repeat the test used above to determine if the
* gamma was insignificant.
*/
#endif /* !RELEASE_BUILD */
#endif /* READ_GAMMA */
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED

172
pngread.c
View File

@@ -28,10 +28,10 @@ png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
{
#ifndef PNG_USER_MEM_SUPPORTED
png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
error_fn, warn_fn, NULL, NULL, NULL);
error_fn, warn_fn, NULL, NULL, NULL);
#else
return png_create_read_struct_2(user_png_ver, error_ptr, error_fn,
warn_fn, NULL, NULL, NULL);
warn_fn, NULL, NULL, NULL);
}
/* Alternate create PNG structure for reading, and allocate any memory
@@ -43,7 +43,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
{
png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
#endif /* USER_MEM */
if (png_ptr != NULL)
@@ -245,7 +245,7 @@ png_start_read_image(png_structrp png_ptr)
*/
else
png_app_error(png_ptr,
"png_start_read_image/png_read_update_info: duplicate call");
"png_start_read_image/png_read_update_info: duplicate call");
}
}
@@ -779,7 +779,7 @@ png_gt(size_t a, size_t b)
void PNGAPI
png_read_png(png_structrp png_ptr, png_inforp info_ptr, int transforms,
voidp params)
voidp params)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -1055,7 +1055,7 @@ png_image_read_init(png_imagep image)
if (info_ptr != NULL)
{
png_controlp control = png_voidcast(png_controlp,
png_malloc_warn(png_ptr, (sizeof *control)));
png_malloc_warn(png_ptr, (sizeof *control)));
if (control != NULL)
{
@@ -1131,7 +1131,9 @@ png_image_read_header(png_voidp argument)
png_structrp png_ptr = image->opaque->png_ptr;
png_inforp info_ptr = image->opaque->info_ptr;
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
png_set_benign_errors(png_ptr, 1/*warn*/);
#endif
png_read_info(png_ptr, info_ptr);
/* Do this the fast way; just read directly out of png_struct. */
@@ -1242,12 +1244,12 @@ png_image_begin_read_from_stdio(png_imagep image, FILE* file)
else
return png_image_error(image,
"png_image_begin_read_from_stdio: invalid argument");
"png_image_begin_read_from_stdio: invalid argument");
}
else if (image != NULL)
return png_image_error(image,
"png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION");
"png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION");
return 0;
}
@@ -1280,12 +1282,12 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name)
else
return png_image_error(image,
"png_image_begin_read_from_file: invalid argument");
"png_image_begin_read_from_file: invalid argument");
}
else if (image != NULL)
return png_image_error(image,
"png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION");
"png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION");
return 0;
}
@@ -1334,7 +1336,7 @@ image_init_memory_io(png_voidp param)
int PNGAPI
png_image_begin_read_from_memory(png_imagep image, png_const_voidp memory,
png_size_t size)
png_size_t size)
{
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
@@ -1356,12 +1358,12 @@ png_image_begin_read_from_memory(png_imagep image, png_const_voidp memory,
else
return png_image_error(image,
"png_image_begin_read_from_memory: invalid argument");
"png_image_begin_read_from_memory: invalid argument");
}
else if (image != NULL)
return png_image_error(image,
"png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION");
"png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION");
return 0;
}
@@ -1407,12 +1409,12 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
* IHDR, PLTE, tRNS, IDAT, and IEND chunks.
*/
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER,
NULL, -1);
NULL, -1);
/* But do not ignore image data handling chunks */
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT,
chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5);
}
chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5);
}
}
# define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p)
@@ -1614,7 +1616,7 @@ decode_gamma(png_image_read_control *display, png_uint_32 value,
default:
png_impossiblepp(display->image->opaque->png_ptr,
"unexpected encoding");
"unexpected encoding");
break;
}
@@ -1623,9 +1625,9 @@ decode_gamma(png_image_read_control *display, png_uint_32 value,
static png_uint_32
png_colormap_compose(png_image_read_control *display,
png_uint_32 foreground, unsigned int foreground_significant_bits,
int foreground_encoding, png_uint_32 alpha,
png_uint_32 background, int encoding)
png_uint_32 foreground, unsigned int foreground_significant_bits,
int foreground_encoding, png_uint_32 alpha,
png_uint_32 background, int encoding)
{
/* The file value is composed on the background, the background has the given
* encoding and so does the result, the file is encoded with P_FILE and the
@@ -1662,21 +1664,21 @@ png_colormap_compose(png_image_read_control *display,
*/
static void
png_create_colormap_entry(png_image_read_control *display,
png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue,
png_uint_32 alpha, int encoding)
png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue,
png_uint_32 alpha, int encoding)
{
png_imagep image = display->image;
# define png_ptr image->opaque->png_ptr /* for error messages */
const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
P_LINEAR : P_sRGB;
const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
(red != green || green != blue);
(red != green || green != blue);
int use_sBIT = encoding == P_FILE;
affirm(ip <= 255);
implies(encoding != P_LINEAR, red <= 255U && green <= 255U && blue <= 255U
&& display->sBIT[0] <= 8U && display->sBIT[1] <= 8U
&& display->sBIT[2] <= 8U && display->sBIT[3] <= 8U);
&& display->sBIT[0] <= 8U && display->sBIT[1] <= 8U
&& display->sBIT[2] <= 8U && display->sBIT[3] <= 8U);
/* This is a hack for the grayscale colormap below. */
if (encoding == P_FILE8)
@@ -1701,11 +1703,11 @@ png_create_colormap_entry(png_image_read_control *display,
if (convert_to_Y != 0 || output_encoding == P_LINEAR)
{
red = convert_to_linear(display, red,
use_sBIT ? display->sBIT[0] : 8U);
use_sBIT ? display->sBIT[0] : 8U);
green = convert_to_linear(display, green,
use_sBIT ? display->sBIT[1] : 8U);
use_sBIT ? display->sBIT[1] : 8U);
blue = convert_to_linear(display, blue,
use_sBIT ? display->sBIT[2] : 8U);
use_sBIT ? display->sBIT[2] : 8U);
alpha *= 257U;
if (use_sBIT)
alpha = update_for_sBIT(alpha, display->sBIT[3], 16U);
@@ -1717,11 +1719,11 @@ png_create_colormap_entry(png_image_read_control *display,
else
{
red = convert_to_sRGB(display, red,
use_sBIT ? display->sBIT[0] : 8U);
use_sBIT ? display->sBIT[0] : 8U);
green = convert_to_sRGB(display, green,
use_sBIT ? display->sBIT[1] : 8U);
use_sBIT ? display->sBIT[1] : 8U);
blue = convert_to_sRGB(display, blue,
use_sBIT ? display->sBIT[2] : 8U);
use_sBIT ? display->sBIT[2] : 8U);
if (use_sBIT)
alpha = update_for_sBIT(alpha, display->sBIT[3], 8U);
encoding = P_sRGB;
@@ -1830,7 +1832,7 @@ png_create_colormap_entry(png_image_read_control *display,
{
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
(image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
(image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
# else
# define afirst 0
# endif
@@ -2007,7 +2009,7 @@ make_ga_colormap(png_image_read_control *display)
for (g=0; g<6; ++g)
png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51,
P_sRGB);
P_sRGB);
}
return i;
@@ -2031,7 +2033,7 @@ make_rgb_colormap(png_image_read_control *display)
for (b=0; b<6; ++b)
png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255,
P_sRGB);
P_sRGB);
}
}
@@ -2084,7 +2086,7 @@ png_image_read_colormap(png_voidp argument)
else if (display->background == NULL /* no way to remove it */)
png_error(png_ptr,
"a background color must be supplied to remove alpha/transparency");
"background color must be supplied to remove alpha/transparency");
/* Get a copy of the background color (this avoids repeating the checks
* below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the
@@ -2184,7 +2186,7 @@ png_image_read_colormap(png_voidp argument)
*/
if (i != trans)
png_create_colormap_entry(display, i, val, val, val, 255,
P_FILE/*8-bit with file gamma*/);
P_FILE/*8-bit with file gamma*/);
/* Else this entry is transparent. The colors don't matter if
* there is an alpha channel (back_alpha == 0), but it does no
@@ -2199,10 +2201,10 @@ png_image_read_colormap(png_voidp argument)
#ifdef __COVERITY__
/* Coverity says back_r|g|b might be 16-bit values */
png_affirmpp(png_ptr, back_r < 256 && back_g < 256 &&
back_b < 256);
back_b < 256);
#endif
png_create_colormap_entry(display, i, back_r, back_g, back_b,
back_alpha, output_encoding);
back_alpha, output_encoding);
}
}
@@ -2268,7 +2270,7 @@ png_image_read_colormap(png_voidp argument)
* matches.
*/
png_create_colormap_entry(display, gray, back_g, back_g,
back_g, 65535, P_LINEAR);
back_g, 65535, P_LINEAR);
}
/* The background passed to libpng, however, must be the
@@ -2276,15 +2278,15 @@ png_image_read_colormap(png_voidp argument)
*/
c.index = 0; /*unused*/
c.gray = c.red = c.green = c.blue =
png_check_u16(png_ptr, gray);
png_check_u16(png_ptr, gray);
/* NOTE: does this work without expanding tRNS to alpha?
* It should be the color->gray case below apparently
* doesn't.
*/
png_set_background_fixed(png_ptr, &c,
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
output_processing = PNG_CMAP_NONE;
break;
@@ -2316,7 +2318,7 @@ png_image_read_colormap(png_voidp argument)
back_b < 256);
#endif
png_create_colormap_entry(display, 254, back_r, back_g, back_b,
back_alpha, output_encoding);
back_alpha, output_encoding);
}
else
@@ -2384,7 +2386,7 @@ png_image_read_colormap(png_voidp argument)
/* And make sure the corresponding palette entry matches. */
png_create_colormap_entry(display, gray, back_g, back_g,
back_g, 65535, P_LINEAR);
back_g, 65535, P_LINEAR);
}
/* The background passed to libpng, however, must be the sRGB
@@ -2394,8 +2396,8 @@ png_image_read_colormap(png_voidp argument)
c.gray = c.red = c.green = c.blue = png_check_u16(png_ptr, gray);
png_set_background_fixed(png_ptr, &c,
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
output_processing = PNG_CMAP_NONE;
}
@@ -2415,7 +2417,7 @@ png_image_read_colormap(png_voidp argument)
{
png_uint_32 gray = (i * 256 + 115) / 231;
png_create_colormap_entry(display, i++, gray, gray, gray,
255, P_sRGB);
255, P_sRGB);
}
/* NOTE: this preserves the full precision of the application
@@ -2493,7 +2495,7 @@ png_image_read_colormap(png_voidp argument)
* png_set_tRNS_to_alpha before png_set_background_fixed.
*/
png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1,
-1);
-1);
data_encoding = P_sRGB;
/* The output will now be one or two 8-bit gray or gray+alpha
@@ -2601,8 +2603,8 @@ png_image_read_colormap(png_voidp argument)
*/
expand_tRNS = 1;
png_set_background_fixed(png_ptr, &c,
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
}
output_processing = PNG_CMAP_NONE;
@@ -2636,7 +2638,7 @@ png_image_read_colormap(png_voidp argument)
/* Add a transparent entry. */
png_create_colormap_entry(display, cmap_entries, 255, 255,
255, 0, P_sRGB);
255, 0, P_sRGB);
/* This is stored as the background index for the processing
* algorithm.
@@ -2657,7 +2659,7 @@ png_image_read_colormap(png_voidp argument)
*/
for (b=0; b<256; b = (b << 1) | 0x7f)
png_create_colormap_entry(display, cmap_entries++,
r, g, b, 128, P_sRGB);
r, g, b, 128, P_sRGB);
}
}
@@ -2684,7 +2686,7 @@ png_image_read_colormap(png_voidp argument)
cmap_entries = make_rgb_colormap(display);
png_create_colormap_entry(display, cmap_entries, back_r,
back_g, back_b, 0/*unused*/, output_encoding);
back_g, back_b, 0/*unused*/, output_encoding);
if (output_encoding == P_LINEAR)
{
@@ -2706,9 +2708,9 @@ png_image_read_colormap(png_voidp argument)
* index.
*/
if (memcmp((png_const_bytep)display->colormap +
sample_size * cmap_entries,
(png_const_bytep)display->colormap +
sample_size * PNG_RGB_INDEX(r,g,b),
sample_size * cmap_entries,
(png_const_bytep)display->colormap +
sample_size * PNG_RGB_INDEX(r,g,b),
sample_size) != 0)
{
/* The background color must be added. */
@@ -2750,8 +2752,8 @@ png_image_read_colormap(png_voidp argument)
c.blue = png_check_u16(png_ptr, back_b);
png_set_background_fixed(png_ptr, &c,
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
output_processing = PNG_CMAP_RGB;
}
@@ -2803,7 +2805,7 @@ png_image_read_colormap(png_voidp argument)
{
if (trans[i] == 0)
png_create_colormap_entry(display, i, back_r, back_g,
back_b, 0, output_encoding);
back_b, 0, output_encoding);
else
{
@@ -2928,7 +2930,7 @@ static int
png_image_read_and_map(png_voidp argument)
{
png_image_read_control *display = png_voidcast(png_image_read_control*,
argument);
argument);
png_imagep image = display->image;
png_structrp png_ptr = image->opaque->png_ptr;
int passes;
@@ -3065,7 +3067,7 @@ png_image_read_and_map(png_voidp argument)
if (alpha >= 196)
*outrow = PNG_RGB_INDEX(inrow[0], inrow[1],
inrow[2]);
inrow[2]);
else if (alpha < 64)
*outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND;
@@ -3117,7 +3119,7 @@ static int
png_image_read_colormapped(png_voidp argument)
{
png_image_read_control *display = png_voidcast(png_image_read_control*,
argument);
argument);
png_imagep image = display->image;
png_controlp control = image->opaque;
png_structrp png_ptr = control->png_ptr;
@@ -3255,7 +3257,7 @@ static int
png_image_read_composite(png_voidp argument)
{
png_image_read_control *display = png_voidcast(png_image_read_control*,
argument);
argument);
png_imagep image = display->image;
png_structrp png_ptr = image->opaque->png_ptr;
int passes;
@@ -3383,7 +3385,7 @@ static int
png_image_read_background(png_voidp argument)
{
png_image_read_control *display = png_voidcast(png_image_read_control*,
argument);
argument);
png_imagep image = display->image;
png_structrp png_ptr = image->opaque->png_ptr;
png_inforp info_ptr = image->opaque->info_ptr;
@@ -3442,8 +3444,7 @@ png_image_read_background(png_voidp argument)
for (pass = 0; pass < passes; ++pass)
{
png_bytep row = png_voidcast(png_bytep,
display->first_row);
png_bytep row = png_voidcast(png_bytep, display->first_row);
unsigned int startx, stepx, stepy;
png_uint_32 y;
@@ -3471,7 +3472,7 @@ png_image_read_background(png_voidp argument)
for (; y<height; y += stepy)
{
png_bytep inrow = png_voidcast(png_bytep,
display->local_row);
display->local_row);
png_bytep outrow = first_row + y * step_row;
png_const_bytep end_row = outrow + width;
@@ -3517,7 +3518,7 @@ png_image_read_background(png_voidp argument)
for (; y<height; y += stepy)
{
png_bytep inrow = png_voidcast(png_bytep,
display->local_row);
display->local_row);
png_bytep outrow = first_row + y * step_row;
png_const_bytep end_row = outrow + width;
@@ -3565,7 +3566,7 @@ png_image_read_background(png_voidp argument)
*/
{
png_uint_16p first_row = png_voidcast(png_uint_16p,
display->first_row);
display->first_row);
/* The division by two is safe because the caller passed in a
* stride which was multiplied by 2 (below) to get row_bytes.
*/
@@ -3615,7 +3616,7 @@ png_image_read_background(png_voidp argument)
/* Read the row, which is packed: */
png_read_row(png_ptr, png_voidcast(png_bytep,
display->local_row), NULL);
display->local_row), NULL);
inrow = png_voidcast(png_const_uint_16p, display->local_row);
/* Now do the pre-multiplication on each pixel in this row.
@@ -3660,7 +3661,7 @@ static int
png_image_read_direct(png_voidp argument)
{
png_image_read_control *display = png_voidcast(png_image_read_control*,
argument);
argument);
png_imagep image = display->image;
png_structrp png_ptr = image->opaque->png_ptr;
png_inforp info_ptr = image->opaque->info_ptr;
@@ -3711,7 +3712,7 @@ png_image_read_direct(png_voidp argument)
do_local_background = 1/*maybe*/;
png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE,
PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT);
PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT);
}
change &= PNG_BIC_MASK(PNG_FORMAT_FLAG_COLOR);
@@ -3830,8 +3831,8 @@ png_image_read_direct(png_voidp argument)
* pixels.
*/
png_set_background_fixed(png_ptr, &c,
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
0/*gamma: not used*/);
}
else /* compose on row: implemented below. */
@@ -4073,7 +4074,7 @@ png_image_read_direct(png_voidp argument)
int PNGAPI
png_image_finish_read(png_imagep image, png_const_colorp background,
void *buffer, ptrdiff_t row_stride, void *colormap)
void *buffer, ptrdiff_t row_stride, void *colormap)
{
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
@@ -4138,15 +4139,16 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
* all the setup has already been done.
*/
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
result = png_safe_execute(image,
png_image_read_colormap, &display) &&
png_safe_execute(image,
png_image_read_colormapped, &display);
result =
png_safe_execute(image,
png_image_read_colormap, &display) &&
png_safe_execute(image,
png_image_read_colormapped, &display);
else
result =
png_safe_execute(image,
png_image_read_direct, &display);
png_image_read_direct, &display);
png_image_free(image);
return result;
@@ -4154,27 +4156,27 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
else
return png_image_error(image,
"png_image_finish_read[color-map]: no color-map");
"png_image_finish_read[color-map]: no color-map");
}
else
return png_image_error(image,
"png_image_finish_read: image too large");
"png_image_finish_read: image too large");
}
else
return png_image_error(image,
"png_image_finish_read: invalid argument");
"png_image_finish_read: invalid argument");
}
else
return png_image_error(image,
"png_image_finish_read: row_stride too large");
"png_image_finish_read: row_stride too large");
}
else if (image != NULL)
return png_image_error(image,
"png_image_finish_read: damaged PNG_IMAGE_VERSION");
"png_image_finish_read: damaged PNG_IMAGE_VERSION");
return 0;
}

View File

@@ -91,7 +91,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
*/
void PNGAPI
png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
png_rw_ptr read_data_fn)
png_rw_ptr read_data_fn)
{
if (png_ptr == NULL)
return;

View File

@@ -3434,9 +3434,29 @@ png_init_gamma(png_transformp *transform, png_transform_controlp tc)
}
}
#if !PNG_RELEASE_BUILD
int /* PRIVATE(debug only) */
png_gamma_check(png_const_structrp png_ptr, png_const_transform_controlp tc)
/* Debugging only routine to repeat the test used above to determine if the
* gamma was insignificant.
*
* NOTE: JB20160723: This may still be incorrect in a complicated transform
* pipeline because it uses 'tc_sBIT' for the end of the pipeline whereas the
* init above happens earlier. I don't think this matters because the test
* is only invoked if the gamma transform is eliminated or if there is a bug
* and in the former case the sBIT values should remain unchanged.
*/
{
png_fixed_point dummy;
return png_gamma_equal(png_ptr, png_ptr->row_gamma, tc->gamma, &dummy,
tc_sBIT(tc));
}
#endif /* !RELEASE_BUILD */
static png_fixed_point
translate_gamma_flags(png_const_structrp png_ptr, png_fixed_point gamma,
int is_screen)
int is_screen)
/* If 'is_screen' is set this returns the inverse of the supplied value; i.e.
* this routine always returns an encoding value.
*/
@@ -3511,7 +3531,7 @@ add_gamma_transform(png_structrp png_ptr, unsigned int order,
void PNGFAPI
png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
png_fixed_point file_gamma)
png_fixed_point file_gamma)
{
png_debug(1, "in png_set_gamma_fixed");
@@ -3566,7 +3586,7 @@ void PNGAPI
png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma)
{
png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
convert_gamma_value(png_ptr, file_gamma));
convert_gamma_value(png_ptr, file_gamma));
}
#endif /* FLOATING_POINT */
#endif /* READ_GAMMA */
@@ -4044,7 +4064,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
void PNGAPI
png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red,
double green)
double green)
{
png_set_rgb_to_gray_fixed(png_ptr, error_action,
png_fixed(png_ptr, red, "rgb to gray red coefficient"),
@@ -5490,7 +5510,7 @@ png_set_background(png_structrp png_ptr,
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
void PNGFAPI
png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
png_fixed_point output_gamma)
png_fixed_point output_gamma)
{
if (png_ptr != NULL)
{
@@ -5603,7 +5623,7 @@ void PNGAPI
png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)
{
png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,
output_gamma));
output_gamma));
}
#endif /* FLOATING_POINT */
#endif /* READ_ALPHA_MODE */

View File

@@ -2,7 +2,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* Copyright (c) 1998-2002,2004,2006-2017 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.)
*
@@ -231,10 +231,10 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
else if (warn < 2) /* else silent */
{
if (warn != 0)
png_chunk_warning(png_ptr, "insufficient memory to read chunk");
png_chunk_warning(png_ptr, "insufficient memory to read chunk");
else
png_chunk_error(png_ptr, "insufficient memory to read chunk");
png_chunk_error(png_ptr, "insufficient memory to read chunk");
}
}
@@ -260,12 +260,12 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
* are minimal.
*/
(void)png_safecat(msg, (sizeof msg), 4, " using zstream");
# if PNG_RELEASE_BUILD
png_chunk_warning(png_ptr, msg);
png_ptr->zowner = 0;
# else
png_chunk_error(png_ptr, msg);
# endif
#if PNG_RELEASE_BUILD
png_chunk_warning(png_ptr, msg);
png_ptr->zowner = 0;
#else
png_chunk_error(png_ptr, msg);
#endif
}
/* Implementation note: unlike 'png_deflate_claim' this internal function
@@ -283,21 +283,17 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
*/
{
int ret; /* zlib return code */
# if PNG_ZLIB_VERNUM >= 0x1240
#if ZLIB_VERNUM >= 0x1240
int window_bits = 0;
# if defined(PNG_SET_OPTION_SUPPORTED) && \
defined(PNG_MAXIMUM_INFLATE_WINDOW)
int window_bits;
# if defined(PNG_SET_OPTION_SUPPORTED) && \
defined(PNG_MAXIMUM_INFLATE_WINDOW)
if (png_ptr->maximum_inflate_window)
window_bits = 15;
else
window_bits = 0;
# else
# define window_bits 0
# endif
# endif
# endif
#endif /* ZLIB_VERNUM >= 0x1240 */
/* Initialize the alloc/free callbacks every time: */
png_ptr->zstream.zalloc = png_zalloc;
@@ -317,22 +313,28 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
*/
if (png_ptr->zstream.state != NULL)
{
# if PNG_ZLIB_VERNUM < 0x1240
ret = inflateReset(&png_ptr->zstream);
# else
ret = inflateReset2(&png_ptr->zstream, window_bits);
# endif
#if ZLIB_VERNUM >= 0x1240
ret = inflateReset2(&png_ptr->zstream, window_bits);
#else
ret = inflateReset(&png_ptr->zstream);
#endif
}
else
{
# if PNG_ZLIB_VERNUM < 0x1240
ret = inflateInit(&png_ptr->zstream);
# else
ret = inflateInit2(&png_ptr->zstream, window_bits);
# endif
#if ZLIB_VERNUM >= 0x1240
ret = inflateInit2(&png_ptr->zstream, window_bits);
#else
ret = inflateInit(&png_ptr->zstream);
#endif
}
#if ZLIB_VERNUM >= 0x1240
/* Turn off validation of the ADLER32 checksum */
if (png_ptr->current_crc == crc_quiet_use)
ret = inflateReset2(&png_ptr->zstream, -window_bits);
#endif
if (ret == Z_OK && png_ptr->zstream.state != NULL)
{
png_ptr->zowner = owner;
@@ -507,7 +509,7 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
png_uint_32 avail_in = *input_size_ptr;
png_alloc_size_t avail_out = *output_size_ptr;
int ret = png_zlib_inflate(png_ptr, owner, finish,
&input, &avail_in, &output, &avail_out);
&input, &avail_in, &output, &avail_out);
/* And implement the non-zlib semantics (the size values are updated to the
* amounts consumed and written, not the amount remaining.)
@@ -525,9 +527,9 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
*/
static int
png_decompress_chunk(png_structrp png_ptr,
png_uint_32 chunklength, png_uint_32 prefix_size,
png_alloc_size_t *newlength /* must be initialized to the maximum! */,
int terminate /*add a '\0' to the end of the uncompressed data*/)
png_uint_32 chunklength, png_uint_32 prefix_size,
png_alloc_size_t *newlength /* must be initialized to the maximum! */,
int terminate /*add a '\0' to the end of the uncompressed data*/)
{
/* TODO: implement different limits for different types of chunk.
*
@@ -538,14 +540,14 @@ png_decompress_chunk(png_structrp png_ptr,
*/
png_alloc_size_t limit = PNG_SIZE_MAX;
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (png_ptr->user_chunk_malloc_max > 0 &&
png_ptr->user_chunk_malloc_max < limit)
limit = png_ptr->user_chunk_malloc_max;
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
if (PNG_USER_CHUNK_MALLOC_MAX < limit)
limit = PNG_USER_CHUNK_MALLOC_MAX;
# endif
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (png_ptr->user_chunk_malloc_max > 0 &&
png_ptr->user_chunk_malloc_max < limit)
limit = png_ptr->user_chunk_malloc_max;
#elif PNG_USER_CHUNK_MALLOC_MAX > 0
if (PNG_USER_CHUNK_MALLOC_MAX < limit)
limit = PNG_USER_CHUNK_MALLOC_MAX;
#endif
if (limit >= prefix_size + (terminate != 0))
{
@@ -564,8 +566,8 @@ png_decompress_chunk(png_structrp png_ptr,
png_uint_32 lzsize = chunklength - prefix_size;
ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
/* input: */ png_ptr->read_buffer + prefix_size, &lzsize,
/* output: */ NULL, newlength);
/* input: */ png_ptr->read_buffer + prefix_size, &lzsize,
/* output: */ NULL, newlength);
if (ret == Z_STREAM_END)
{
@@ -585,15 +587,15 @@ png_decompress_chunk(png_structrp png_ptr,
*/
png_alloc_size_t new_size = *newlength;
png_alloc_size_t buffer_size = prefix_size + new_size +
(terminate != 0);
(terminate != 0);
png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr,
buffer_size));
buffer_size));
if (text != NULL)
{
ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
png_ptr->read_buffer + prefix_size, &lzsize,
text + prefix_size, newlength);
png_ptr->read_buffer + prefix_size, &lzsize,
text + prefix_size, newlength);
if (ret == Z_STREAM_END)
{
@@ -638,7 +640,7 @@ png_decompress_chunk(png_structrp png_ptr,
* the extra space may otherwise be used as a Trojan Horse.
*/
if (ret == Z_STREAM_END &&
chunklength - prefix_size != lzsize)
chunklength - prefix_size != lzsize)
png_chunk_benign_error(png_ptr, "extra compressed data");
}
@@ -688,8 +690,8 @@ png_decompress_chunk(png_structrp png_ptr,
*/
static int
png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size,
int finish)
png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size,
int finish)
{
if (png_ptr->zowner == png_ptr->chunk_name)
{
@@ -729,7 +731,8 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
* streams.
*/
ret = inflate(&png_ptr->zstream,
*chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
*chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH :
Z_SYNC_FLUSH));
}
while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));
@@ -763,7 +766,7 @@ png_handle_skip(png_structrp png_ptr)
static void
png_handle_error(png_structrp png_ptr
# ifdef PNG_ERROR_TEXT_SUPPORTED
, png_const_charp error
, png_const_charp error
# else
# define png_handle_error(pp,e) png_handle_error(pp)
# endif
@@ -823,7 +826,6 @@ png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr)
png_ptr->interlaced = interlace_type;
png_ptr->color_type = color_type;
png_ptr->filter_method = filter_method;
png_ptr->compression_type = compression_type;
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
color_type, interlace_type, compression_type, filter_method);
@@ -1111,7 +1113,7 @@ png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr)
png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
(void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy,
1/*prefer cHRM values*/);
1/*prefer cHRM values*/);
png_colorspace_sync(png_ptr, info_ptr);
}
#else
@@ -1234,8 +1236,8 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2);
png_ptr->zstream.avail_in = read_length;
(void)png_inflate_read(png_ptr, local_buffer,
(sizeof local_buffer), &length, profile_header, &size,
0/*finish: don't, because the output is too small*/);
(sizeof local_buffer), &length, profile_header, &size,
0/*finish: don't, because the output is too small*/);
if (size == 0)
{
@@ -1245,14 +1247,14 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
png_get_uint_32(profile_header);
if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
keyword, profile_length))
keyword, profile_length))
{
/* The length is apparently ok, so we can check the 132
* byte header.
*/
if (png_icc_check_header(png_ptr, &png_ptr->colorspace,
keyword, profile_length, profile_header,
(png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0))
keyword, profile_length, profile_header,
(png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0))
{
/* Now read the tag table; a variable size buffer is
* needed at this point, allocate one for the whole
@@ -1260,20 +1262,20 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
* that none of these stuff will overflow.
*/
const png_uint_32 tag_count = png_get_uint_32(
profile_header+128);
profile_header+128);
png_bytep profile = png_read_buffer(png_ptr,
profile_length, 2/*silent*/);
profile_length, 2/*silent*/);
if (profile != NULL)
{
memcpy(profile, profile_header,
(sizeof profile_header));
(sizeof profile_header));
size = 12 * tag_count;
(void)png_inflate_read(png_ptr, local_buffer,
(sizeof local_buffer), &length,
profile + (sizeof profile_header), &size, 0);
(sizeof local_buffer), &length,
profile + (sizeof profile_header), &size, 0);
/* Still expect a buffer error because we expect
* there to be some tag data!
@@ -1281,26 +1283,26 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
if (size == 0)
{
if (png_icc_check_tag_table(png_ptr,
&png_ptr->colorspace, keyword, profile_length,
profile))
&png_ptr->colorspace, keyword, profile_length,
profile))
{
/* The profile has been validated for basic
* security issues, so read the whole thing in.
*/
size = profile_length - (sizeof profile_header)
- 12 * tag_count;
- 12 * tag_count;
(void)png_inflate_read(png_ptr, local_buffer,
(sizeof local_buffer), &length,
profile + (sizeof profile_header) +
12 * tag_count, &size, 1/*finish*/);
(sizeof local_buffer), &length,
profile + (sizeof profile_header) +
12 * tag_count, &size, 1/*finish*/);
if (length > 0
# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED
&& png_ptr->benign_error_action ==
PNG_ERROR
&& png_ptr->benign_error_action ==
PNG_ERROR
# endif /* BENIGN_READ_ERRORS */
)
)
errmsg = "extra compressed data";
/* But otherwise allow extra data: */
@@ -1312,7 +1314,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
* keep going.
*/
png_chunk_warning(png_ptr,
"extra compressed data");
"extra compressed data");
}
png_crc_finish(png_ptr, length);
@@ -1321,23 +1323,23 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
/* Check for a match against sRGB */
png_icc_set_sRGB(png_ptr,
&png_ptr->colorspace, profile,
png_ptr->zstream.adler);
&png_ptr->colorspace, profile,
png_ptr->zstream.adler);
# endif
/* Steal the profile for info_ptr. */
if (info_ptr != NULL)
{
png_free_data(png_ptr, info_ptr,
PNG_FREE_ICCP, 0);
PNG_FREE_ICCP, 0);
info_ptr->iccp_name = png_voidcast(char*,
png_malloc_base(png_ptr,
keyword_length+1));
png_malloc_base(png_ptr,
keyword_length+1));
if (info_ptr->iccp_name != NULL)
{
memcpy(info_ptr->iccp_name, keyword,
keyword_length+1);
keyword_length+1);
info_ptr->iccp_profile = profile;
png_ptr->read_buffer = NULL; /*steal*/
info_ptr->free_me |= PNG_FREE_ICCP;
@@ -1347,7 +1349,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
else
{
png_ptr->colorspace.flags |=
PNG_COLORSPACE_INVALID;
PNG_COLORSPACE_INVALID;
errmsg = "out of memory";
}
}
@@ -1970,7 +1972,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr)
}
png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams,
(png_charp)units, params);
(png_charp)units, params);
png_free(png_ptr, params);
}
@@ -2004,7 +2006,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr)
}
png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)",
length + 1);
length + 1);
buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);
@@ -2055,7 +2057,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr)
else
/* This is the (only) success case. */
png_set_sCAL_s(png_ptr, info_ptr, buffer[0],
(png_charp)buffer+1, (png_charp)buffer+heighti);
(png_charp)buffer+1, (png_charp)buffer+heighti);
}
}
#else
@@ -2196,6 +2198,9 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr)
}
#endif /* USER_LIMITS */
/* Note, "length" is sufficient here; we won't be adding
* a null terminator later.
*/
buffer = png_read_buffer(png_ptr, length, 2/*silent*/);
if (buffer == NULL)
@@ -2237,7 +2242,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr)
* and text chunks.
*/
if (png_decompress_chunk(png_ptr, length, keyword_length+2,
&uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
&uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
{
png_text text;
@@ -2371,7 +2376,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr)
* iCCP and text chunks.
*/
if (png_decompress_chunk(png_ptr, length, prefix_length,
&uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
&uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
buffer = png_ptr->read_buffer;
else
@@ -2485,7 +2490,7 @@ png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name)
/* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */
static void
png_make_unknown_chunk(png_structrp png_ptr, png_unknown_chunkp chunk,
png_bytep data)
png_bytep data)
{
chunk->data = data;
chunk->size = png_ptr->chunk_length;
@@ -2498,7 +2503,7 @@ png_make_unknown_chunk(png_structrp png_ptr, png_unknown_chunkp chunk,
/* Handle an unknown, or known but disabled, chunk */
void /* PRIVATE */
png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
png_bytep chunk_data)
png_bytep chunk_data)
{
png_debug(1, "in png_handle_unknown");
@@ -2560,7 +2565,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
keep = png_ptr->unknown_default;
if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
# ifdef PNG_USER_LIMITS_SUPPORTED
switch (png_ptr->user_chunk_cache_max)
@@ -2588,9 +2593,9 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
png_unknown_chunk unknown_chunk;
png_make_unknown_chunk(png_ptr, &unknown_chunk,
chunk_data);
chunk_data);
png_set_unknown_chunks(png_ptr, info_ptr, &unknown_chunk,
1);
1);
return;
}
# ifdef PNG_USER_LIMITS_SUPPORTED
@@ -2621,24 +2626,61 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
* ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
*/
static void
png_check_chunk_name(png_structrp png_ptr, png_uint_32 chunk_name)
void /* PRIVATE */
png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name)
{
int i;
png_uint_32 cn=chunk_name;
png_debug(1, "in png_check_chunk_name");
for (i=1; i<=4; ++i)
{
int c = chunk_name & 0xff;
int c = cn & 0xff;
/* This is unrecoverable at present because it most likely indicates
* a broken stream.
*/
if (c < 65 || c > 122 || (c > 90 && c < 97))
png_chunk_error(png_ptr, "invalid chunk type");
chunk_name >>= 8;
cn >>= 8;
}
}
void /* PRIVATE */
png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length)
{
png_alloc_size_t limit = PNG_UINT_31_MAX;
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
if (png_ptr->user_chunk_malloc_max > 0 &&
png_ptr->user_chunk_malloc_max < limit)
limit = png_ptr->user_chunk_malloc_max;
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
if (PNG_USER_CHUNK_MALLOC_MAX < limit)
limit = PNG_USER_CHUNK_MALLOC_MAX;
# endif
if (png_ptr->chunk_name == png_IDAT)
{
/* color_type 0 x 2 3 4 x 6 */
int channels[]={1,0,3,1,2,0,4};
png_alloc_size_t idat_limit = PNG_UINT_31_MAX;
size_t row_factor =
(png_ptr->width * channels[png_ptr->color_type] *
(png_ptr->bit_depth > 8? 2: 1)
+ 1 + (png_ptr->interlaced? 6: 0));
if (png_ptr->height > PNG_UINT_32_MAX/row_factor)
idat_limit=PNG_UINT_31_MAX;
else
idat_limit = png_ptr->height * row_factor;
row_factor = row_factor > 32566? 32566 : row_factor;
idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */
idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX;
limit = limit < idat_limit? idat_limit : limit;
}
if (length > limit)
{
png_debug2(0," length = %lu, limit = %lu",
(unsigned long)length,(unsigned long)limit);
png_chunk_error(png_ptr, "chunk data is too large");
}
}
@@ -3461,7 +3503,7 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
static void
png_read_filter_row_sub(png_alloc_size_t row_bytes, unsigned int bpp,
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
{
while (row_bytes >= bpp)
{
@@ -3480,7 +3522,7 @@ png_read_filter_row_sub(png_alloc_size_t row_bytes, unsigned int bpp,
static void
png_read_filter_row_up(png_alloc_size_t row_bytes, unsigned int bpp,
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
{
while (row_bytes > 0)
{
@@ -3496,7 +3538,7 @@ png_read_filter_row_up(png_alloc_size_t row_bytes, unsigned int bpp,
static void
png_read_filter_row_avg(png_alloc_size_t row_bytes, unsigned int bpp,
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
{
while (row_bytes >= bpp)
{
@@ -3514,8 +3556,8 @@ png_read_filter_row_avg(png_alloc_size_t row_bytes, unsigned int bpp,
static void
png_read_filter_row_paeth_1byte_pixel(png_alloc_size_t row_bytes,
unsigned int bpp, png_bytep row, png_const_bytep prev_row,
png_const_bytep prev_pixels)
unsigned int bpp, png_bytep row, png_const_bytep prev_row,
png_const_bytep prev_pixels)
{
png_const_bytep rp_end = row + row_bytes;
png_byte a, c;
@@ -3547,7 +3589,10 @@ png_read_filter_row_paeth_1byte_pixel(png_alloc_size_t row_bytes,
/* Find the best predictor, the least of pa, pb, pc favoring the earlier
* ones in the case of a tie.
*/
if (pb < pa) pa = pb, a = b;
if (pb < pa)
{
pa = pb; a = b;
}
if (pc < pa) a = c;
/* Calculate the current pixel in a, and move the previous row pixel to c
@@ -3563,8 +3608,8 @@ png_read_filter_row_paeth_1byte_pixel(png_alloc_size_t row_bytes,
static void
png_read_filter_row_paeth_multibyte_pixel(png_alloc_size_t row_bytes,
unsigned int bpp, png_bytep row, png_const_bytep prev_row,
png_const_bytep prev_pixels)
unsigned int bpp, png_bytep row, png_const_bytep prev_row,
png_const_bytep prev_pixels)
{
png_bytep rp_end = row + bpp;
@@ -3592,7 +3637,10 @@ png_read_filter_row_paeth_multibyte_pixel(png_alloc_size_t row_bytes,
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
# endif
if (pb < pa) pa = pb, a = b;
if (pb < pa)
{
pa = pb; a = b;
}
if (pc < pa) a = c;
a = 0xFFU & (a + *row);
@@ -3624,7 +3672,10 @@ png_read_filter_row_paeth_multibyte_pixel(png_alloc_size_t row_bytes,
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
# endif
if (pb < pa) pa = pb, a = b;
if (pb < pa)
{
pa = pb; a = b;
}
if (pc < pa) a = c;
a = 0xFFU & (a + *row);
@@ -3700,7 +3751,7 @@ png_inflate_IDAT(png_structrp png_ptr, int finish,
png_uint_32 avail_in = png_ptr->zstream.avail_in;
ret = png_zlib_inflate(png_ptr, png_IDAT, finish,
&next_in, &avail_in, &output, &output_size/*remaining*/);
&next_in, &avail_in, &output, &output_size/*remaining*/);
debug(next_in == png_ptr->zstream.next_in);
debug(avail_in == png_ptr->zstream.avail_in);
@@ -3770,24 +3821,38 @@ png_inflate_IDAT(png_structrp png_ptr, int finish,
*/
if (!png_ptr->zstream_error) /* first time */
{
# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED
switch (png_ptr->IDAT_error_action)
{
case PNG_ERROR:
#ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED
switch (png_ptr->IDAT_error_action)
{
case PNG_ERROR:
if(!strncmp(png_ptr->zstream.msg,"incorrect data check",20))
{
if (png_ptr->current_crc != crc_quiet_use)
png_chunk_warning(png_ptr, "ADLER32 checksum mismatch");
}
else
{
png_chunk_error(png_ptr, png_ptr->zstream.msg);
break;
}
break;
case PNG_WARN:
png_chunk_warning(png_ptr, png_ptr->zstream.msg);
break;
case PNG_WARN:
png_chunk_warning(png_ptr, png_ptr->zstream.msg);
break;
default: /* ignore */
/* Keep going */
break;
}
# else
png_chunk_error(png_ptr, png_ptr->zstream.msg);
# endif /* !BENIGN_ERRORS */
default: /* ignore */
/* Keep going */
break;
}
#else
{
if(!strncmp(png_ptr->zstream.msg,"incorrect data check",20))
png_chunk_warning(png_ptr, "ADLER32 checksum mismatch");
else
png_chunk_error(png_ptr, png_ptr->zstream.msg);
}
#endif /* !BENIGN_ERRORS */
/* And prevent the report about too many IDATs on streams with internal
* LZ errors:
@@ -3872,7 +3937,7 @@ png_read_start_IDAT(png_structrp png_ptr)
*/
png_row_op /*PRIVATE*/
png_read_process_IDAT(png_structrp png_ptr, png_bytep transformed_row,
png_bytep display_row, int save_row)
png_bytep display_row, int save_row)
{
/* Common sub-expressions. These are all constant across the whole PNG, but
* are recalculated here each time because this is fast and it only happens
@@ -4292,7 +4357,7 @@ png_read_process_IDAT(png_structrp png_ptr, png_bytep transformed_row,
/* Run the list. It is ok if it doesn't end up doing
* anything; this can happen with a lazy init.
*
* NOTE: if the only thingin the list is a palette check
* NOTE: if the only thing in the list is a palette check
* function it can remove itself at this point.
*/
max_depth = png_run_transform_list_forwards(png_ptr, &tc);
@@ -4309,10 +4374,11 @@ png_read_process_IDAT(png_structrp png_ptr, png_bytep transformed_row,
png_ptr->row_range == tc.range &&
png_ptr->row_bit_depth == tc.bit_depth);
# ifdef PNG_READ_GAMMA_SUPPORTED
/* This sometimes fails at present when gamma
* transforms are eliminated in PNG_TC_INIT_FINAL:
/* This checks the output gamma taking into account the
* fact that small gamma changes are eliminated.
*/
debug(png_ptr->row_gamma == tc.gamma);
debug(png_ptr->row_gamma == tc.gamma ||
png_gamma_check(png_ptr, &tc));
# endif /* READ_GAMMA */
/* If the caller needs the row saved (for the progressive
@@ -4366,7 +4432,7 @@ png_read_process_IDAT(png_structrp png_ptr, png_bytep transformed_row,
impossible("bad row state");
} /* forever switch */
PNG_UNUSED(save_row); /* May not be used above */
PNG_UNUSED(save_row) /* May not be used above */
}
void /* PRIVATE */
@@ -4548,7 +4614,7 @@ png_read_update_info(png_structrp png_ptr, png_inforp info_ptr)
png_int_32 /* PRIVATE */
png_read_setting(png_structrp png_ptr, png_uint_32 setting,
png_uint_32 parameter, png_int_32 value)
png_uint_32 parameter, png_int_32 value)
{
/* Caller checks the arguments for basic validity */
int only_get = (setting & PNG_SF_GET) != 0U;

View File

@@ -105,14 +105,14 @@ png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
double green_x, double green_y, double blue_x, double blue_y)
{
png_set_cHRM_fixed(png_ptr, info_ptr,
png_fixed(png_ptr, white_x, "cHRM White X"),
png_fixed(png_ptr, white_y, "cHRM White Y"),
png_fixed(png_ptr, red_x, "cHRM Red X"),
png_fixed(png_ptr, red_y, "cHRM Red Y"),
png_fixed(png_ptr, green_x, "cHRM Green X"),
png_fixed(png_ptr, green_y, "cHRM Green Y"),
png_fixed(png_ptr, blue_x, "cHRM Blue X"),
png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
png_fixed(png_ptr, white_x, "cHRM White X"),
png_fixed(png_ptr, white_y, "cHRM White Y"),
png_fixed(png_ptr, red_x, "cHRM Red X"),
png_fixed(png_ptr, red_y, "cHRM Red Y"),
png_fixed(png_ptr, green_x, "cHRM Green X"),
png_fixed(png_ptr, green_y, "cHRM Green Y"),
png_fixed(png_ptr, blue_x, "cHRM Blue X"),
png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
}
void PNGAPI
@@ -121,15 +121,15 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
double blue_X, double blue_Y, double blue_Z)
{
png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
png_fixed(png_ptr, red_X, "cHRM Red X"),
png_fixed(png_ptr, red_Y, "cHRM Red Y"),
png_fixed(png_ptr, red_Z, "cHRM Red Z"),
png_fixed(png_ptr, green_X, "cHRM Green X"),
png_fixed(png_ptr, green_Y, "cHRM Green Y"),
png_fixed(png_ptr, green_Z, "cHRM Green Z"),
png_fixed(png_ptr, blue_X, "cHRM Blue X"),
png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
png_fixed(png_ptr, red_X, "cHRM Red X"),
png_fixed(png_ptr, red_Y, "cHRM Red Y"),
png_fixed(png_ptr, red_Z, "cHRM Red Z"),
png_fixed(png_ptr, green_X, "cHRM Green X"),
png_fixed(png_ptr, green_Y, "cHRM Green Y"),
png_fixed(png_ptr, green_Z, "cHRM Green Z"),
png_fixed(png_ptr, blue_X, "cHRM Blue X"),
png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
}
# endif /* FLOATING_POINT */
@@ -304,10 +304,10 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
length = strlen(units) + 1;
png_debug1(3, "allocating units for info (%lu bytes)",
(unsigned long)length);
(unsigned long)length);
info_ptr->pcal_units = png_voidcast(png_charp,
png_malloc_warn(png_ptr, length));
png_malloc_warn(png_ptr, length));
if (info_ptr->pcal_units == NULL)
{
@@ -386,7 +386,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw);
info_ptr->scal_s_width = png_voidcast(png_charp,
png_malloc_warn(png_ptr, lengthw));
png_malloc_warn(png_ptr, lengthw));
if (info_ptr->scal_s_width == NULL)
{
@@ -402,7 +402,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh);
info_ptr->scal_s_height = png_voidcast(png_charp,
png_malloc_warn(png_ptr, lengthh));
png_malloc_warn(png_ptr, lengthh));
if (info_ptr->scal_s_height == NULL)
{
@@ -442,9 +442,9 @@ png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
char sheight[PNG_sCAL_MAX_DIGITS+1];
png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width,
PNG_sCAL_PRECISION);
PNG_sCAL_PRECISION);
png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height,
PNG_sCAL_PRECISION);
PNG_sCAL_PRECISION);
png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
}
@@ -644,7 +644,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
*/
{
int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name,
proflen, profile, (info_ptr->format & PNG_FORMAT_FLAG_COLOR) != 0);
proflen, profile, (info_ptr->format & PNG_FORMAT_FLAG_COLOR) != 0);
png_colorspace_sync_info(png_ptr, info_ptr);
@@ -654,7 +654,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
/* But do write the gAMA and cHRM chunks from the profile. */
info_ptr->colorspace.flags |=
PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
}
length = strlen(name)+1;
@@ -669,7 +669,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
memcpy(new_iccp_name, name, length);
new_iccp_profile = png_voidcast(png_bytep,
png_malloc_warn(png_ptr, proflen));
png_malloc_warn(png_ptr, proflen));
if (new_iccp_profile == NULL)
{
@@ -819,14 +819,14 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
* the overflow checks.
*/
new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
info_ptr->text, old_num_text, max_text-old_num_text,
sizeof *new_text));
info_ptr->text, old_num_text, max_text-old_num_text,
sizeof *new_text));
}
if (new_text == NULL)
{
png_chunk_report(png_ptr, "too many text chunks",
PNG_CHUNK_WRITE_ERROR);
PNG_CHUNK_WRITE_ERROR);
return 1;
}
@@ -854,7 +854,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
{
png_chunk_report(png_ptr, "text compression mode is out of range",
PNG_CHUNK_WRITE_ERROR);
PNG_CHUNK_WRITE_ERROR);
continue;
}
@@ -886,7 +886,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
# else /* iTXt */
{
png_chunk_report(png_ptr, "iTXt chunk not supported",
PNG_CHUNK_WRITE_ERROR);
PNG_CHUNK_WRITE_ERROR);
continue;
}
# endif
@@ -921,7 +921,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
if (textp->key == NULL)
{
png_chunk_report(png_ptr, "text chunk: out of memory",
PNG_CHUNK_WRITE_ERROR);
PNG_CHUNK_WRITE_ERROR);
return 1;
}
@@ -1031,7 +1031,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
if ((info_ptr->format & PNG_FORMAT_FLAG_ALPHA) != 0)
png_chunk_report(png_ptr,
"png_set_tRNS: invalid on PNG with alpha channel", PNG_CHUNK_ERROR);
"png_set_tRNS: invalid on PNG with alpha channel", PNG_CHUNK_ERROR);
else if ((info_ptr->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
{
@@ -1057,7 +1057,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
if (num_trans > max_num)
{
png_chunk_report(png_ptr, "png_set_tRNS: num_trans too large",
PNG_CHUNK_ERROR);
PNG_CHUNK_ERROR);
/* If control returns simply limit it; the behavior prior to 1.7 was to
* issue a warning and skip the palette in png_write_tRNS.
*/
@@ -1074,11 +1074,11 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
* indices.
*/
info_ptr->trans_alpha = png_voidcast(png_bytep, png_malloc(png_ptr,
PNG_MAX_PALETTE_LENGTH));
PNG_MAX_PALETTE_LENGTH));
info_ptr->free_me |= PNG_FREE_TRNS;
memcpy(info_ptr->trans_alpha, trans_alpha,
(unsigned)/*SAFE*/num_trans);
(unsigned)/*SAFE*/num_trans);
info_ptr->valid |= PNG_INFO_tRNS;
info_ptr->num_trans = png_check_bits(png_ptr, num_trans, 9);
}
@@ -1109,8 +1109,8 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
else
png_chunk_report(png_ptr,
"tRNS chunk has out-of-range samples for bit_depth",
PNG_CHUNK_ERROR);
"tRNS chunk has out-of-range samples for bit_depth",
PNG_CHUNK_ERROR);
}
}
}
@@ -1138,8 +1138,8 @@ png_set_sPLT(png_structrp png_ptr,
* overflows. Notice that the parameters are (int) and (size_t)
*/
np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr,
info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
sizeof *np));
info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
sizeof *np));
if (np == NULL)
{
@@ -1200,7 +1200,7 @@ png_set_sPLT(png_structrp png_ptr,
* checked it when doing the allocation.
*/
memcpy(np->entries, entries->entries,
entries->nentries * sizeof (png_sPLT_entry));
entries->nentries * sizeof (png_sPLT_entry));
/* Note that 'continue' skips the advance of the out pointer and out
* count, so an invalid entry is not added.
@@ -1208,8 +1208,9 @@ png_set_sPLT(png_structrp png_ptr,
info_ptr->valid |= PNG_INFO_sPLT;
++(info_ptr->splt_palettes_num);
++np;
++entries;
}
while (++entries, --nentries);
while (--nentries);
if (nentries > 0)
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
@@ -1230,10 +1231,10 @@ check_location(png_const_structrp png_ptr, int location)
{
/* Write struct, so unknown chunks come from the app */
png_app_warning(png_ptr,
"png_set_unknown_chunks now expects a valid location");
"png_set_unknown_chunks now expects a valid location");
/* Use the old behavior */
location = png_check_byte(png_ptr, png_ptr->mode &
(PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));
(PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));
}
/* This need not be an internal error - if the app calls
@@ -1256,7 +1257,7 @@ check_location(png_const_structrp png_ptr, int location)
void PNGAPI
png_set_unknown_chunks(png_structrp png_ptr,
png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
{
png_unknown_chunkp np;
@@ -1326,12 +1327,12 @@ png_set_unknown_chunks(png_structrp png_ptr,
else
{
np->data = png_voidcast(png_bytep,
png_malloc_base(png_ptr, unknowns->size));
png_malloc_base(png_ptr, unknowns->size));
if (np->data == NULL)
{
png_chunk_report(png_ptr, "unknown chunk: out of memory",
PNG_CHUNK_ERROR);
PNG_CHUNK_ERROR);
/* But just skip storing the unknown chunk */
continue;
}
@@ -1536,7 +1537,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
for (i=0; i<num_chunks; ++i)
{
old_num_chunks = add_one_chunk(png_ptr, new_list, old_num_chunks,
chunk_list+5*i, keep);
chunk_list+5*i, keep);
}
/* Now remove any spurious 'default' entries. */
@@ -1624,7 +1625,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_alloc_size_t size)
png_error(png_ptr, "invalid compression buffer size");
# if (defined PNG_SEQUENTIAL_READ_SUPPORTED) || defined PNG_WRITE_SUPPORTED
png_ptr->IDAT_size = (png_uint_32)/*SAFE*/size;
png_ptr->IDAT_size = (png_uint_32)/*SAFE*/size;
# endif /* SEQUENTIAL_READ || WRITE */
}

View File

@@ -391,7 +391,9 @@ struct png_struct_def
png_uint_32 width; /* width of image in pixels */
png_uint_32 height; /* height of image in pixels */
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
#ifdef PNG_READ_SUPPORTED
png_uint_32 chunk_length; /* Length (possibly remaining) in said chunk. */
#endif /* READ */
png_uint_32 crc; /* current chunk CRC value */
unsigned int mode :6; /* where we are in the PNG file */
@@ -420,7 +422,6 @@ struct png_struct_def
/* Single byte values, typically used either to save space or to hold 1-byte
* values from the PNG chunk specifications.
*/
png_byte compression_type; /* file compression type (always 0) */
png_byte filter_method; /* file filter type (only non-0 with MNG) */
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
png_byte color_type; /* color type of file */
@@ -449,7 +450,6 @@ struct png_struct_def
*/
#ifdef PNG_READ_SUPPORTED
png_bytep row_buffer; /* primary row buffer */
#endif /* READ */
#if (defined(PNG_PROGRESSIVE_READ_SUPPORTED) ||\
defined(PNG_READ_INTERLACING_SUPPORTED)) &&\
defined(PNG_TRANSFORM_MECH_SUPPORTED)
@@ -458,11 +458,11 @@ struct png_struct_def
*/
#endif /* (PROGRESSIVE_READ || READ_INTERLACING) && TRANSFORM_MECH */
#ifdef PNG_READ_SUPPORTED
png_alloc_size_t row_bytes_read; /* Total read in row */
#endif /* READ */
png_uint_32 row_number; /* current row in pass */
#ifdef PNG_READ_SUPPORTED
#ifdef PNG_READ_GAMMA_SUPPORTED
png_fixed_point row_gamma; /* Gamma of final output */
#if 0 /* NYI */
@@ -487,23 +487,22 @@ struct png_struct_def
unsigned int invalid_info; /* PNG_INFO_* for invalidated chunks */
unsigned int palette_updated:1; /* png_struct::palette changed */
#endif /* READ_TRANSFORMS */
#ifdef PNG_WRITE_SUPPORTED
unsigned int write_rows :1; /* libpng has complete rows to write */
#endif /* WRITE */
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
unsigned int read_started :1; /* at least one call to png_read_row */
#endif /* SEQUENTIAL_READ */
#if defined (PNG_READ_INTERLACING_SUPPORTED) ||\
defined (PNG_WRITE_INTERLACING_SUPPORTED)
unsigned int do_interlace :1; /* libpng handles the interlace */
# endif /* R/W INTERLACING */
unsigned int pass :3; /* current (interlace) pass (0 - 6) */
/* The next two fields are just used by the IDAT process functions to store
/* The next field is just used by the read IDAT process functions to store
* the state of IDAT processing; they should not be altered or used by other
* functions.
*/
unsigned int row_state :2; /* state of row parsing (internal) */
#endif /* READ */
#if defined (PNG_READ_INTERLACING_SUPPORTED) ||\
defined (PNG_WRITE_INTERLACING_SUPPORTED)
unsigned int do_interlace :1; /* libpng handles the interlace */
# endif /* R/W INTERLACING */
unsigned int pass :3; /* current (interlace) pass (0 - 6) */
/* The following fields are set by png_row_init to the pixel depths of the
* pixels at various states. If transforms are not supported they will

386
pngtest.c
View File

@@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng
*
* Last changed in libpng 1.5.25 [(PENDING RELEASE)]
* Last changed in libpng 1.6.26 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2016 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.)
@@ -130,13 +130,13 @@ static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
static int
tIME_to_str(png_structp png_ptr, png_charp ts, png_const_timep t)
{
png_const_charp str = png_convert_to_rfc1123(png_ptr, t);
png_const_charp str = png_convert_to_rfc1123(png_ptr, t);
if (str == NULL)
return 0;
if (str == NULL)
return 0;
strcpy(ts, str);
return 1;
strcpy(ts, str);
return 1;
}
#endif /* older libpng */
#endif
@@ -240,95 +240,95 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
* png_byte pixel_depth bits per pixel (depth*channels)
*/
/* Counts the number of zero samples (or zero pixels if color_type is 3 */
/* Counts the number of zero samples (or zero pixels if color_type is 3 */
if (row_info->color_type == 0 || row_info->color_type == 3)
{
int pos = 0;
png_uint_32 n, nstop;
if (row_info->color_type == 0 || row_info->color_type == 3)
{
int pos = 0;
png_uint_32 n, nstop;
for (n = 0, nstop=row_info->width; n<nstop; n++)
{
if (row_info->bit_depth == 1)
{
if (((*dp << pos++ ) & 0x80) == 0)
zero_samples++;
for (n = 0, nstop=row_info->width; n<nstop; n++)
{
if (row_info->bit_depth == 1)
{
if (((*dp << pos++ ) & 0x80) == 0)
zero_samples++;
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (row_info->bit_depth == 2)
{
if (((*dp << (pos+=2)) & 0xc0) == 0)
zero_samples++;
if (row_info->bit_depth == 2)
{
if (((*dp << (pos+=2)) & 0xc0) == 0)
zero_samples++;
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (row_info->bit_depth == 4)
{
if (((*dp << (pos+=4)) & 0xf0) == 0)
zero_samples++;
if (row_info->bit_depth == 4)
{
if (((*dp << (pos+=4)) & 0xf0) == 0)
zero_samples++;
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (pos == 8)
{
pos = 0;
dp++;
}
}
if (row_info->bit_depth == 8)
if (*dp++ == 0)
zero_samples++;
if (row_info->bit_depth == 8)
if (*dp++ == 0)
zero_samples++;
if (row_info->bit_depth == 16)
{
if ((*dp | *(dp+1)) == 0)
zero_samples++;
dp+=2;
}
}
}
else /* Other color types */
{
png_uint_32 n, nstop;
int channel;
int color_channels = row_info->channels;
if (row_info->color_type > 3)
color_channels--;
if (row_info->bit_depth == 16)
{
if ((*dp | *(dp+1)) == 0)
zero_samples++;
dp+=2;
}
}
}
else /* Other color types */
{
png_uint_32 n, nstop;
int channel;
int color_channels = row_info->channels;
if (row_info->color_type > 3)
color_channels--;
for (n = 0, nstop=row_info->width; n<nstop; n++)
{
for (channel = 0; channel < color_channels; channel++)
{
if (row_info->bit_depth == 8)
if (*dp++ == 0)
zero_samples++;
for (n = 0, nstop=row_info->width; n<nstop; n++)
{
for (channel = 0; channel < color_channels; channel++)
{
if (row_info->bit_depth == 8)
if (*dp++ == 0)
zero_samples++;
if (row_info->bit_depth == 16)
{
if ((*dp | *(dp+1)) == 0)
zero_samples++;
if (row_info->bit_depth == 16)
{
if ((*dp | *(dp+1)) == 0)
zero_samples++;
dp+=2;
}
}
if (row_info->color_type > 3)
{
dp++;
if (row_info->bit_depth == 16)
dp++;
}
}
}
dp+=2;
}
}
if (row_info->color_type > 3)
{
dp++;
if (row_info->bit_depth == 16)
dp++;
}
}
}
}
#endif /* WRITE_USER_TRANSFORM */
@@ -345,10 +345,10 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
#ifdef PNG_IO_STATE_SUPPORTED
void
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
png_uint_32 io_op);
png_uint_32 io_op);
void
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
png_uint_32 io_op)
png_uint_32 io_op)
{
png_uint_32 io_state = png_get_io_state(png_ptr);
int err = 0;
@@ -532,7 +532,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
memory_infop pinfo;
png_set_mem_fn(png_ptr, NULL, NULL, NULL);
pinfo = (memory_infop)png_malloc(png_ptr,
(sizeof *pinfo));
(sizeof *pinfo));
pinfo->size = size;
current_allocation += size;
total_allocation += size;
@@ -562,7 +562,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
if (verbose != 0)
printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
pinfo->pointer);
pinfo->pointer);
return (png_voidp)(pinfo->pointer);
}
@@ -769,9 +769,9 @@ write_vpAg_chunk(png_structp write_ptr)
if (verbose != 0)
fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
(unsigned long)user_chunk_data.vpAg_width,
(unsigned long)user_chunk_data.vpAg_height,
user_chunk_data.vpAg_units);
(unsigned long)user_chunk_data.vpAg_width,
(unsigned long)user_chunk_data.vpAg_height,
user_chunk_data.vpAg_units);
png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);
@@ -812,7 +812,7 @@ write_chunks(png_structp write_ptr, int location)
#ifdef PNG_TEXT_SUPPORTED
static void
pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
int num_text)
int num_text)
{
while (num_text > 0)
{
@@ -894,26 +894,26 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
pngtest_debug("Allocating read and write structures");
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
read_ptr =
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
#else
read_ptr =
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
png_set_error_fn(read_ptr, &error_parameters, pngtest_error,
pngtest_warning);
pngtest_warning);
#ifdef PNG_WRITE_SUPPORTED
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
write_ptr =
png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
#else
write_ptr =
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
png_set_error_fn(write_ptr, &error_parameters, pngtest_error,
pngtest_warning);
pngtest_warning);
#endif
pngtest_debug("Allocating read_info, write_info and end_info structures");
read_info_ptr = png_create_info_struct(read_ptr);
@@ -926,7 +926,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
init_callback_info(read_info_ptr);
png_set_read_user_chunk_fn(read_ptr, &user_chunk_data,
read_user_chunk_callback);
read_user_chunk_callback);
#endif
#ifdef PNG_SETJMP_SUPPORTED
@@ -964,15 +964,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif
#endif
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
if (strict != 0)
{
/* Treat png_benign_error() as errors on read */
png_set_benign_errors(read_ptr, 0);
#ifdef PNG_WRITE_SUPPORTED
# ifdef PNG_WRITE_SUPPORTED
/* Treat them as errors on write */
png_set_benign_errors(write_ptr, 0);
#endif
# endif
/* if strict is not set, then app warnings and errors are treated as
* warnings in release builds, but not in unstable builds; this can be
@@ -985,10 +986,15 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
/* Allow application (pngtest) errors and warnings to pass */
png_set_benign_errors(read_ptr, 1);
#ifdef PNG_WRITE_SUPPORTED
/* Turn off CRC and ADLER32 checking while reading */
png_set_crc_action(read_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE);
# ifdef PNG_WRITE_SUPPORTED
png_set_benign_errors(write_ptr, 1);
#endif
# endif
}
#endif /* BENIGN_ERRORS */
pngtest_debug("Initializing input and output streams");
#ifdef PNG_STDIO_SUPPORTED
@@ -1001,9 +1007,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
# ifdef PNG_WRITE_SUPPORTED
png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data,
# ifdef PNG_WRITE_FLUSH_SUPPORTED
pngtest_flush);
pngtest_flush);
# else
NULL);
NULL);
# endif
# endif
#endif
@@ -1043,11 +1049,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
*/
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,
NULL, 0);
NULL, 0);
#endif
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,
NULL, 0);
NULL, 0);
#endif
#endif
@@ -1071,7 +1077,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
&color_type, &interlace_type, &compression_type, &filter_type) != 0)
{
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
color_type, interlace_type, compression_type, filter_type);
color_type, interlace_type, compression_type, filter_type);
/* num_passes may not be available below if interlace support is not
* provided by libpng for both read and write.
*/
@@ -1098,13 +1104,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_cHRM_SUPPORTED
{
png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
blue_y;
blue_y;
if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y,
&red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
&red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
{
png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,
red_y, green_x, green_y, blue_x, blue_y);
red_y, green_x, green_y, blue_x, blue_y);
}
}
#endif
@@ -1121,13 +1127,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_cHRM_SUPPORTED
{
double white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
blue_y;
blue_y;
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
&red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
&red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
{
png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
red_y, green_x, green_y, blue_x, blue_y);
red_y, green_x, green_y, blue_x, blue_y);
}
}
#endif
@@ -1149,10 +1155,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int compression_type;
if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
&profile, &proflen) != 0)
&profile, &proflen) != 0)
{
png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
profile, proflen);
profile, proflen);
}
}
#endif
@@ -1209,10 +1215,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int type, nparams;
if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
&nparams, &units, &params) != 0)
&nparams, &units, &params) != 0)
{
png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
nparams, units, params);
nparams, units, params);
}
}
#endif
@@ -1242,7 +1248,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
double scal_width, scal_height;
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
&scal_height) != 0)
&scal_height) != 0)
{
png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
}
@@ -1254,7 +1260,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_charp scal_width, scal_height;
if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
&scal_height) != 0)
&scal_height) != 0)
{
png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,
scal_height);
@@ -1295,7 +1301,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
for (i=0; i<num_text; i++)
{
printf(" Text compression[%d]=%d\n",
i, text_ptr[i].compression);
i, text_ptr[i].compression);
}
}
@@ -1332,7 +1338,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_color_16p trans_color;
if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,
&trans_color) != 0)
&trans_color) != 0)
{
int sample_max = (1 << bit_depth);
/* libpng doesn't reject a tRNS chunk with out-of-range samples */
@@ -1351,12 +1357,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{
png_unknown_chunkp unknowns;
int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr,
&unknowns);
&unknowns);
if (num_unknowns != 0)
{
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
num_unknowns);
num_unknowns);
#if PNG_LIBPNG_VER < 10600
/* Copy the locations from the read_info_ptr. The automatically
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
@@ -1366,7 +1372,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int i;
for (i = 0; i < num_unknowns; i++)
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
unknowns[i].location);
unknowns[i].location);
}
#endif
}
@@ -1396,7 +1402,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef SINGLE_ROWBUF_ALLOC
pngtest_debug("Allocating row buffer...");
row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr));
png_get_rowbytes(read_ptr, read_info_ptr));
pngtest_debug1("\t0x%08lx", (unsigned long)row_buf);
#endif /* SINGLE_ROWBUF_ALLOC */
@@ -1410,10 +1416,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
*/
if (png_set_interlace_handling(read_ptr) != num_passes)
png_error(write_ptr,
"png_set_interlace_handling(read): wrong pass count ");
"png_set_interlace_handling(read): wrong pass count ");
if (png_set_interlace_handling(write_ptr) != num_passes)
png_error(write_ptr,
"png_set_interlace_handling(write): wrong pass count ");
"png_set_interlace_handling(write): wrong pass count ");
#else /* png_set_interlace_handling not called on either read or write */
# define calc_pass_height
#endif /* not using libpng interlace handling */
@@ -1450,10 +1456,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr));
png_get_rowbytes(read_ptr, read_info_ptr));
pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
(unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
(unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
#endif /* !SINGLE_ROWBUF_ALLOC */
png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
@@ -1511,7 +1517,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
for (i=0; i<num_text; i++)
{
printf(" Text compression[%d]=%d\n",
i, text_ptr[i].compression);
i, text_ptr[i].compression);
}
}
@@ -1545,12 +1551,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{
png_unknown_chunkp unknowns;
int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr,
&unknowns);
&unknowns);
if (num_unknowns != 0)
{
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
num_unknowns);
num_unknowns);
#if PNG_LIBPNG_VER < 10600
/* Copy the locations from the read_info_ptr. The automatically
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
@@ -1560,7 +1566,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int i;
for (i = 0; i < num_unknowns; i++)
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
unknowns[i].location);
unknowns[i].location);
}
#endif
}
@@ -1594,7 +1600,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
iwidth = png_get_image_width(write_ptr, write_info_ptr);
iheight = png_get_image_height(write_ptr, write_info_ptr);
fprintf(STDERR, "\n Image width = %lu, height = %lu\n",
(unsigned long)iwidth, (unsigned long)iheight);
(unsigned long)iwidth, (unsigned long)iheight);
}
#endif
@@ -1627,7 +1633,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
* above, but this is safe.
*/
fprintf(STDERR, "\n %s: %d libpng errors found (%d warnings)",
inname, error_count, warning_count);
inname, error_count, warning_count);
if (strict != 0)
return (1);
@@ -1638,14 +1644,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
else if (unsupported_chunks > 0)
{
fprintf(STDERR, "\n %s: unsupported chunks (%d)%s",
inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
}
# endif
else if (warning_count > 0)
{
fprintf(STDERR, "\n %s: %d libpng warnings found",
inname, warning_count);
inname, warning_count);
if (strict != 0)
return (1);
@@ -1681,18 +1687,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (num_in != num_out)
{
fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
inname, outname);
inname, outname);
if (wrote_question == 0 && unsupported_chunks == 0)
{
fprintf(STDERR,
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
inname, PNG_ZBUF_SIZE);
" Was %s written with the same maximum IDAT"
" chunk size (%d bytes),",
inname, PNG_ZBUF_SIZE);
fprintf(STDERR,
"\n filtering heuristic (libpng default), compression");
"\n filtering heuristic (libpng default), compression");
fprintf(STDERR,
" level (zlib default),\n and zlib version (%s)?\n\n",
ZLIB_VERSION);
" level (zlib default),\n and zlib version (%s)?\n\n",
ZLIB_VERSION);
wrote_question = 1;
}
@@ -1712,17 +1719,18 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (memcmp(inbuf, outbuf, num_in))
{
fprintf(STDERR, "\nFiles %s and %s are different\n", inname,
outname);
outname);
if (wrote_question == 0 && unsupported_chunks == 0)
{
fprintf(STDERR,
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
" Was %s written with the same maximum"
" IDAT chunk size (%d bytes),",
inname, PNG_ZBUF_SIZE);
fprintf(STDERR,
"\n filtering heuristic (libpng default), compression");
"\n filtering heuristic (libpng default), compression");
fprintf(STDERR,
" level (zlib default),\n and zlib version (%s)?\n\n",
" level (zlib default),\n and zlib version (%s)?\n\n",
ZLIB_VERSION);
wrote_question = 1;
}
@@ -1773,12 +1781,12 @@ main(int argc, char *argv[])
fprintf(STDERR, "%s", png_get_copyright(NULL));
/* Show the version of libpng used in building the library */
fprintf(STDERR, " library (%lu):%s",
(unsigned long)png_access_version_number(),
png_get_header_version(NULL));
(unsigned long)png_access_version_number(),
png_get_header_version(NULL));
/* Show the version of libpng used in building the application */
fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
PNG_HEADER_VERSION_STRING);
PNG_HEADER_VERSION_STRING);
/* Do some consistency checking on the memory allocation settings, I'm
* not sure this matters, but it is nice to know, the first of these
@@ -1796,7 +1804,7 @@ main(int argc, char *argv[])
if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
{
fprintf(STDERR,
"Warning: versions are different between png.h and png.c\n");
"Warning: versions are different between png.h and png.c\n");
fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING);
fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver);
++ierror;
@@ -1851,19 +1859,19 @@ main(int argc, char *argv[])
}
if (multiple == 0 && argc == 3 + verbose)
outname = argv[2 + verbose];
outname = argv[2 + verbose];
if ((multiple == 0 && argc > 3 + verbose) ||
(multiple != 0 && argc < 2))
{
fprintf(STDERR,
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
argv[0], argv[0]);
fprintf(STDERR,
" reads/writes one PNG file (without -m) or multiple files (-m)\n");
fprintf(STDERR,
" with -m %s is used as a temporary file\n", outname);
exit(1);
fprintf(STDERR,
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
argv[0], argv[0]);
fprintf(STDERR,
" reads/writes one PNG file (without -m) or multiple files (-m)\n");
fprintf(STDERR,
" with -m %s is used as a temporary file\n", outname);
exit(1);
}
if (multiple != 0)
@@ -1884,7 +1892,7 @@ main(int argc, char *argv[])
{
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
(unsigned long)zero_samples);
(unsigned long)zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
@@ -1904,20 +1912,20 @@ main(int argc, char *argv[])
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
if (allocation_now != current_allocation)
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
current_allocation - allocation_now);
current_allocation - allocation_now);
if (current_allocation != 0)
{
memory_infop pinfo = pinformation;
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
current_allocation);
current_allocation);
while (pinfo != NULL)
{
fprintf(STDERR, " %lu bytes at %p\n",
(unsigned long)pinfo->size,
pinfo->pointer);
(unsigned long)pinfo->size,
pinfo->pointer);
pinfo = pinfo->next;
}
}
@@ -1925,13 +1933,13 @@ main(int argc, char *argv[])
}
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
fprintf(STDERR, " Current memory allocation: %10d bytes\n",
current_allocation);
current_allocation);
fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
maximum_allocation);
maximum_allocation);
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
total_allocation);
total_allocation);
fprintf(STDERR, " Number of allocations: %10d\n",
num_allocations);
num_allocations);
#endif
}
@@ -1966,7 +1974,7 @@ main(int argc, char *argv[])
{
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
(unsigned long)zero_samples);
(unsigned long)zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
@@ -1993,19 +2001,19 @@ main(int argc, char *argv[])
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
if (allocation_now != current_allocation)
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
current_allocation - allocation_now);
current_allocation - allocation_now);
if (current_allocation != 0)
{
memory_infop pinfo = pinformation;
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
current_allocation);
current_allocation);
while (pinfo != NULL)
{
fprintf(STDERR, " %lu bytes at %p\n",
(unsigned long)pinfo->size, pinfo->pointer);
(unsigned long)pinfo->size, pinfo->pointer);
pinfo = pinfo->next;
}
}
@@ -2013,13 +2021,13 @@ main(int argc, char *argv[])
}
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
fprintf(STDERR, " Current memory allocation: %10d bytes\n",
current_allocation);
current_allocation);
fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
maximum_allocation);
maximum_allocation);
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
total_allocation);
total_allocation);
fprintf(STDERR, " Number of allocations: %10d\n",
num_allocations);
num_allocations);
#endif
}
@@ -2028,13 +2036,13 @@ main(int argc, char *argv[])
t_misc += (t_stop - t_start);
t_start = t_stop;
fprintf(STDERR, " CPU time used = %.3f seconds",
(t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
(t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
fprintf(STDERR, " (decoding %.3f,\n",
t_decode/(float)CLOCKS_PER_SEC);
t_decode/(float)CLOCKS_PER_SEC);
fprintf(STDERR, " encoding %.3f ,",
t_encode/(float)CLOCKS_PER_SEC);
t_encode/(float)CLOCKS_PER_SEC);
fprintf(STDERR, " other %.3f seconds)\n\n",
t_misc/(float)CLOCKS_PER_SEC);
t_misc/(float)CLOCKS_PER_SEC);
#endif
if (ierror == 0)
@@ -2046,19 +2054,19 @@ main(int argc, char *argv[])
dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
fprintf(STDERR, " Default limits:\n");
fprintf(STDERR, " width_max = %lu\n",
(unsigned long) png_get_user_width_max(dummy_ptr));
(unsigned long) png_get_user_width_max(dummy_ptr));
fprintf(STDERR, " height_max = %lu\n",
(unsigned long) png_get_user_height_max(dummy_ptr));
(unsigned long) png_get_user_height_max(dummy_ptr));
if (png_get_chunk_cache_max(dummy_ptr) == 0)
fprintf(STDERR, " cache_max = unlimited\n");
else
fprintf(STDERR, " cache_max = %lu\n",
(unsigned long) png_get_chunk_cache_max(dummy_ptr));
(unsigned long) png_get_chunk_cache_max(dummy_ptr));
if (png_get_chunk_malloc_max(dummy_ptr) == 0)
fprintf(STDERR, " malloc_max = unlimited\n");
else
fprintf(STDERR, " malloc_max = %lu\n",
(unsigned long) png_get_chunk_malloc_max(dummy_ptr));
(unsigned long) png_get_chunk_malloc_max(dummy_ptr));
png_destroy_read_struct(&dummy_ptr, NULL, NULL);
return (int)(ierror != 0);
@@ -2068,11 +2076,11 @@ int
main(void)
{
fprintf(STDERR,
" test ignored because libpng was not built with read support\n");
" test ignored because libpng was not built with read support\n");
/* And skip this test */
return PNG_LIBPNG_VER < 10600 ? 0 : 77;
}
#endif
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_7_0beta82 Your_png_h_is_not_version_1_7_0beta82;
typedef png_libpng_version_1_7_0beta90 Your_png_h_is_not_version_1_7_0beta90;

View File

@@ -2697,7 +2697,7 @@ png_do_invert_all(png_transformp *transform, png_transform_controlp tc)
while (png_upcast(void*,dp) < dp_end)
*dp++ = ~*sp++;
PNG_UNUSED(transform);
PNG_UNUSED(transform)
}
static void
@@ -2748,7 +2748,7 @@ png_do_invert_channel(png_transformp *transform, png_transform_controlp tc)
}
}
PNG_UNUSED(transform);
PNG_UNUSED(transform)
}
static void
@@ -3579,7 +3579,7 @@ png_set_user_transform_info(png_structrp png_ptr, png_voidp ptr, int depth,
}
else
png_app_error(png_ptr,
"cannot change user info after image start");
"cannot change user info after image start");
}
# else /* !READ_USER_TRANSFORM */
PNG_UNUSED(depth)

View File

@@ -45,7 +45,7 @@ png_write_data(png_structrp png_ptr, png_const_voidp data, png_size_t length)
*/
if (png_ptr->rw_data_fn != NULL )
png_ptr->rw_data_fn(png_ptr,
png_constcast(png_bytep,png_voidcast(png_const_bytep,data)), length);
png_constcast(png_bytep,png_voidcast(png_const_bytep,data)), length);
else
png_app_error(png_ptr, "No write function");
@@ -130,7 +130,7 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
if (write_data_fn == NULL)
{
png_app_error(png_ptr,
"API change: png_set_write_fn requires a function");
"API change: png_set_write_fn requires a function");
return;
}

View File

@@ -24,7 +24,7 @@
/* Write out all the unknown chunks for the current given location */
static void
write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
unsigned int where)
unsigned int where)
{
if (info_ptr->unknown_chunks_num != 0)
{
@@ -169,7 +169,7 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
png_ptr->mng_features_permitted != 0)
{
png_app_error(png_ptr,
"MNG features are not allowed in a PNG datastream");
"MNG features are not allowed in a PNG datastream");
/* Recovery: disable MNG features: */
png_ptr->mng_features_permitted = 0;
}
@@ -177,8 +177,8 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
/* Write IHDR information. */
png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
info_ptr->bit_depth, color_type, info_ptr->compression_type,
info_ptr->filter_type, info_ptr->interlace_type);
info_ptr->bit_depth, color_type, info_ptr->compression_type,
info_ptr->filter_type, info_ptr->interlace_type);
# ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
/* This are used for checking later on: */
@@ -235,11 +235,11 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
*/
if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
png_app_warning(png_ptr,
"profile matches sRGB but writing iCCP instead");
"profile matches sRGB but writing iCCP instead");
# endif /* WRITE_sRGB */
png_write_iCCP(png_ptr, info_ptr->iccp_name,
info_ptr->iccp_profile);
info_ptr->iccp_profile);
}
# ifdef PNG_WRITE_sRGB_SUPPORTED
else /* iCCP not written */
@@ -280,7 +280,7 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
else /* 1.7.0: flag multiple calls; previously ignored */
png_app_error(png_ptr,
"png_write_info_before_PLTE called more than once");
"png_write_info_before_PLTE called more than once");
}
void PNGAPI
@@ -322,15 +322,15 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
if ((info_ptr->valid & PNG_INFO_tRNS) !=0)
{
png_write_tRNS(png_ptr, info_ptr->trans_alpha,
&(info_ptr->trans_color), info_ptr->num_trans,
PNG_COLOR_TYPE_FROM_FORMAT(info_ptr->format));
&(info_ptr->trans_color), info_ptr->num_trans,
PNG_COLOR_TYPE_FROM_FORMAT(info_ptr->format));
}
# endif /* WRITE_tRNS */
# ifdef PNG_WRITE_bKGD_SUPPORTED
if ((info_ptr->valid & PNG_INFO_bKGD) != 0)
png_write_bKGD(png_ptr, &(info_ptr->background),
PNG_COLOR_TYPE_FROM_FORMAT(info_ptr->format));
PNG_COLOR_TYPE_FROM_FORMAT(info_ptr->format));
# endif /* WRITE_bKGD */
# ifdef PNG_WRITE_hIST_SUPPORTED
@@ -354,7 +354,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
# ifdef PNG_WRITE_sCAL_SUPPORTED
if ((info_ptr->valid & PNG_INFO_sCAL) != 0)
png_write_sCAL_s(png_ptr, info_ptr->scal_unit, info_ptr->scal_s_width,
info_ptr->scal_s_height);
info_ptr->scal_s_height);
# endif /* WRITE_sCAL */
# ifdef PNG_WRITE_pHYs_SUPPORTED
@@ -570,10 +570,10 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
defined(PNG_WRITE_TRANSFORMS_SUPPORTED)
static void
write_row_buffered(png_structrp png_ptr,
png_const_bytep row, unsigned int row_info_flags,
void (*copy_fn)(png_const_structrp png_ptr, png_bytep row_buffer,
png_const_bytep row, png_uint_32 x, unsigned int count, unsigned int p),
unsigned int copy_parameter)
png_const_bytep row, unsigned int row_info_flags,
void (*copy_fn)(png_const_structrp png_ptr, png_bytep row_buffer,
png_const_bytep row, png_uint_32 x, unsigned int count, unsigned int p),
unsigned int copy_parameter)
{
unsigned int max_pixels = png_max_pixel_block(png_ptr);
const unsigned int pass = png_ptr->pass;
@@ -648,7 +648,7 @@ write_row_buffered(png_structrp png_ptr,
* maxpixels says if this is the final block in the row.
*/
png_write_png_data(png_ptr, prev_pixels, pixel_buffer.buffer, x,
max_pixels, row_info_flags);
max_pixels, row_info_flags);
}
}
#endif /* WRITE { INTERLACING || TRANSFORMS } */
@@ -656,19 +656,19 @@ write_row_buffered(png_structrp png_ptr,
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
static void
copy_row(png_const_structrp png_ptr, png_bytep row_buffer,
png_const_bytep row, png_uint_32 x, unsigned int count,
unsigned int pixel_depth)
png_const_bytep row, png_uint_32 x, unsigned int count,
unsigned int pixel_depth)
{
/* Copy row[x..x+count] pixels to row_buffer. */
png_copy_row(png_ptr, row_buffer, row, x, count, pixel_depth, 1/*clear*/,
0/* x_in_dest; row[x]->row_buffer */);
0/* x_in_dest; row[x]->row_buffer */);
}
#endif /* WRITE_TRANSFORMS */
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
static void
interlace_row_lbd(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
png_uint_32 x, unsigned int count, const unsigned int B)
png_uint_32 x, unsigned int count, const unsigned int B)
{
/* Pick out the correct pixels for the interlace pass. The basic idea here
* is to go through the row with a source pointer and a destination pointer
@@ -745,7 +745,7 @@ interlace_row_lbd(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
static void
interlace_row_byte(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
png_uint_32 x, unsigned int count, unsigned int cbytes)
png_uint_32 x, unsigned int count, unsigned int cbytes)
{
const unsigned int pass = png_ptr->pass;
const unsigned int inc = PNG_PASS_COL_OFFSET(pass);
@@ -764,12 +764,12 @@ interlace_row_byte(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
static void
write_row_core(png_structrp png_ptr, png_const_bytep row,
unsigned int row_info_flags)
unsigned int row_info_flags)
{
# ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
if (png_ptr->transform_list != NULL)
write_row_buffered(png_ptr, row, row_info_flags,
copy_row, png_ptr->row_input_pixel_depth);
copy_row, png_ptr->row_input_pixel_depth);
else
# endif /* WRITE_TRANSFORMS */
@@ -859,12 +859,12 @@ interlace_row(png_structrp png_ptr, png_const_bytep row)
/*FALL THROUGH*/
case 1U: /* B will be 0 */
write_row_buffered(png_ptr, row, row_info_flags,
interlace_row_lbd, B);
interlace_row_lbd, B);
break;
default: /* Parameter is the pixel size in bytes */
write_row_buffered(png_ptr, row, row_info_flags,
interlace_row_byte, input_depth >> 3);
interlace_row_byte, input_depth >> 3);
break;
}
} /* pass < 6 */
@@ -895,7 +895,7 @@ interlace_row(png_structrp png_ptr, png_const_bytep row)
*/
static void
png_write_rows_internal(png_structrp png_ptr, png_const_bytep *rows,
png_uint_32 num_rows)
png_uint_32 num_rows)
{
if (png_ptr != NULL && num_rows > 0U && rows != NULL)
{
@@ -1011,9 +1011,9 @@ png_write_rows_internal(png_structrp png_ptr, png_const_bytep *rows,
else /* app does interlace */
affirm(PNG_PASS_IN_IMAGE(png_ptr->width, png_ptr->height,
png_ptr->pass) &&
png_ptr->row_number <
PNG_PASS_ROWS(png_ptr->height, png_ptr->pass));
png_ptr->pass) &&
png_ptr->row_number <
PNG_PASS_ROWS(png_ptr->height, png_ptr->pass));
}
} /* png_ptr, rows, num_rows all valid */
@@ -1042,7 +1042,7 @@ png_write_rows(png_structrp png_ptr, png_bytepp rows, png_uint_32 num_rows)
if (png_ptr != NULL)
png_write_rows_internal(png_ptr, png_constcast(png_const_bytep*,rows),
num_rows);
num_rows);
}
/* Write the image. You only need to call this function once, even
@@ -1202,7 +1202,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
{
if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
png_app_error(png_ptr,
"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
/* Continue if ignored - this is the pre-1.6.10 behavior */
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
@@ -1266,7 +1266,7 @@ static int
png_image_write_init(png_imagep image)
{
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image,
png_safe_error, png_safe_warning);
png_safe_error, png_safe_warning);
if (png_ptr != NULL)
{
@@ -1275,7 +1275,7 @@ png_image_write_init(png_imagep image)
if (info_ptr != NULL)
{
png_controlp control = png_voidcast(png_controlp,
png_malloc_warn(png_ptr, (sizeof *control)));
png_malloc_warn(png_ptr, (sizeof *control)));
if (control != NULL)
{
@@ -1326,12 +1326,12 @@ static int
png_write_image_16bit(png_voidp argument)
{
png_image_write_control *display = png_voidcast(png_image_write_control*,
argument);
argument);
png_imagep image = display->image;
png_structrp png_ptr = image->opaque->png_ptr;
png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
display->first_row);
display->first_row);
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
png_uint_16p row_end;
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
@@ -1436,7 +1436,7 @@ png_write_image_16bit(png_voidp argument)
static png_byte
png_unpremultiply(png_const_structrp png_ptr, png_uint_32 component,
png_uint_32 alpha, png_uint_32 reciprocal/*from the above macro*/)
png_uint_32 alpha, png_uint_32 reciprocal/*from the above macro*/)
{
/* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0
* is represented as some other value there is more likely to be a
@@ -1485,12 +1485,12 @@ static int
png_write_image_8bit(png_voidp argument)
{
png_image_write_control *display = png_voidcast(png_image_write_control*,
argument);
argument);
png_imagep image = display->image;
png_structrp png_ptr = image->opaque->png_ptr;
png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
display->first_row);
display->first_row);
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
png_uint_32 y = image->height;
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
@@ -1536,7 +1536,7 @@ png_write_image_8bit(png_voidp argument)
c = channels;
do /* always at least one channel */
*out_ptr++ = png_unpremultiply(png_ptr, *in_ptr++, alpha,
reciprocal);
reciprocal);
while (--c > 0);
/* Skip to next component (skip the intervening alpha channel) */
@@ -1545,7 +1545,7 @@ png_write_image_8bit(png_voidp argument)
} /* while out_ptr < row_end */
png_write_row(png_ptr, png_voidcast(png_const_bytep,
display->local_row));
display->local_row));
input_row += display->row_bytes/(sizeof (png_uint_16));
} /* while y */
}
@@ -1637,7 +1637,7 @@ png_image_set_PLTE(png_image_write_control *display)
else /* Gray */
palette[i].blue = palette[i].red = palette[i].green =
PNG_sRGB_FROM_LINEAR(display->image->opaque->png_ptr,
255 * *entry);
255 * *entry);
}
else /* alpha */
@@ -1661,20 +1661,20 @@ png_image_set_PLTE(png_image_write_control *display)
if (channels >= 3) /* RGB */
{
palette[i].blue = png_unpremultiply(
display->image->opaque->png_ptr, entry[afirst + (2 ^ bgr)],
alpha, reciprocal);
display->image->opaque->png_ptr, entry[afirst + (2 ^ bgr)],
alpha, reciprocal);
palette[i].green = png_unpremultiply(
display->image->opaque->png_ptr, entry[afirst + 1], alpha,
reciprocal);
display->image->opaque->png_ptr, entry[afirst + 1], alpha,
reciprocal);
palette[i].red = png_unpremultiply(
display->image->opaque->png_ptr, entry[afirst + bgr], alpha,
reciprocal);
display->image->opaque->png_ptr, entry[afirst + bgr], alpha,
reciprocal);
}
else /* gray */
palette[i].blue = palette[i].red = palette[i].green =
png_unpremultiply(display->image->opaque->png_ptr,
entry[afirst], alpha, reciprocal);
png_unpremultiply(display->image->opaque->png_ptr,
entry[afirst], alpha, reciprocal);
}
}
@@ -1721,11 +1721,11 @@ png_image_set_PLTE(png_image_write_control *display)
# endif
png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette,
entries);
entries);
if (num_trans > 0)
png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS,
num_trans, NULL);
num_trans, NULL);
image->colormap_entries = entries;
}
@@ -1734,7 +1734,7 @@ static int
png_image_write_main(png_voidp argument)
{
png_image_write_control *display = png_voidcast(png_image_write_control*,
argument);
argument);
png_imagep image = display->image;
png_structrp png_ptr = image->opaque->png_ptr;
png_inforp info_ptr = image->opaque->info_ptr;
@@ -1802,24 +1802,24 @@ png_image_write_main(png_voidp argument)
png_uint_32 entries = image->colormap_entries;
png_set_IHDR(png_ptr, info_ptr, image->width, image->height,
entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)),
PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)),
PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_image_set_PLTE(display);
}
else
png_error(image->opaque->png_ptr,
"no color-map for color-mapped image");
"no color-map for color-mapped image");
}
else
png_set_IHDR(png_ptr, info_ptr, image->width, image->height,
write_16bit ? 16 : 8,
((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) +
((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0),
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
write_16bit ? 16 : 8,
((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) +
((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0),
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
/* Counter-intuitively the data transformations must be called *after*
* png_write_info, not before as in the read code, but the 'set' functions
@@ -1834,11 +1834,11 @@ png_image_write_main(png_voidp argument)
if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
png_set_cHRM_fixed(png_ptr, info_ptr,
/* color x y */
/* white */ 31270, 32900,
/* red */ 64000, 33000,
/* green */ 30000, 60000,
/* blue */ 15000, 6000
/* color x y */
/* white */ 31270, 32900,
/* red */ 64000, 33000,
/* green */ 30000, 60000,
/* blue */ 15000, 6000
);
}
@@ -1925,7 +1925,7 @@ png_image_write_main(png_voidp argument)
(colormap == 0 && display->convert_to_8bit != 0))
{
png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr)));
png_get_rowbytes(png_ptr, info_ptr)));
int result;
display->local_row = row;
@@ -1965,10 +1965,10 @@ png_image_write_main(png_voidp argument)
static void (PNGCBAPI
image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data,
png_size_t size)
png_size_t size)
{
png_image_write_control *display = png_voidcast(png_image_write_control*,
png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
const png_alloc_size_t ob = display->output_bytes;
/* Check for overflow; this should never happen: */
@@ -1999,22 +1999,22 @@ static int
png_image_write_memory(png_voidp argument)
{
png_image_write_control *display = png_voidcast(png_image_write_control*,
argument);
argument);
/* The rest of the memory-specific init and write_main in an error protected
* environment. This case needs to use callbacks for the write operations
* since libpng has no built in support for writing to memory.
*/
png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/,
image_memory_write, image_memory_flush);
image_memory_write, image_memory_flush);
return png_image_write_main(display);
}
int PNGAPI
png_image_write_to_memory(png_imagep image, void *memory,
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit,
const void *buffer, ptrdiff_t row_stride, const void *colormap)
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit,
const void *buffer, ptrdiff_t row_stride, const void *colormap)
{
/* Write the image to the given buffer, or count the bytes if it is NULL */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
@@ -2066,12 +2066,12 @@ png_image_write_to_memory(png_imagep image, void *memory,
else
return png_image_error(image,
"png_image_write_to_memory: invalid argument");
"png_image_write_to_memory: invalid argument");
}
else if (image != NULL)
return png_image_error(image,
"png_image_write_to_memory: incorrect PNG_IMAGE_VERSION");
"png_image_write_to_memory: incorrect PNG_IMAGE_VERSION");
else
return 0;
@@ -2080,7 +2080,7 @@ png_image_write_to_memory(png_imagep image, void *memory,
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
int PNGAPI
png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
const void *buffer, ptrdiff_t row_stride, const void *colormap)
const void *buffer, ptrdiff_t row_stride, const void *colormap)
{
/* Write the image to the given (FILE*). */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
@@ -2111,12 +2111,12 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
else
return png_image_error(image,
"png_image_write_to_stdio: invalid argument");
"png_image_write_to_stdio: invalid argument");
}
else if (image != NULL)
return png_image_error(image,
"png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION");
"png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION");
else
return 0;
@@ -2124,8 +2124,8 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
int PNGAPI
png_image_write_to_file(png_imagep image, const char *file_name,
int convert_to_8bit, const void *buffer, ptrdiff_t row_stride,
const void *colormap)
int convert_to_8bit, const void *buffer, ptrdiff_t row_stride,
const void *colormap)
{
/* Write the image to the named file. */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
@@ -2137,7 +2137,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
if (fp != NULL)
{
if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer,
row_stride, colormap) != 0)
row_stride, colormap) != 0)
{
int error; /* from fflush/fclose */
@@ -2178,12 +2178,12 @@ png_image_write_to_file(png_imagep image, const char *file_name,
else
return png_image_error(image,
"png_image_write_to_file: invalid argument");
"png_image_write_to_file: invalid argument");
}
else if (image != NULL)
return png_image_error(image,
"png_image_write_to_file: incorrect PNG_IMAGE_VERSION");
"png_image_write_to_file: incorrect PNG_IMAGE_VERSION");
else
return 0;

View File

@@ -1,7 +1,7 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2016 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

@@ -59,7 +59,7 @@ png_write_sig(png_structrp png_ptr)
/* Write the rest of the 8 byte signature */
png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
(png_size_t)(8 - png_ptr->sig_bytes));
(png_size_t)(8 - png_ptr->sig_bytes));
if (png_ptr->sig_bytes < 3)
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
@@ -172,7 +172,7 @@ png_write_chunk_end(png_structrp png_ptr)
*/
static void
png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
png_const_voidp data, png_size_t length)
png_const_voidp data, png_size_t length)
{
if (png_ptr == NULL)
return;
@@ -189,10 +189,10 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
/* This is the API that calls the internal function above. */
void PNGAPI
png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string,
png_const_voidp data, png_size_t length)
png_const_voidp data, png_size_t length)
{
png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data,
length);
length);
}
static png_alloc_size_t
@@ -314,7 +314,7 @@ typedef struct png_compression_buffer
/* Deleting a compression buffer deletes the whole list: */
static void
png_free_compression_buffer(png_const_structrp png_ptr,
png_compression_bufferp *listp)
png_compression_bufferp *listp)
{
png_compression_bufferp list = *listp;
@@ -338,7 +338,7 @@ png_free_compression_buffer(png_const_structrp png_ptr,
*/
static png_compression_bufferp
png_get_compression_buffer(png_const_structrp png_ptr,
png_compression_bufferp *end)
png_compression_bufferp *end)
{
png_compression_bufferp next = *end;
@@ -1714,7 +1714,7 @@ png_image_size(png_const_structrp png_ptr)
/* Initialize the compressor for the appropriate type of compression. */
static png_zlib_statep
png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
png_alloc_size_t data_size)
png_alloc_size_t data_size)
{
png_zlib_statep ps = get_zlib_state(png_ptr);
@@ -1789,8 +1789,8 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
else
ret = deflateInit2(&ps->s.zs, pz_value(level, settings), Z_DEFLATED,
pz_value(windowBits, settings), pz_value(memLevel, settings),
pz_value(strategy, settings));
pz_value(windowBits, settings), pz_value(memLevel, settings),
pz_value(strategy, settings));
ps->pz_current = settings;
@@ -1824,7 +1824,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
*/
static int /* success */
png_compress_chunk_data(png_structrp png_ptr, png_uint_32 chunk_name,
png_uint_32 prefix_len, png_const_voidp input, png_alloc_size_t input_len)
png_uint_32 prefix_len, png_const_voidp input, png_alloc_size_t input_len)
{
/* To find the length of the output it is necessary to first compress the
* input. The result is buffered rather than using the two-pass algorithm
@@ -2148,7 +2148,6 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
png_ptr->color_type = png_check_byte(png_ptr, color_type);
png_ptr->interlaced = png_check_byte(png_ptr, interlace_type);
png_ptr->filter_method = png_check_byte(png_ptr, filter_method);
png_ptr->compression_type = png_check_byte(png_ptr, compression_type);
png_ptr->width = width;
png_ptr->height = height;
@@ -3234,7 +3233,7 @@ png_write_IDAT(png_structrp png_ptr, int flush)
*/
static int
png_compress_IDAT_data(png_structrp png_ptr, png_zlib_statep ps,
png_zlib_compressp pz, png_const_voidp input, uInt input_len, int flush)
png_zlib_compressp pz, png_const_voidp input, uInt input_len, int flush)
{
/* Delay initialize the z_stream. */
if (png_ptr->zowner != png_IDAT)
@@ -3278,7 +3277,7 @@ png_compress_IDAT_data(png_structrp png_ptr, png_zlib_statep ps,
*/
static void
png_compress_IDAT(png_structrp png_ptr, png_const_voidp input, uInt input_len,
int flush)
int flush)
{
png_zlib_statep ps = png_ptr->zlib_state;
int ret = png_compress_IDAT_data(png_ptr, ps, &ps->s, input, input_len,
@@ -4447,7 +4446,7 @@ select_filter(png_zlib_statep ps, png_const_bytep row,
*/
void /* PRIVATE */
png_write_png_rows(png_structrp png_ptr, png_const_bytep *rows,
png_uint_32 num_rows)
png_uint_32 num_rows)
{
const png_zlib_statep ps = png_ptr->zlib_state;
const unsigned int bpp = png_ptr->row_output_pixel_depth;
@@ -4755,8 +4754,8 @@ write_png_data(png_structrp png_ptr, png_const_bytep prev_row,
void /* PRIVATE */
png_write_png_data(png_structrp png_ptr, png_bytep prev_pixels,
png_const_bytep unfiltered_row, png_uint_32 x,
unsigned int width/*pixels*/, unsigned int row_info_flags)
png_const_bytep unfiltered_row, png_uint_32 x,
unsigned int width/*pixels*/, unsigned int row_info_flags)
{
const png_zlib_statep ps = png_ptr->zlib_state;
@@ -4876,8 +4875,8 @@ png_write_start_IDAT(png_structrp png_ptr)
void /* PRIVATE */
png_write_png_data(png_structrp png_ptr, png_bytep prev_pixels,
png_const_bytep unfiltered_row, png_uint_32 x,
unsigned int width/*pixels*/, unsigned int row_info_flags)
png_const_bytep unfiltered_row, png_uint_32 x,
unsigned int width/*pixels*/, unsigned int row_info_flags)
{
const unsigned int bpp = png_ptr->row_output_pixel_depth;
int flush;
@@ -4895,7 +4894,7 @@ png_write_png_data(png_structrp png_ptr, png_bytep prev_pixels,
write_unfiltered_rowbits(png_ptr, unfiltered_row, row_bits,
x == 0 ? PNG_FILTER_VALUE_NONE : PNG_FILTER_VALUE_LAST, flush);
PNG_UNUSED(prev_pixels);
PNG_UNUSED(prev_pixels)
/* Handle end of row: */
if ((row_info_flags & png_row_end) != 0)
@@ -4905,7 +4904,7 @@ png_write_png_data(png_structrp png_ptr, png_bytep prev_pixels,
png_int_32 /* PRIVATE */
png_write_setting(png_structrp png_ptr, png_uint_32 setting,
png_uint_32 parameter, png_int_32 value)
png_uint_32 parameter, png_int_32 value)
{
/* Caller checks the arguments for basic validity */
int only_get = (setting & PNG_SF_GET) != 0U;
@@ -4930,24 +4929,24 @@ png_write_setting(png_structrp png_ptr, png_uint_32 setting,
/* Settings in zlib_state: */
case PNG_SW_COMPRESS_png_level:
return compression_setting(png_ptr, parameter, png_level, value,
only_get);
only_get);
# ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
case PNG_SW_COMPRESS_zlib_level:
return compression_setting(png_ptr, parameter, level, value,
only_get);
only_get);
case PNG_SW_COMPRESS_windowBits:
return compression_setting(png_ptr, parameter, windowBits, value,
only_get);
only_get);
case PNG_SW_COMPRESS_memLevel:
return compression_setting(png_ptr, parameter, memLevel, value,
only_get);
only_get);
case PNG_SW_COMPRESS_strategy:
return compression_setting(png_ptr, parameter, strategy, value,
only_get);
only_get);
case PNG_SW_COMPRESS_method:
if (value != 8) /* Only supported method */
@@ -4964,7 +4963,7 @@ png_write_setting(png_structrp png_ptr, png_uint_32 setting,
return set_filter(get_zlib_state(png_ptr), value);
else if (png_ptr->zlib_state != NULL &&
png_ptr->zlib_state->filter_mask != 0U/*unset*/)
png_ptr->zlib_state->filter_mask != 0U/*unset*/)
return png_ptr->zlib_state->filter_mask;
else

View File

@@ -126,7 +126,7 @@ $# to work, download Brian Kernighan's awk (Brian Kernighan is the author of
$# awk.) You can find source code and a built executable (called awk95.exe)
$# here:
$#
$# http://www.cs.princeton.edu/~bwk/btl.mirror/
$# https://www.cs.princeton.edu/~bwk/btl.mirror/
$#
$# The executable works just fine.
$#

View File

@@ -1,7 +1,7 @@
VisualStudio instructions
libpng version 1.7.0beta82 - July 4, 2016
libpng version 1.7.0beta90 - August 28, 2017
Copyright (c) 2010,2013,2015 Glenn Randers-Pehrson

View File

@@ -2,7 +2,7 @@
<!--
* zlib.props - location of zlib source
*
* libpng version 1.7.0beta82 - July 4, 2016
* libpng version 1.7.0beta90 - August 28, 2017
*
* Copyright (c) 2011,2013,2014 Glenn Randers-Pehrson
*

View File

@@ -1,9 +1,9 @@
Makefiles for libpng version 1.7.0beta82 - July 4, 2016
Makefiles for libpng version 1.7.0beta90 - August 28, 2017
pnglibconf.h.prebuilt => Stores configuration settings
makefile.linux => Linux/ELF makefile
(gcc, creates libpng17.so.17.1.7.0beta82)
(gcc, creates libpng17.so.17.1.7.0beta90)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
@@ -33,12 +33,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 libpng17.so.17.1.7.0beta82)
creates libpng17.so.17.1.7.0beta90)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng17.so.17.1.7.0beta82)
creates libpng17.so.17.1.7.0beta90)
makefile.so9 => Solaris 9 makefile (gcc,
creates libpng17.so.17.1.7.0beta82)
creates libpng17.so.17.1.7.0beta90)
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit makefile

View File

@@ -21,7 +21,7 @@ PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
PNG_DFN ""
PNG_DFN "EXPORTS"
PNG_DFN ";Version 1.7.0beta82"
PNG_DFN ";Version 1.7.0beta90"
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"

View File

@@ -11,7 +11,7 @@
# Modeled after libxml-config.
version=1.7.0beta82
version=1.7.0beta90
prefix=""
libdir=""
libs=""

View File

@@ -5,6 +5,6 @@ includedir=@includedir@/libpng17
Name: libpng
Description: Loads and saves PNG files
Version: 1.7.0beta82
Version: 1.7.0beta90
Libs: -L${libdir} -lpng17
Cflags: -I${includedir}

View File

@@ -92,7 +92,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
.c.pic.o:
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c
all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config

View File

@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng17
LIB= png17
SHLIB_MAJOR= 0
SHLIB_MINOR= 1.7.0beta82
SHLIB_MINOR= 1.7.0beta90
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= 17
SHLIB_MINOR= 1.7.0beta82
SHLIB_MINOR= 1.7.0beta90
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= 17
SHLIB_MINOR= 1.7.0beta82
SHLIB_MINOR= 1.7.0beta90
LIB= png
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \

View File

@@ -83,7 +83,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
.c.pic.o:
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c
all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config

View File

@@ -1,8 +1,8 @@
/* libpng 1.7.0beta82 STANDARD API DEFINITION */
/* libpng 1.7.0beta90 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */
/* libpng version 1.7.0beta82, July 4, 2016 */
/* libpng version 1.7.0beta90, August 28, 2017 */
/* Copyright (c) 1998-2016 Glenn Randers-Pehrson */

View File

@@ -1,4 +1,4 @@
;Version 1.7.0beta82
;Version 1.7.0beta90
;--------------------------------------------------------------
; LIBPNG symbol list as a Win32 DEF file
; Contains all the symbols that can be exported from libpng

BIN
tests/bad_iccp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

BIN
tests/badadler.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

BIN
tests/badcrc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 B

BIN
tests/huge_idat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

View File

@@ -1,2 +1,7 @@
#!/bin/sh
./pngtest --relaxed ${srcdir}/tests/badcrc.png
./pngtest --relaxed ${srcdir}/tests/badadler.png
./pngtest --relaxed ${srcdir}/tests/bad_iccp.png
./pngtest --relaxed ${srcdir}/tests/huge_idat.png
./pngtest --relaxed ${srcdir}/tests/empty_ancillary_chunks.png
exec ./pngtest --strict ${srcdir}/pngtest.png