mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
91 Commits
v1.6.15bet
...
v1.6.17rc0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a60de343a9 | ||
|
|
f2c37d0abf | ||
|
|
bc27b2f432 | ||
|
|
3645008e22 | ||
|
|
06ee532286 | ||
|
|
bbe2be3f54 | ||
|
|
bb098218ca | ||
|
|
217d38cdea | ||
|
|
377fb53944 | ||
|
|
7f85da8df7 | ||
|
|
3e0bef6da4 | ||
|
|
82511341d7 | ||
|
|
4029db9aac | ||
|
|
7011a8cec3 | ||
|
|
9a3de48b48 | ||
|
|
494e75ac83 | ||
|
|
3f49c1e42a | ||
|
|
68f4ea7423 | ||
|
|
c6b29ff896 | ||
|
|
76f93293a0 | ||
|
|
d375ca5e0d | ||
|
|
60a7506744 | ||
|
|
d3ff44f0d5 | ||
|
|
43d90b1610 | ||
|
|
de23a49231 | ||
|
|
4b65a89cf4 | ||
|
|
471b38aa00 | ||
|
|
b6c9ac6304 | ||
|
|
8cd78da8b3 | ||
|
|
8f0e2729dd | ||
|
|
c73d6219f2 | ||
|
|
6ef579df50 | ||
|
|
bd76965879 | ||
|
|
7a015b92b2 | ||
|
|
2f56fe4071 | ||
|
|
9d6cab3b21 | ||
|
|
04affde6a1 | ||
|
|
018b4fccb9 | ||
|
|
bba3aa9533 | ||
|
|
b6788ccaff | ||
|
|
cde8cd6b30 | ||
|
|
19ec55f40e | ||
|
|
6a6eb354ff | ||
|
|
6b5abbe58e | ||
|
|
66c1ec5a26 | ||
|
|
ecd074945c | ||
|
|
88dd30b232 | ||
|
|
10569a452f | ||
|
|
dc294204b6 | ||
|
|
06ee38423b | ||
|
|
6d8c88177a | ||
|
|
f43b5e3709 | ||
|
|
a00ea0aeae | ||
|
|
0659cddd21 | ||
|
|
66d846b0cc | ||
|
|
d040886dc4 | ||
|
|
91f9e0370d | ||
|
|
86a7eef997 | ||
|
|
530eec311d | ||
|
|
7c5d037032 | ||
|
|
ee16fc4a6f | ||
|
|
2d24cbdd98 | ||
|
|
e8ef689cb9 | ||
|
|
aebb7585c9 | ||
|
|
5b9ac20297 | ||
|
|
9c05216461 | ||
|
|
d4965b4014 | ||
|
|
b8eb945946 | ||
|
|
6df21524cd | ||
|
|
fa49aae286 | ||
|
|
05e11008c0 | ||
|
|
40656e9855 | ||
|
|
7cee075a32 | ||
|
|
985dc00f1f | ||
|
|
cda68df8c1 | ||
|
|
70cb8f9a7e | ||
|
|
674c3e5816 | ||
|
|
61ea3eacb0 | ||
|
|
8e7c35fc81 | ||
|
|
234fe626af | ||
|
|
03df189954 | ||
|
|
6f2c50e7fc | ||
|
|
c9720568d0 | ||
|
|
5be76ae252 | ||
|
|
a2fe24d186 | ||
|
|
97dd654ba4 | ||
|
|
f1b547a509 | ||
|
|
5efb1327df | ||
|
|
b5113f4e70 | ||
|
|
445475a166 | ||
|
|
2eb712e519 |
75
ANNOUNCE
75
ANNOUNCE
@@ -1,4 +1,4 @@
|
||||
Libpng 1.6.15beta03 - November 3, 2014
|
||||
Libpng 1.6.17rc03 - March 12, 2015
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
@@ -8,33 +8,74 @@ Files available for download:
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
1.6.15beta03.tar.xz (LZMA-compressed, recommended)
|
||||
1.6.15beta03.tar.gz
|
||||
1.6.17rc03.tar.xz (LZMA-compressed, recommended)
|
||||
1.6.17rc03.tar.gz
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
lp1615b03.7z (LZMA-compressed, recommended)
|
||||
lp1615b03.zip
|
||||
lp1617r03.7z (LZMA-compressed, recommended)
|
||||
lp1617r03.zip
|
||||
|
||||
Other information:
|
||||
|
||||
1.6.15beta03-README.txt
|
||||
1.6.15beta03-LICENSE.txt
|
||||
libpng-1.6.15beta03-*.asc (armored detached GPG signatures)
|
||||
1.6.17rc03-README.txt
|
||||
1.6.17rc03-LICENSE.txt
|
||||
libpng-1.6.17rc03-*.asc (armored detached GPG signatures)
|
||||
|
||||
Changes since the last public release (1.6.14):
|
||||
Changes since the last public release (1.6.16):
|
||||
|
||||
Version 1.6.15beta01 [October 29, 2014]
|
||||
Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x !== 0)"
|
||||
Simplified png_free_data().
|
||||
Added missing "ptr = NULL" after some instances of png_free().
|
||||
Version 1.6.17beta01 [January 29, 2015]
|
||||
Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h
|
||||
Corrected the width limit calculation in png_check_IHDR().
|
||||
Removed user limits from pngfix. Also pass NULL pointers to
|
||||
png_read_row to skip the unnecessary row de-interlace stuff.
|
||||
Added testing of png_set_packing() to pngvalid.c
|
||||
Regenerated configure scripts in the *.tar distributions with libtool-2.4.4
|
||||
Implement previously untested cases of libpng transforms in pngvalid.c
|
||||
Fixed byte order in 2-byte filler, in png_do_read_filler().
|
||||
Made the check for out-of-range values in png_set_tRNS() detect
|
||||
values that are exactly 2^bit_depth, and work on 16-bit platforms.
|
||||
Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47.
|
||||
Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
|
||||
pngset.c to avoid warnings about dead code.
|
||||
|
||||
Version 1.6.15beta02 [November 1, 2014]
|
||||
Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to "if (x !== 0)"
|
||||
Version 1.6.17beta02 [February 7, 2015]
|
||||
Work around one more Coverity-scan dead-code warning.
|
||||
Do not build png_product2() when it is unused.
|
||||
|
||||
Version 1.6.15beta03 [November 3, 2014]
|
||||
Added PNG_USE_ARM_NEON configuration flag (Marcin Juszkiewicz).
|
||||
Version 1.6.17beta03 [February 17, 2015]
|
||||
Display user limits in the output from pngtest.
|
||||
Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column
|
||||
and 1-million-row default limits in pnglibconf.dfa, that can be reset
|
||||
by the user at build time or run time. This provides a more robust
|
||||
defense against DOS and as-yet undiscovered overflows.
|
||||
|
||||
Version 1.6.17beta04 [February 21, 2015]
|
||||
Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default.
|
||||
Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins).
|
||||
Rebuilt configure scripts with automake-1.15 and libtool-2.4.6
|
||||
|
||||
Version 1.6.17beta05 [February 25, 2015]
|
||||
Restored compiling of png_reciprocal2 with PNG_NO_16BIT.
|
||||
|
||||
Version 1.6.17beta06 [February 27, 2015]
|
||||
Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block
|
||||
of png.h.
|
||||
Avoid runtime checks when converting integer to png_byte with
|
||||
Visual Studio (Sergey Kosarevsky)
|
||||
|
||||
Version 1.6.17rc01 [March 4, 2015]
|
||||
No changes.
|
||||
|
||||
Version 1.6.17rc02 [March 9, 2015]
|
||||
Removed some comments that the configure script did not handle
|
||||
properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt.
|
||||
Free the unknown_chunks structure even when it contains no data.
|
||||
|
||||
Version 1.6.17rc03 [March 12, 2015]
|
||||
Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF
|
||||
for consistency, and remove some useless tests (Alexey Petruchik).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
140
CHANGES
140
CHANGES
@@ -2102,7 +2102,7 @@ Version 1.4.0beta24 [July 25, 2008]
|
||||
png_decompress_chunk(), and remove "chunkdata" from parameter list.
|
||||
Put a call to png_check_chunk_name() in png_read_chunk_header().
|
||||
Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte.
|
||||
Removed two calls to png_check_chunk_name() occuring later in the process.
|
||||
Removed two calls to png_check_chunk_name() occurring later in the process.
|
||||
Define PNG_NO_ERROR_NUMBERS by default in pngconf.h
|
||||
|
||||
Version 1.4.0beta25 [July 30, 2008]
|
||||
@@ -5034,16 +5034,150 @@ Version 1.6.14 [October 23, 2014]
|
||||
No changes.
|
||||
|
||||
Version 1.6.15beta01 [October 29, 2014]
|
||||
Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x !== 0)"
|
||||
Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)"
|
||||
Simplified png_free_data().
|
||||
Added missing "ptr = NULL" after some instances of png_free().
|
||||
|
||||
Version 1.6.15beta02 [November 1, 2014]
|
||||
Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to "if (x !== 0)"
|
||||
Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)"
|
||||
|
||||
Version 1.6.15beta03 [November 3, 2014]
|
||||
Added PNG_USE_ARM_NEON configuration flag (Marcin Juszkiewicz).
|
||||
|
||||
Version 1.6.15beta04 [November 4, 2014]
|
||||
Removed new PNG_USE_ARM_NEON configuration flag and made a one-line
|
||||
revision to configure.ac to support ARM on aarch64 instead (John Bowler).
|
||||
|
||||
Version 1.6.15beta05 [November 5, 2014]
|
||||
Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
|
||||
example.c, pngtest.c, and applications in the contrib directory.
|
||||
Avoid out-of-bounds memory access in png_user_version_check().
|
||||
Simplified and future-proofed png_user_version_check().
|
||||
Fixed GCC unsigned int->float warnings. Various versions of GCC
|
||||
seem to generate warnings when an unsigned value is implicitly
|
||||
converted to double. This is probably a GCC bug but this change
|
||||
avoids the issue by explicitly converting to (int) where safe.
|
||||
Free all allocated memory in pngimage. The file buffer cache was left
|
||||
allocated at the end of the program, harmless but it causes memory
|
||||
leak reports from clang.
|
||||
Fixed array size calculations to avoid warnings. At various points
|
||||
in the code the number of elements in an array is calculated using
|
||||
sizeof. This generates a compile time constant of type (size_t) which
|
||||
is then typically assigned to an (unsigned int) or (int). Some versions
|
||||
of GCC on 64-bit systems warn about the apparent narrowing, even though
|
||||
the same compiler does apparently generate the correct, in-range,
|
||||
numeric constant. This adds appropriate, safe, casts to make the
|
||||
warnings go away.
|
||||
|
||||
Version 1.6.15beta06 [November 6, 2014]
|
||||
Reverted use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING
|
||||
in the manual, example.c, pngtest.c, and applications in the contrib
|
||||
directory. It was incorrect advice.
|
||||
|
||||
Version 1.6.15beta07 [November 7, 2014]
|
||||
Removed #ifdef PNG_16BIT_SUPPORTED/#endif around png_product2(); it is
|
||||
needed by png_reciprocal2().
|
||||
Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and
|
||||
png_do_swap().
|
||||
Changed all "#endif /* PNG_FEATURE_SUPPORTED */" to "#endif /* FEATURE */"
|
||||
|
||||
Version 1.6.15beta08 [November 8, 2014]
|
||||
More housecleaning in *.h
|
||||
|
||||
Version 1.6.15rc01 [November 13, 2014]
|
||||
|
||||
Version 1.6.15rc02 [November 14, 2014]
|
||||
The macros passed in the command line to Borland make were ignored if
|
||||
similarly-named macros were already defined in makefiles. This behavior
|
||||
is different from POSIX make and other make programs. Surround the
|
||||
macro definitions with ifndef guards (Cosmin).
|
||||
|
||||
Version 1.6.15rc03 [November 16, 2014]
|
||||
Added "-D_CRT_SECURE_NO_WARNINGS" to CFLAGS in scripts/makefile.vcwin32.
|
||||
Removed the obsolete $ARCH variable from scripts/makefile.darwin.
|
||||
|
||||
Version 1.6.15 [November 20, 2014]
|
||||
No changes.
|
||||
|
||||
Version 1.6.16beta01 [December 14, 2014]
|
||||
Added ".align 2" to arm/filter_neon.S to support old GAS assemblers that
|
||||
don't do alignment correctly.
|
||||
Revised Makefile.am and scripts/symbols.dfn to work with MinGW/MSYS
|
||||
(Bob Friesenhahn).
|
||||
|
||||
Version 1.6.16beta02 [December 15, 2014]
|
||||
Revised Makefile.am and scripts/*.dfn again to work with MinGW/MSYS;
|
||||
renamed scripts/*.dfn to scripts/*.c (John Bowler).
|
||||
|
||||
Version 1.6.16beta03 [December 21, 2014]
|
||||
Quiet a "comparison always true" warning in pngstest.c (John Bowler).
|
||||
|
||||
Version 1.6.16rc01 [December 21, 2014]
|
||||
Restored a test on width that was removed from png.c at libpng-1.6.9
|
||||
(Bug report by Alex Eubanks, CVE-2015-0973).
|
||||
|
||||
Version 1.6.16rc02 [December 21, 2014]
|
||||
Undid the update to pngrutil.c in 1.6.16rc01.
|
||||
|
||||
Version 1.6.16rc03 [December 21, 2014]
|
||||
Fixed an overflow in png_combine_row() with very wide interlaced images
|
||||
(Bug report and fix by John Bowler, CVE-2014-9495).
|
||||
|
||||
Version 1.6.16 [December 22, 2014]
|
||||
No changes.
|
||||
|
||||
Version 1.6.17beta01 [January 29, 2015]
|
||||
Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h
|
||||
Corrected the width limit calculation in png_check_IHDR().
|
||||
Removed user limits from pngfix. Also pass NULL pointers to
|
||||
png_read_row to skip the unnecessary row de-interlace stuff.
|
||||
Added testing of png_set_packing() to pngvalid.c
|
||||
Regenerated configure scripts in the *.tar distributions with libtool-2.4.4
|
||||
Implement previously untested cases of libpng transforms in pngvalid.c
|
||||
Fixed byte order in 2-byte filler, in png_do_read_filler().
|
||||
Made the check for out-of-range values in png_set_tRNS() detect
|
||||
values that are exactly 2^bit_depth, and work on 16-bit platforms.
|
||||
Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47.
|
||||
Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
|
||||
pngset.c to avoid warnings about dead code.
|
||||
|
||||
Version 1.6.17beta02 [February 7, 2015]
|
||||
Work around one more Coverity-scan dead-code warning.
|
||||
Do not build png_product2() when it is unused.
|
||||
|
||||
Version 1.6.17beta03 [February 17, 2015]
|
||||
Display user limits in the output from pngtest.
|
||||
Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column
|
||||
and 1-million-row default limits in pnglibconf.dfa, that can be reset
|
||||
by the user at build time or run time. This provides a more robust
|
||||
defense against DOS and as-yet undiscovered overflows.
|
||||
|
||||
Version 1.6.17beta04 [February 21, 2015]
|
||||
Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default.
|
||||
Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins).
|
||||
Rebuilt configure scripts with automake-1.15 and libtool-2.4.6
|
||||
|
||||
Version 1.6.17beta05 [February 25, 2015]
|
||||
Restored compiling of png_reciprocal2 with PNG_NO_16BIT.
|
||||
|
||||
Version 1.6.17beta06 [February 27, 2015]
|
||||
Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block
|
||||
of png.h.
|
||||
Avoid runtime checks when converting integer to png_byte with
|
||||
Visual Studio (Sergey Kosarevsky)
|
||||
|
||||
Version 1.6.17rc01 [March 4, 2015]
|
||||
No changes.
|
||||
|
||||
Version 1.6.17rc02 [March 9, 2015]
|
||||
Removed some comments that the configure script did not handle
|
||||
properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt.
|
||||
Free the unknown_chunks structure even when it contains no data.
|
||||
|
||||
Version 1.6.17rc03 [March 12, 2015]
|
||||
Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF
|
||||
for consistency, and remove some useless tests (Alexey Petruchik).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
# Copyright (C) 2007-2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2007-2015 Glenn Randers-Pehrson
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@@ -16,7 +16,7 @@ enable_testing()
|
||||
|
||||
set(PNGLIB_MAJOR 1)
|
||||
set(PNGLIB_MINOR 6)
|
||||
set(PNGLIB_RELEASE 15)
|
||||
set(PNGLIB_RELEASE 17)
|
||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||
|
||||
@@ -30,8 +30,7 @@ if(NOT WIN32)
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
if(NOT M_LIBRARY)
|
||||
message(STATUS
|
||||
"math library 'libm' not found - floating point support disabled")
|
||||
message(STATUS "math lib 'libm' not found; floating point support disabled")
|
||||
endif()
|
||||
else()
|
||||
# not needed on windows
|
||||
@@ -39,22 +38,14 @@ else()
|
||||
endif()
|
||||
|
||||
# COMMAND LINE OPTIONS
|
||||
if(DEFINED PNG_SHARED)
|
||||
option(PNG_SHARED "Build shared lib" ${PNG_SHARED})
|
||||
else()
|
||||
option(PNG_SHARED "Build shared lib" ON)
|
||||
endif()
|
||||
if(DEFINED PNG_STATIC)
|
||||
option(PNG_STATIC "Build static lib" ${PNG_STATIC})
|
||||
else()
|
||||
option(PNG_STATIC "Build static lib" ON)
|
||||
endif()
|
||||
|
||||
option(PNG_TESTS "Build libpng tests" YES)
|
||||
option(PNG_SHARED "Build shared lib" ON)
|
||||
option(PNG_STATIC "Build static lib" ON)
|
||||
option(PNG_TESTS "Build libpng tests" ON)
|
||||
|
||||
# Many more configuration options could be added here
|
||||
option(PNG_DEBUG "Build with debug output" NO)
|
||||
option(PNGARG "Disable ANSI-C prototypes" NO)
|
||||
option(PNG_FRAMEWORK "Build OS X framework" OFF)
|
||||
option(PNG_DEBUG "Build with debug output" OFF)
|
||||
option(PNGARG "Disable ANSI-C prototypes" OFF)
|
||||
|
||||
# SET LIBNAME
|
||||
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
@@ -134,7 +125,7 @@ if(PNG_SHARED)
|
||||
endif()
|
||||
|
||||
if(PNG_STATIC)
|
||||
# does not work without changing name
|
||||
# does not work without changing name
|
||||
set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
|
||||
add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
|
||||
list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_STATIC})
|
||||
@@ -145,10 +136,27 @@ if(PNG_STATIC)
|
||||
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(PNG_FRAMEWORK)
|
||||
set(PNG_LIB_NAME_FRAMEWORK ${PNG_LIB_NAME}_framework)
|
||||
add_library(${PNG_LIB_NAME_FRAMEWORK} SHARED ${libpng_sources})
|
||||
list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_FRAMEWORK})
|
||||
set_target_properties(${PNG_LIB_NAME_FRAMEWORK} PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${PNGLIB_VERSION}
|
||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR}
|
||||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION}
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng
|
||||
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
||||
PUBLIC_HEADER "${libpng_public_hdrs}"
|
||||
OUTPUT_NAME png)
|
||||
target_link_libraries(${PNG_LIB_NAME_FRAMEWORK} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(NOT PNG_LIB_TARGETS)
|
||||
message(SEND_ERROR
|
||||
"No library variant selected to build. "
|
||||
"Please enable at least one of the following options: PNG_STATIC, PNG_SHARED")
|
||||
"Please enable at least one of the following options: "
|
||||
" PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
|
||||
endif()
|
||||
|
||||
if(PNG_SHARED AND WIN32)
|
||||
@@ -253,7 +261,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.15beta03
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.17rc03
|
||||
VERSION 16.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 16
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
@@ -284,7 +292,8 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
${PNG_EXPORT_RULE}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
if(PNG_SHARED)
|
||||
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
|
||||
|
||||
11
INSTALL
11
INSTALL
@@ -17,7 +17,7 @@ VIII. Configuring libpng for 16-bit platforms
|
||||
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. Configuring libpng for multiprocessing
|
||||
XV. Setjmp/longjmp issues
|
||||
XVI. Other sources of information about libpng
|
||||
|
||||
I. Simple installation
|
||||
@@ -189,7 +189,7 @@ run "make install".
|
||||
VIII. Configuring libpng for 16-bit platforms
|
||||
|
||||
You will want to look into zconf.h to tell zlib (and thus libpng) that
|
||||
it cannot allocate more then 64K at a time. Even if you can, the memory
|
||||
it cannot allocate more than 64K at a time. Even if you can, the memory
|
||||
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
|
||||
|
||||
IX. Configuring for DOS
|
||||
@@ -362,7 +362,7 @@ $PREFIX/include directory). Do not edit pnglibconf.h after you have built
|
||||
libpng, because than the settings would not accurately reflect the settings
|
||||
that were used to build libpng.
|
||||
|
||||
XV. Configuring libpng for multiprocessing
|
||||
XV. Setjmp/longjmp issues
|
||||
|
||||
Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
|
||||
is known to be not thread-safe on some platforms and we don't know of
|
||||
@@ -375,6 +375,11 @@ configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
|
||||
|
||||
in your pnglibconf.h or pngusr.h.
|
||||
|
||||
Starting with libpng-1.6.0, the library included a "simplified API".
|
||||
This requires setjmp/longjmp, so you must either build the library
|
||||
with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
|
||||
|
||||
XVI. Other sources of information about libpng:
|
||||
|
||||
Further information can be found in the README and libpng-manual.txt
|
||||
|
||||
6
LICENSE
6
LICENSE
@@ -10,8 +10,8 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.15beta03, November 3, 2014, are
|
||||
Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.17rc03, March 12, 2015, are
|
||||
Copyright (c) 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
|
||||
@@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
November 3, 2014
|
||||
March 12, 2015
|
||||
|
||||
19
Makefile.am
19
Makefile.am
@@ -129,7 +129,7 @@ EXTRA_DIST= \
|
||||
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
|
||||
CMakeLists.txt example.c libpng-manual.txt
|
||||
|
||||
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.dfn
|
||||
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.c
|
||||
|
||||
CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \
|
||||
@@ -152,7 +152,7 @@ AM_CFLAGS = ${PNG_COPTS}
|
||||
# checks for this and sets DFNCPP appropriately.
|
||||
DFNCPP = @DFNCPP@
|
||||
|
||||
SUFFIXES = .chk .dfn .out
|
||||
SUFFIXES = .chk .out
|
||||
|
||||
$(PNGLIB_BASENAME).pc: libpng.pc
|
||||
cp libpng.pc $@
|
||||
@@ -237,18 +237,17 @@ if DO_PNG_PREFIX
|
||||
SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
||||
endif
|
||||
|
||||
.dfn.out:
|
||||
rm -f $@ $*.c $*.tf[12]
|
||||
.c.out:
|
||||
rm -f $@ $*.tf[12]
|
||||
test -d scripts || mkdir scripts || test -d scripts
|
||||
echo '#include "$<"' >$*.c
|
||||
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) $*.c > $*.tf1
|
||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1
|
||||
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
|
||||
rm -f $*.c $*.tf1
|
||||
rm -f $*.tf1
|
||||
mv $*.tf2 $@
|
||||
|
||||
# The .dfn file for pnglibconf.h is machine generated
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
||||
# The .c file for pnglibconf.h is machine generated
|
||||
pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
||||
rm -f $@ $*.tf[45]
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\
|
||||
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||
@@ -268,7 +267,7 @@ scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.ou
|
||||
|
||||
# used on demand to regenerate the standard header, CPPFLAGS should
|
||||
# be empty - no non-standard defines
|
||||
scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||
scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||
rm -f $@ pnglibconf.tf[67]
|
||||
test -z "$(CPPFLAGS)"
|
||||
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
|
||||
|
||||
2
README
2
README
@@ -1,4 +1,4 @@
|
||||
README for libpng version 1.6.15beta03 - November 3, 2014 (shared library 16.0)
|
||||
README for libpng version 1.6.17rc03 - March 12, 2015 (shared library 16.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
|
||||
/* WARNING: it is strongly recommended that you do not build libpng with
|
||||
@@ -130,4 +131,4 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
|
||||
}
|
||||
}
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
|
||||
/* filter_neon.S - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* This is required to get the symbol renames, which are #defines, and also
|
||||
* includes the definition (or not) of PNG_ARM_NEON_OPT and
|
||||
* PNG_ARM_NEON_IMPLEMENTATION.
|
||||
/* This is required to get the symbol renames, which are #defines, and the
|
||||
* definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
|
||||
*/
|
||||
#define PNG_VERSION_INFO_ONLY
|
||||
#include "../pngpriv.h"
|
||||
@@ -21,6 +20,8 @@
|
||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for
|
||||
* ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it
|
||||
* only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h
|
||||
@@ -28,7 +29,6 @@
|
||||
*/
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
#ifdef __ELF__
|
||||
@@ -47,6 +47,13 @@ ELF .size \name, . - \name
|
||||
.purgem endfunc
|
||||
.endm
|
||||
.text
|
||||
|
||||
/* Explicitly specifying alignment here because some versions of
|
||||
* GAS don't align code correctly. This is harmless in correctly
|
||||
* written versions of GAS.
|
||||
*/
|
||||
.align 2
|
||||
|
||||
.if \export
|
||||
.global \name
|
||||
.endif
|
||||
@@ -242,5 +249,5 @@ func png_read_filter_row_paeth3_neon, export=1
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
|
||||
#endif /* READ */
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by James Yu <james.yu at linaro.org>, October 2013.
|
||||
* Based on filter_neon.S, written by Mans Rullgard, 2011.
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* This code requires -mfpu=neon on the command line: */
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
@@ -35,7 +37,6 @@
|
||||
#define png_ldr(type,pointer)\
|
||||
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
void
|
||||
@@ -368,5 +369,5 @@ png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */
|
||||
#endif /* READ */
|
||||
|
||||
12
configure.ac
12
configure.ac
@@ -18,7 +18,7 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.6.15beta03],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.6.17rc03],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
@@ -39,10 +39,10 @@ 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.6.15beta03
|
||||
PNGLIB_VERSION=1.6.17rc03
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_RELEASE=15
|
||||
PNGLIB_RELEASE=17
|
||||
|
||||
dnl End of version number stuff
|
||||
|
||||
@@ -283,21 +283,17 @@ AC_ARG_ENABLE([arm-neon],
|
||||
[case "$enableval" in
|
||||
no|off)
|
||||
# disable the default enabling on __ARM_NEON__ systems:
|
||||
AC_DEFINE([PNG_USE_ARM_NEON], [], [ARM NEON support])
|
||||
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
||||
[Disable ARM Neon optimizations])
|
||||
# Prevent inclusion of the assembler files below:
|
||||
enable_arm_neon=no;;
|
||||
check)
|
||||
AC_DEFINE([PNG_USE_ARM_NEON], [], [ARM NEON support])
|
||||
AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
|
||||
[Check for ARM Neon support at run-time]);;
|
||||
api)
|
||||
AC_DEFINE([PNG_USE_ARM_NEON], [], [ARM NEON support])
|
||||
AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
|
||||
[Turn on ARM Neon optimizations at run-time]);;
|
||||
yes|on)
|
||||
AC_DEFINE([PNG_USE_ARM_NEON], [], [ARM NEON support])
|
||||
AC_DEFINE([PNG_ARM_NEON_OPT], [2],
|
||||
[Enable ARM Neon optimizations])
|
||||
AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
|
||||
@@ -314,7 +310,7 @@ AC_ARG_ENABLE([arm-neon],
|
||||
AM_CONDITIONAL([PNG_ARM_NEON],
|
||||
[test "$enable_arm_neon" != 'no' &&
|
||||
case "$host_cpu" in
|
||||
arm*) :;;
|
||||
arm*|aarch64*) :;;
|
||||
*) test "$enable_arm_neon" != '';;
|
||||
esac])
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by John Bowler, 2014.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -16,8 +16,8 @@
|
||||
* png_have_neon implemented for Linux by reading the widely available
|
||||
* pseudo-file /proc/cpuinfo.
|
||||
*
|
||||
* This code is strict ANSI-C and is probably moderately portable, it does
|
||||
* however use <stdio.h> and assumes that /proc/cpuinfo is never localized.
|
||||
* This code is strict ANSI-C and is probably moderately portable; it does
|
||||
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -152,8 +152,10 @@ png_have_neon(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
else
|
||||
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,8 @@ int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
|
||||
|
||||
/* could pass pointers to user-defined error handlers instead of NULLs: */
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), NULL, NULL,
|
||||
NULL);
|
||||
if (!png_ptr)
|
||||
return 4; /* out of memory */
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
|
||||
/* could also replace libpng warning-handler (final NULL), but no need: */
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
|
||||
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), mainprog_ptr,
|
||||
readpng2_error_handler, readpng2_warning_handler);
|
||||
if (!png_ptr)
|
||||
return 4; /* out of memory */
|
||||
|
||||
@@ -90,7 +90,7 @@ int writepng_init(mainprog_info *mainprog_ptr)
|
||||
|
||||
/* could also replace libpng warning-handler (final NULL), but no need: */
|
||||
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
|
||||
png_ptr = png_create_write_struct(png_get_libpng_ver(NULL), mainprog_ptr,
|
||||
writepng_error_handler, NULL);
|
||||
if (!png_ptr)
|
||||
return 4; /* out of memory */
|
||||
|
||||
@@ -337,6 +337,9 @@ validate_T(void)
|
||||
* In both cases the file data is held in a linked list of buffers - not all
|
||||
* of these are in use at any time.
|
||||
*/
|
||||
#define NEW(type) ((type *)malloc(sizeof (type)))
|
||||
#define DELETE(ptr) (free(ptr))
|
||||
|
||||
struct buffer_list
|
||||
{
|
||||
struct buffer_list *next; /* next buffer in list */
|
||||
@@ -361,6 +364,25 @@ buffer_init(struct buffer *buffer)
|
||||
buffer->current = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
buffer_destroy_list(struct buffer_list *list)
|
||||
{
|
||||
if (list != NULL)
|
||||
{
|
||||
struct buffer_list *next = list->next;
|
||||
DELETE(list);
|
||||
buffer_destroy_list(next);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
buffer_destroy(struct buffer *buffer)
|
||||
{
|
||||
struct buffer_list *list = buffer->first.next;
|
||||
buffer_init(buffer);
|
||||
buffer_destroy_list(list);
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
static void
|
||||
buffer_start_write(struct buffer *buffer)
|
||||
@@ -390,8 +412,6 @@ get_buffer(png_structp pp)
|
||||
return (struct buffer*)png_get_io_ptr(pp);
|
||||
}
|
||||
|
||||
#define NEW(type) ((type *)malloc(sizeof (type)))
|
||||
|
||||
static struct buffer_list *
|
||||
buffer_extend(struct buffer_list *current)
|
||||
{
|
||||
@@ -598,6 +618,17 @@ display_clean(struct display *dp)
|
||||
dp->results = 0; /* reset for next time */
|
||||
}
|
||||
|
||||
static void
|
||||
display_destroy(struct display *dp)
|
||||
{
|
||||
/* Release any memory held in the display. */
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
buffer_destroy(&dp->written_file);
|
||||
# endif
|
||||
|
||||
buffer_destroy(&dp->original_file);
|
||||
}
|
||||
|
||||
static struct display *
|
||||
get_dp(png_structp pp)
|
||||
/* The display pointer is always stored in the png_struct error pointer */
|
||||
@@ -1605,6 +1636,9 @@ main(const int argc, const char * const * const argv)
|
||||
display_clean(&d);
|
||||
}
|
||||
|
||||
/* Release allocated memory */
|
||||
display_destroy(&d);
|
||||
|
||||
return errors != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*-
|
||||
* pngstest.c
|
||||
*
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
* Copyright (c) 2013-2014 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -3173,32 +3173,43 @@ read_one_file(Image *image)
|
||||
{
|
||||
long int cb = ftell(f);
|
||||
|
||||
if (cb > 0 && (unsigned long int)cb < (size_t)~(size_t)0)
|
||||
if (cb > 0)
|
||||
{
|
||||
png_bytep b = voidcast(png_bytep, malloc((size_t)cb));
|
||||
|
||||
if (b != NULL)
|
||||
if ((unsigned long int)cb <= (size_t)~(size_t)0)
|
||||
{
|
||||
rewind(f);
|
||||
png_bytep b = voidcast(png_bytep, malloc((size_t)cb));
|
||||
|
||||
if (fread(b, (size_t)cb, 1, f) == 1)
|
||||
if (b != NULL)
|
||||
{
|
||||
fclose(f);
|
||||
image->input_memory_size = cb;
|
||||
image->input_memory = b;
|
||||
rewind(f);
|
||||
|
||||
if (fread(b, (size_t)cb, 1, f) == 1)
|
||||
{
|
||||
fclose(f);
|
||||
image->input_memory_size = cb;
|
||||
image->input_memory = b;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
free(b);
|
||||
return logclose(image, f, image->file_name,
|
||||
": read failed: ");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
free(b);
|
||||
return logclose(image, f, image->file_name,
|
||||
": read failed: ");
|
||||
}
|
||||
": out of memory: ");
|
||||
}
|
||||
|
||||
else
|
||||
return logclose(image, f, image->file_name,
|
||||
": out of memory: ");
|
||||
": file too big for this architecture: ");
|
||||
/* cb is the length of the file as a (long) and
|
||||
* this is greater than the maximum amount of
|
||||
* memory that can be requested from malloc.
|
||||
*/
|
||||
}
|
||||
|
||||
else if (cb == 0)
|
||||
|
||||
@@ -1242,4 +1242,4 @@ main(void)
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
#endif /* SET_UNKNOWN_CHUNKS && READ*/
|
||||
#endif /* SET_UNKNOWN_CHUNKS && READ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -223,7 +223,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
|
||||
/* 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 */
|
||||
|
||||
@@ -425,7 +425,8 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
} /* end for row */
|
||||
|
||||
/* prepare the standard PNG structures */
|
||||
png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
png_ptr = png_create_write_struct (png_get_libpng_ver(NULL), NULL, NULL,
|
||||
NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
return FALSE;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/* pngfix.c
|
||||
*
|
||||
* Copyright (c) 2014 John Cunningham Bowler
|
||||
* Copyright (c) 2014-2015 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.14 [October 23, 2014]
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Tool to check and fix the zlib inflate 'too far back' problem, see the usage
|
||||
* message for more information.
|
||||
* Tool to check and fix the zlib inflate 'too far back' problem.
|
||||
* See the usage message for more information.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -2138,7 +2138,7 @@ zlib_end(struct zlib *zlib)
|
||||
*
|
||||
* z-rc is the zlib failure code; message is the error message with
|
||||
* spaces replaced by '-'. The compressed byte count indicates where
|
||||
* in the zlib stream the error occured.
|
||||
* in the zlib stream the error occurred.
|
||||
*/
|
||||
type_name(zlib->chunk->chunk_type, stdout);
|
||||
printf(" SKP %s %d %s ", zlib_flevel(zlib), zlib->file_bits,
|
||||
@@ -3577,7 +3577,6 @@ read_png(struct control *control)
|
||||
{
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr = NULL;
|
||||
volatile png_bytep row = NULL, display = NULL;
|
||||
volatile int rc;
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, control,
|
||||
@@ -3594,6 +3593,16 @@ read_png(struct control *control)
|
||||
rc = setjmp(control->file.jmpbuf);
|
||||
if (rc == 0)
|
||||
{
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
/* Remove any limits on the size of PNG files that can be read,
|
||||
* without this we may reject files based on built-in safety
|
||||
* limits.
|
||||
*/
|
||||
png_set_user_limits(png_ptr, 0x7fffffff, 0x7fffffff);
|
||||
png_set_chunk_cache_max(png_ptr, 0);
|
||||
png_set_chunk_malloc_max(png_ptr, 0);
|
||||
# endif
|
||||
|
||||
png_set_read_fn(png_ptr, control, read_callback);
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
@@ -3606,32 +3615,22 @@ read_png(struct control *control)
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
{
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
||||
int passes = png_set_interlace_handling(png_ptr);
|
||||
int pass;
|
||||
|
||||
row = png_voidcast(png_byte*, malloc(rowbytes));
|
||||
display = png_voidcast(png_byte*, malloc(rowbytes));
|
||||
png_start_read_image(png_ptr);
|
||||
|
||||
if (row == NULL || display == NULL)
|
||||
png_error(png_ptr, "OOM allocating row buffers");
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_uint_32 y = height;
|
||||
|
||||
{
|
||||
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
||||
int passes = png_set_interlace_handling(png_ptr);
|
||||
int pass;
|
||||
|
||||
png_start_read_image(png_ptr);
|
||||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_uint_32 y = height;
|
||||
|
||||
/* NOTE: this trashes the row each time; interlace handling won't
|
||||
* work, but this avoids memory thrashing for speed testing.
|
||||
*/
|
||||
while (y-- > 0)
|
||||
png_read_row(png_ptr, row, display);
|
||||
}
|
||||
}
|
||||
/* NOTE: this skips asking libpng to return either version of
|
||||
* the image row, but libpng still reads the rows.
|
||||
*/
|
||||
while (y-- > 0)
|
||||
png_read_row(png_ptr, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (control->file.global->verbose)
|
||||
@@ -3642,8 +3641,6 @@ read_png(struct control *control)
|
||||
}
|
||||
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
if (row != NULL) free(row);
|
||||
if (display != NULL) free(display);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -3705,21 +3702,21 @@ usage(const char *prog)
|
||||
" gAMA, sRGB [all]: These specify the gamma encoding used for the pixel",
|
||||
" values.",
|
||||
" cHRM, iCCP [color]: These specify how colors are encoded. iCCP also",
|
||||
" specifies the exact encoding of a pixel value however in practice",
|
||||
" most programs will ignore it.",
|
||||
" specifies the exact encoding of a pixel value; however, in",
|
||||
" practice most programs will ignore it.",
|
||||
" bKGD [transform]: This is used by libpng transforms."
|
||||
" --max=<number>:",
|
||||
" Use IDAT chunks sized <number>. If no number is given the the IDAT",
|
||||
" chunks will be the maximum size permitted; 2^31-1 bytes. If the option",
|
||||
" is omitted the original chunk sizes will not be changed. When the",
|
||||
" option is given --strip=unsafe is set automatically, this may be",
|
||||
" option is given --strip=unsafe is set automatically. This may be",
|
||||
" cancelled if you know that all unknown unsafe-to-copy chunks really are",
|
||||
" safe to copy across an IDAT size change. This is true of all chunks",
|
||||
" that have ever been formally proposed as PNG extensions.",
|
||||
" MESSAGES",
|
||||
" By default the program only outputs summaries for each file.",
|
||||
" --quiet (-q):",
|
||||
" Do not output the summaries except for files which cannot be read. With",
|
||||
" Do not output the summaries except for files that cannot be read. With",
|
||||
" two --quiets these are not output either.",
|
||||
" --errors (-e):",
|
||||
" Output errors from libpng and the program (except too-far-back).",
|
||||
@@ -3752,7 +3749,7 @@ usage(const char *prog)
|
||||
" the following codes. Notice that the results for each file are combined",
|
||||
" together - check one file at a time to get a meaningful error code!",
|
||||
" 0x01: The zlib too-far-back error existed in at least one chunk.",
|
||||
" 0x02: At least once chunk had a CRC error.",
|
||||
" 0x02: At least one chunk had a CRC error.",
|
||||
" 0x04: A chunk length was incorrect.",
|
||||
" 0x08: The file was truncated.",
|
||||
" Errors less than 16 are potentially recoverable, for a single file if the",
|
||||
@@ -3760,7 +3757,7 @@ usage(const char *prog)
|
||||
" non-zero code is returned).",
|
||||
" 0x10: The file could not be read, even with corrections.",
|
||||
" 0x20: The output file could not be written.",
|
||||
" 0x40: An unexpected, potentially internal, error occured.",
|
||||
" 0x40: An unexpected, potentially internal, error occurred.",
|
||||
" If the command line arguments are incorrect the program exits with exit",
|
||||
" 255. Some older operating systems only support 7-bit exit codes, on those",
|
||||
" systems it is suggested that this program is first tested by supplying",
|
||||
@@ -3820,7 +3817,7 @@ usage(const char *prog)
|
||||
" SKP: The chunk was skipped because of a zlib issue (zlib-rc) with",
|
||||
" explanation 'message'",
|
||||
" ERR: The read of the file was aborted. The parameters explain why.",
|
||||
"$3 status: For 'ERR' the accumulate status code from 'EXIT CODES' above.",
|
||||
"$3 status: For 'ERR' the accumulated status code from 'EXIT CODES' above.",
|
||||
" This is printed as a 2 digit hexadecimal value",
|
||||
" comp-level: The recorded compression level (FLEVEL) of a zlib stream",
|
||||
" expressed as a string {supfast,stdfast,default,maximum}",
|
||||
|
||||
@@ -136,7 +136,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
|
||||
/* create the two png(-info) structures */
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), NULL,
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
@@ -313,7 +313,7 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
|
||||
/* prepare the standard PNG structures */
|
||||
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||
png_ptr = png_create_write_struct(png_get_libpng_ver(NULL), NULL,
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#if 0 /* in case someone actually tries to compile this */
|
||||
|
||||
/* example.c - an example of using libpng
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Maintained 1998-2014 Glenn Randers-Pehrson
|
||||
* Maintained 1996, 1997 Andreas Dilger)
|
||||
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
@@ -494,7 +494,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
max_screen_colors, histogram, 0);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
#endif /* READ_QUANTIZE */
|
||||
|
||||
/* Invert monochrome files to have 0 as white and 1 as black */
|
||||
png_set_invert_mono(png_ptr);
|
||||
@@ -532,7 +532,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
#else
|
||||
number_passes = 1;
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
|
||||
/* Optional call to gamma correct and add the background to the palette
|
||||
@@ -744,7 +744,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
* to pass the current row as new_row, and the function will combine
|
||||
* the old row and the new row.
|
||||
*/
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
}
|
||||
|
||||
end_callback(png_structp png_ptr, png_infop info)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.6.15beta03 - November 3, 2014
|
||||
libpng version 1.6.17rc03 - March 12, 2015
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
This document is released under the libpng license.
|
||||
For conditions of distribution and use, see the disclaimer
|
||||
@@ -11,9 +11,9 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.6.15beta03 - November 3, 2014
|
||||
libpng versions 0.97, January 1998, through 1.6.17rc03 - March 12, 2015
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
libpng 1.0 beta 6 - version 0.96 - May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
@@ -336,7 +336,7 @@ prediction.
|
||||
|
||||
If you are intending to keep the file pointer open for use in libpng,
|
||||
you must ensure you don't read more than 8 bytes from the beginning
|
||||
of the file, and you also have to make a call to png_set_sig_bytes_read()
|
||||
of the file, and you also have to make a call to png_set_sig_bytes()
|
||||
with the number of bytes you read from the beginning. Libpng will
|
||||
then only check the bytes (if any) that your program didn't read.
|
||||
|
||||
@@ -344,22 +344,23 @@ then only check the bytes (if any) that your program didn't read.
|
||||
to replace them with custom functions. See the discussion under
|
||||
Customizing libpng.
|
||||
|
||||
|
||||
FILE *fp = fopen(file_name, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
fread(header, 1, number, fp);
|
||||
is_png = !png_sig_cmp(header, 0, number);
|
||||
if (fread(header, 1, number, fp) != number)
|
||||
{
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
is_png = !png_sig_cmp(header, 0, number);
|
||||
if (!is_png)
|
||||
{
|
||||
return (NOT_PNG);
|
||||
}
|
||||
|
||||
|
||||
Next, png_struct and png_info need to be allocated and initialized. In
|
||||
order to ensure that the size of these structures is correct even with a
|
||||
dynamically linked libpng, there are functions to initialize and
|
||||
@@ -648,15 +649,12 @@ User limits
|
||||
|
||||
The PNG specification allows the width and height of an image to be as
|
||||
large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
|
||||
Since very few applications really need to process such large images,
|
||||
we have imposed an arbitrary 1-million limit on rows and columns.
|
||||
Larger images will be rejected immediately with a png_error() call. If
|
||||
you wish to change this limit, you can use
|
||||
you wish to change these limits, you can use
|
||||
|
||||
png_set_user_limits(png_ptr, width_max, height_max);
|
||||
|
||||
to set your own limits, or use width_max = height_max = 0x7fffffffL
|
||||
to allow all valid dimensions (libpng may reject some very large images
|
||||
to set your own limits (libpng may reject some very wide images
|
||||
anyway because of potential buffer overflow conditions).
|
||||
|
||||
You should put this statement after you create the PNG structure and
|
||||
@@ -1267,13 +1265,13 @@ in until png_read_end() has read the chunk data following the image.
|
||||
the PNG datastream is embedded in
|
||||
a MNG-1.0 datastream)
|
||||
|
||||
Any or all of interlace_type, compression_type, or
|
||||
filter_method can be NULL if you are
|
||||
not interested in their values.
|
||||
Any of width, height, color_type, bit_depth,
|
||||
interlace_type, compression_type, or filter_method can
|
||||
be NULL if you are not interested in their values.
|
||||
|
||||
Note that png_get_IHDR() returns 32-bit data into
|
||||
the application's width and height variables.
|
||||
This is an unsafe situation if these are 16-bit
|
||||
This is an unsafe situation if these are not png_uint_32
|
||||
variables. In such situations, the
|
||||
png_get_image_width() and png_get_image_height()
|
||||
functions described below are safer.
|
||||
@@ -1996,7 +1994,7 @@ value when you call it in this position:
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||
|
||||
If you need to reduce an RGB file to a paletted file, or if a paletted
|
||||
file has more entries then will fit on your screen, png_set_quantize()
|
||||
file has more entries than will fit on your screen, png_set_quantize()
|
||||
will do that. Note that this is a simple match quantization that merely
|
||||
finds the closest color available. This should work fairly well with
|
||||
optimized palettes, but fairly badly with linear color cubes. If you
|
||||
@@ -2549,7 +2547,7 @@ png_infop info_ptr;
|
||||
64K. The library seems to run fine with sizes
|
||||
of 4K. Although you can give it much less if
|
||||
necessary (I assume you can give it chunks of
|
||||
1 byte, I haven't tried less then 256 bytes
|
||||
1 byte, I haven't tried less than 256 bytes
|
||||
yet). When this function returns, you may
|
||||
want to display any rows that were generated
|
||||
in the row callback if you don't already do
|
||||
@@ -5034,11 +5032,15 @@ The signatures of many exported functions were changed, such that
|
||||
png_infop became png_inforp or png_const_inforp
|
||||
where "rp" indicates a "restricted pointer".
|
||||
|
||||
The support for FAR/far types has been eliminated and the definition of
|
||||
png_alloc_size_t is now controlled by a flag so that 'small size_t' systems
|
||||
can select it if necessary.
|
||||
|
||||
Error detection in some chunks has improved; in particular the iCCP chunk
|
||||
reader now does pretty complete validation of the basic format. Some bad
|
||||
profiles that were previously accepted are now accepted with a warning or
|
||||
rejected, depending upon the png_set_benign_errors() setting, in particular the
|
||||
very old broken Microsoft/HP 3144-byte sRGB profile. Starting with
|
||||
rejected, depending upon the png_set_benign_errors() setting, in particular
|
||||
the very old broken Microsoft/HP 3144-byte sRGB profile. Starting with
|
||||
libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by
|
||||
means of
|
||||
|
||||
@@ -5049,7 +5051,7 @@ means of
|
||||
#endif
|
||||
|
||||
It's not a good idea to do this if you are using the "simplified API",
|
||||
which needs to be able to recognize an sRGB profile conveyed via the iCCP
|
||||
which needs to be able to recognize sRGB profiles conveyed via the iCCP
|
||||
chunk.
|
||||
|
||||
The PNG spec requirement that only grayscale profiles may appear in images
|
||||
@@ -5277,13 +5279,13 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
XVI. Y2K Compliance in libpng
|
||||
|
||||
November 3, 2014
|
||||
March 12, 2015
|
||||
|
||||
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.6.15beta03 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.6.17rc03 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
|
||||
|
||||
71
libpng.3
71
libpng.3
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNG 3 "November 3, 2014"
|
||||
.TH LIBPNG 3 "March 12, 2015"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.15beta03
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.17rc03
|
||||
.SH SYNOPSIS
|
||||
\fB
|
||||
#include <png.h>\fP
|
||||
@@ -504,10 +504,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.6.15beta03 - November 3, 2014
|
||||
libpng version 1.6.17rc03 - March 12, 2015
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
This document is released under the libpng license.
|
||||
For conditions of distribution and use, see the disclaimer
|
||||
@@ -515,9 +515,9 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.6.15beta03 - November 3, 2014
|
||||
libpng versions 0.97, January 1998, through 1.6.17rc03 - March 12, 2015
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
libpng 1.0 beta 6 - version 0.96 - May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
@@ -840,7 +840,7 @@ prediction.
|
||||
|
||||
If you are intending to keep the file pointer open for use in libpng,
|
||||
you must ensure you don't read more than 8 bytes from the beginning
|
||||
of the file, and you also have to make a call to png_set_sig_bytes_read()
|
||||
of the file, and you also have to make a call to png_set_sig_bytes()
|
||||
with the number of bytes you read from the beginning. Libpng will
|
||||
then only check the bytes (if any) that your program didn't read.
|
||||
|
||||
@@ -848,22 +848,23 @@ then only check the bytes (if any) that your program didn't read.
|
||||
to replace them with custom functions. See the discussion under
|
||||
Customizing libpng.
|
||||
|
||||
|
||||
FILE *fp = fopen(file_name, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
fread(header, 1, number, fp);
|
||||
is_png = !png_sig_cmp(header, 0, number);
|
||||
if (fread(header, 1, number, fp) != number)
|
||||
{
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
is_png = !png_sig_cmp(header, 0, number);
|
||||
if (!is_png)
|
||||
{
|
||||
return (NOT_PNG);
|
||||
}
|
||||
|
||||
|
||||
Next, png_struct and png_info need to be allocated and initialized. In
|
||||
order to ensure that the size of these structures is correct even with a
|
||||
dynamically linked libpng, there are functions to initialize and
|
||||
@@ -1152,15 +1153,12 @@ callback function:
|
||||
|
||||
The PNG specification allows the width and height of an image to be as
|
||||
large as 2^(31\-1 (0x7fffffff), or about 2.147 billion rows and columns.
|
||||
Since very few applications really need to process such large images,
|
||||
we have imposed an arbitrary 1-million limit on rows and columns.
|
||||
Larger images will be rejected immediately with a png_error() call. If
|
||||
you wish to change this limit, you can use
|
||||
you wish to change these limits, you can use
|
||||
|
||||
png_set_user_limits(png_ptr, width_max, height_max);
|
||||
|
||||
to set your own limits, or use width_max = height_max = 0x7fffffffL
|
||||
to allow all valid dimensions (libpng may reject some very large images
|
||||
to set your own limits (libpng may reject some very wide images
|
||||
anyway because of potential buffer overflow conditions).
|
||||
|
||||
You should put this statement after you create the PNG structure and
|
||||
@@ -1771,13 +1769,13 @@ in until png_read_end() has read the chunk data following the image.
|
||||
the PNG datastream is embedded in
|
||||
a MNG-1.0 datastream)
|
||||
|
||||
Any or all of interlace_type, compression_type, or
|
||||
filter_method can be NULL if you are
|
||||
not interested in their values.
|
||||
Any of width, height, color_type, bit_depth,
|
||||
interlace_type, compression_type, or filter_method can
|
||||
be NULL if you are not interested in their values.
|
||||
|
||||
Note that png_get_IHDR() returns 32-bit data into
|
||||
the application's width and height variables.
|
||||
This is an unsafe situation if these are 16-bit
|
||||
This is an unsafe situation if these are not png_uint_32
|
||||
variables. In such situations, the
|
||||
png_get_image_width() and png_get_image_height()
|
||||
functions described below are safer.
|
||||
@@ -2500,7 +2498,7 @@ value when you call it in this position:
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||
|
||||
If you need to reduce an RGB file to a paletted file, or if a paletted
|
||||
file has more entries then will fit on your screen, png_set_quantize()
|
||||
file has more entries than will fit on your screen, png_set_quantize()
|
||||
will do that. Note that this is a simple match quantization that merely
|
||||
finds the closest color available. This should work fairly well with
|
||||
optimized palettes, but fairly badly with linear color cubes. If you
|
||||
@@ -3053,7 +3051,7 @@ png_infop info_ptr;
|
||||
64K. The library seems to run fine with sizes
|
||||
of 4K. Although you can give it much less if
|
||||
necessary (I assume you can give it chunks of
|
||||
1 byte, I haven't tried less then 256 bytes
|
||||
1 byte, I haven't tried less than 256 bytes
|
||||
yet). When this function returns, you may
|
||||
want to display any rows that were generated
|
||||
in the row callback if you don't already do
|
||||
@@ -5538,11 +5536,15 @@ The signatures of many exported functions were changed, such that
|
||||
png_infop became png_inforp or png_const_inforp
|
||||
where "rp" indicates a "restricted pointer".
|
||||
|
||||
The support for FAR/far types has been eliminated and the definition of
|
||||
png_alloc_size_t is now controlled by a flag so that 'small size_t' systems
|
||||
can select it if necessary.
|
||||
|
||||
Error detection in some chunks has improved; in particular the iCCP chunk
|
||||
reader now does pretty complete validation of the basic format. Some bad
|
||||
profiles that were previously accepted are now accepted with a warning or
|
||||
rejected, depending upon the png_set_benign_errors() setting, in particular the
|
||||
very old broken Microsoft/HP 3144-byte sRGB profile. Starting with
|
||||
rejected, depending upon the png_set_benign_errors() setting, in particular
|
||||
the very old broken Microsoft/HP 3144-byte sRGB profile. Starting with
|
||||
libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by
|
||||
means of
|
||||
|
||||
@@ -5553,7 +5555,7 @@ means of
|
||||
#endif
|
||||
|
||||
It's not a good idea to do this if you are using the "simplified API",
|
||||
which needs to be able to recognize an sRGB profile conveyed via the iCCP
|
||||
which needs to be able to recognize sRGB profiles conveyed via the iCCP
|
||||
chunk.
|
||||
|
||||
The PNG spec requirement that only grayscale profiles may appear in images
|
||||
@@ -5781,13 +5783,13 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
.SH XVI. Y2K Compliance in libpng
|
||||
|
||||
November 3, 2014
|
||||
March 12, 2015
|
||||
|
||||
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.6.15beta03 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.6.17rc03 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
|
||||
@@ -6033,7 +6035,14 @@ the first widely used release:
|
||||
1.6.14beta01-07 16 10614 16.so.16.14[.0]
|
||||
1.6.14rc01-02 16 10614 16.so.16.14[.0]
|
||||
1.6.14 16 10614 16.so.16.14[.0]
|
||||
1.6.15beta01-03 16 10615 16.so.16.15[.0]
|
||||
1.6.15beta01-08 16 10615 16.so.16.15[.0]
|
||||
1.6.15rc01-03 16 10615 16.so.16.15[.0]
|
||||
1.6.15 16 10615 16.so.16.15[.0]
|
||||
1.6.16beta01-03 16 10616 16.so.16.16[.0]
|
||||
1.6.16rc01-02 16 10616 16.so.16.16[.0]
|
||||
1.6.16 16 10616 16.so.16.16[.0]
|
||||
1.6.17beta01-06 16 10617 16.so.16.17[.0]
|
||||
1.6.17rc01-03 16 10617 16.so.16.17[.0]
|
||||
|
||||
Henceforth the source version will match the shared-library minor
|
||||
and patch numbers; the shared-library major version number will be
|
||||
@@ -6090,7 +6099,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.6.15beta03 - November 3, 2014:
|
||||
Libpng version 1.6.17rc03 - March 12, 2015:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
||||
|
||||
@@ -6113,7 +6122,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.15beta03, November 3, 2014, are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.17rc03, March 12, 2015, are
|
||||
Copyright (c) 2004,2006-2014 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
@@ -6212,7 +6221,7 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
November 3, 2014
|
||||
March 12, 2015
|
||||
|
||||
.\" end of man page
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 "November 3, 2014"
|
||||
.TH LIBPNGPF 3 "March 12, 2015"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.15beta03
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.17rc03
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
|
||||
2
png.5
2
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "November 3, 2014"
|
||||
.TH PNG 5 "March 12, 2015"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
||||
331
png.c
331
png.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "pngpriv.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_15beta03 Your_png_h_is_not_version_1_6_15beta03;
|
||||
typedef png_libpng_version_1_6_17rc03 Your_png_h_is_not_version_1_6_17rc03;
|
||||
|
||||
/* 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
|
||||
@@ -34,7 +34,7 @@ png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
|
||||
if (num_bytes > 8)
|
||||
png_error(png_ptr, "Too many bytes for PNG signature");
|
||||
|
||||
png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);
|
||||
png_ptr->sig_bytes = (png_byte)((num_bytes < 0 ? 0 : num_bytes) & 0xff);
|
||||
}
|
||||
|
||||
/* Checks whether the supplied bytes match the PNG signature. We allow
|
||||
@@ -65,7 +65,7 @@ png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));
|
||||
}
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
/* Function to allocate memory for zlib */
|
||||
@@ -140,8 +140,10 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
|
||||
do
|
||||
{
|
||||
uInt safe_length = (uInt)length;
|
||||
#ifndef __COVERITY__
|
||||
if (safe_length == 0)
|
||||
safe_length = (uInt)-1; /* evil, but safe */
|
||||
#endif
|
||||
|
||||
crc = crc32(crc, ptr, safe_length);
|
||||
|
||||
@@ -165,15 +167,25 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
|
||||
int
|
||||
png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
|
||||
{
|
||||
/* Libpng versions 1.0.0 and later are binary compatible if the version
|
||||
* string matches through the second '.'; we must recompile any
|
||||
* applications that use any older library version.
|
||||
*/
|
||||
|
||||
if (user_png_ver != NULL)
|
||||
{
|
||||
int i = 0;
|
||||
int i = -1;
|
||||
int found_dots = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (user_png_ver[i] != png_libpng_ver[i])
|
||||
i++;
|
||||
if (user_png_ver[i] != PNG_LIBPNG_VER_STRING[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i++]);
|
||||
if (user_png_ver[i] == '.')
|
||||
found_dots++;
|
||||
} while (found_dots < 2 && user_png_ver[i] != 0 &&
|
||||
PNG_LIBPNG_VER_STRING[i] != 0);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -181,37 +193,25 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
|
||||
|
||||
if ((png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) != 0)
|
||||
{
|
||||
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||
* we must recompile any applications that use any older library version.
|
||||
* For versions after libpng 1.0, we will be compatible, so we need
|
||||
* only check the first and third digits (note that when we reach version
|
||||
* 1.10 we will need to check the fourth symbol, namely user_png_ver[3]).
|
||||
*/
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
|
||||
(user_png_ver[0] == '1' && (user_png_ver[2] != png_libpng_ver[2] ||
|
||||
user_png_ver[3] != png_libpng_ver[3])) ||
|
||||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
|
||||
{
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
size_t pos = 0;
|
||||
char m[128];
|
||||
size_t pos = 0;
|
||||
char m[128];
|
||||
|
||||
pos = png_safecat(m, (sizeof m), pos,
|
||||
"Application built with libpng-");
|
||||
pos = png_safecat(m, (sizeof m), pos, user_png_ver);
|
||||
pos = png_safecat(m, (sizeof m), pos, " but running with ");
|
||||
pos = png_safecat(m, (sizeof m), pos, png_libpng_ver);
|
||||
PNG_UNUSED(pos)
|
||||
pos = png_safecat(m, (sizeof m), pos,
|
||||
"Application built with libpng-");
|
||||
pos = png_safecat(m, (sizeof m), pos, user_png_ver);
|
||||
pos = png_safecat(m, (sizeof m), pos, " but running with ");
|
||||
pos = png_safecat(m, (sizeof m), pos, PNG_LIBPNG_VER_STRING);
|
||||
PNG_UNUSED(pos)
|
||||
|
||||
png_warning(png_ptr, m);
|
||||
png_warning(png_ptr, m);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
png_ptr->flags = 0;
|
||||
png_ptr->flags = 0;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Success return. */
|
||||
@@ -478,9 +478,10 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
||||
/* Free any tRNS entry */
|
||||
if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0)
|
||||
{
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
png_free(png_ptr, info_ptr->trans_alpha);
|
||||
info_ptr->trans_alpha = NULL;
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
info_ptr->num_trans = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -546,20 +547,17 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
||||
|
||||
else
|
||||
{
|
||||
if (info_ptr->splt_palettes_num != 0)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < info_ptr->splt_palettes_num; i++)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < info_ptr->splt_palettes_num; i++)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->splt_palettes[i].name);
|
||||
png_free(png_ptr, info_ptr->splt_palettes[i].entries);
|
||||
}
|
||||
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes = NULL;
|
||||
info_ptr->splt_palettes_num = 0;
|
||||
png_free(png_ptr, info_ptr->splt_palettes[i].name);
|
||||
png_free(png_ptr, info_ptr->splt_palettes[i].entries);
|
||||
}
|
||||
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes = NULL;
|
||||
info_ptr->splt_palettes_num = 0;
|
||||
info_ptr->valid &= ~PNG_INFO_sPLT;
|
||||
}
|
||||
}
|
||||
@@ -579,15 +577,12 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
||||
{
|
||||
int i;
|
||||
|
||||
if (info_ptr->unknown_chunks_num != 0)
|
||||
{
|
||||
for (i = 0; i < info_ptr->unknown_chunks_num; i++)
|
||||
png_free(png_ptr, info_ptr->unknown_chunks[i].data);
|
||||
for (i = 0; i < info_ptr->unknown_chunks_num; i++)
|
||||
png_free(png_ptr, info_ptr->unknown_chunks[i].data);
|
||||
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
info_ptr->unknown_chunks = NULL;
|
||||
info_ptr->unknown_chunks_num = 0;
|
||||
}
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
info_ptr->unknown_chunks = NULL;
|
||||
info_ptr->unknown_chunks_num = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -633,7 +628,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
||||
|
||||
info_ptr->free_me &= ~mask;
|
||||
}
|
||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
/* This function returns a pointer to the io_ptr associated with the user
|
||||
* functions. The application should free any memory associated with this
|
||||
@@ -668,7 +663,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
|
||||
}
|
||||
# endif
|
||||
|
||||
#ifdef PNG_SAVE_INT_32_SUPPORTED
|
||||
# ifdef PNG_SAVE_INT_32_SUPPORTED
|
||||
/* The png_save_int_32 function assumes integers are stored in two's
|
||||
* complement format. If this isn't the case, then this routine needs to
|
||||
* be modified to write data in two's complement format. Note that,
|
||||
@@ -683,7 +678,7 @@ png_save_int_32(png_bytep buf, png_int_32 i)
|
||||
buf[2] = (png_byte)((i >> 8) & 0xff);
|
||||
buf[3] = (png_byte)(i & 0xff);
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
|
||||
# ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
/* Convert the supplied time into an RFC 1123 string suitable for use in
|
||||
@@ -736,7 +731,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
|
||||
return 1;
|
||||
}
|
||||
|
||||
# if PNG_LIBPNG_VER < 10700
|
||||
# if PNG_LIBPNG_VER < 10700
|
||||
/* To do: remove the following from libpng-1.7 */
|
||||
/* Original API that uses a private buffer in png_struct.
|
||||
* Deprecated because it causes png_struct to carry a spurious temporary
|
||||
@@ -757,10 +752,10 @@ png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
# endif
|
||||
# endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
# endif /* LIBPNG_VER < 10700 */
|
||||
# endif /* TIME_RFC1123 */
|
||||
|
||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
png_const_charp PNGAPI
|
||||
png_get_copyright(png_const_structrp png_ptr)
|
||||
@@ -771,14 +766,14 @@ png_get_copyright(png_const_structrp png_ptr)
|
||||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.15beta03 - November 3, 2014" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.17rc03 - March 12, 2015" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2015 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.6.15beta03 - November 3, 2014\
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson\
|
||||
return "libpng version 1.6.17rc03 - March 12, 2015\
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
# endif
|
||||
@@ -874,9 +869,9 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||
|
||||
for (i = 0, v = 0; i < num_palette; i++, v += color_inc)
|
||||
{
|
||||
palette[i].red = (png_byte)v;
|
||||
palette[i].green = (png_byte)v;
|
||||
palette[i].blue = (png_byte)v;
|
||||
palette[i].red = (png_byte)(v & 0xff);
|
||||
palette[i].green = (png_byte)(v & 0xff);
|
||||
palette[i].blue = (png_byte)(v & 0xff);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -939,7 +934,7 @@ png_reset_zstream(png_structrp png_ptr)
|
||||
/* WARNING: this resets the window bits to the maximum! */
|
||||
return (inflateReset(&png_ptr->zstream));
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
/* This function was added to libpng-1.0.7 */
|
||||
png_uint_32 PNGAPI
|
||||
@@ -949,8 +944,6 @@ png_access_version_number(void)
|
||||
return((png_uint_32)PNG_LIBPNG_VER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
/* Ensure that png_ptr->zstream.msg holds some appropriate error message string.
|
||||
* If it doesn't 'ret' is used to set it to something appropriate, even in cases
|
||||
@@ -1077,7 +1070,7 @@ png_colorspace_set_gamma(png_const_structrp png_ptr,
|
||||
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 assymetrical it is
|
||||
* occur. Since the fixed point representation is asymetrical it is
|
||||
* possible for 1/gamma to overflow the limit of 21474 and this means the
|
||||
* gamma value must be at least 5/100000 and hence at most 20000.0. For
|
||||
* safety the limits here are a little narrower. The values are 0.00016 to
|
||||
@@ -1183,7 +1176,7 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif /* GAMMA */
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
|
||||
@@ -1326,7 +1319,7 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
|
||||
* (1/white-y), so we can immediately see that as white-y approaches 0 the
|
||||
* accuracy inherent in the cHRM chunk drops off substantially.
|
||||
*
|
||||
* libpng arithmetic: a simple invertion of the above equations
|
||||
* libpng arithmetic: a simple inversion of the above equations
|
||||
* ------------------------------------------------------------
|
||||
*
|
||||
* white_scale = 1/white-y
|
||||
@@ -1819,7 +1812,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
PNG_UNUSED(pos)
|
||||
|
||||
/* This is recoverable, but make it unconditionally an app_error on write to
|
||||
* avoid writing invalid ICC profiles into PNG files. (I.e. we handle them
|
||||
* avoid writing invalid ICC profiles into PNG files (i.e., we handle them
|
||||
* on read, with a warning, but on write unless the app turns off
|
||||
* application errors the PNG won't be written.)
|
||||
*/
|
||||
@@ -1838,7 +1831,7 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
/* sRGB sets known gamma, end points and (from the chunk) intent. */
|
||||
/* IMPORTANT: these are not necessarily the values found in an ICC profile
|
||||
* because ICC profiles store values adapted to a D50 environment; it is
|
||||
* expected that the ICC profile mediaWhitePointTag will be D50, see the
|
||||
* expected that the ICC profile mediaWhitePointTag will be D50; see the
|
||||
* checks and code elsewhere to understand this better.
|
||||
*
|
||||
* These XYZ values, which are accurate to 5dp, produce rgb to gray
|
||||
@@ -2168,7 +2161,8 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
return 1; /* success, maybe with warnings */
|
||||
}
|
||||
|
||||
#if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
#if PNG_sRGB_PROFILE_CHECKS >= 0
|
||||
/* Information about the known ICC sRGB profiles */
|
||||
static const struct
|
||||
{
|
||||
@@ -2326,8 +2320,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_report(png_ptr,
|
||||
"out-of-date sRGB profile with no signature",
|
||||
PNG_CHUNK_WARNING);
|
||||
}
|
||||
|
||||
@@ -2340,8 +2334,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
||||
* way. This probably indicates a data error or uninformed hacking.
|
||||
* Fall through to "no match".
|
||||
*/
|
||||
png_chunk_report(png_ptr, "Not recognizing known sRGB profile that"
|
||||
" has been edited",
|
||||
png_chunk_report(png_ptr,
|
||||
"Not recognizing known sRGB profile that has been edited",
|
||||
PNG_CHUNK_WARNING);
|
||||
break;
|
||||
# endif
|
||||
@@ -2351,9 +2345,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
||||
|
||||
return 0; /* no match */
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_icc_set_sRGB(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
|
||||
@@ -2367,7 +2360,7 @@ png_icc_set_sRGB(png_const_structrp png_ptr,
|
||||
(void)png_colorspace_set_sRGB(png_ptr, colorspace,
|
||||
(int)/*already checked*/png_get_uint_32(profile+64));
|
||||
}
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
#endif /* sRGB */
|
||||
|
||||
int /* PRIVATE */
|
||||
png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
@@ -2459,10 +2452,21 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
|
||||
png_error(png_ptr, "internal error handling cHRM->XYZ");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* READ_RGB_TO_GRAY */
|
||||
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* This exists solely to work round a warning from GNU C. */
|
||||
static int /* PRIVATE */
|
||||
png_gt(size_t a, size_t b)
|
||||
{
|
||||
return a > b;
|
||||
}
|
||||
#else
|
||||
# define png_gt(a,b) ((a) > (b))
|
||||
#endif
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_IHDR(png_const_structrp png_ptr,
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
@@ -2477,22 +2481,43 @@ png_check_IHDR(png_const_structrp png_ptr,
|
||||
png_warning(png_ptr, "Image width is zero in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
else if (width > PNG_UINT_31_MAX)
|
||||
|
||||
if (width > PNG_UINT_31_MAX)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid image width in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
else
|
||||
|
||||
if (png_gt(((width + 7) & (~7)),
|
||||
((PNG_SIZE_MAX
|
||||
- 48 /* big_row_buf hack */
|
||||
- 1) /* filter byte */
|
||||
/ 8) /* 8-byte RGBA pixels */
|
||||
- 1)) /* extra max_pixel_depth pad */
|
||||
{
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (width > png_ptr->user_width_max)
|
||||
# else
|
||||
if (width > PNG_USER_WIDTH_MAX)
|
||||
# endif
|
||||
{
|
||||
png_warning(png_ptr, "Image width exceeds user limit in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
/* The size of the row must be within the limits of this architecture.
|
||||
* Because the read code can perform arbitrary transformations the
|
||||
* maximum size is checked here. Because the code in png_read_start_row
|
||||
* adds extra space "for safety's sake" in several places a conservative
|
||||
* limit is used here.
|
||||
*
|
||||
* NOTE: it would be far better to check the size that is actually used,
|
||||
* but the effect in the real world is minor and the changes are more
|
||||
* extensive, therefore much more dangerous and much more difficult to
|
||||
* write in a way that avoids compiler warnings.
|
||||
*/
|
||||
png_warning(png_ptr, "Image width is too large for this architecture");
|
||||
error = 1;
|
||||
}
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (width > png_ptr->user_width_max)
|
||||
#else
|
||||
if (width > PNG_USER_WIDTH_MAX)
|
||||
#endif
|
||||
{
|
||||
png_warning(png_ptr, "Image width exceeds user limit in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
|
||||
if (height == 0)
|
||||
@@ -2500,22 +2525,21 @@ png_check_IHDR(png_const_structrp png_ptr,
|
||||
png_warning(png_ptr, "Image height is zero in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
else if (height > PNG_UINT_31_MAX)
|
||||
|
||||
if (height > PNG_UINT_31_MAX)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid image height in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
else
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (height > png_ptr->user_height_max)
|
||||
#else
|
||||
if (height > PNG_USER_HEIGHT_MAX)
|
||||
#endif
|
||||
{
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (height > png_ptr->user_height_max)
|
||||
# else
|
||||
if (height > PNG_USER_HEIGHT_MAX)
|
||||
# endif
|
||||
{
|
||||
png_warning(png_ptr, "Image height exceeds user limit in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
png_warning(png_ptr, "Image height exceeds user limit in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
|
||||
/* Check other values */
|
||||
@@ -2554,7 +2578,7 @@ png_check_IHDR(png_const_structrp png_ptr,
|
||||
error = 1;
|
||||
}
|
||||
|
||||
# ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
/* Accept filter_method 64 (intrapixel differencing) only if
|
||||
* 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
|
||||
* 2. Libpng did not read a PNG signature (this filter_method is only
|
||||
@@ -2587,13 +2611,13 @@ png_check_IHDR(png_const_structrp png_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
# else
|
||||
#else
|
||||
if (filter_type != PNG_FILTER_TYPE_BASE)
|
||||
{
|
||||
png_warning(png_ptr, "Unknown filter method in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (error == 1)
|
||||
png_error(png_ptr, "Invalid IHDR data");
|
||||
@@ -2747,7 +2771,7 @@ png_check_fp_string(png_const_charp string, png_size_t size)
|
||||
|
||||
return 0; /* i.e. fail */
|
||||
}
|
||||
#endif /* pCAL or sCAL */
|
||||
#endif /* pCAL || sCAL */
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@@ -3175,7 +3199,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
|
||||
png_error(png_ptr, "ASCII conversion buffer too small");
|
||||
}
|
||||
# endif /* FIXED_POINT */
|
||||
#endif /* READ_SCAL */
|
||||
#endif /* SCAL */
|
||||
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
|
||||
!defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
|
||||
@@ -3193,7 +3217,7 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
|
||||
png_fixed_error(png_ptr, text);
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(text)
|
||||
PNG_UNUSED(text)
|
||||
# endif
|
||||
|
||||
return (png_fixed_point)r;
|
||||
@@ -3374,29 +3398,29 @@ png_gamma_significant(png_fixed_point gamma_val)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
# ifdef PNG_16BIT_SUPPORTED
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
/* A local convenience routine. */
|
||||
static png_fixed_point
|
||||
png_product2(png_fixed_point a, png_fixed_point b)
|
||||
{
|
||||
/* The required result is 1/a * 1/b; the following preserves accuracy. */
|
||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
double r = a * 1E-5;
|
||||
r *= b;
|
||||
r = floor(r+.5);
|
||||
|
||||
if (r <= 2147483647. && r >= -2147483648.)
|
||||
return (png_fixed_point)r;
|
||||
# else
|
||||
#else
|
||||
png_fixed_point res;
|
||||
|
||||
if (png_muldiv(&res, a, b, 100000) != 0)
|
||||
return res;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return 0; /* overflow */
|
||||
}
|
||||
# endif /* 16BIT */
|
||||
#endif /* 16BIT */
|
||||
|
||||
/* The inverse of the above. */
|
||||
png_fixed_point
|
||||
@@ -3404,12 +3428,15 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b)
|
||||
{
|
||||
/* The required result is 1/a * 1/b; the following preserves accuracy. */
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
double r = 1E15/a;
|
||||
r /= b;
|
||||
r = floor(r+.5);
|
||||
if (a != 0 && b != 0)
|
||||
{
|
||||
double r = 1E15/a;
|
||||
r /= b;
|
||||
r = floor(r+.5);
|
||||
|
||||
if (r <= 2147483647. && r >= -2147483648.)
|
||||
return (png_fixed_point)r;
|
||||
if (r <= 2147483647. && r >= -2147483648.)
|
||||
return (png_fixed_point)r;
|
||||
}
|
||||
#else
|
||||
/* This may overflow because the range of png_fixed_point isn't symmetric,
|
||||
* but this API is only used for the product of file and screen gamma so it
|
||||
@@ -3548,6 +3575,7 @@ png_log8bit(unsigned int x)
|
||||
* Zero (257): 0
|
||||
* End (258): 23499
|
||||
*/
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
static png_int_32
|
||||
png_log16bit(png_uint_32 x)
|
||||
{
|
||||
@@ -3598,6 +3626,7 @@ png_log16bit(png_uint_32 x)
|
||||
/* Safe, because the result can't have more than 20 bits: */
|
||||
return (png_int_32)((lg2 + 2048) >> 12);
|
||||
}
|
||||
#endif /* 16BIT */
|
||||
|
||||
/* The 'exp()' case must invert the above, taking a 20-bit fixed point
|
||||
* logarithmic value and returning a 16 or 8-bit number as appropriate. In
|
||||
@@ -3698,7 +3727,7 @@ png_exp8bit(png_fixed_point lg2)
|
||||
* step.
|
||||
*/
|
||||
x -= x >> 8;
|
||||
return (png_byte)((x + 0x7fffffU) >> 24);
|
||||
return (png_byte)(((x + 0x7fffffU) >> 24) & 0xff);
|
||||
}
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
@@ -3721,7 +3750,31 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
|
||||
if (value > 0 && value < 255)
|
||||
{
|
||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
double r = floor(255*pow(value/255.,gamma_val*.00001)+.5);
|
||||
/* 'value' is unsigned, ANSI-C90 requires the compiler to correctly
|
||||
* convert this to a floating point value. This includes values that
|
||||
* would overflow if 'value' were to be converted to 'int'.
|
||||
*
|
||||
* Apparently GCC, however, does an intermediate conversion to (int)
|
||||
* on some (ARM) but not all (x86) platforms, possibly because of
|
||||
* hardware FP limitations. (E.g. if the hardware conversion always
|
||||
* assumes the integer register contains a signed value.) This results
|
||||
* in ANSI-C undefined behavior for large values.
|
||||
*
|
||||
* Other implementations on the same machine might actually be ANSI-C90
|
||||
* conformant and therefore compile spurious extra code for the large
|
||||
* values.
|
||||
*
|
||||
* We can be reasonably sure that an unsigned to float conversion
|
||||
* won't be faster than an int to float one. Therefore this code
|
||||
* assumes responsibility for the undefined behavior, which it knows
|
||||
* can't happen because of the check above.
|
||||
*
|
||||
* Note the argument to this routine is an (unsigned int) because, on
|
||||
* 16-bit platforms, it is assigned a value which might be out of
|
||||
* range for an (int); that would result in undefined behavior in the
|
||||
* caller if the *argument* ('value') were to be declared (int).
|
||||
*/
|
||||
double r = floor(255*pow((int)/*SAFE*/value/255.,gamma_val*.00001)+.5);
|
||||
return (png_byte)r;
|
||||
# else
|
||||
png_int_32 lg2 = png_log8bit(value);
|
||||
@@ -3735,7 +3788,7 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
|
||||
# endif
|
||||
}
|
||||
|
||||
return (png_byte)value;
|
||||
return (png_byte)(value & 0xff);
|
||||
}
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
@@ -3745,7 +3798,13 @@ png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)
|
||||
if (value > 0 && value < 65535)
|
||||
{
|
||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5);
|
||||
/* The same (unsigned int)->(double) constraints apply here as above,
|
||||
* however in this case the (unsigned int) to (int) conversion can
|
||||
* overflow on an ANSI-C90 compliant system so the cast needs to ensure
|
||||
* that this is not possible.
|
||||
*/
|
||||
double r = floor(65535*pow((png_int_32)value/65535.,
|
||||
gamma_val*.00001)+.5);
|
||||
return (png_uint_16)r;
|
||||
# else
|
||||
png_int_32 lg2 = png_log16bit(value);
|
||||
@@ -3799,6 +3858,12 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
{
|
||||
/* Various values derived from 'shift': */
|
||||
PNG_CONST unsigned int num = 1U << (8U - shift);
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
/* CSE the division and work round wacky GCC warnings (see the comments
|
||||
* in png_gamma_8bit_correct for where these come from.)
|
||||
*/
|
||||
PNG_CONST double fmax = 1./(((png_int_32)1 << (16U - shift))-1);
|
||||
#endif
|
||||
PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
|
||||
PNG_CONST unsigned int max_by_2 = 1U << (15U-shift);
|
||||
unsigned int i;
|
||||
@@ -3830,7 +3895,10 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
png_uint_32 ig = (j << (8-shift)) + i;
|
||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
/* Inline the 'max' scaling operation: */
|
||||
double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5);
|
||||
/* See png_gamma_8bit_correct for why the cast to (int) is
|
||||
* required here.
|
||||
*/
|
||||
double d = floor(65535.*pow(ig*fmax, gamma_val*.00001)+.5);
|
||||
sub_table[j] = (png_uint_16)d;
|
||||
# else
|
||||
if (shift != 0)
|
||||
@@ -3942,7 +4010,7 @@ png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
|
||||
|
||||
else
|
||||
for (i=0; i<256; ++i)
|
||||
table[i] = (png_byte)i;
|
||||
table[i] = (png_byte)(i & 0xff);
|
||||
}
|
||||
|
||||
/* Used from png_read_destroy and below to release the memory used by the gamma
|
||||
@@ -4082,7 +4150,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
||||
*
|
||||
*/
|
||||
if (sig_bit > 0 && sig_bit < 16U)
|
||||
shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */
|
||||
/* shift == insignificant bits */
|
||||
shift = (png_byte)((16U - sig_bit) & 0xff);
|
||||
|
||||
else
|
||||
shift = 0; /* keep all 16 bits */
|
||||
@@ -4151,7 +4220,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
|
||||
int setting = (2 + (onoff != 0)) << option;
|
||||
int current = png_ptr->options;
|
||||
|
||||
png_ptr->options = (png_byte)((current & ~mask) | setting);
|
||||
png_ptr->options = (png_byte)(((current & ~mask) | setting) & 0xff);
|
||||
|
||||
return (current & mask) >> option;
|
||||
}
|
||||
@@ -4218,7 +4287,7 @@ const png_uint_16 png_sRGB_table[256] =
|
||||
57105,57646,58190,58737,59287,59840,60396,60955,
|
||||
61517,62082,62650,63221,63795,64372,64952,65535
|
||||
};
|
||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||
#endif /* SIMPLIFIED_READ */
|
||||
|
||||
/* The base/delta tables are required for both read and write (but currently
|
||||
* only the simplified versions.)
|
||||
@@ -4418,4 +4487,4 @@ png_image_error(png_imagep image, png_const_charp error_message)
|
||||
}
|
||||
|
||||
#endif /* SIMPLIFIED READ/WRITE */
|
||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
98
png.h
98
png.h
@@ -1,8 +1,9 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.15beta03 - November 3, 2014
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* libpng version 1.6.17rc03, March 12, 2015
|
||||
*
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -11,7 +12,7 @@
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.15beta03 - November 3, 2014: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.6.17rc03, March 12, 2015: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
@@ -206,7 +207,14 @@
|
||||
* 1.6.14beta01-07 16 10614 16.so.16.14[.0]
|
||||
* 1.6.14rc01-02 16 10614 16.so.16.14[.0]
|
||||
* 1.6.14 16 10614 16.so.16.14[.0]
|
||||
* 1.6.15beta01-03 16 10615 16.so.16.15[.0]
|
||||
* 1.6.15beta01-08 16 10615 16.so.16.15[.0]
|
||||
* 1.6.15rc01-03 16 10615 16.so.16.15[.0]
|
||||
* 1.6.15 16 10615 16.so.16.15[.0]
|
||||
* 1.6.16beta01-03 16 10616 16.so.16.16[.0]
|
||||
* 1.6.16rc01-02 16 10616 16.so.16.16[.0]
|
||||
* 1.6.16 16 10616 16.so.16.16[.0]
|
||||
* 1.6.17beta01-06 16 10617 16.so.16.17[.0]
|
||||
* 1.6.17rc01-03 16 10617 16.so.16.17[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
@@ -238,8 +246,8 @@
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.15beta03, November 3, 2014, are
|
||||
* Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.17rc03, March 12, 2015, are
|
||||
* Copyright (c) 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
* with the following individual added to the list of Contributing Authors:
|
||||
*
|
||||
@@ -350,13 +358,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* November 3, 2014
|
||||
* March 12, 2015
|
||||
*
|
||||
* 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.6.15beta03 are Y2K compliant. It is my belief that
|
||||
* upward through 1.6.17rc03 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
|
||||
@@ -418,9 +426,9 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.15beta03"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.17rc03"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.6.15beta03 - November 3, 2014\n"
|
||||
" libpng version 1.6.17rc03 - March 12, 2015\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
@@ -428,7 +436,7 @@
|
||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 6
|
||||
#define PNG_LIBPNG_VER_RELEASE 15
|
||||
#define PNG_LIBPNG_VER_RELEASE 17
|
||||
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
@@ -451,7 +459,7 @@
|
||||
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
|
||||
PNG_LIBPNG_BUILD_PRIVATE */
|
||||
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_RC
|
||||
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||
* We must not include leading zeros.
|
||||
@@ -459,7 +467,7 @@
|
||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10615 /* 1.6.15 */
|
||||
#define PNG_LIBPNG_VER 10617 /* 1.6.17 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
@@ -564,7 +572,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_6_15beta03;
|
||||
typedef char* png_libpng_version_1_6_17rc03;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
@@ -1177,7 +1185,7 @@ PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,
|
||||
|
||||
/* Convert from time_t to png_time. Uses gmtime() */
|
||||
PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));
|
||||
#endif /* PNG_CONVERT_tIME_SUPPORTED */
|
||||
#endif /* CONVERT_tIME */
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
|
||||
@@ -1383,7 +1391,7 @@ PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,
|
||||
/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
|
||||
PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,
|
||||
png_uint_32 filler, int flags));
|
||||
#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
|
||||
#endif /* READ_FILLER || WRITE_FILLER */
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Swap bytes in 16-bit depth files. */
|
||||
@@ -1573,6 +1581,7 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
|
||||
#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
|
||||
#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* These functions give the user control over the scan-line filtering in
|
||||
* libpng and the compression methods used by zlib. These functions are
|
||||
* mainly useful for testing, as the defaults should work with most users.
|
||||
@@ -1647,7 +1656,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
|
||||
(png_structrp png_ptr, int heuristic_method, int num_weights,
|
||||
png_const_fixed_point_p filter_weights,
|
||||
png_const_fixed_point_p filter_costs))
|
||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_WEIGHTED_FILTER */
|
||||
|
||||
/* Heuristic used for row filter selection. These defines should NOT be
|
||||
* changed.
|
||||
@@ -1657,7 +1666,6 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
|
||||
#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
|
||||
#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* Set the library compression level. Currently, valid values range from
|
||||
* 0 - 9, corresponding directly to the zlib compression levels 0 - 9
|
||||
* (0 - no compression, 9 - "maximal" compression). Note that tests have
|
||||
@@ -1665,6 +1673,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
|
||||
* for PNG images, and do considerably fewer caclulations. In the future,
|
||||
* these values may not correspond directly to the zlib compression levels.
|
||||
*/
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,
|
||||
int level));
|
||||
|
||||
@@ -1682,7 +1691,7 @@ PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,
|
||||
|
||||
PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,
|
||||
int method));
|
||||
#endif
|
||||
#endif /* WRITE_CUSTOMIZE_COMPRESSION */
|
||||
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
/* Also set zlib parameters for compressing non-IDAT chunks */
|
||||
@@ -1703,7 +1712,8 @@ PNG_EXPORT(225, void, png_set_text_compression_window_bits,
|
||||
|
||||
PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
|
||||
int method));
|
||||
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
|
||||
#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
|
||||
#endif /* WRITE */
|
||||
|
||||
/* These next functions are called for input/output, memory, and error
|
||||
* handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
|
||||
@@ -1814,7 +1824,7 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
|
||||
*
|
||||
* The integer return from the callback function is interpreted thus:
|
||||
*
|
||||
* negative: An error occured, png_chunk_error will be called.
|
||||
* negative: An error occurred; png_chunk_error will be called.
|
||||
* zero: The chunk was not handled, the chunk will be saved. A critical
|
||||
* chunk will cause an error at this point unless it is to be saved.
|
||||
* positive: The chunk was handled, libpng will ignore/discard it.
|
||||
@@ -1870,7 +1880,7 @@ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));
|
||||
*/
|
||||
PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,
|
||||
png_bytep old_row, png_const_bytep new_row));
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,
|
||||
png_alloc_size_t size), PNG_ALLOCATED);
|
||||
@@ -2071,7 +2081,7 @@ PNG_EXPORT(128, png_int_32, png_get_x_offset_microns,
|
||||
PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
|
||||
(png_const_structrp png_ptr, png_const_inforp info_ptr));
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
#endif /* EASY_ACCESS */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Returns pointer to signature string read from PNG header */
|
||||
@@ -2323,7 +2333,7 @@ PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,
|
||||
PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int unit,
|
||||
png_const_charp swidth, png_const_charp sheight));
|
||||
#endif /* PNG_sCAL_SUPPORTED */
|
||||
#endif /* sCAL */
|
||||
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Provide the default handling for all unknown chunks or, optionally, for
|
||||
@@ -2551,8 +2561,8 @@ PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,
|
||||
PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
|
||||
int *unit_type));
|
||||
# endif /* PNG_pHYs_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
|
||||
# endif /* pHYs */
|
||||
#endif /* INCH_CONVERSIONS */
|
||||
|
||||
/* Added in libpng-1.4.0 */
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
@@ -2575,7 +2585,7 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
|
||||
# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */
|
||||
# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */
|
||||
# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */
|
||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||
#endif /* IO_STATE */
|
||||
|
||||
/* Interlace support. The following macros are always defined so that if
|
||||
* libpng interlace handling is turned off the macros may be used to handle
|
||||
@@ -2659,27 +2669,29 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
|
||||
* (png_uint_16)(alpha) \
|
||||
+ (png_uint_16)(bg)*(png_uint_16)(255 \
|
||||
- (png_uint_16)(alpha)) + 128); \
|
||||
(composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
|
||||
(composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); }
|
||||
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
{ png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
|
||||
* (png_uint_32)(alpha) \
|
||||
+ (png_uint_32)(bg)*(65535 \
|
||||
- (png_uint_32)(alpha)) + 32768); \
|
||||
(composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
|
||||
(composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); }
|
||||
|
||||
#else /* Standard method using integer division */
|
||||
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
(composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
|
||||
127) / 255)
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
(composite) = \
|
||||
(png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
|
||||
127) / 255))
|
||||
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
(composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
|
||||
32767) / 65535)
|
||||
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
|
||||
(composite) = \
|
||||
(png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
|
||||
32767) / 65535))
|
||||
#endif /* READ_COMPOSITE_NODIV */
|
||||
|
||||
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
|
||||
@@ -3107,7 +3119,7 @@ PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,
|
||||
PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,
|
||||
FILE* file));
|
||||
/* The PNG header is read from the stdio FILE object. */
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* STDIO */
|
||||
|
||||
PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,
|
||||
png_const_voidp memory, png_size_t size));
|
||||
@@ -3152,7 +3164,7 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
|
||||
/* Free any data allocated by libpng in image->opaque, setting the pointer to
|
||||
* NULL. May be called at any time after the structure is initialized.
|
||||
*/
|
||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||
#endif /* SIMPLIFIED_READ */
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
@@ -3198,12 +3210,12 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
||||
*
|
||||
* Note that the write API does not support interlacing or sub-8-bit pixels.
|
||||
*/
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */
|
||||
#endif /* STDIO */
|
||||
#endif /* SIMPLIFIED_WRITE */
|
||||
/*******************************************************************************
|
||||
* END OF SIMPLIFIED API
|
||||
******************************************************************************/
|
||||
#endif /* PNG_SIMPLIFIED_{READ|WRITE}_SUPPORTED */
|
||||
#endif /* SIMPLIFIED_{READ|WRITE} */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
|
||||
@@ -3251,7 +3263,7 @@ PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
|
||||
|
||||
PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
|
||||
int onoff));
|
||||
#endif /* PNG_SET_OPTION_SUPPORTED */
|
||||
#endif /* SET_OPTION */
|
||||
|
||||
/*******************************************************************************
|
||||
* END OF HARDWARE AND SOFTWARE OPTIONS
|
||||
|
||||
28
pngconf.h
28
pngconf.h
@@ -1,9 +1,9 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.15beta03 - November 3, 2014
|
||||
* libpng version 1.6.17rc03, (PENDING RELEASE)
|
||||
*
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -11,9 +11,7 @@
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
* Any machine specific code is near the front of this file, so if you
|
||||
* are configuring libpng for a machine, you may want to read the section
|
||||
* starting here down to where it starts to typedef png_color, png_text,
|
||||
* and png_info.
|
||||
@@ -22,26 +20,6 @@
|
||||
#ifndef PNGCONF_H
|
||||
#define PNGCONF_H
|
||||
|
||||
/* To do: Do all of this in scripts/pnglibconf.dfa */
|
||||
#ifdef PNG_SAFE_LIMITS_SUPPORTED
|
||||
# ifdef PNG_USER_WIDTH_MAX
|
||||
# undef PNG_USER_WIDTH_MAX
|
||||
# define PNG_USER_WIDTH_MAX 1000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_HEIGHT_MAX
|
||||
# undef PNG_USER_HEIGHT_MAX
|
||||
# define PNG_USER_HEIGHT_MAX 1000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# undef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_CHUNK_CACHE_MAX
|
||||
# undef PNG_USER_CHUNK_CACHE_MAX
|
||||
# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||
|
||||
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Copyright (c) 1998-2013 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.)
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
|
||||
22
pngerror.c
22
pngerror.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
@@ -27,7 +27,7 @@ static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
* should not be changed. If there is a need to handle errors differently,
|
||||
@@ -103,7 +103,7 @@ png_err,(png_const_structrp png_ptr),PNG_NORETURN)
|
||||
use the default handler, which will not return. */
|
||||
png_default_error(png_ptr, "");
|
||||
}
|
||||
#endif /* PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* ERROR_TEXT */
|
||||
|
||||
/* Utility to safely appends strings to a buffer. This never errors out so
|
||||
* error checking is not required in the caller.
|
||||
@@ -355,7 +355,7 @@ png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||
*/
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
@@ -473,7 +473,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
buffer[iout] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* WARNINGS || ERROR_TEXT */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
@@ -490,7 +490,7 @@ png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* READ && ERROR_TEXT */
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void PNGAPI
|
||||
@@ -506,7 +506,7 @@ png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
@@ -525,7 +525,7 @@ png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
@@ -824,7 +824,7 @@ png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
#endif
|
||||
PNG_UNUSED(png_ptr) /* Make compiler happy */
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
/* This function is called when the application wants to use another method
|
||||
* of handling errors and warnings. Note that the error function MUST NOT
|
||||
@@ -959,5 +959,5 @@ png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* SIMPLIFIED READ/WRITE */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
50
pngget.c
50
pngget.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -455,12 +455,12 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
return (retval);
|
||||
}
|
||||
#endif /* PNG_pHYs_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
|
||||
#endif /* pHYs */
|
||||
#endif /* INCH_CONVERSIONS */
|
||||
|
||||
/* png_get_channels really belongs in here, too, but it's been around longer */
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
#endif /* EASY_ACCESS */
|
||||
|
||||
|
||||
png_byte PNGAPI
|
||||
@@ -799,14 +799,20 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "IHDR");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
|
||||
height == NULL || bit_depth == NULL || color_type == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return (0);
|
||||
|
||||
*width = info_ptr->width;
|
||||
*height = info_ptr->height;
|
||||
*bit_depth = info_ptr->bit_depth;
|
||||
*color_type = info_ptr->color_type;
|
||||
if (width != NULL)
|
||||
*width = info_ptr->width;
|
||||
|
||||
if (height != NULL)
|
||||
*height = info_ptr->height;
|
||||
|
||||
if (bit_depth != NULL)
|
||||
*bit_depth = info_ptr->bit_depth;
|
||||
|
||||
if (color_type != NULL)
|
||||
*color_type = info_ptr->color_type;
|
||||
|
||||
if (compression_type != NULL)
|
||||
*compression_type = info_ptr->compression_type;
|
||||
@@ -1117,7 +1123,7 @@ png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_byte PNGAPI
|
||||
png_get_rgb_to_gray_status (png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
|
||||
return (png_byte)((png_ptr ? png_ptr->rgb_to_gray_status : 0) & 0xff);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1135,21 +1141,21 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
return png_ptr->IDAT_read_size;
|
||||
# else
|
||||
#else
|
||||
return PNG_IDAT_READ_SIZE;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
else
|
||||
return png_ptr->zbuffer_size;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
@@ -1180,7 +1186,7 @@ png_get_chunk_malloc_max (png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
|
||||
}
|
||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||
#endif /* SET_USER_LIMITS */
|
||||
|
||||
/* These functions were added to libpng 1.4.0 */
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
@@ -1195,7 +1201,7 @@ png_get_io_chunk_type (png_const_structrp png_ptr)
|
||||
{
|
||||
return png_ptr->chunk_name;
|
||||
}
|
||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||
#endif /* IO_STATE */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
@@ -1210,4 +1216,4 @@ png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
/* pnginfo.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 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.)
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@@ -121,7 +120,7 @@ struct png_info_def
|
||||
int num_text; /* number of comments read or comments to write */
|
||||
int max_text; /* current size of text array */
|
||||
png_textp text; /* array of comments read or comments to write */
|
||||
#endif /* PNG_TEXT_SUPPORTED */
|
||||
#endif /* TEXT */
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
/* The tIME chunk holds the last time the displayed image data was
|
||||
|
||||
14
pngmem.c
14
pngmem.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -41,7 +41,7 @@ png_destroy_png_struct(png_structrp png_ptr)
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||
* 64K. However, zlib may allocate more than 64K if you don't tell
|
||||
* it not to. See zconf.h and png.h for more information. zlib does
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
@@ -199,7 +199,7 @@ png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* USER_MEM */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will issue a png_warning and return NULL instead of issuing a
|
||||
@@ -244,7 +244,7 @@ png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* USER_MEM */
|
||||
|
||||
free(ptr);
|
||||
}
|
||||
@@ -277,5 +277,5 @@ png_get_mem_ptr(png_const_structrp png_ptr)
|
||||
|
||||
return png_ptr->mem_ptr;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* USER_MEM */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
16
pngpread.c
16
pngpread.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -168,7 +168,7 @@ png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),
|
||||
num_to_check);
|
||||
png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);
|
||||
png_ptr->sig_bytes = (png_byte)((png_ptr->sig_bytes + num_to_check) & 0xff);
|
||||
|
||||
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
|
||||
{
|
||||
@@ -726,7 +726,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
* or the stream marked as finished.
|
||||
*/
|
||||
while (png_ptr->zstream.avail_in > 0 &&
|
||||
!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -1036,6 +1036,7 @@ png_push_process_row(png_structrp png_ptr)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
@@ -1045,6 +1046,7 @@ png_push_process_row(png_structrp png_ptr)
|
||||
void /* PRIVATE */
|
||||
png_read_push_finish_row(png_structrp png_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
@@ -1069,6 +1071,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
if (png_ptr->row_number < png_ptr->num_rows)
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
if (png_ptr->interlaced != 0)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
@@ -1103,6 +1106,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
|
||||
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
|
||||
}
|
||||
#endif /* READ_INTERLACING */
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
@@ -1127,6 +1131,7 @@ png_push_have_row(png_structrp png_ptr, png_bytep row)
|
||||
(int)png_ptr->pass);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
void PNGAPI
|
||||
png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
|
||||
png_const_bytep new_row)
|
||||
@@ -1141,6 +1146,7 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
|
||||
if (new_row != NULL)
|
||||
png_combine_row(png_ptr, old_row, 1/*blocky display*/);
|
||||
}
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
void PNGAPI
|
||||
png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,
|
||||
@@ -1165,4 +1171,4 @@ png_get_progressive_ptr(png_const_structrp png_ptr)
|
||||
|
||||
return png_ptr->io_ptr;
|
||||
}
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
94
pngpriv.h
94
pngpriv.h
@@ -1,13 +1,11 @@
|
||||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
* Last changed in libpng 1.6.10 [March 6, 1014]]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@@ -123,8 +121,8 @@
|
||||
* Note that gcc-4.9 defines __ARM_NEON instead of __ARM_NEON__, so we
|
||||
* check both variants.
|
||||
*/
|
||||
# if defined(PNG_USE_ARM_NEON) && (defined(__ARM_NEON__) || \
|
||||
defined(__ARM_NEON)) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
|
||||
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
# define PNG_ARM_NEON_OPT 2
|
||||
# else
|
||||
# define PNG_ARM_NEON_OPT 0
|
||||
@@ -172,7 +170,7 @@
|
||||
*/
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 2
|
||||
# endif /* __ARM_NEON__ */
|
||||
# endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */
|
||||
# endif /* !PNG_ARM_NEON_IMPLEMENTATION */
|
||||
|
||||
# ifndef PNG_ARM_NEON_IMPLEMENTATION
|
||||
/* Use the intrinsics code by default. */
|
||||
@@ -300,46 +298,9 @@
|
||||
|
||||
/* SECURITY and SAFETY:
|
||||
*
|
||||
* By default libpng is built without any internal limits on image size,
|
||||
* individual heap (png_malloc) allocations or the total amount of memory used.
|
||||
* If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used
|
||||
* (unless individually overridden). These limits are believed to be fairly
|
||||
* safe, but builders of secure systems should verify the values against the
|
||||
* real system capabilities.
|
||||
*/
|
||||
#ifdef PNG_SAFE_LIMITS_SUPPORTED
|
||||
/* 'safe' limits */
|
||||
# ifndef PNG_USER_WIDTH_MAX
|
||||
# define PNG_USER_WIDTH_MAX 1000000
|
||||
# endif
|
||||
# ifndef PNG_USER_HEIGHT_MAX
|
||||
# define PNG_USER_HEIGHT_MAX 1000000
|
||||
# endif
|
||||
# ifndef PNG_USER_CHUNK_CACHE_MAX
|
||||
# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||
# endif
|
||||
# ifndef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# define PNG_USER_CHUNK_MALLOC_MAX 8000000
|
||||
# endif
|
||||
#else
|
||||
/* values for no limits */
|
||||
# ifndef PNG_USER_WIDTH_MAX
|
||||
# define PNG_USER_WIDTH_MAX 0x7fffffff
|
||||
# endif
|
||||
# ifndef PNG_USER_HEIGHT_MAX
|
||||
# define PNG_USER_HEIGHT_MAX 0x7fffffff
|
||||
# endif
|
||||
# ifndef PNG_USER_CHUNK_CACHE_MAX
|
||||
# define PNG_USER_CHUNK_CACHE_MAX 0
|
||||
# endif
|
||||
# ifndef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# define PNG_USER_CHUNK_MALLOC_MAX 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Moved to pngpriv.h at libpng-1.5.0 */
|
||||
/* NOTE: some of these may have been used in external applications as
|
||||
* these definitions were exposed in pngconf.h prior to 1.5.
|
||||
* libpng is built with support for internal limits on image dimensions and
|
||||
* memory usage. These are documented in scripts/pnglibconf.dfa of the
|
||||
* source and recorded in the machine generated header file pnglibconf.h.
|
||||
*/
|
||||
|
||||
/* If you are running on a machine where you cannot allocate more
|
||||
@@ -582,13 +543,13 @@
|
||||
#define PNG_RGB_TO_GRAY_WARN 0x400000
|
||||
#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
|
||||
#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */
|
||||
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
|
||||
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
|
||||
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
|
||||
/* 0x8000000 unused */
|
||||
/* 0x10000000 unused */
|
||||
/* 0x20000000 unused */
|
||||
/* 0x40000000 unused */
|
||||
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
|
||||
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
|
||||
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
|
||||
/* 0x8000000 unused */
|
||||
/* 0x10000000 unused */
|
||||
/* 0x20000000 unused */
|
||||
/* 0x40000000 unused */
|
||||
/* Flags for png_create_struct */
|
||||
#define PNG_STRUCT_PNG 0x0001
|
||||
#define PNG_STRUCT_INFO 0x0002
|
||||
@@ -780,15 +741,17 @@
|
||||
* macro will fail on top-bit-set values because of the sign extension.
|
||||
*/
|
||||
#define PNG_CHUNK_FROM_STRING(s)\
|
||||
PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
|
||||
PNG_U32(0xff & (s)[0], 0xff & (s)[1], 0xff & (s)[2], 0xff & (s)[3])
|
||||
|
||||
/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
|
||||
* signed and the argument is a (char[]) This macro will fail miserably on
|
||||
* systems where (char) is more than 8 bits.
|
||||
*/
|
||||
#define PNG_STRING_FROM_CHUNK(s,c)\
|
||||
(void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\
|
||||
((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))
|
||||
(void)(((char*)(s))[0]=(char)(((c)>>24) & 0xff), \
|
||||
((char*)(s))[1]=(char)(((c)>>16) & 0xff),\
|
||||
((char*)(s))[2]=(char)(((c)>>8) & 0xff), \
|
||||
((char*)(s))[3]=(char)((c & 0xff)))
|
||||
|
||||
/* Do the same but terminate with a null character. */
|
||||
#define PNG_CSTRING_FROM_CHUNK(s,c)\
|
||||
@@ -850,12 +813,13 @@ PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
|
||||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
|
||||
PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
|
||||
#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
|
||||
((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
|
||||
#define PNG_sRGB_FROM_LINEAR(linear) \
|
||||
((png_byte)(0xff & ((png_sRGB_base[(linear)>>15] \
|
||||
+ ((((linear) & 0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)))
|
||||
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
|
||||
* encoded value with maximum error 0.646365. Note that the input is not a
|
||||
* 16-bit value; it has been multiplied by 255! */
|
||||
#endif /* PNG_SIMPLIFIED_READ/WRITE */
|
||||
#endif /* SIMPLIFIED_READ/WRITE */
|
||||
|
||||
|
||||
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
|
||||
@@ -910,7 +874,7 @@ PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,
|
||||
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
|
||||
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* Internal array allocator, outputs no error or warning messages on failure,
|
||||
* just returns NULL.
|
||||
* just returns NULL.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,
|
||||
int nelements, size_t element_size),PNG_ALLOCATED);
|
||||
@@ -1229,7 +1193,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
/* Finish a row while reading, dealing with interlacing passes, etc. */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
/* Initialize the row buffers, etc. */
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
|
||||
@@ -1305,7 +1269,7 @@ PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif /* PNG_READ_iCCP_SUPPORTED */
|
||||
#endif /* READ_iCCP */
|
||||
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,
|
||||
@@ -1340,7 +1304,7 @@ PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif /* PNG_READ_sPLT_SUPPORTED */
|
||||
#endif /* READ_sPLT */
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,
|
||||
@@ -1454,7 +1418,7 @@ PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr),PNG_EMPTY);
|
||||
# endif
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
/* Added at libpng version 1.6.0 */
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
|
||||
63
pngread.c
63
pngread.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -44,7 +44,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
{
|
||||
png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
|
||||
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* USER_MEM */
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@@ -252,7 +252,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
/* Optional call to update the users info_ptr structure */
|
||||
void PNGAPI
|
||||
@@ -302,7 +302,7 @@ png_start_read_image(png_structrp png_ptr)
|
||||
"png_start_read_image/png_read_update_info: duplicate call");
|
||||
}
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
@@ -369,7 +369,7 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
#endif /* MNG_FEATURES */
|
||||
|
||||
void PNGAPI
|
||||
png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
@@ -436,7 +436,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined");
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* If interlaced and we do not need a new row, combine row and return.
|
||||
@@ -605,7 +605,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
(*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
|
||||
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
/* Read one or more rows of image data. If the image is interlaced,
|
||||
@@ -672,7 +672,7 @@ png_read_rows(png_structrp png_ptr, png_bytepp row,
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
/* Read the entire image. If the image has an alpha channel or a tRNS
|
||||
@@ -746,7 +746,7 @@ png_read_image(png_structrp png_ptr, png_bytepp image)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
/* Read the end of the PNG file. Will not read past the end of the
|
||||
@@ -814,8 +814,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
/* Zero length IDATs are legal after the last IDAT has been
|
||||
* read, but not after other chunks have been read.
|
||||
*/
|
||||
if ((length > 0) ||
|
||||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
||||
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
|
||||
png_crc_finish(png_ptr, length);
|
||||
@@ -913,7 +912,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
} while ((png_ptr->mode & PNG_HAVE_IEND) == 0);
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
/* Free all memory used in the read struct */
|
||||
static void
|
||||
@@ -1221,8 +1220,8 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
PNG_UNUSED(params)
|
||||
}
|
||||
#endif /* PNG_INFO_IMAGE_SUPPORTED */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* INFO_IMAGE */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
/* SIMPLIFIED READ
|
||||
@@ -1508,7 +1507,7 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* STDIO */
|
||||
|
||||
static void PNGCBAPI
|
||||
png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)
|
||||
@@ -1619,14 +1618,14 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
|
||||
|
||||
/* But do not ignore image data handling chunks */
|
||||
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT,
|
||||
chunks_to_process, (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)
|
||||
#else
|
||||
# define PNG_SKIP_CHUNKS(p) ((void)0)
|
||||
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
|
||||
#endif /* HANDLE_AS_UNKNOWN */
|
||||
|
||||
/* The following macro gives the exact rounded answer for all values in the
|
||||
* range 0..255 (it actually divides by 51.2, but the rounding still generates
|
||||
@@ -2053,7 +2052,7 @@ make_rgb_colormap(png_image_read_control *display)
|
||||
|
||||
/* Return a palette index to the above palette given three 8-bit sRGB values. */
|
||||
#define PNG_RGB_INDEX(r,g,b) \
|
||||
((png_byte)(6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b)))
|
||||
((png_byte)(0xff & (6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b))))
|
||||
|
||||
static int
|
||||
png_image_read_colormap(png_voidp argument)
|
||||
@@ -2286,8 +2285,14 @@ png_image_read_colormap(png_voidp argument)
|
||||
output_processing = PNG_CMAP_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef __COVERITY__
|
||||
/* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
|
||||
* here.
|
||||
*/
|
||||
back_alpha = 255;
|
||||
#else
|
||||
back_alpha = output_encoding == P_LINEAR ? 65535 : 255;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* output_processing means that the libpng-processed row will be
|
||||
@@ -2412,7 +2417,14 @@ png_image_read_colormap(png_voidp argument)
|
||||
*/
|
||||
background_index = i;
|
||||
png_create_colormap_entry(display, i++, back_r, back_g, back_b,
|
||||
output_encoding == P_LINEAR ? 65535U : 255U, output_encoding);
|
||||
#ifdef __COVERITY__
|
||||
/* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
|
||||
* here.
|
||||
*/ 255U,
|
||||
#else
|
||||
output_encoding == P_LINEAR ? 65535U : 255U,
|
||||
#endif
|
||||
output_encoding);
|
||||
|
||||
/* For non-opaque input composite on the sRGB background - this
|
||||
* requires inverting the encoding for each component. The input
|
||||
@@ -3013,7 +3025,8 @@ png_image_read_and_map(png_voidp argument)
|
||||
*outrow = gray;
|
||||
|
||||
else
|
||||
*outrow = (png_byte)(PNG_CMAP_TRANS_BACKGROUND+1);
|
||||
*outrow =
|
||||
(png_byte)(0xff & (PNG_CMAP_TRANS_BACKGROUND+1));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3246,7 +3259,7 @@ png_image_read_composite(png_voidp argument)
|
||||
png_uint_32 width = image->width;
|
||||
ptrdiff_t step_row = display->row_bytes;
|
||||
unsigned int channels =
|
||||
(image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
||||
(image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
||||
int pass;
|
||||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
@@ -4117,5 +4130,5 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* SIMPLIFIED_READ */
|
||||
#endif /* READ */
|
||||
|
||||
8
pngrio.c
8
pngrio.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -26,7 +26,7 @@
|
||||
* reads from a file pointer. Note that this routine sometimes gets called
|
||||
* with very small lengths, so you should implement some kind of simple
|
||||
* buffering if you are using unbuffered reads. This should never be asked
|
||||
* to read more then 64K on a 16 bit machine.
|
||||
* to read more than 64K on a 16 bit machine.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
|
||||
@@ -117,4 +117,4 @@ png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_ptr->output_flush_fn = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
278
pngrtran.c
278
pngrtran.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -91,7 +91,8 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
/* Is it OK to set a transformation now? Only if png_start_read_image or
|
||||
* png_read_update_info have not been called. It is not necessary for the IHDR
|
||||
* to have been read in all cases, the parameter allows for this check too.
|
||||
* to have been read in all cases; the need_IHDR parameter allows for this
|
||||
* check too.
|
||||
*/
|
||||
static int
|
||||
png_rtran_ok(png_structrp png_ptr, int need_IHDR)
|
||||
@@ -142,7 +143,7 @@ png_set_background_fixed(png_structrp png_ptr,
|
||||
|
||||
png_ptr->background = *background_color;
|
||||
png_ptr->background_gamma = background_gamma;
|
||||
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
|
||||
png_ptr->background_gamma_type = (png_byte)(0xff & background_gamma_code);
|
||||
if (need_expand != 0)
|
||||
png_ptr->transformations |= PNG_BACKGROUND_EXPAND;
|
||||
else
|
||||
@@ -393,7 +394,7 @@ png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)
|
||||
/* Dither file to 8-bit. Supply a palette, the current number
|
||||
* of elements in the palette, the maximum number of elements
|
||||
* allowed, and a histogram if possible. If the current number
|
||||
* of colors is greater then the maximum number, the palette will be
|
||||
* of colors is greater than the maximum number, the palette will be
|
||||
* modified to fit in the maximum number. "full_quantize" indicates
|
||||
* whether we need a quantizing cube set up for RGB images, or if we
|
||||
* simply are reducing the number of colors in a paletted image.
|
||||
@@ -793,7 +794,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
png_free(png_ptr, distance);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
#endif /* READ_QUANTIZE */
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
void PNGFAPI
|
||||
@@ -842,7 +843,7 @@ 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));
|
||||
}
|
||||
# endif /* FLOATING_POINT_SUPPORTED */
|
||||
# endif /* FLOATING_POINT */
|
||||
#endif /* READ_GAMMA */
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
@@ -914,7 +915,7 @@ png_set_tRNS_to_alpha(png_structrp png_ptr)
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
}
|
||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||
#endif /* READ_EXPAND */
|
||||
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise
|
||||
@@ -998,7 +999,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
png_uint_16 red_int, green_int;
|
||||
|
||||
/* NOTE: this calculation does not round, but this behavior is retained
|
||||
* for consistency, the inaccuracy is very small. The code here always
|
||||
* for consistency; the inaccuracy is very small. The code here always
|
||||
* overwrites the coefficients, regardless of whether they have been
|
||||
* defaulted or set already.
|
||||
*/
|
||||
@@ -1091,7 +1092,7 @@ png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma)
|
||||
* the palette.
|
||||
*/
|
||||
|
||||
/*For the moment 'png_init_palette_transformations' and
|
||||
/* For the moment 'png_init_palette_transformations' and
|
||||
* 'png_init_rgb_transformations' only do some flag canceling optimizations.
|
||||
* The intent is that these two routines should have palette or rgb operations
|
||||
* extracted from 'png_init_read_transformations'.
|
||||
@@ -1175,14 +1176,14 @@ png_init_palette_transformations(png_structrp png_ptr)
|
||||
int i, istop = png_ptr->num_trans;
|
||||
|
||||
for (i=0; i<istop; i++)
|
||||
png_ptr->trans_alpha[i] = (png_byte)(255 -
|
||||
png_ptr->trans_alpha[i]);
|
||||
png_ptr->trans_alpha[i] = (png_byte)(0xff & (255 -
|
||||
png_ptr->trans_alpha[i]));
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */
|
||||
#endif /* READ_INVERT_ALPHA */
|
||||
}
|
||||
} /* background expand and (therefore) no alpha association. */
|
||||
#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
|
||||
#endif /* READ_EXPAND && READ_BACKGROUND */
|
||||
}
|
||||
|
||||
static void /* PRIVATE */
|
||||
@@ -1267,7 +1268,7 @@ png_init_rgb_transformations(png_structrp png_ptr)
|
||||
}
|
||||
}
|
||||
} /* background expand and (therefore) no alpha association. */
|
||||
#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
|
||||
#endif /* READ_EXPAND && READ_BACKGROUND */
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
@@ -1345,7 +1346,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
#endif
|
||||
|
||||
/* Certain transformations have the effect of preventing other
|
||||
* transformations that happen afterward in png_do_read_transformations,
|
||||
* transformations that happen afterward in png_do_read_transformations;
|
||||
* resolve the interdependencies here. From the code of
|
||||
* png_do_read_transformations the order is:
|
||||
*
|
||||
@@ -1459,8 +1460,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
|
||||
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
|
||||
#endif /* READ_EXPAND && READ_BACKGROUND */
|
||||
#endif /* READ_GRAY_TO_RGB */
|
||||
|
||||
/* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations
|
||||
* can be performed directly on the palette, and some (such as rgb to gray)
|
||||
@@ -1503,7 +1504,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
CHOP(png_ptr->background.gray);
|
||||
# undef CHOP
|
||||
}
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */
|
||||
#endif /* READ_BACKGROUND && READ_EXPAND_16 */
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
(defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \
|
||||
@@ -1797,7 +1798,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
|
||||
else
|
||||
/* Transformation does not include PNG_BACKGROUND */
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
||||
#endif /* READ_BACKGROUND */
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* RGB_TO_GRAY needs to have non-gamma-corrected values! */
|
||||
@@ -1827,7 +1828,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
else
|
||||
#endif
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
#endif /* READ_GAMMA */
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
/* No GAMMA transformation (see the hanging else 4 lines above) */
|
||||
@@ -1866,7 +1867,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
|
||||
png_ptr->transformations &= ~PNG_COMPOSE;
|
||||
}
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
||||
#endif /* READ_BACKGROUND */
|
||||
|
||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0 &&
|
||||
@@ -1912,7 +1913,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
png_ptr->palette[i].blue = (png_byte)component;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SHIFT_SUPPORTED */
|
||||
#endif /* READ_SHIFT */
|
||||
}
|
||||
|
||||
/* Modify the info structure to reflect the transformations. The
|
||||
@@ -2017,19 +2018,19 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
CONFIGURATION ERROR: you must enable at least one 16 to 8 method
|
||||
# endif
|
||||
# endif
|
||||
#endif /* !READ_16BIT_SUPPORTED */
|
||||
#endif /* !READ_16BIT */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
|
||||
info_ptr->color_type = (png_byte)(info_ptr->color_type |
|
||||
PNG_COLOR_MASK_COLOR);
|
||||
info_ptr->color_type = (png_byte)(0xff & (info_ptr->color_type |
|
||||
PNG_COLOR_MASK_COLOR));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
info_ptr->color_type = (png_byte)(info_ptr->color_type &
|
||||
~PNG_COLOR_MASK_COLOR);
|
||||
info_ptr->color_type = (png_byte)(0xff & (info_ptr->color_type &
|
||||
~PNG_COLOR_MASK_COLOR));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
@@ -2071,8 +2072,8 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0)
|
||||
{
|
||||
info_ptr->color_type = (png_byte)(info_ptr->color_type &
|
||||
~PNG_COLOR_MASK_ALPHA);
|
||||
info_ptr->color_type = (png_byte)(0xff & (info_ptr->color_type &
|
||||
~PNG_COLOR_MASK_ALPHA));
|
||||
info_ptr->num_trans = 0;
|
||||
}
|
||||
#endif
|
||||
@@ -2105,8 +2106,8 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
}
|
||||
#endif
|
||||
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
|
||||
info_ptr->bit_depth);
|
||||
info_ptr->pixel_depth = (png_byte)(0xff & (info_ptr->channels *
|
||||
info_ptr->bit_depth));
|
||||
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
|
||||
|
||||
@@ -2217,7 +2218,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
break;
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
|
||||
row_info->pixel_depth = (png_byte)(0xff & (8 * row_info->channels));
|
||||
row_info->rowbytes = row_width * row_info->channels;
|
||||
}
|
||||
}
|
||||
@@ -2355,8 +2356,8 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||
value >>= shift[channel];
|
||||
if (++channel >= channels)
|
||||
channel = 0;
|
||||
*bp++ = (png_byte)(value >> 8);
|
||||
*bp++ = (png_byte)(value & 0xff);
|
||||
*bp++ = (png_byte)(0xff & (value >> 8));
|
||||
*bp++ = (png_byte)(0xff & value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2419,7 +2420,7 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
|
||||
row_info->pixel_depth = (png_byte)(0xff & (8 * row_info->channels));
|
||||
row_info->rowbytes = row_info->width * row_info->channels;
|
||||
}
|
||||
}
|
||||
@@ -2447,7 +2448,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
|
||||
row_info->pixel_depth = (png_byte)(0xff & (8 * row_info->channels));
|
||||
row_info->rowbytes = row_info->width * row_info->channels;
|
||||
}
|
||||
}
|
||||
@@ -2569,7 +2570,7 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
|
||||
|
||||
/* This does nothing:
|
||||
*(--dp) = *(--sp);
|
||||
@@ -2592,8 +2593,8 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
|
||||
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
|
||||
|
||||
/* This does nothing:
|
||||
*(--dp) = *(--sp);
|
||||
@@ -2621,7 +2622,7 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
|
||||
*(--dp) = *(--sp);
|
||||
}
|
||||
}
|
||||
@@ -2636,8 +2637,8 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(255 - *(--sp));
|
||||
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
|
||||
*(--dp) = (png_byte)(0xff & (255 - *(--sp)));
|
||||
/*
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
@@ -2714,13 +2715,13 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
png_bytep dp = sp + (png_size_t)row_width * 2;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
}
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
row_info->channels = 2;
|
||||
row_info->pixel_depth = 32;
|
||||
row_info->rowbytes = row_width * 4;
|
||||
@@ -2735,8 +2736,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
}
|
||||
row_info->channels = 2;
|
||||
row_info->pixel_depth = 32;
|
||||
@@ -2795,8 +2796,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
png_bytep dp = sp + (png_size_t)row_width * 2;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
@@ -2804,8 +2805,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
}
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
row_info->channels = 4;
|
||||
row_info->pixel_depth = 64;
|
||||
row_info->rowbytes = row_width * 8;
|
||||
@@ -2824,8 +2825,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
}
|
||||
|
||||
row_info->channels = 4;
|
||||
@@ -2917,10 +2918,10 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
}
|
||||
}
|
||||
row_info->channels = (png_byte)(row_info->channels + 2);
|
||||
row_info->channels = (png_byte)(0xff & (row_info->channels + 2));
|
||||
row_info->color_type |= PNG_COLOR_MASK_COLOR;
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels *
|
||||
row_info->bit_depth);
|
||||
row_info->pixel_depth = (png_byte)(0xff & (row_info->channels *
|
||||
row_info->bit_depth));
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
}
|
||||
@@ -3062,7 +3063,8 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
/* NOTE: this is the historical approach which simply
|
||||
* truncates the results.
|
||||
*/
|
||||
*(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
|
||||
*(dp++) =
|
||||
(png_byte)(0xff & ((rc*red + gc*green + bc*blue)>>15));
|
||||
}
|
||||
|
||||
else
|
||||
@@ -3086,10 +3088,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_uint_16 red, green, blue, w;
|
||||
png_byte hi,lo;
|
||||
|
||||
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
|
||||
hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
|
||||
hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo));
|
||||
|
||||
if (red == green && red == blue)
|
||||
{
|
||||
@@ -3137,10 +3140,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_uint_16 red, green, blue, gray16;
|
||||
png_byte hi,lo;
|
||||
|
||||
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
|
||||
hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
|
||||
hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo));
|
||||
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
@@ -3163,11 +3167,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
}
|
||||
|
||||
row_info->channels = (png_byte)(row_info->channels - 2);
|
||||
row_info->color_type = (png_byte)(row_info->color_type &
|
||||
~PNG_COLOR_MASK_COLOR);
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels *
|
||||
row_info->bit_depth);
|
||||
row_info->channels = (png_byte)(0xff & (row_info->channels - 2));
|
||||
row_info->color_type = (png_byte)(0xff & (row_info->color_type &
|
||||
~PNG_COLOR_MASK_COLOR));
|
||||
row_info->pixel_depth = (png_byte)(0xff & (row_info->channels *
|
||||
row_info->bit_depth));
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
return rgb_error;
|
||||
@@ -3409,10 +3413,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
if (v == png_ptr->trans_color.gray)
|
||||
{
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray
|
||||
& 0xff);
|
||||
*sp = (png_byte)(0xff &
|
||||
(png_ptr->background.gray >> 8));
|
||||
*(sp + 1) = (png_byte)(0xff &
|
||||
png_ptr->background.gray);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -3435,10 +3439,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
if (v == png_ptr->trans_color.gray)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray
|
||||
& 0xff);
|
||||
*sp = (png_byte)(0xff &
|
||||
(png_ptr->background.gray >> 8));
|
||||
*(sp + 1) = (png_byte)(0xff &
|
||||
png_ptr->background.gray);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3516,15 +3520,18 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
b == png_ptr->trans_color.blue)
|
||||
{
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
*sp = (png_byte)(0xff &
|
||||
(png_ptr->background.red >> 8));
|
||||
*(sp + 1) = (png_byte)(0xff &
|
||||
png_ptr->background.red);
|
||||
*(sp + 2) = (png_byte)(0xff &
|
||||
(png_ptr->background.green >> 8));
|
||||
*(sp + 3) = (png_byte)(0xff &
|
||||
png_ptr->background.green);
|
||||
*(sp + 4) = (png_byte)(0xff &
|
||||
(png_ptr->background.blue >> 8));
|
||||
*(sp + 5) = (png_byte)(0xff &
|
||||
png_ptr->background.blue);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -3562,15 +3569,15 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
g == png_ptr->trans_color.green &&
|
||||
b == png_ptr->trans_color.blue)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
*sp = (png_byte)(0xff & (png_ptr->background.red >> 8));
|
||||
*(sp + 1) = (png_byte)(0xff & png_ptr->background.red);
|
||||
*(sp + 2) = (png_byte)(0xff &
|
||||
(png_ptr->background.green >> 8));
|
||||
*(sp + 3) = (png_byte)(0xff &
|
||||
png_ptr->background.green);
|
||||
*(sp + 4) = (png_byte)(0xff &
|
||||
(png_ptr->background.blue >> 8));
|
||||
*(sp + 5) = (png_byte)(0xff & png_ptr->background.blue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3652,9 +3659,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
else if (a == 0)
|
||||
{
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
*sp = (png_byte)(0xff &
|
||||
(png_ptr->background.gray >> 8));
|
||||
*(sp + 1) = (png_byte)(0xff & png_ptr->background.gray);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -3683,9 +3690,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
if (a == 0)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
*sp = (png_byte)(0xff &
|
||||
(png_ptr->background.gray >> 8));
|
||||
*(sp + 1) = (png_byte)(0xff & png_ptr->background.gray);
|
||||
}
|
||||
|
||||
else if (a < 0xffff)
|
||||
@@ -3812,15 +3819,15 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
else if (a == 0)
|
||||
{
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
*sp = (png_byte)(0xff & (png_ptr->background.red >> 8));
|
||||
*(sp + 1) = (png_byte)(0xff & png_ptr->background.red );
|
||||
*(sp + 2) = (png_byte)(0xff &
|
||||
(png_ptr->background.green >> 8));
|
||||
*(sp + 3) = (png_byte)(0xff &
|
||||
png_ptr->background.green);
|
||||
*(sp + 4) = (png_byte)(0xff &
|
||||
(png_ptr->background.blue >> 8));
|
||||
*(sp + 5) = (png_byte)(0xff & png_ptr->background.blue);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -3830,8 +3837,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.red);
|
||||
if (optimize == 0)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
w = gamma_16_from_1[((w & 0xff) >>
|
||||
gamma_shift)][w >> 8];
|
||||
*sp = (png_byte)((w >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(w & 0xff);
|
||||
|
||||
@@ -3867,15 +3874,16 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
if (a == 0)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
*sp = (png_byte)(0xff & (png_ptr->background.red >> 8));
|
||||
*(sp + 1) = (png_byte)(0xff & png_ptr->background.red);
|
||||
*(sp + 2) = (png_byte)(0xff &
|
||||
(png_ptr->background.green >> 8));
|
||||
*(sp + 3) = (png_byte)(0xff &
|
||||
png_ptr->background.green);
|
||||
*(sp + 4) = (png_byte)(0xff &
|
||||
(png_ptr->background.blue >> 8));
|
||||
*(sp + 5) = (png_byte)(0xff &
|
||||
png_ptr->background.blue & 0xff);
|
||||
}
|
||||
|
||||
else if (a < 0xffff)
|
||||
@@ -3911,7 +3919,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_READ_ALPHA_MODE_SUPPORTED */
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE */
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
/* Gamma correct the image, avoiding the alpha channel. Make sure
|
||||
@@ -4062,11 +4070,12 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
int c = *sp & 0x0c;
|
||||
int d = *sp & 0x03;
|
||||
|
||||
*sp = (png_byte)(
|
||||
((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)|
|
||||
*sp = (png_byte)(0xff &
|
||||
(((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)|
|
||||
((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)|
|
||||
((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)|
|
||||
((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) ));
|
||||
((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) & 0xff))
|
||||
);
|
||||
sp++;
|
||||
}
|
||||
}
|
||||
@@ -4397,8 +4406,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0x03;
|
||||
*dp = (png_byte)(value | (value << 2) | (value << 4) |
|
||||
(value << 6));
|
||||
*dp = (png_byte)(0xff & (value | (value << 2) |
|
||||
(value << 4) | (value << 6)));
|
||||
if (shift == 6)
|
||||
{
|
||||
shift = 0;
|
||||
@@ -4422,7 +4431,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
value = (*sp >> shift) & 0x0f;
|
||||
*dp = (png_byte)(value | (value << 4));
|
||||
*dp = (png_byte)(0xff & (value | (value << 4)));
|
||||
if (shift == 4)
|
||||
{
|
||||
shift = 0;
|
||||
@@ -4493,7 +4502,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
|
||||
row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||
row_info->channels = 2;
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);
|
||||
row_info->pixel_depth =
|
||||
(png_byte)(0xff & (row_info->bit_depth << 1));
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
|
||||
row_width);
|
||||
}
|
||||
@@ -4560,7 +4570,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
row_info->channels = 4;
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
|
||||
row_info->pixel_depth = (png_byte)(0xff & (row_info->bit_depth << 2));
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
}
|
||||
@@ -4593,7 +4603,7 @@ png_do_expand_16(png_row_infop row_info, png_bytep row)
|
||||
|
||||
row_info->rowbytes *= 2;
|
||||
row_info->bit_depth = 16;
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels * 16);
|
||||
row_info->pixel_depth = (png_byte)(0xff & (row_info->channels * 16));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -4690,7 +4700,7 @@ png_do_quantize(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
#endif /* READ_QUANTIZE */
|
||||
|
||||
/* Transform the row. The order of transformations is significant,
|
||||
* and is very touchy. If you add a transformation, take care to
|
||||
@@ -4836,7 +4846,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
/* Because PNG_COMPOSE does the gamma transform if there is something to
|
||||
* do (if there is an alpha channel or transparency.)
|
||||
*/
|
||||
!((png_ptr->transformations & PNG_COMPOSE) &&
|
||||
!((png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
((png_ptr->num_trans != 0) ||
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) &&
|
||||
#endif
|
||||
@@ -4885,7 +4895,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
if (row_info->rowbytes == 0)
|
||||
png_error(png_ptr, "png_do_quantize returned rowbytes=0");
|
||||
}
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
#endif /* READ_QUANTIZE */
|
||||
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
/* Do the expansion now, after all the arithmetic has been done. Notice
|
||||
@@ -4962,7 +4972,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
{
|
||||
{
|
||||
if (png_ptr->read_user_transform_fn != NULL)
|
||||
(*(png_ptr->read_user_transform_fn)) /* User read transform function */
|
||||
(png_ptr, /* png_ptr */
|
||||
@@ -4981,13 +4991,13 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
if (png_ptr->user_transform_channels != 0)
|
||||
row_info->channels = png_ptr->user_transform_channels;
|
||||
#endif
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth *
|
||||
row_info->channels);
|
||||
row_info->pixel_depth = (png_byte)(0xff & (row_info->bit_depth *
|
||||
row_info->channels));
|
||||
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ_TRANSFORMS */
|
||||
#endif /* READ */
|
||||
|
||||
94
pngrutil.c
94
pngrutil.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -108,7 +108,7 @@ png_get_uint_16)(png_const_bytep buf)
|
||||
return (png_uint_16)val;
|
||||
}
|
||||
|
||||
#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */
|
||||
#endif /* READ_INT_FUNCTIONS */
|
||||
|
||||
/* Read and check the PNG file signature */
|
||||
void /* PRIVATE */
|
||||
@@ -321,7 +321,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
|
||||
|
||||
return buffer;
|
||||
}
|
||||
#endif /* PNG_READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */
|
||||
#endif /* READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */
|
||||
|
||||
/* png_inflate_claim: claim the zstream for some nefarious purpose that involves
|
||||
* decompression. Returns Z_OK on success, else a zlib error code. It checks
|
||||
@@ -718,7 +718,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_COMPRESSED_TEXT_SUPPORTED */
|
||||
#endif /* READ_COMPRESSED_TEXT */
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
/* Perform a partial read and decompress, producing 'avail_out' bytes and
|
||||
@@ -788,6 +788,7 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
|
||||
#endif
|
||||
|
||||
/* Read and check the IDHR chunk */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
@@ -821,13 +822,13 @@ png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
/* Set internal variables */
|
||||
png_ptr->width = width;
|
||||
png_ptr->height = height;
|
||||
png_ptr->bit_depth = (png_byte)bit_depth;
|
||||
png_ptr->interlaced = (png_byte)interlace_type;
|
||||
png_ptr->color_type = (png_byte)color_type;
|
||||
png_ptr->bit_depth = (png_byte)(bit_depth & 0xff);
|
||||
png_ptr->interlaced = (png_byte)(interlace_type & 0xff);
|
||||
png_ptr->color_type = (png_byte)(color_type & 0xff);
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_ptr->filter_type = (png_byte)filter_type;
|
||||
png_ptr->filter_type = (png_byte)(filter_type & 0xff);
|
||||
#endif
|
||||
png_ptr->compression_type = (png_byte)compression_type;
|
||||
png_ptr->compression_type = (png_byte)(compression_type & 0xff);
|
||||
|
||||
/* Find number of channels */
|
||||
switch (png_ptr->color_type)
|
||||
@@ -852,8 +853,8 @@ png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
}
|
||||
|
||||
/* Set up other useful info */
|
||||
png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *
|
||||
png_ptr->channels);
|
||||
png_ptr->pixel_depth =
|
||||
(png_byte)(0xff & (png_ptr->bit_depth * png_ptr->channels));
|
||||
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
|
||||
png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
|
||||
png_debug1(3, "channels = %d", png_ptr->channels);
|
||||
@@ -1294,7 +1295,7 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
(void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);
|
||||
png_colorspace_sync(png_ptr, info_ptr);
|
||||
}
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
#endif /* READ_sRGB */
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
@@ -1515,8 +1516,10 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
else if (size > 0)
|
||||
errmsg = "truncated";
|
||||
|
||||
#ifndef __COVERITY__
|
||||
else
|
||||
errmsg = png_ptr->zstream.msg;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* else png_icc_check_tag_table output an error */
|
||||
@@ -1567,7 +1570,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (errmsg != NULL) /* else already output */
|
||||
png_chunk_benign_error(png_ptr, errmsg);
|
||||
}
|
||||
#endif /* PNG_READ_iCCP_SUPPORTED */
|
||||
#endif /* READ_iCCP */
|
||||
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
@@ -1744,7 +1747,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
png_free(png_ptr, new_palette.entries);
|
||||
}
|
||||
#endif /* PNG_READ_sPLT_SUPPORTED */
|
||||
#endif /* READ_sPLT */
|
||||
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
@@ -2729,7 +2732,8 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
|
||||
/* The following is safe because of the PNG_SIZE_MAX init above */
|
||||
png_ptr->unknown_chunk.size = (png_size_t)length/*SAFE*/;
|
||||
/* 'mode' is a flag array, only the bottom four bits matter here */
|
||||
png_ptr->unknown_chunk.location = (png_byte)png_ptr->mode/*SAFE*/;
|
||||
png_ptr->unknown_chunk.location =
|
||||
(png_byte)(0xff & png_ptr->mode/*SAFE*/);
|
||||
|
||||
if (length == 0)
|
||||
png_ptr->unknown_chunk.data = NULL;
|
||||
@@ -2758,7 +2762,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
#endif /* READ_UNKNOWN_CHUNKS */
|
||||
|
||||
/* Handle an unknown, or known but disabled, chunk */
|
||||
void /* PRIVATE */
|
||||
@@ -2804,7 +2808,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
&png_ptr->unknown_chunk);
|
||||
|
||||
/* ret is:
|
||||
* negative: An error occured, png_chunk_error will be called.
|
||||
* negative: An error occurred; png_chunk_error will be called.
|
||||
* zero: The chunk was not handled, the chunk will be discarded
|
||||
* unless png_set_keep_unknown_chunks has been used to set
|
||||
* a 'keep' behavior for this particular chunk, in which
|
||||
@@ -2858,7 +2862,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
else
|
||||
/* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */
|
||||
# endif /* PNG_READ_USER_CHUNKS_SUPPORTED */
|
||||
# endif /* READ_USER_CHUNKS */
|
||||
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
{
|
||||
@@ -2925,7 +2929,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
--(png_ptr->user_chunk_cache_max);
|
||||
/* FALL THROUGH */
|
||||
case 0: /* no limit */
|
||||
# endif /* PNG_USER_LIMITS_SUPPORTED */
|
||||
# endif /* USER_LIMITS */
|
||||
/* Here when the limit isn't reached or when limits are compiled
|
||||
* out; store the chunk.
|
||||
*/
|
||||
@@ -2954,7 +2958,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_crc_finish(png_ptr, length);
|
||||
PNG_UNUSED(info_ptr)
|
||||
PNG_UNUSED(keep)
|
||||
#endif /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
#endif /* !READ_UNKNOWN_CHUNKS */
|
||||
|
||||
/* Check for unhandled critical chunks */
|
||||
if (handled == 0 && PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
|
||||
@@ -3003,7 +3007,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
{
|
||||
unsigned int pixel_depth = png_ptr->transformed_pixel_depth;
|
||||
png_const_bytep sp = png_ptr->row_buf + 1;
|
||||
png_uint_32 row_width = png_ptr->width;
|
||||
png_alloc_size_t row_width = png_ptr->width;
|
||||
unsigned int pass = png_ptr->pass;
|
||||
png_bytep end_ptr = 0;
|
||||
png_byte end_byte = 0;
|
||||
@@ -3193,7 +3197,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
*/
|
||||
# define MASK(pass,depth,display,png)\
|
||||
((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png))
|
||||
#endif /* !PNG_USE_COMPILE_TIME_MASKS */
|
||||
#endif /* !USE_COMPILE_TIME_MASKS */
|
||||
|
||||
/* Use the appropriate mask to copy the required bits. In some cases
|
||||
* the byte mask will be 0 or 0xff; optimize these cases. row_width is
|
||||
@@ -3226,7 +3230,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
if (m != 0) /* something to copy */
|
||||
{
|
||||
if (m != 0xff)
|
||||
*dp = (png_byte)((*dp & ~m) | (*sp & m));
|
||||
*dp = (png_byte)(((*dp & ~m) | (*sp & m)) & 0xff);
|
||||
else
|
||||
*dp = *sp;
|
||||
}
|
||||
@@ -3278,7 +3282,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
|
||||
/* But don't allow this number to exceed the actual row width. */
|
||||
if (bytes_to_copy > row_width)
|
||||
bytes_to_copy = row_width;
|
||||
bytes_to_copy = (unsigned int)/*SAFE*/row_width;
|
||||
}
|
||||
|
||||
else /* normal row; Adam7 only ever gives us one pixel to copy. */
|
||||
@@ -3444,7 +3448,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_ALIGN_ code */
|
||||
#endif /* ALIGN_TYPE code */
|
||||
|
||||
/* The true default - use a memcpy: */
|
||||
for (;;)
|
||||
@@ -3458,7 +3462,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
dp += bytes_to_jump;
|
||||
row_width -= bytes_to_jump;
|
||||
if (bytes_to_copy > row_width)
|
||||
bytes_to_copy = row_width;
|
||||
bytes_to_copy = (unsigned int)/*SAFE*/row_width;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3468,7 +3472,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
/* Here if pixel_depth < 8 to check 'end_ptr' below. */
|
||||
}
|
||||
else
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
/* If here then the switch above wasn't used so just memcpy the whole row
|
||||
* from the temporary row buffer (notice that this overwrites the end of the
|
||||
@@ -3478,7 +3482,8 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
|
||||
/* Restore the overwritten bits from the last byte if necessary. */
|
||||
if (end_ptr != NULL)
|
||||
*end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask));
|
||||
*end_ptr =
|
||||
(png_byte)(0xff & ((end_byte & end_mask) | (*end_ptr & ~end_mask)));
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
@@ -3724,7 +3729,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
PNG_UNUSED(transformations) /* Silence compiler warning */
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
static void
|
||||
png_read_filter_row_sub(png_row_infop row_info, png_bytep row,
|
||||
@@ -3772,16 +3777,14 @@ png_read_filter_row_avg(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (i = 0; i < bpp; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
((int)(*pp++) / 2 )) & 0xff);
|
||||
*rp = (png_byte)(((int)(*rp) + ((int)(*pp++) / 2 )) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
*rp = (png_byte)(((int)(*rp) +
|
||||
(int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
|
||||
*rp = (png_byte)(((int)(*rp) + (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
|
||||
|
||||
rp++;
|
||||
}
|
||||
@@ -3797,7 +3800,7 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
|
||||
/* First pixel/byte */
|
||||
c = *prev_row++;
|
||||
a = *row + c;
|
||||
*row++ = (png_byte)a;
|
||||
*row++ = (png_byte)(a & 0xff);
|
||||
|
||||
/* Remainder */
|
||||
while (row < rp_end)
|
||||
@@ -3831,7 +3834,7 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
|
||||
*/
|
||||
c = b;
|
||||
a += *row;
|
||||
*row++ = (png_byte)a;
|
||||
*row++ = (png_byte)(a & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3848,7 +3851,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
||||
while (row < rp_end)
|
||||
{
|
||||
int a = *row + *prev_row++;
|
||||
*row++ = (png_byte)a;
|
||||
*row++ = (png_byte)(a & 0xff);
|
||||
}
|
||||
|
||||
/* Remainder */
|
||||
@@ -3879,7 +3882,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
||||
if (pc < pa) a = c;
|
||||
|
||||
a += *row;
|
||||
*row++ = (png_byte)a;
|
||||
*row++ = (png_byte)(a & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4178,7 +4181,7 @@ png_read_finish_row(png_structrp png_ptr)
|
||||
/* Here after at the end of the last row of the last pass. */
|
||||
png_read_finish_IDAT(png_ptr);
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_read_start_row(png_structrp png_ptr)
|
||||
@@ -4228,7 +4231,7 @@ png_read_start_row(png_structrp png_ptr)
|
||||
|
||||
max_pixel_depth = png_ptr->pixel_depth;
|
||||
|
||||
/* WARNING: * png_read_transform_info (pngrtran.c) performs a simpliar set of
|
||||
/* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of
|
||||
* calculations to calculate the final pixel depth, then
|
||||
* png_do_read_transforms actually does the transforms. This means that the
|
||||
* code which effectively calculates this value is actually repeated in three
|
||||
@@ -4372,7 +4375,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
/* This value is stored in png_struct and double checked in the row read
|
||||
* code.
|
||||
*/
|
||||
png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth;
|
||||
png_ptr->maximum_pixel_depth = (png_byte)(max_pixel_depth & 0xff);
|
||||
png_ptr->transformed_pixel_depth = 0; /* calculated on demand */
|
||||
|
||||
/* Align the width on the next larger 8 pixels. Mainly used
|
||||
@@ -4444,8 +4447,11 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
png_debug1(3, "height = %u,", png_ptr->height);
|
||||
png_debug1(3, "iwidth = %u,", png_ptr->iwidth);
|
||||
png_debug1(3, "num_rows = %u,", png_ptr->num_rows);
|
||||
png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes);
|
||||
png_debug1(3, "irowbytes = %lu",
|
||||
png_debug1(3, "row_bytes = %lu,", (unsigned long)row_bytes);
|
||||
png_debug1(3, "png_ptr->rowbytes = %lu,", (unsigned long)png_ptr->rowbytes);
|
||||
png_debug1(3, "png_ptr->info_rowbytes = %lu,",
|
||||
(unsigned long)png_ptr->info_rowbytes);
|
||||
png_debug1(3, "PNG_ROWBYTES = %lu",
|
||||
(unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
|
||||
|
||||
/* The sequential reader needs a buffer for IDAT, but the progressive reader
|
||||
@@ -4471,4 +4477,4 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
83
pngset.c
83
pngset.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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,9 +130,9 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
||||
png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
|
||||
}
|
||||
# endif /* PNG_FLOATING_POINT_SUPPORTED */
|
||||
# endif /* FLOATING_POINT */
|
||||
|
||||
#endif /* PNG_cHRM_SUPPORTED */
|
||||
#endif /* cHRM */
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
void PNGFAPI
|
||||
@@ -190,6 +190,7 @@ png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->hist == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for hIST chunk data");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -271,7 +272,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_debug1(1, "in %s storage function", "pCAL");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL
|
||||
|| (nparams > 0 && params == NULL))
|
||||
|| (nparams > 0 && params == NULL))
|
||||
return;
|
||||
|
||||
length = strlen(purpose) + 1;
|
||||
@@ -301,6 +302,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->pcal_purpose == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL purpose");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -322,6 +324,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->pcal_units == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL units");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -333,6 +336,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->pcal_params == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL params");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -349,6 +353,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->pcal_params[i] == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL parameter");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -398,6 +403,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->scal_s_width == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -416,6 +422,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
info_ptr->scal_s_width = NULL;
|
||||
|
||||
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -519,6 +526,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
else
|
||||
{
|
||||
png_warning(png_ptr, "Invalid palette length");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -531,7 +539,6 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
))
|
||||
{
|
||||
png_error(png_ptr, "Invalid palette");
|
||||
return;
|
||||
}
|
||||
|
||||
/* It may not actually be necessary to set png_ptr->palette here;
|
||||
@@ -655,6 +662,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (new_iccp_name == NULL)
|
||||
{
|
||||
png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -668,6 +676,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
new_iccp_name = NULL;
|
||||
png_benign_error(png_ptr,
|
||||
"Insufficient memory to process iCCP profile");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -743,6 +752,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
png_chunk_report(png_ptr, "too many text chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -798,7 +808,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
else
|
||||
lang_key_len = 0;
|
||||
}
|
||||
# else /* PNG_iTXt_SUPPORTED */
|
||||
# else /* iTXt */
|
||||
{
|
||||
png_chunk_report(png_ptr, "iTXt chunk not supported",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
@@ -831,6 +841,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
png_chunk_report(png_ptr, "text chunk: out of memory",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -904,6 +915,7 @@ png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
mod_time->second > 60)
|
||||
{
|
||||
png_warning(png_ptr, "Ignoring invalid time value");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -920,6 +932,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_debug1(1, "in %s storage function", "tRNS");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
|
||||
return;
|
||||
|
||||
if (trans_alpha != NULL)
|
||||
@@ -945,16 +958,21 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
if (trans_color != NULL)
|
||||
{
|
||||
int sample_max = (1 << info_ptr->bit_depth);
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
if (info_ptr->bit_depth < 16)
|
||||
{
|
||||
int sample_max = (1 << info_ptr->bit_depth) - 1;
|
||||
|
||||
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||
trans_color->gray > sample_max) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
(trans_color->red > sample_max ||
|
||||
trans_color->green > sample_max ||
|
||||
trans_color->blue > sample_max)))
|
||||
png_warning(png_ptr,
|
||||
"tRNS chunk has out-of-range samples for bit_depth");
|
||||
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||
trans_color->gray > sample_max) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
(trans_color->red > sample_max ||
|
||||
trans_color->green > sample_max ||
|
||||
trans_color->blue > sample_max)))
|
||||
png_warning(png_ptr,
|
||||
"tRNS chunk has out-of-range samples for bit_depth");
|
||||
}
|
||||
#endif
|
||||
|
||||
info_ptr->trans_color = *trans_color;
|
||||
|
||||
@@ -1001,6 +1019,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
{
|
||||
/* Out of memory or too many chunks */
|
||||
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1069,7 +1088,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
if (nentries > 0)
|
||||
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
|
||||
}
|
||||
#endif /* PNG_sPLT_SUPPORTED */
|
||||
#endif /* sPLT */
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
static png_byte
|
||||
@@ -1116,7 +1135,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
png_unknown_chunkp np;
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 ||
|
||||
unknowns == NULL)
|
||||
unknowns == NULL)
|
||||
return;
|
||||
|
||||
/* Check for the failure cases where support has been disabled at compile
|
||||
@@ -1130,6 +1149,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on read");
|
||||
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
@@ -1138,6 +1158,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on write");
|
||||
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
@@ -1155,6 +1176,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
{
|
||||
png_chunk_report(png_ptr, "too many unknown chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1232,8 +1254,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
check_location(png_ptr, location);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STORE_UNKNOWN_CHUNKS */
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
@@ -1264,6 +1285,7 @@ add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)
|
||||
if (memcmp(list, add, 4) == 0)
|
||||
{
|
||||
list[4] = (png_byte)keep;
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -1291,6 +1313,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)
|
||||
{
|
||||
png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1329,7 +1352,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
};
|
||||
|
||||
chunk_list = chunks_to_ignore;
|
||||
num_chunks = (sizeof chunks_to_ignore)/5;
|
||||
num_chunks = (unsigned int)/*SAFE*/(sizeof chunks_to_ignore)/5U;
|
||||
}
|
||||
|
||||
else /* num_chunks_in > 0 */
|
||||
@@ -1340,6 +1363,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
* which can be switched off.
|
||||
*/
|
||||
png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1355,6 +1379,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
if (num_chunks + old_num_chunks > UINT_MAX/5)
|
||||
{
|
||||
png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1492,23 +1517,27 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Compression buffer size cannot be changed because it is in use");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef __COVERITY__
|
||||
if (size > ZLIB_IO_MAX)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Compression buffer size limited to system maximum");
|
||||
size = ZLIB_IO_MAX; /* must fit */
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (size < 6)
|
||||
if (size < 6)
|
||||
{
|
||||
/* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
|
||||
* if this is permitted.
|
||||
*/
|
||||
png_warning(png_ptr,
|
||||
"Compression buffer size cannot be reduced below 6");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1550,8 +1579,8 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
|
||||
void PNGAPI
|
||||
png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
|
||||
}
|
||||
|
||||
/* This function was added to libpng 1.4.1 */
|
||||
@@ -1562,7 +1591,7 @@ png_set_chunk_malloc_max (png_structrp png_ptr,
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
|
||||
}
|
||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||
#endif /* ?SET_USER_LIMITS */
|
||||
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
@@ -1585,7 +1614,7 @@ png_set_benign_errors(png_structrp png_ptr, int allowed)
|
||||
png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN |
|
||||
PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN);
|
||||
}
|
||||
#endif /* PNG_BENIGN_ERRORS_SUPPORTED */
|
||||
#endif /* BENIGN_ERRORS */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Whether to report invalid palette index; added at libng-1.5.10.
|
||||
@@ -1608,4 +1637,4 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
|
||||
png_ptr->num_palette_max = -1;
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 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.)
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@@ -101,7 +100,7 @@ typedef struct png_XYZ
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* A colorspace is all the above plus, potentially, profile information,
|
||||
/* A colorspace is all the above plus, potentially, profile information;
|
||||
* however at present libpng does not use the profile internally so it is only
|
||||
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||
* is retained here and is checked.
|
||||
@@ -274,7 +273,7 @@ struct png_struct_def
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
||||
#endif
|
||||
#endif /* PNG_bKGD_SUPPORTED */
|
||||
#endif /* bKGD */
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
||||
@@ -331,7 +330,7 @@ struct png_struct_def
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* For the Borland special 64K segment handler */
|
||||
|
||||
50
pngtest.c
50
pngtest.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -311,7 +311,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* WRITE_USER_TRANSFORM */
|
||||
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
/* START of code to validate stdio-free compilation */
|
||||
@@ -420,7 +420,7 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||
#endif
|
||||
}
|
||||
#endif /* !PNG_STDIO_SUPPORTED */
|
||||
#endif /* !STDIO */
|
||||
|
||||
/* This function is called when there is a warning, but the library thinks
|
||||
* it can continue anyway. Replacement functions don't have to do anything
|
||||
@@ -469,7 +469,7 @@ pngtest_error(png_structp png_ptr, png_const_charp message)
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||
* 64K. However, zlib may allocate more than 64K if you don't tell
|
||||
* it not to. See zconf.h and png.h for more information. zlib does
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
@@ -605,7 +605,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */
|
||||
#endif /* USER_MEM && DEBUG */
|
||||
/* END of code to test memory allocation/deallocation */
|
||||
|
||||
|
||||
@@ -780,8 +780,8 @@ write_chunks(png_structp write_ptr, int location)
|
||||
write_vpAg_chunk(write_ptr);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#else /* !PNG_READ_USER_CHUNKS_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
#else /* !READ_USER_CHUNKS */
|
||||
# define write_chunks(pp,loc) ((void)0)
|
||||
#endif
|
||||
/* END of code to demonstrate user chunk support */
|
||||
@@ -1290,7 +1290,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#endif /* TIME_RFC1123 */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1406,7 +1406,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
t_encode += (t_stop - t_start);
|
||||
t_start = t_stop;
|
||||
#endif
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
#ifndef SINGLE_ROWBUF_ALLOC
|
||||
pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y);
|
||||
@@ -1473,7 +1473,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#endif /* TIME_RFC1123 */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1678,7 +1678,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
@@ -1701,6 +1701,8 @@ main(int argc, char *argv[])
|
||||
int multiple = 0;
|
||||
int ierror = 0;
|
||||
|
||||
png_structp dummy_ptr;
|
||||
|
||||
fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
||||
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
|
||||
fprintf(STDERR, "%s", png_get_copyright(NULL));
|
||||
@@ -1835,7 +1837,7 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR, " tIME = %s\n", tIME_string);
|
||||
|
||||
tIME_chunk_present = 0;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#endif /* TIME_RFC1123 */
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1924,7 +1926,7 @@ main(int argc, char *argv[])
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
if (tIME_chunk_present != 0)
|
||||
fprintf(STDERR, " tIME = %s\n", tIME_string);
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#endif /* TIME_RFC1123 */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1994,6 +1996,24 @@ main(int argc, char *argv[])
|
||||
else
|
||||
fprintf(STDERR, " libpng FAILS test\n");
|
||||
|
||||
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));
|
||||
fprintf(STDERR, " height_max = %lu\n",
|
||||
(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));
|
||||
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));
|
||||
png_destroy_read_struct(&dummy_ptr, NULL, NULL);
|
||||
|
||||
return (int)(ierror != 0);
|
||||
}
|
||||
#else
|
||||
@@ -2008,4 +2028,4 @@ main(void)
|
||||
#endif
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_15beta03 Your_png_h_is_not_version_1_6_15beta03;
|
||||
typedef png_libpng_version_1_6_17rc03 Your_png_h_is_not_version_1_6_17rc03;
|
||||
|
||||
30
pngtrans.c
30
pngtrans.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -273,7 +273,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
*rp = (png_byte)(~(*rp));
|
||||
*rp = (png_byte)((~(*rp)) & 0xff);
|
||||
rp++;
|
||||
}
|
||||
}
|
||||
@@ -287,7 +287,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < istop; i += 2)
|
||||
{
|
||||
*rp = (png_byte)(~(*rp));
|
||||
*rp = (png_byte)((~(*rp)) & 0xff);
|
||||
rp += 2;
|
||||
}
|
||||
}
|
||||
@@ -302,8 +302,8 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < istop; i += 4)
|
||||
{
|
||||
*rp = (png_byte)(~(*rp));
|
||||
*(rp + 1) = (png_byte)(~(*(rp + 1)));
|
||||
*rp = (png_byte)((~(*rp)) & 0xff);
|
||||
*(rp + 1) = (png_byte)((~(*(rp + 1))) & 0xff);
|
||||
rp += 4;
|
||||
}
|
||||
}
|
||||
@@ -478,7 +478,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
*rp = table[*rp];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */
|
||||
#endif /* PACKSWAP || WRITE_PACKSWAP */
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
@@ -675,7 +675,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
#endif /* READ_BGR || WRITE_BGR */
|
||||
|
||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||
@@ -778,7 +778,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
@@ -803,8 +803,9 @@ png_set_user_transform_info(png_structrp png_ptr, png_voidp
|
||||
#endif
|
||||
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
png_ptr->user_transform_depth = (png_byte)(user_transform_depth & 0xff);
|
||||
png_ptr->user_transform_channels =
|
||||
(png_byte)(user_transform_channels & 0xff);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -844,7 +845,6 @@ png_get_current_pass_number(png_const_structrp png_ptr)
|
||||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* USER_TRANSFORM_INFO */
|
||||
#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# here by entering the appropriate values as #defines preceded by '@' (to cause,
|
||||
# them to be passed through to the build of pnglibconf.h), for example:
|
||||
#
|
||||
# @# define PNG_USER_WIDTH_MAX 1000000
|
||||
# @# define PNG_USER_HEIGHT_MAX 1000000
|
||||
# @# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||
# @# define PNG_USER_CHUNK_MALLOC_MAX 8000000
|
||||
# @# define PNG_USER_WIDTH_MAX 65535
|
||||
# @# define PNG_USER_HEIGHT_MAX 65535
|
||||
# @# define PNG_USER_CHUNK_CACHE_MAX 256
|
||||
# @# define PNG_USER_CHUNK_MALLOC_MAX 640000
|
||||
|
||||
6
pngwio.c
6
pngwio.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
@@ -151,7 +151,7 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
# endif
|
||||
#else
|
||||
PNG_UNUSED(output_flush_fn)
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#endif /* WRITE_FLUSH */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* It is an error to read while writing a png file */
|
||||
@@ -165,4 +165,4 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
93
pngwrite.c
93
pngwrite.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -69,7 +69,7 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
#endif /* WRITE_UNKNOWN_CHUNKS */
|
||||
|
||||
/* Writes all the PNG information. This is the suggested way to use the
|
||||
* library. If you have a new chunk to add, make a function to write it,
|
||||
@@ -219,7 +219,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
int j;
|
||||
for (j = 0; j<(int)info_ptr->num_trans; j++)
|
||||
info_ptr->trans_alpha[j] =
|
||||
(png_byte)(255 - info_ptr->trans_alpha[j]);
|
||||
(png_byte)((255 - info_ptr->trans_alpha[j]) & 0xff);
|
||||
}
|
||||
#endif
|
||||
png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color),
|
||||
@@ -457,11 +457,11 @@ png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime)
|
||||
png_debug(1, "in png_convert_from_struct_tm");
|
||||
|
||||
ptime->year = (png_uint_16)(1900 + ttime->tm_year);
|
||||
ptime->month = (png_byte)(ttime->tm_mon + 1);
|
||||
ptime->day = (png_byte)ttime->tm_mday;
|
||||
ptime->hour = (png_byte)ttime->tm_hour;
|
||||
ptime->minute = (png_byte)ttime->tm_min;
|
||||
ptime->second = (png_byte)ttime->tm_sec;
|
||||
ptime->month = (png_byte)((ttime->tm_mon + 1) & 0xff);
|
||||
ptime->day = (png_byte)(ttime->tm_mday & 0xff);
|
||||
ptime->hour = (png_byte)(ttime->tm_hour & 0xff);
|
||||
ptime->minute = (png_byte)(ttime->tm_min & 0xff);
|
||||
ptime->second = (png_byte)(ttime->tm_sec & 0xff);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
@@ -497,7 +497,7 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
{
|
||||
png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
|
||||
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* USER_MEM */
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* Set the zlib control values to defaults; they can be overridden by the
|
||||
@@ -521,7 +521,7 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_ptr->zlib_text_mem_level = 8;
|
||||
png_ptr->zlib_text_window_bits = 15;
|
||||
png_ptr->zlib_text_method = 8;
|
||||
#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
|
||||
#endif /* WRITE_COMPRESSED_TEXT */
|
||||
|
||||
/* This is a highly dubious configuration option; by default it is off,
|
||||
* but it may be appropriate for private builds that are testing
|
||||
@@ -671,10 +671,10 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
||||
*(rp + 5) = (png_byte)(blue & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
#endif /* MNG_FEATURES */
|
||||
|
||||
/* Called by user to write a row of image data */
|
||||
void PNGAPI
|
||||
@@ -811,7 +811,8 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
row_info.width = png_ptr->usr_width;
|
||||
row_info.channels = png_ptr->usr_channels;
|
||||
row_info.bit_depth = png_ptr->usr_bit_depth;
|
||||
row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels);
|
||||
row_info.pixel_depth =
|
||||
(png_byte)(0xff & (row_info.bit_depth * row_info.channels));
|
||||
row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
|
||||
|
||||
png_debug1(3, "row_info->color_type = %d", row_info.color_type);
|
||||
@@ -915,7 +916,7 @@ png_write_flush(png_structrp png_ptr)
|
||||
png_ptr->flush_rows = 0;
|
||||
png_flush(png_ptr);
|
||||
}
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#endif /* WRITE_FLUSH */
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */
|
||||
@@ -1019,7 +1020,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
case 6:
|
||||
case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
|
||||
/* FALL THROUGH */
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
case PNG_FILTER_VALUE_NONE:
|
||||
png_ptr->do_filter = PNG_FILTER_NONE; break;
|
||||
|
||||
@@ -1037,11 +1038,11 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
png_ptr->do_filter = PNG_FILTER_PAETH; break;
|
||||
|
||||
default:
|
||||
png_ptr->do_filter = (png_byte)filters; break;
|
||||
png_ptr->do_filter = (png_byte)(filters & 0xff); break;
|
||||
#else
|
||||
default:
|
||||
png_app_error(png_ptr, "Unknown row filter for method 0");
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
}
|
||||
|
||||
/* If we have allocated the row_buf, this means we have already started
|
||||
@@ -1050,8 +1051,8 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
* it is too late to start using the filters that need it, since we
|
||||
* will be missing the data in the previous row. If an application
|
||||
* wants to start and stop using particular filters during compression,
|
||||
* it should start out with all of the filters, and then add and
|
||||
* remove them after the start of compression.
|
||||
* it should start out with all of the filters, and then remove them
|
||||
* or add them back after the start of compression.
|
||||
*/
|
||||
if (png_ptr->row_buf != NULL)
|
||||
{
|
||||
@@ -1070,8 +1071,8 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Up filter after starting");
|
||||
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
|
||||
~PNG_FILTER_UP);
|
||||
png_ptr->do_filter =
|
||||
(png_byte)((png_ptr->do_filter & ~PNG_FILTER_UP) & 0xff);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1088,8 +1089,8 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Average filter after starting");
|
||||
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
|
||||
~PNG_FILTER_AVG);
|
||||
png_ptr->do_filter =
|
||||
(png_byte)((png_ptr->do_filter & ~PNG_FILTER_AVG) & 0xff);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1106,7 +1107,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Paeth filter after starting");
|
||||
png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
|
||||
png_ptr->do_filter &= (png_byte)((~PNG_FILTER_PAETH) & 0xff);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1118,7 +1119,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter == PNG_NO_FILTERS)
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
||||
}
|
||||
}
|
||||
@@ -1210,7 +1211,7 @@ png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
||||
}
|
||||
|
||||
/* Safe to set this now */
|
||||
png_ptr->num_prev_filters = (png_byte)num_weights;
|
||||
png_ptr->num_prev_filters = (png_byte)(num_weights & 0xff);
|
||||
}
|
||||
|
||||
/* If, in the future, there are other filter methods, this would
|
||||
@@ -1370,8 +1371,9 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
|
||||
}
|
||||
}
|
||||
#endif /* FIXED_POINT */
|
||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_WEIGHTED_FILTER */
|
||||
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_compression_level(png_structrp png_ptr, int level)
|
||||
{
|
||||
@@ -1417,8 +1419,8 @@ png_set_compression_window_bits(png_structrp png_ptr, int window_bits)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Prior to 1.6.0 this would warn but then set the window_bits value, this
|
||||
* meant that negative window bits values could be selected which would cause
|
||||
/* Prior to 1.6.0 this would warn but then set the window_bits value. This
|
||||
* meant that negative window bits values could be selected that would cause
|
||||
* libpng to write a non-standard PNG file with raw deflate or gzip
|
||||
* compressed IDAT or ancillary chunks. Such files can be read and there is
|
||||
* no warning on read, so this seems like a very bad idea.
|
||||
@@ -1454,6 +1456,7 @@ png_set_compression_method(png_structrp png_ptr, int method)
|
||||
|
||||
png_ptr->zlib_method = method;
|
||||
}
|
||||
#endif /* WRITE_CUSTOMIZE_COMPRESSION */
|
||||
|
||||
/* The following were added to libpng-1.5.4 */
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
@@ -1527,7 +1530,7 @@ png_set_text_compression_method(png_structrp png_ptr, int method)
|
||||
|
||||
png_ptr->zlib_text_method = method;
|
||||
}
|
||||
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
|
||||
#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
|
||||
/* end of API added to libpng-1.5.4 */
|
||||
|
||||
void PNGAPI
|
||||
@@ -1888,7 +1891,7 @@ png_unpremultiply(png_uint_32 component, png_uint_32 alpha,
|
||||
component *= 255;
|
||||
|
||||
/* Convert the component to sRGB. */
|
||||
return (png_byte)PNG_sRGB_FROM_LINEAR(component);
|
||||
return (png_byte)(PNG_sRGB_FROM_LINEAR(component) & 0xff);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1937,7 +1940,7 @@ png_write_image_8bit(png_voidp argument)
|
||||
while (out_ptr < row_end)
|
||||
{
|
||||
png_uint_16 alpha = in_ptr[aindex];
|
||||
png_byte alphabyte = (png_byte)PNG_DIV257(alpha);
|
||||
png_byte alphabyte = (png_byte)(PNG_DIV257(alpha) & 0xff);
|
||||
png_uint_32 reciprocal = 0;
|
||||
int c;
|
||||
|
||||
@@ -1980,7 +1983,7 @@ png_write_image_8bit(png_voidp argument)
|
||||
png_uint_32 component = *in_ptr++;
|
||||
|
||||
component *= 255;
|
||||
*out_ptr++ = (png_byte)PNG_sRGB_FROM_LINEAR(component);
|
||||
*out_ptr++ = (png_byte)(PNG_sRGB_FROM_LINEAR(component) & 0xff);
|
||||
}
|
||||
|
||||
png_write_row(png_ptr, output_row);
|
||||
@@ -2039,23 +2042,23 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
{
|
||||
if (channels >= 3) /* RGB */
|
||||
{
|
||||
palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
|
||||
entry[(2 ^ bgr)]);
|
||||
palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
|
||||
entry[1]);
|
||||
palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 *
|
||||
entry[bgr]);
|
||||
palette[i].blue = (png_byte)(0xff & PNG_sRGB_FROM_LINEAR(255 *
|
||||
entry[(2 ^ bgr)]));
|
||||
palette[i].green = (png_byte)(0xff & PNG_sRGB_FROM_LINEAR(255 *
|
||||
entry[1]));
|
||||
palette[i].red = (png_byte)(0xff & PNG_sRGB_FROM_LINEAR(255 *
|
||||
entry[bgr]));
|
||||
}
|
||||
|
||||
else /* Gray */
|
||||
palette[i].blue = palette[i].red = palette[i].green =
|
||||
(png_byte)PNG_sRGB_FROM_LINEAR(255 * *entry);
|
||||
(png_byte)(PNG_sRGB_FROM_LINEAR((255 * *entry)) & 0xff);
|
||||
}
|
||||
|
||||
else /* alpha */
|
||||
{
|
||||
png_uint_16 alpha = entry[afirst ? 0 : channels-1];
|
||||
png_byte alphabyte = (png_byte)PNG_DIV257(alpha);
|
||||
png_byte alphabyte = (png_byte)(PNG_DIV257(alpha) & 0xff);
|
||||
png_uint_32 reciprocal = 0;
|
||||
|
||||
/* Calculate a reciprocal, as in the png_write_image_8bit code above
|
||||
@@ -2287,7 +2290,9 @@ png_image_write_main(png_voidp argument)
|
||||
* it about 50 times. The speed-up in pngstest was about 10-20% of the
|
||||
* total (user) time on a heavily loaded system.
|
||||
*/
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
png_set_compression_level(png_ptr, 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check for the cases that currently require a pre-transform on the row
|
||||
@@ -2450,6 +2455,6 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* STDIO */
|
||||
#endif /* SIMPLIFIED_WRITE */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
47
pngwtran.c
47
pngwtran.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -56,14 +56,14 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
else
|
||||
{
|
||||
mask = 0x80;
|
||||
*dp = (png_byte)v;
|
||||
*dp = (png_byte)(v & 0xff);
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask != 0x80)
|
||||
*dp = (png_byte)v;
|
||||
*dp = (png_byte)(v & 0xff);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 6;
|
||||
*dp = (png_byte)v;
|
||||
*dp = (png_byte)(v & 0xff);
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
}
|
||||
|
||||
if (shift != 6)
|
||||
*dp = (png_byte)v;
|
||||
*dp = (png_byte)(v & 0xff);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 4;
|
||||
*dp = (png_byte)v;
|
||||
*dp = (png_byte)(v & 0xff);
|
||||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
}
|
||||
|
||||
if (shift != 4)
|
||||
*dp = (png_byte)v;
|
||||
*dp = (png_byte)(v & 0xff);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -150,8 +150,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
break;
|
||||
}
|
||||
|
||||
row_info->bit_depth = (png_byte)bit_depth;
|
||||
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
|
||||
row_info->bit_depth = (png_byte)(bit_depth & 0xff);
|
||||
row_info->pixel_depth =
|
||||
(png_byte)((bit_depth * row_info->channels) & 0xff);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
|
||||
row_info->width);
|
||||
}
|
||||
@@ -353,7 +354,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
@@ -392,7 +393,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -422,7 +423,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = *(sp++);
|
||||
*/
|
||||
sp+=3; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,11 +446,11 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = *(sp++);
|
||||
*/
|
||||
sp+=6; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
|
||||
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
@@ -464,7 +465,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,11 +484,11 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = *(sp++);
|
||||
*/
|
||||
sp+=2; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
|
||||
*(dp++) = (png_byte)((255 - *(sp++)) & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -538,8 +539,10 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
# ifdef PNG_16BIT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
@@ -568,5 +571,5 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE_TRANSFORMS */
|
||||
#endif /* WRITE */
|
||||
|
||||
110
pngwutil.c
110
pngwutil.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2015 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.)
|
||||
*
|
||||
@@ -278,15 +278,15 @@ optimize_cmf(png_bytep data, png_alloc_size_t data_size)
|
||||
|
||||
z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);
|
||||
|
||||
data[0] = (png_byte)z_cmf;
|
||||
data[0] = (png_byte)(z_cmf & 0xff);
|
||||
tmp = data[1] & 0xe0;
|
||||
tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;
|
||||
data[1] = (png_byte)tmp;
|
||||
data[1] = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
|
||||
#endif /* WRITE_OPTIMIZE_CMF */
|
||||
|
||||
/* Initialize the compressor for the appropriate type of compression. */
|
||||
static int
|
||||
@@ -663,7 +663,7 @@ png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp)
|
||||
if (output_len > 0)
|
||||
png_error(png_ptr, "error writing ancillary chunked compressed data");
|
||||
}
|
||||
#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
|
||||
#endif /* WRITE_COMPRESSED_TEXT */
|
||||
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
|
||||
defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
@@ -743,11 +743,11 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||
|
||||
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
return key_len;
|
||||
}
|
||||
#endif
|
||||
#endif /* WRITE_TEXT || WRITE_pCAL || WRITE_iCCP || WRITE_sPLT */
|
||||
|
||||
/* Write the IHDR chunk, and update the png_struct with the necessary
|
||||
* information. Note that the rest of this code depends upon this
|
||||
@@ -871,18 +871,18 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
interlace_type=PNG_INTERLACE_NONE;
|
||||
#endif
|
||||
|
||||
/* Save the relevent information */
|
||||
png_ptr->bit_depth = (png_byte)bit_depth;
|
||||
png_ptr->color_type = (png_byte)color_type;
|
||||
png_ptr->interlaced = (png_byte)interlace_type;
|
||||
/* Save the relevant information */
|
||||
png_ptr->bit_depth = (png_byte)(bit_depth & 0xff);
|
||||
png_ptr->color_type = (png_byte)(color_type & 0xff);
|
||||
png_ptr->interlaced = (png_byte)(interlace_type & 0xff);
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_ptr->filter_type = (png_byte)filter_type;
|
||||
png_ptr->filter_type = (png_byte)(filter_type & 0xff);
|
||||
#endif
|
||||
png_ptr->compression_type = (png_byte)compression_type;
|
||||
png_ptr->compression_type = (png_byte)(compression_type & 0xff);
|
||||
png_ptr->width = width;
|
||||
png_ptr->height = height;
|
||||
|
||||
png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);
|
||||
png_ptr->pixel_depth = (png_byte)((bit_depth * png_ptr->channels) & 0xff);
|
||||
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
|
||||
/* Set the usr info, so any transformations can modify it */
|
||||
png_ptr->usr_width = png_ptr->width;
|
||||
@@ -892,11 +892,11 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
/* Pack the header information into the buffer */
|
||||
png_save_uint_32(buf, width);
|
||||
png_save_uint_32(buf + 4, height);
|
||||
buf[8] = (png_byte)bit_depth;
|
||||
buf[9] = (png_byte)color_type;
|
||||
buf[10] = (png_byte)compression_type;
|
||||
buf[11] = (png_byte)filter_type;
|
||||
buf[12] = (png_byte)interlace_type;
|
||||
buf[8] = (png_byte)(bit_depth & 0xff);
|
||||
buf[9] = (png_byte)(color_type & 0xff);
|
||||
buf[10] = (png_byte)(compression_type & 0xff);
|
||||
buf[11] = (png_byte)(filter_type & 0xff);
|
||||
buf[12] = (png_byte)(interlace_type & 0xff);
|
||||
|
||||
/* Write the chunk */
|
||||
png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
|
||||
@@ -1181,7 +1181,7 @@ png_write_sRGB(png_structrp png_ptr, int srgb_intent)
|
||||
png_warning(png_ptr,
|
||||
"Invalid sRGB rendering intent specified");
|
||||
|
||||
buf[0]=(png_byte)srgb_intent;
|
||||
buf[0]=(png_byte)(srgb_intent & 0xff);
|
||||
png_write_complete_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
|
||||
}
|
||||
#endif
|
||||
@@ -1285,10 +1285,10 @@ png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette)
|
||||
{
|
||||
if (spalette->depth == 8)
|
||||
{
|
||||
entrybuf[0] = (png_byte)ep->red;
|
||||
entrybuf[1] = (png_byte)ep->green;
|
||||
entrybuf[2] = (png_byte)ep->blue;
|
||||
entrybuf[3] = (png_byte)ep->alpha;
|
||||
entrybuf[0] = (png_byte)(ep->red & 0xff);
|
||||
entrybuf[1] = (png_byte)(ep->green & 0xff);
|
||||
entrybuf[2] = (png_byte)(ep->blue & 0xff);
|
||||
entrybuf[3] = (png_byte)(ep->alpha & 0xff);
|
||||
png_save_uint_16(entrybuf + 4, ep->frequency);
|
||||
}
|
||||
|
||||
@@ -1309,10 +1309,10 @@ png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette)
|
||||
{
|
||||
if (spalette->depth == 8)
|
||||
{
|
||||
entrybuf[0] = (png_byte)ep[i].red;
|
||||
entrybuf[1] = (png_byte)ep[i].green;
|
||||
entrybuf[2] = (png_byte)ep[i].blue;
|
||||
entrybuf[3] = (png_byte)ep[i].alpha;
|
||||
entrybuf[0] = (png_byte)(ep[i].red & 0xff);
|
||||
entrybuf[1] = (png_byte)(ep[i].green & 0xff);
|
||||
entrybuf[2] = (png_byte)(ep[i].blue & 0xff);
|
||||
entrybuf[3] = (png_byte)(ep[i].alpha & 0xff);
|
||||
png_save_uint_16(entrybuf + 4, ep[i].frequency);
|
||||
}
|
||||
|
||||
@@ -1348,8 +1348,8 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)
|
||||
{
|
||||
png_byte maxbits;
|
||||
|
||||
maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 :
|
||||
png_ptr->usr_bit_depth);
|
||||
maxbits = color_type==PNG_COLOR_TYPE_PALETTE ? 8 :
|
||||
(png_byte)(png_ptr->usr_bit_depth & 0xff);
|
||||
|
||||
if (sbit->red == 0 || sbit->red > maxbits ||
|
||||
sbit->green == 0 || sbit->green > maxbits ||
|
||||
@@ -1765,7 +1765,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
|
||||
png_write_compressed_data_out(png_ptr, &comp);
|
||||
|
||||
else
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.input_len);
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len);
|
||||
|
||||
png_write_chunk_end(png_ptr);
|
||||
}
|
||||
@@ -1786,7 +1786,7 @@ png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
|
||||
|
||||
png_save_int_32(buf, x_offset);
|
||||
png_save_int_32(buf + 4, y_offset);
|
||||
buf[8] = (png_byte)unit_type;
|
||||
buf[8] = (png_byte)(unit_type & 0xff);
|
||||
|
||||
png_write_complete_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
|
||||
}
|
||||
@@ -1841,8 +1841,8 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
png_write_chunk_data(png_ptr, new_purpose, purpose_len);
|
||||
png_save_int_32(buf, X0);
|
||||
png_save_int_32(buf + 4, X1);
|
||||
buf[8] = (png_byte)type;
|
||||
buf[9] = (png_byte)nparams;
|
||||
buf[8] = (png_byte)(type & 0xff);
|
||||
buf[9] = (png_byte)(nparams & 0xff);
|
||||
png_write_chunk_data(png_ptr, buf, (png_size_t)10);
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len);
|
||||
|
||||
@@ -1877,7 +1877,7 @@ png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width,
|
||||
return;
|
||||
}
|
||||
|
||||
buf[0] = (png_byte)unit;
|
||||
buf[0] = (png_byte)(unit & 0xff);
|
||||
memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */
|
||||
memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */
|
||||
|
||||
@@ -1902,7 +1902,7 @@ png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit,
|
||||
|
||||
png_save_uint_32(buf, x_pixels_per_unit);
|
||||
png_save_uint_32(buf + 4, y_pixels_per_unit);
|
||||
buf[8] = (png_byte)unit_type;
|
||||
buf[8] = (png_byte)(unit_type & 0xff);
|
||||
|
||||
png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
|
||||
}
|
||||
@@ -1968,7 +1968,7 @@ png_write_start_row(png_structrp png_ptr)
|
||||
|
||||
/* 1.5.6: added to allow checking in the row write code. */
|
||||
png_ptr->transformed_pixel_depth = png_ptr->pixel_depth;
|
||||
png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
|
||||
png_ptr->maximum_pixel_depth = (png_byte)(usr_pixel_depth & 0xff);
|
||||
|
||||
/* Set up row buffer */
|
||||
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);
|
||||
@@ -2015,7 +2015,7 @@ png_write_start_row(png_structrp png_ptr)
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* If interlaced, we need to set up width and height of pass */
|
||||
@@ -2180,7 +2180,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 7;
|
||||
*dp++ = (png_byte)d;
|
||||
*dp++ = (png_byte)(d & 0xff);
|
||||
d = 0;
|
||||
}
|
||||
|
||||
@@ -2189,7 +2189,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
|
||||
}
|
||||
if (shift != 7)
|
||||
*dp = (png_byte)d;
|
||||
*dp = (png_byte)(d & 0xff);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -2218,7 +2218,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 6;
|
||||
*dp++ = (png_byte)d;
|
||||
*dp++ = (png_byte)(d & 0xff);
|
||||
d = 0;
|
||||
}
|
||||
|
||||
@@ -2226,7 +2226,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
shift -= 2;
|
||||
}
|
||||
if (shift != 6)
|
||||
*dp = (png_byte)d;
|
||||
*dp = (png_byte)(d & 0xff);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -2254,7 +2254,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 4;
|
||||
*dp++ = (png_byte)d;
|
||||
*dp++ = (png_byte)(d & 0xff);
|
||||
d = 0;
|
||||
}
|
||||
|
||||
@@ -2262,7 +2262,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
shift -= 4;
|
||||
}
|
||||
if (shift != 4)
|
||||
*dp = (png_byte)d;
|
||||
*dp = (png_byte)(d & 0xff);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -2314,7 +2314,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
* been specified by the application, and then writes the row out with the
|
||||
* chosen filter.
|
||||
*/
|
||||
static void
|
||||
static void /* PRIVATE */
|
||||
png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
png_size_t row_bytes);
|
||||
|
||||
@@ -2688,8 +2688,8 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
|
||||
for (lp = row_buf + 1; i < row_bytes; i++)
|
||||
{
|
||||
*dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
||||
& 0xff);
|
||||
*dp++ =
|
||||
(png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff);
|
||||
}
|
||||
best_row = png_ptr->avg_row;
|
||||
}
|
||||
@@ -2905,7 +2905,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||
#endif
|
||||
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
|
||||
#else /* PNG_SLOW_PAETH */
|
||||
#else /* SLOW_PAETH */
|
||||
p = a + b - c;
|
||||
pa = abs(p - a);
|
||||
pb = abs(p - b);
|
||||
@@ -2919,7 +2919,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
|
||||
else
|
||||
p = c;
|
||||
#endif /* PNG_SLOW_PAETH */
|
||||
#endif /* SLOW_PAETH */
|
||||
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||
|
||||
@@ -2968,7 +2968,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
best_row = png_ptr->paeth_row;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
|
||||
/* Do the actual writing of the filtered row data from the chosen filter. */
|
||||
png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);
|
||||
@@ -2988,7 +2988,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
png_ptr->prev_filters[j] = best_row[0];
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
}
|
||||
|
||||
|
||||
@@ -3003,6 +3003,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
|
||||
png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
/* Swap the current and previous rows */
|
||||
if (png_ptr->prev_row != NULL)
|
||||
{
|
||||
@@ -3012,6 +3013,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
png_ptr->prev_row = png_ptr->row_buf;
|
||||
png_ptr->row_buf = tptr;
|
||||
}
|
||||
#endif /* WRITE_FILTER */
|
||||
|
||||
/* Finish row - updates counters and flushes zlib if last row */
|
||||
png_write_finish_row(png_ptr);
|
||||
@@ -3024,6 +3026,6 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
{
|
||||
png_write_flush(png_ptr);
|
||||
}
|
||||
#endif
|
||||
#endif /* WRITE_FLUSH */
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
VisualStudio instructions
|
||||
|
||||
libpng version 1.6.15beta03 - November 3, 2014
|
||||
libpng version 1.6.17rc03 - March 12, 2015
|
||||
|
||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
* zlib.props - location of zlib source
|
||||
*
|
||||
* libpng version 1.6.15beta03 - November 3, 2014
|
||||
* libpng version 1.6.17rc03 - March 12, 2015
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
*
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Makefiles for libpng version 1.6.15beta03 - November 3, 2014
|
||||
Makefiles for libpng version 1.6.17rc03 - March 12, 2015
|
||||
|
||||
pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng16.so.16.1.6.15beta03)
|
||||
(gcc, creates libpng16.so.16.1.6.17rc03)
|
||||
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 libpng16.so.16.1.6.15beta03)
|
||||
creates libpng16.so.16.1.6.17rc03)
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc,
|
||||
creates libpng16.so.16.1.6.15beta03)
|
||||
creates libpng16.so.16.1.6.17rc03)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng16.so.16.1.6.15beta03)
|
||||
creates libpng16.so.16.1.6.17rc03)
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* def.dfn - define format of libpng.def
|
||||
/* def.c - define format of libpng.def
|
||||
*
|
||||
* Last changed in libpng version 1.5.7 [December 15, 2011]
|
||||
* Copyright (c) 2010-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2011-2014 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -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.6.15beta03"
|
||||
PNG_DFN ";Version 1.6.17rc03"
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
|
||||
@@ -17,7 +17,7 @@
|
||||
BEGIN{
|
||||
out="/dev/null" # as a flag
|
||||
out_count=0 # count of output lines
|
||||
err=0 # set if an error occured
|
||||
err=0 # set if an error occurred
|
||||
sort=0 # sort the output
|
||||
array[""]=""
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/* intprefix.dfn - generate an unprefixed internal symbol list
|
||||
/* intprefix.c - generate an unprefixed internal symbol list
|
||||
*
|
||||
* Last changed in libpng version 1.6.0 [January 30, 2012]
|
||||
* Copyright (c) 2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2013-2014 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.6.15beta03
|
||||
version=1.6.17rc03
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
||||
@@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.6.15beta03
|
||||
Version: 1.6.17rc03
|
||||
Libs: -L${libdir} -lpng16
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -52,7 +52,9 @@ LDFLAGS=-L$(ZLIB_DIR) -M $(LDEBUG)
|
||||
|
||||
# Pre-built configuration
|
||||
# See scripts\pnglibconf.mak for more options
|
||||
!ifndef PNGLIBCONF_H_PREBUILT
|
||||
PNGLIBCONF_H_PREBUILT = scripts\pnglibconf.h.prebuilt
|
||||
!endif
|
||||
|
||||
## Variables
|
||||
OBJS = \
|
||||
|
||||
@@ -60,7 +60,9 @@ LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG)
|
||||
|
||||
# Pre-built configuration
|
||||
# See scripts\pnglibconf.mak for more options
|
||||
!ifndef PNGLIBCONF_H_PREBUILT
|
||||
PNGLIBCONF_H_PREBUILT = scripts\pnglibconf.h.prebuilt
|
||||
!endif
|
||||
|
||||
## Variables
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
VERMAJ = 1
|
||||
VERMIN = 6
|
||||
VERMIC = 15
|
||||
VERMIC = 17
|
||||
VER = $(VERMAJ).$(VERMIN).$(VERMIC)
|
||||
NAME = libpng
|
||||
PACKAGE = $(NAME)-$(VER)
|
||||
|
||||
@@ -36,12 +36,11 @@ LN_SF=ln -sf
|
||||
RANLIB=ranlib
|
||||
CP=cp
|
||||
RM_F=/bin/rm -f
|
||||
ARCH=-arch ppc -arch i386 -arch x86_64
|
||||
|
||||
CPPFLAGS=-I$(ZLIBINC)
|
||||
# CFLAGS=-W -Wall -O3 -funroll-loops
|
||||
CFLAGS=-W -Wall -O -funroll-loops $(ARCH)
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz $(ARCH)
|
||||
CFLAGS=-W -Wall -O -funroll-loops
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(exec_prefix)/lib
|
||||
@@ -113,7 +112,7 @@ $(LIBSOMAJ): $(OBJSDLL)
|
||||
$(CC) -dynamiclib \
|
||||
-install_name $(LIBPATH)/$(LIBSOMAJ) \
|
||||
-current_version 16 -compatibility_version 16 \
|
||||
$(ARCH) -o $(LIBSOMAJ) \
|
||||
-o $(LIBSOMAJ) \
|
||||
$(OBJSDLL) -L$(ZLIBLIB) -lz
|
||||
|
||||
pngtest: pngtest.o $(LIBSO)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
RELEASE = 15
|
||||
RELEASE = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
|
||||
@@ -18,7 +18,7 @@ exec_prefix=$(prefix)
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
RELEASE = 15
|
||||
RELEASE = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).dll
|
||||
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng16
|
||||
|
||||
LIB= png16
|
||||
SHLIB_MAJOR= 0
|
||||
SHLIB_MINOR= 1.6.15beta03
|
||||
SHLIB_MINOR= 1.6.17rc03
|
||||
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
|
||||
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include
|
||||
|
||||
LIB= png
|
||||
SHLIB_MAJOR= 16
|
||||
SHLIB_MINOR= 1.6.15beta03
|
||||
SHLIB_MINOR= 1.6.17rc03
|
||||
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
|
||||
|
||||
@@ -11,7 +11,7 @@ LIBDIR= ${PREFIX}/lib
|
||||
MANDIR= ${PREFIX}/man/cat
|
||||
|
||||
SHLIB_MAJOR= 16
|
||||
SHLIB_MINOR= 1.6.15beta03
|
||||
SHLIB_MINOR= 1.6.17rc03
|
||||
|
||||
LIB= png
|
||||
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \
|
||||
|
||||
@@ -16,7 +16,9 @@ CP=copy
|
||||
|
||||
# Pre-built configuration
|
||||
# See scripts\pnglibconf.mak for more options
|
||||
!ifndef PNGLIBCONF_H_PREBUILT
|
||||
PNGLIBCONF_H_PREBUILT = scripts\pnglibconf.h.prebuilt
|
||||
!endif
|
||||
|
||||
O=.obj
|
||||
E=.exe
|
||||
|
||||
@@ -16,7 +16,7 @@ CC = cl
|
||||
LD = link
|
||||
AR = lib
|
||||
CPPFLAGS = -I..\zlib
|
||||
CFLAGS = -nologo -D_CRT_SECURE_NO_DEPRECATE -MD -O2 -W3
|
||||
CFLAGS = -nologo -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -MD -O2 -W3
|
||||
LDFLAGS = -nologo
|
||||
ARFLAGS = -nologo
|
||||
CP = copy
|
||||
|
||||
@@ -303,7 +303,7 @@ option BENIGN_READ_ERRORS requires BENIGN_ERRORS
|
||||
option MNG_FEATURES
|
||||
|
||||
# Arithmetic options, the first is the big switch that chooses between internal
|
||||
# floating and fixed point arithmetic implementations - it does not affect an
|
||||
# floating and fixed point arithmetic implementations - it does not affect any
|
||||
# APIs. The second two (the _POINT settings) switch off individual APIs.
|
||||
#
|
||||
# Prior to libpng 1.6.8 one of the API (_POINT) variants had to be selected. At
|
||||
@@ -350,36 +350,15 @@ option USER_MEM
|
||||
|
||||
option IO_STATE
|
||||
|
||||
# This is only for PowerPC big-endian and 680x0 systems
|
||||
# some testing, not enabled by default.
|
||||
# NO LONGER USED
|
||||
|
||||
#option READ_BIG_ENDIAN disabled
|
||||
|
||||
# Allow users to control limits on what the READ code will
|
||||
# read:
|
||||
|
||||
# Added at libpng-1.2.43; adds limit fields to png_struct,
|
||||
# allows some usages of these fields
|
||||
|
||||
option USER_LIMITS
|
||||
|
||||
# Added at libpng-1.2.6; adds setting APIs, allows additional
|
||||
# usage of this field (UTSL)
|
||||
|
||||
option SET_USER_LIMITS requires USER_LIMITS
|
||||
|
||||
# Feature added at libpng-1.4.0, this flag added at 1.4.1
|
||||
option SET_USER_LIMITS enables SET_CHUNK_CACHE_LIMIT
|
||||
# Feature added at libpng-1.4.1, this flag added at 1.4.1
|
||||
|
||||
option SET_USER_LIMITS enables SET_CHUNK_MALLOC_LIMIT
|
||||
|
||||
# Libpng limits.
|
||||
# Libpng limits: limit the size of images and data on read.
|
||||
#
|
||||
# If these settings are *not* set libpng will not limit the size of
|
||||
# images or the size of data in ancilliary chunks. This does lead to
|
||||
# security issues if PNG files come from untrusted sources. Settings have the
|
||||
# If this option is disabled all the limit checking code will be disabled:
|
||||
|
||||
option USER_LIMITS requires READ
|
||||
|
||||
# The default settings given below for the limits mean that libpng will
|
||||
# limit the size of images or the size of data in ancilliary chunks to less
|
||||
# than the specification or implementation limits. Settings have the
|
||||
# following interpretations:
|
||||
#
|
||||
# USER_WIDTH_MAX: maximum width of an image that will be read
|
||||
@@ -388,18 +367,18 @@ option SET_USER_LIMITS enables SET_CHUNK_MALLOC_LIMIT
|
||||
# USER_CHUNK_CACHE_MAX: maximum number of chunks to be cached
|
||||
#
|
||||
# Only chunks that are variable in number are counted towards the
|
||||
# USER_CHUNK_CACHE_MAX limit
|
||||
setting USER_WIDTH_MAX
|
||||
setting USER_HEIGHT_MAX
|
||||
setting USER_CHUNK_CACHE_MAX
|
||||
setting USER_CHUNK_MALLOC_MAX
|
||||
|
||||
# To default all these settings to values that are large but probably
|
||||
# safe turn the SAFE_LIMITS option on; this will cause the value in
|
||||
# pngpriv.h to be used. Individual values can also be set, simply set
|
||||
# them in pngusr.dfa with '@#define PNG_setting value' lines.
|
||||
option SAFE_LIMITS enables USER_LIMITS disabled
|
||||
= SAFE_LIMITS SAFE_LIMITS
|
||||
# Use 0x7fffffff for unlimited
|
||||
setting USER_WIDTH_MAX default 1000000
|
||||
setting USER_HEIGHT_MAX default 1000000
|
||||
|
||||
# Use 0 for unlimited
|
||||
setting USER_CHUNK_CACHE_MAX default 1000
|
||||
setting USER_CHUNK_MALLOC_MAX default 8000000
|
||||
|
||||
# If this option is enabled APIs to set the above limits at run time are added;
|
||||
# without this the hardwired (compile time) limits will be used.
|
||||
option SET_USER_LIMITS requires USER_LIMITS
|
||||
|
||||
# All of the following options relate to code capabilities for
|
||||
# processing image data before creating a PNG or after reading one.
|
||||
@@ -541,6 +520,7 @@ option USER_TRANSFORM_INFO if READ_USER_TRANSFORM, WRITE_USER_TRANSFORM
|
||||
# non-IDAT chunks (zTXt, iTXt, iCCP, and unknown chunks). This feature
|
||||
# was added at libpng-1.5.3.
|
||||
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION requires WRITE
|
||||
option WRITE_CUSTOMIZE_COMPRESSION requires WRITE
|
||||
|
||||
# Any chunks you are not interested in, you can undef here. The
|
||||
# ones that allocate memory may be expecially important (hIST,
|
||||
@@ -666,7 +646,7 @@ setting QUANTIZE_BLUE_BITS default 5
|
||||
# are only interested in 8 bits anyway. Increasing this value
|
||||
# results in more memory being used, and more pow() functions
|
||||
# being called to fill in the gamma tables. Don't set this value
|
||||
# less then 8, and even that may not work (I haven't tested it).
|
||||
# less than 8, and even that may not work (I haven't tested it).
|
||||
|
||||
setting MAX_GAMMA_8 default 11
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* libpng 1.6.15beta03 STANDARD API DEFINITION */
|
||||
/* libpng 1.6.17rc03 STANDARD API DEFINITION */
|
||||
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* Libpng version 1.6.15beta03 - November 3, 2014 */
|
||||
/* Libpng version 1.6.17rc03 - March 12, 2015 */
|
||||
|
||||
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
|
||||
|
||||
@@ -97,7 +97,6 @@
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
|
||||
#define PNG_SAVE_INT_32_SUPPORTED
|
||||
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
@@ -129,6 +128,7 @@
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_FILLER_SUPPORTED
|
||||
#define PNG_WRITE_FILTER_SUPPORTED
|
||||
@@ -198,6 +198,10 @@
|
||||
#define PNG_QUANTIZE_RED_BITS 5
|
||||
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
|
||||
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
|
||||
#define PNG_USER_CHUNK_CACHE_MAX 1000
|
||||
#define PNG_USER_CHUNK_MALLOC_MAX 8000000
|
||||
#define PNG_USER_HEIGHT_MAX 1000000
|
||||
#define PNG_USER_WIDTH_MAX 1000000
|
||||
#define PNG_WEIGHT_SHIFT 8
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
#define PNG_ZLIB_VERNUM 0 /* unknown */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/* prefix.dfn - generate an unprefixed symbol list
|
||||
/* prefix.c - generate an unprefixed symbol list
|
||||
*
|
||||
* Last changed in libpng version 1.6.0 [January 30, 2012]
|
||||
* Copyright (c) 2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2013-2014 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/* sym.dfn - define format of libpng.sym
|
||||
/* sym.c - define format of libpng.sym
|
||||
*
|
||||
* Last changed in libpng version 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2011-2014 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/* symbols.dfn - find all exported symbols
|
||||
/* symbols.c - find all exported symbols
|
||||
*
|
||||
* Last changed in libpng version 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2011-2014 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -1,4 +1,4 @@
|
||||
;Version 1.6.15beta03
|
||||
;Version 1.6.17rc03
|
||||
;--------------------------------------------------------------
|
||||
; LIBPNG symbol list as a Win32 DEF file
|
||||
; Contains all the symbols that can be exported from libpng
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/* vers.dfn - define format of libpng.vers
|
||||
/* vers.c - define format of libpng.vers
|
||||
*
|
||||
* Last changed in libpng version 1.5.0 [January 6, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2011-2014 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
Reference in New Issue
Block a user