Merge branch releases/1.8 revisions r5311:r5314 into trunk

- Update libpng to 1.6.23 (from 1.6.21)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5315 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2016-07-09 09:36:42 +00:00
parent 14a41bbc61
commit 413316708c
25 changed files with 1289 additions and 341 deletions

View File

@ -1,4 +1,4 @@
Libpng 1.6.21 - January 15, 2016
Libpng 1.6.23 - June 9, 2016
This is a public release of libpng, intended for use in production codes.
@ -7,51 +7,39 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
libpng-1.6.21.tar.xz (LZMA-compressed, recommended)
libpng-1.6.21.tar.gz
libpng-1.6.23.tar.xz (LZMA-compressed, recommended)
libpng-1.6.23.tar.gz
Source files with CRLF line endings (for Windows), without the
"configure" script
/scratch/glennrp/Libpng16/lpng1621.7z (LZMA-compressed, recommended)
/scratch/glennrp/Libpng16/lpng1621.zip
lpng1623.7z (LZMA-compressed, recommended)
lpng1623.zip
Other information:
libpng-1.6.21-README.txt
libpng-1.6.21-LICENSE.txt
libpng-1.6.21-*.asc (armored detached GPG signatures)
libpng-1.6.23-README.txt
libpng-1.6.23-LICENSE.txt
libpng-1.6.23-*.asc (armored detached GPG signatures)
Changes since the last public release (1.6.20):
Changes since the last public release (1.6.22):
Fixed syntax "$(command)" in tests/pngstest that some shells other than
bash could not parse (Bug report by Nelson Beebe). Use `command` instead.
Moved png_check_keyword() from pngwutil.c to pngset.c
Removed LE/BE dependencies in pngvalid, to 'fix' the current problem
in the BigEndian tests by not testing it, making the BE code the same
as the LE version.
Fixes to pngvalid for various reduced build configurations (eliminate unused
statics) and a fix for the case in rgb_to_gray when the digitize option
reduces graylo to 0, producing a large error.
Widened the 'limit' check on the internally calculated error limits in
the 'DIGITIZE' case (the code used prior to 1.7 for rgb_to_gray error
checks) and changed the check to only operate in non-release builds
(base build type not RC or RELEASE.)
Fixed undefined behavior in pngvalid.c, undefined because
(png_byte) << shift is undefined if it changes the signed bit
(because png_byte is promoted to int). The libpng exported functions
png_get_uint_32 and png_get_uint_16 handle this. (Bug reported by
David Drysdale as a result of reports from UBSAN in clang 3.8).
This changes pngvalid to use BE random numbers; this used to produce
errors but these should not be fixed as a result of the previous changes.
In projects/vstudio, combined readme.txt and WARNING into README.txt
Relocated assert() in contrib/tools/pngfix.c, bug found by American
Fuzzy Lop, reported by Brian Carpenter.
Marked 'limit' UNUSED in transform_range_check(). This only affects
release builds.
Worked around a false-positive Coverity issue in pngvalid.c.
Stop a potential memory leak in png_set_tRNS() (Bug report by Ted Ying).
Fixed the progressive reader to handle empty first IDAT chunk properly
(patch by Timothy Nikkel). This bug was introduced in libpng-1.6.0 and
only affected the libpng16 branch.
Added tests in pngvalid.c to check zero-length IDAT chunks in various
positions. Fixed the sequential reader to handle these more robustly
(John Bowler).
Corrected progressive read input buffer in pngvalid.c. The previous version
the code invariably passed just one byte at a time to libpng. The intent
was to pass a random number of bytes in the range 0..511.
Moved sse2 prototype from pngpriv.h to contrib/intel/intel_sse.patch.
Added missing ")" in pngerror.c (Matt Sarrett).
Fixed undefined behavior in png_push_save_buffer(). Do not call
memcpy() with a null source, even if count is zero (Leon Scroggins III).
Fixed bad link to RFC2083 in png.5 (Nikola Forro).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe)

View File

@ -5063,7 +5063,8 @@ Version 1.6.15beta04 [November 4, 2014]
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().
Fixed an out-of-range read in png_user_version_check() (Bug report from
Qixue Xiao, CVE-2015-8540).
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
@ -5484,6 +5485,117 @@ Version 1.6.21rc02 [January 7, 2016]
Version 1.6.21 [January 15, 2016]
Worked around a false-positive Coverity issue in pngvalid.c.
Version 1.6.22beta01 [January 23, 2016]
Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate
"tmpfile()" implementation in contrib/libtests/pngstest.c
Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io()
if there is no stdio.h support.
Added a png_image_write_to_memory() API and a number of assist macros
to allow an application that uses the simplified API write to bypass
stdio and write directly to memory.
Added some warnings (png.h) and some check code to detect *possible*
overflow in the ROW_STRIDE and simplified image SIZE macros. This
disallows image width/height/format that *might* overflow. This is
a quiet API change that limits in-memory image size (uncompressed) to
less than 4GByte and image row size (stride) to less than 2GByte.
Revised workaround for false-positive Coverity issue in pngvalid.c.
Version 1.6.22beta02 [February 8, 2016]
Only use exit(77) in configure builds.
Corrected error in PNG_IMAGE_PNG_SIZE_MAX. This new macro underreported
the palette size because it failed to take into account that the memory
palette has to be expanded to full RGB when it is written to PNG.
Updated CMakeLists.txt, added supporting scripts/gen*.cmake.in
and test.cmake.in (Roger Leigh).
Relaxed limit checks on gamma values in pngrtran.c. As suggested in
the comments gamma values outside the range currently permitted
by png_set_alpha_mode are useful for HDR data encoding. These values
are already permitted by png_set_gamma so it is reasonable caution to
extend the png_set_alpha_mode range as HDR imaging systems are starting
to emerge.
Version 1.6.22beta03 [March 9, 2016]
Added a common-law trademark notice and export control information
to the LICENSE file, png.h, and the man page.
Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that
were accidentally removed from libpng-1.6.17.
Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h
(Robert C. Seacord).
Removed dubious "#if INT_MAX" test from png.h that was added to
libpng-1.6.19beta02 (John Bowler).
Add ${INCLUDES} in scripts/genout.cmake.in (Bug report by Nixon Kwok).
Updated LICENSE to say files in the contrib directory are not
necessarily under the libpng license, and that some makefiles have
other copyright owners.
Added INTEL-SSE2 support (Mike Klein and Matt Sarett, Google, Inc.).
Made contrib/libtests/timepng more robust. The code no longer gives
up/fails on invalid PNG data, it just skips it (with error messages).
The code no longer fails on PNG files with data beyond IEND. Options
exist to use png_read_png (reading the whole image, not by row) and, in
that case, to apply any of the supported transforms. This makes for
more realistic testing; the decoded data actually gets used in a
meaningful fashion (John Bowler).
Fixed some misleading indentation (Krishnaraj Bhat).
Version 1.6.22beta04 [April 5, 2016]
Force GCC compilation to C89 if needed (Dagobert Michelsen).
SSE filter speed improvements for bpp=3:
memcpy-free implementations of load3() / store3().
call load3() only when needed at the end of a scanline.
Version 1.6.22beta05 [April 27, 2016]
Added PNG_FAST_FILTERS macro (defined as
PNG_FILTER_NONE|PNG_FILTER_SUB|PNG_FILTER_UP).
Various fixes for contrib/libtests/timepng.c
Moved INTEL-SSE code from pngpriv.h into contrib/intel/intel_sse.patch.
Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED
(Bug report by Y.Ohashik).
Version 1.6.22beta06 [May 5, 2016]
Rebased contrib/intel_sse.patch.
Quieted two Coverity issues in contrib/libtests/timepng.c.
Fixed issues with scripts/genout.cmake.in (David Capello, Nixon Kwok):
Added support to use multiple directories in ZLIBINCDIR variable,
Fixed CMAKE_C_FLAGS with multiple values when genout is compiled on MSVC,
Fixed pnglibconf.c compilation on OS X including the sysroot path.
Version 1.6.22rc01 [May 14, 2016]
No changes.
Version 1.6.22rc02 [May 16, 2016]
Removed contrib/timepng from default build; it does not build on platforms
that don't supply clock_gettime().
Version 1.6.22rc03 [May 17, 2016]
Restored contrib/timepng to default build but check for the presence
of clock_gettime() in configure.ac and Makefile.am.
Version 1.6.22 [May 26, 2016]
No changes.
Version 1.6.23beta01 [May 29, 2016]
Stop a potential memory leak in png_set_tRNS() (Bug report by Ted Ying).
Fixed the progressive reader to handle empty first IDAT chunk properly
(patch by Timothy Nikkel). This bug was introduced in libpng-1.6.0 and
only affected the libpng16 branch.
Added tests in pngvalid.c to check zero-length IDAT chunks in various
positions. Fixed the sequential reader to handle these more robustly
(John Bowler).
Version 1.6.23rc01 [June 2, 2016]
Corrected progressive read input buffer in pngvalid.c. The previous version
the code invariably passed just one byte at a time to libpng. The intent
was to pass a random number of bytes in the range 0..511.
Moved sse2 prototype from pngpriv.h to contrib/intel/intel_sse.patch.
Added missing ")" in pngerror.c (Matt Sarrett).
Version 1.6.23rc02 [June 4, 2016]
Fixed undefined behavior in png_push_save_buffer(). Do not call
memcpy() with a null source, even if count is zero (Leon Scroggins III).
Version 1.6.23 [June 9, 2016]
Fixed bad link to RFC2083 in png.5 (Nikola Forro).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@ -1,13 +1,32 @@
# CMakeLists.txt
# Copyright (C) 2007-2015 Glenn Randers-Pehrson
# Copyright (C) 2007,2009-2016 Glenn Randers-Pehrson
# Written by Christian Ehrlicher, 2007
# Revised by Roger Lowman, 2009-2010
# Revised by Clifford Yapp, 2011-2012
# Revised by Roger Leigh, 2016
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
cmake_minimum_required(VERSION 2.8.3)
cmake_policy(VERSION 2.8.3)
# Set MacOSX @rpath usage globally.
if (POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif(POLICY CMP0020)
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif(POLICY CMP0042)
# Use new variable expansion policy.
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif(POLICY CMP0053)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif(POLICY CMP0054)
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
@ -16,7 +35,7 @@ enable_testing()
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
set(PNGLIB_RELEASE 21)
set(PNGLIB_RELEASE 23)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
@ -47,32 +66,284 @@ option(PNG_FRAMEWORK "Build OS X framework" OFF)
option(PNG_DEBUG "Build with debug output" OFF)
option(PNGARG "Disable ANSI-C prototypes" OFF)
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
# SET LIBNAME
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
# to distinguish between debug and release lib
set(CMAKE_DEBUG_POSTFIX "d")
# Use the prebuilt pnglibconf.h file from the scripts folder
# TODO: fix this by building with awk; without this no cmake build can be
# configured directly (to do so indirectly use your local awk to build a
# pnglibconf.h in the build directory.)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
include(CheckCSourceCompiles)
option(ld-version-script "Enable linker version script" ON)
if(ld-version-script AND NOT APPLE)
# Check if LD supports linker scripts.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
local: *;
};
VERS_2 {
global: sym2;
main;
} VERS_1;
")
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
check_c_source_compiles("void sym(void) {}
void sym2(void) {}
int main(void) {return 0;}
" HAVE_LD_VERSION_SCRIPT)
if(NOT HAVE_LD_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
check_c_source_compiles("void sym(void) {}
void sym2(void) {}
int main(void) {return 0;}
" HAVE_SOLARIS_LD_VERSION_SCRIPT)
endif()
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
endif()
# Find symbol prefix. Likely obsolete and unnecessary with recent
# toolchains (it's not done in many other projects).
function(symbol_prefix)
set(SYMBOL_PREFIX)
execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-"
INPUT_FILE /dev/null
OUTPUT_VARIABLE OUT
RESULT_VARIABLE STATUS)
if(CPP_FAIL)
message(WARNING "Failed to run the C preprocessor")
endif()
string(REPLACE "\n" ";" OUT "${OUT}")
foreach(line ${OUT})
string(REGEX MATCH "^PREFIX=" found_match "${line}")
if(found_match)
STRING(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}")
if(found_match)
STRING(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
endif()
set(SYMBOL_PREFIX "${prefix}")
endif()
endforeach()
message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
endfunction()
if(UNIX)
symbol_prefix()
endif()
find_program(AWK NAMES gawk awk)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(NOT AWK)
# No awk available to generate sources; use pre-built pnglibconf.h
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
add_custom_target(genfiles) # Dummy
else()
include(CMakeParseArguments)
# Generate .chk from .out with awk
# generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_chk)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _GC_INPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
endif()
if (NOT _GC_OUTPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
endif()
add_custom_command(OUTPUT "${_GC_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GC_INPUT}"
"-DOUTPUT=${_GC_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake"
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate .out from .c with awk
# generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_out)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _GO_INPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
endif()
if (NOT _GO_OUTPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
endif()
add_custom_command(OUTPUT "${_GO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GO_INPUT}"
"-DOUTPUT=${_GO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake"
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate specific source file with awk
# generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_source)
set(options)
set(oneValueArgs OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _GSO_OUTPUT)
message(FATAL_ERROR "Invalid arguments. generate_source requires output.")
endif()
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=${_GSO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
DEPENDS ${_GSO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Copy file
function(generate_copy source destination)
add_custom_command(OUTPUT "${destination}"
COMMAND "${CMAKE_COMMAND}" -E remove "${destination}"
COMMAND "${CMAKE_COMMAND}" -E copy "${source}"
"${destination}"
DEPENDS "${source}")
endfunction()
# Generate scripts/pnglibconf.h
generate_source(OUTPUT "scripts/pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
# Generate pnglibconf.c
generate_source(OUTPUT "pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
if(PNG_PREFIX)
set(PNGLIBCONF_H_EXTRA_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst")
set(PNGPREFIX_H_EXTRA_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
endif()
generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pnglibconf.h
generate_source(OUTPUT "pnglibconf.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
${PNGLIBCONF_H_EXTRA_DEPENDS})
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pngprefix.h
generate_source(OUTPUT "pngprefix.h"
DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
add_custom_target(symbol-check DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
add_custom_target("genprebuilt"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=scripts/pnglibconf.h.prebuilt"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
# A single target handles generation of all generated files. If
# they are dependend upon separately by multiple targets, this
# confuses parallel make (it would require a separate top-level
# target for each file to track the dependencies properly).
add_custom_target(genfiles DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
"${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
endif(NOT AWK)
# OUR SOURCES
set(libpng_public_hdrs
png.h
pngconf.h
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
)
set(libpng_sources
${libpng_public_hdrs}
set(libpng_private_hdrs
pngpriv.h
pngdebug.h
pnginfo.h
pngpriv.h
pngstruct.h
)
if(AWK)
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
endif()
set(libpng_sources
${libpng_public_hdrs}
${libpng_private_hdrs}
png.c
pngerror.c
pngget.c
@ -98,7 +369,18 @@ set(pngvalid_sources
set(pngstest_sources
contrib/libtests/pngstest.c
)
# SOME NEEDED DEFINITIONS
set(pngunknown_sources
contrib/libtests/pngunknown.c
)
set(pngimage_sources
contrib/libtests/pngimage.c
)
set(pngfix_sources
contrib/tools/pngfix.c
)
set(png_fix_itxt_sources
contrib/tools/png-fix-itxt.c
)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
@ -114,33 +396,59 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
unset(PNG_LIB_TARGETS)
if(PNG_SHARED)
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
set(PNG_LIB_TARGETS ${PNG_LIB_NAME})
add_library(png SHARED ${libpng_sources})
set(PNG_LIB_TARGETS png)
set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME})
add_dependencies(png genfiles)
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
set_target_properties(png PROPERTIES PREFIX "lib")
set_target_properties(png PROPERTIES IMPORT_PREFIX "lib")
endif()
target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY})
if(UNIX AND AWK)
if(HAVE_LD_VERSION_SCRIPT)
set_target_properties(png PROPERTIES LINK_FLAGS
"-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT)
set_target_properties(png PROPERTIES LINK_FLAGS
"-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
endif()
endif()
target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
endif()
if(PNG_STATIC)
# 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})
set(PNG_LIB_NAME_STATIC png_static)
add_library(png_static STATIC ${libpng_sources})
add_dependencies(png_static genfiles)
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
if(NOT MSVC)
set_target_properties(png_static PROPERTIES
OUTPUT_NAME "${PNG_LIB_NAME}"
CLEAN_DIRECT_OUTPUT 1)
else()
set_target_properties(png_static PROPERTIES
OUTPUT_NAME "${PNG_LIB_NAME}_static"
CLEAN_DIRECT_OUTPUT 1)
endif()
list(APPEND PNG_LIB_TARGETS png_static)
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
set_target_properties(png_static PROPERTIES PREFIX "lib")
endif()
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
target_link_libraries(png_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
set(PNG_LIB_NAME_FRAMEWORK png_framework)
add_library(png_framework SHARED ${libpng_sources})
add_dependencies(png_framework genfiles)
list(APPEND PNG_LIB_TARGETS png_framework)
set_target_properties(png_framework PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION ${PNGLIB_VERSION}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR}
@ -149,7 +457,7 @@ if(PNG_FRAMEWORK)
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
PUBLIC_HEADER "${libpng_public_hdrs}"
OUTPUT_NAME png)
target_link_libraries(${PNG_LIB_NAME_FRAMEWORK} ${ZLIB_LIBRARY} ${M_LIBRARY})
target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY})
endif()
if(NOT PNG_LIB_TARGETS)
@ -160,52 +468,170 @@ if(NOT PNG_LIB_TARGETS)
endif()
if(PNG_SHARED AND WIN32)
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
endif()
function(png_add_test)
set(options)
set(oneValueArgs NAME COMMAND)
set(multiValueArgs OPTIONS FILES)
cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _PAT_NAME)
message(FATAL_ERROR "Invalid arguments. png_add_test requires name.")
endif()
if (NOT _PAT_COMMAND)
message(FATAL_ERROR "Invalid arguments. png_add_test requires command.")
endif()
set(TEST_OPTIONS "${_PAT_OPTIONS}")
set(TEST_FILES "${_PAT_FILES}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY)
if(CMAKE_MAJOR_VERSION GREATER 2) # have generator expressions
add_test(NAME "${_PAT_NAME}"
COMMAND "${CMAKE_COMMAND}"
"-DLIBPNG=$<TARGET_FILE:png>"
"-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
else() # old 2.x add_test; limited and won't work well on Windows
# Note LIBPNG is a dummy value as there are no generator expressions
add_test("${_PAT_NAME}" "${CMAKE_COMMAND}"
"-DLIBPNG=${CMAKE_CURRENT_BINARY_DIR}/libpng.so"
"-DTEST_COMMAND=./${_PAT_COMMAND}"
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
endif()
endfunction()
if(PNG_TESTS AND PNG_SHARED)
# does not work with msvc due to png_lib_ver issue
# Find test PNG files by globbing, but sort lists to ensure
# consistency between different filesystems.
file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png")
list(SORT PNGSUITE_PNGS)
file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png")
list(SORT TEST_PNGS)
set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
add_executable(pngtest ${pngtest_sources})
target_link_libraries(pngtest ${PNG_LIB_NAME})
add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
#
target_link_libraries(pngtest png)
png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}")
add_executable(pngvalid ${pngvalid_sources})
target_link_libraries(pngvalid ${PNG_LIB_NAME})
add_test(pngvalid ./pngvalid)
target_link_libraries(pngvalid png)
png_add_test(NAME pngvalid-gamma-16-to-8
COMMAND pngvalid OPTIONS --gamma-16-to-8)
png_add_test(NAME pngvalid-gamma-alpha-mode
COMMAND pngvalid OPTIONS --gamma-alpha-mode)
png_add_test(NAME pngvalid-gamma-background
COMMAND pngvalid OPTIONS --gamma-background)
png_add_test(NAME pngvalid-gamma-expand16-alpha-mode
COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16)
png_add_test(NAME pngvalid-gamma-expand16-background
COMMAND pngvalid OPTIONS --gamma-background --expand16)
png_add_test(NAME pngvalid-gamma-expand16-transform
COMMAND pngvalid OPTIONS --gamma-transform --expand16)
png_add_test(NAME pngvalid-gamma-sbit
COMMAND pngvalid OPTIONS --gamma-sbit)
png_add_test(NAME pngvalid-gamma-threshold
COMMAND pngvalid OPTIONS --gamma-threshold)
png_add_test(NAME pngvalid-gamma-transform
COMMAND pngvalid OPTIONS --gamma-transform)
png_add_test(NAME pngvalid-progressive-interlace-standard
COMMAND pngvalid OPTIONS --standard --progressive-read --interlace)
png_add_test(NAME pngvalid-progressive-size
COMMAND pngvalid OPTIONS --size --progressive-read)
png_add_test(NAME pngvalid-progressive-standard
COMMAND pngvalid OPTIONS --standard --progressive-read)
png_add_test(NAME pngvalid-standard
COMMAND pngvalid OPTIONS --standard)
png_add_test(NAME pngvalid-transform
COMMAND pngvalid OPTIONS --transform)
add_executable(pngstest ${pngstest_sources})
target_link_libraries(pngstest ${PNG_LIB_NAME})
add_test(pngstest ./pngstest
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g01.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g02.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g04.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p01.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p02.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p04.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g01.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g02.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g04.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn2c16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn2c16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbrn2c08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn0g16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbyn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n0g08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n2c08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp1n3p08.png
)
target_link_libraries(pngstest png)
foreach(gamma_type 1.8 linear none sRGB)
foreach(alpha_type none alpha)
set(PNGSTEST_FILES)
foreach(test_png ${TEST_PNGS})
string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}")
string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}")
string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}")
string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}")
set(TEST_PNG_VALID TRUE)
if(TEST_PNG_ALPHA)
if (NOT "${alpha_type}" STREQUAL "alpha")
set(TEST_PNG_VALID FALSE)
endif()
else()
if ("${alpha_type}" STREQUAL "alpha")
set(TEST_PNG_VALID FALSE)
endif()
endif()
if(TEST_PNG_LINEAR)
if(NOT "${gamma_type}" STREQUAL "linear")
set(TEST_PNG_VALID FALSE)
endif()
elseif(TEST_PNG_SRGB)
if(NOT "${gamma_type}" STREQUAL "sRGB")
set(TEST_PNG_VALID FALSE)
endif()
elseif(TEST_PNG_G18)
if(NOT "${gamma_type}" STREQUAL "1.8")
set(TEST_PNG_VALID FALSE)
endif()
else()
if(NOT "${gamma_type}" STREQUAL "none")
set(TEST_PNG_VALID FALSE)
endif()
endif()
if(TEST_PNG_VALID)
list(APPEND PNGSTEST_FILES "${test_png}")
endif()
endforeach()
# Should already be sorted, but sort anyway to be certain.
list(SORT PNGSTEST_FILES)
png_add_test(NAME pngstest-${gamma_type}-${alpha_type}
COMMAND pngstest
OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log
FILES ${PNGSTEST_FILES})
endforeach()
endforeach()
add_executable(pngunknown ${pngunknown_sources})
target_link_libraries(pngunknown png)
png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-sAPI COMMAND pngunknown OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}")
add_executable(pngimage ${pngimage_sources})
target_link_libraries(pngimage png)
png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS})
png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS})
endif()
if(PNG_SHARED)
add_executable(pngfix ${pngfix_sources})
target_link_libraries(pngfix png)
set(PNG_BIN_TARGETS pngfix)
add_executable(png-fix-itxt ${png_fix_itxt_sources})
target_link_libraries(png-fix-itxt ${ZLIB_LIBRARY} ${M_LIBRARY})
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
endif()
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
@ -234,6 +660,15 @@ macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
endmacro()
# Create source generation scripts.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY)
# libpng is a library so default to 'lib'
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
@ -260,22 +695,12 @@ 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.21
set_target_properties(png PROPERTIES
# VERSION 16.${PNGLIB_RELEASE}.1.6.23
VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16
CLEAN_DIRECT_OUTPUT 1)
endif()
if(PNG_STATIC)
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
if(NOT MSVC)
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
OUTPUT_NAME ${PNG_LIB_NAME}
CLEAN_DIRECT_OUTPUT 1)
endif()
endif()
# If CMake > 2.4.x, we set a variable used below to export
# targets to an export file.
@ -298,14 +723,14 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
if(PNG_SHARED)
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(CYGWIN OR MINGW)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(CYGWIN OR MINGW)
if(NOT WIN32)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
@ -314,7 +739,7 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
if(PNG_STATIC)
if(NOT WIN32 OR CYGWIN OR MINGW)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
get_target_property(BUILD_TARGET_LOCATION png_static LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
@ -334,6 +759,11 @@ if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
endif(NOT WIN32 OR CYGWIN OR MINGW)
endif()
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL )
install(TARGETS ${PNG_BIN_TARGETS}
RUNTIME DESTINATION bin)
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
# Install man pages
if(NOT PNG_MAN_DIR)

View File

@ -47,7 +47,9 @@ If configure does not work on your system, or if you have a need to
change configure.ac or Makefile.am, and you have a reasonably
up-to-date set of tools, running ./autogen.sh in a git clone before
running ./configure may fix the problem. To be really sure that you
aren't using any of the included pre-built scripts, you can do this:
aren't using any of the included pre-built scripts, especially if you
are building from a tar distribution instead of a git distribution,
do this:
./configure --enable-maintainer-mode
make maintainer-clean

View File

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

View File

@ -1,4 +1,4 @@
README for libpng version 1.6.21 - January 15, 2016 (shared library 16.0)
README for libpng version 1.6.23 - June 9, 2016 (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.

View File

@ -1,14 +1,14 @@
echo "
There is no \"configure\" script in this distribution (*.zip or *.7z) of
libpng-1.6.21.
libpng-1.6.23.
Instead, please copy the appropriate makefile for your system from the
\"scripts\" directory. Read the INSTALL file for more details.
Update, July 2004: you can get a \"configure\" based distribution
from the libpng distribution sites. Download the file
libpng-1.6.21.tar.gz or libpng-1.6.21.tar.xz.
libpng-1.6.23.tar.gz or libpng-1.6.23.tar.xz.
If the line endings in the files look funny, which is likely to be the
case if you were trying to run \"configure\" on a Linux machine, you may

View File

@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.21 - January 15, 2016
libpng version 1.6.23 - June 9, 2016
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2016 Glenn Randers-Pehrson
@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.6.21 - January 15, 2016
libpng versions 0.97, January 1998, through 1.6.23 - June 9, 2016
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2016 Glenn Randers-Pehrson
@ -2842,7 +2842,7 @@ filter types.
PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG |
PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
PNG_ALL_FILTERS);
PNG_ALL_FILTERS | PNG_FAST_FILTERS);
If an application wants to start and stop using particular filters during
compression, it should start out with all of the filters (to ensure that
@ -4103,6 +4103,13 @@ be written:
Write the image to the named file.
int png_image_write_to_memory (png_imagep image, void *memory,
png_alloc_size_t * PNG_RESTRICT memory_bytes,
int convert_to_8_bit, const void *buffer, ptrdiff_t row_stride,
const void *colormap));
Write the image to memory.
int png_image_write_to_stdio(png_imagep image, FILE *file,
int convert_to_8_bit, const void *buffer,
png_int_32 row_stride, const void *colormap)
@ -4380,8 +4387,9 @@ for any images with bit depths less than 8 bits/pixel.
The 'method' parameter sets the main filtering method, which is
currently only '0' in the PNG 1.2 specification. The 'filters'
parameter sets which filter(s), if any, should be used for each
scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
to turn filtering on and off, respectively.
scanline. Possible values are PNG_ALL_FILTERS, PNG_NO_FILTERS,
or PNG_FAST_FILTERS to turn filtering on and off, or to turn on
just the fast-decoding subset of filters, respectively.
Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
@ -4395,12 +4403,19 @@ means the first row must always be adaptively filtered, because libpng
currently does not allocate the filter buffers until png_write_row()
is called for the first time.)
filters = PNG_FILTER_NONE | PNG_FILTER_SUB
filters = PNG_NO_FILTERS;
filters = PNG_ALL_FILTERS;
filters = PNG_FAST_FILTERS;
or
filters = PNG_FILTER_NONE | PNG_FILTER_SUB |
PNG_FILTER_UP | PNG_FILTER_AVG |
PNG_FILTER_PAETH | PNG_ALL_FILTERS;
PNG_FILTER_PAETH;
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
filters);
The second parameter can also be
PNG_INTRAPIXEL_DIFFERENCING if you are
writing a PNG to be embedded in a MNG
@ -4775,7 +4790,8 @@ There are no substantial API changes between the non-deprecated parts of
the 1.4.5 API and the 1.5.0 API; however, the ability to directly access
members of the main libpng control structures, png_struct and png_info,
deprecated in earlier versions of libpng, has been completely removed from
libpng 1.5.
libpng 1.5, and new private "pngstruct.h", "pnginfo.h", and "pngdebug.h"
header files were created.
We no longer include zlib.h in png.h. The include statement has been moved
to pngstruct.h, where it is not accessible by applications. Applications that
@ -5015,6 +5031,7 @@ includes the following:
png_image_free()
write functions
png_image_write_to_file()
png_image_write_to_memory()
png_image_write_to_stdio()
Starting with libpng-1.6.0, you can configure libpng to prefix all exported
@ -5328,7 +5345,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.6.21 are Y2K compliant. It is my belief that earlier
upward through 1.6.23 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

View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "January 15, 2016"
.TH LIBPNG 3 "June 9, 2016"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.21
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.23
.SH SYNOPSIS
\fB
#include <png.h>\fP
@ -229,6 +229,8 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.21
\fBint png_image_write_to_file (png_imagep \fP\fIimage\fP\fB, const char \fP\fI*file\fP\fB, int \fP\fIconvert_to_8bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fP\fIrow_stride\fP\fB, void \fI*colormap\fP\fB);\fP
\fBint png_image_write_to_memory (png_imagep \fP\fIimage\fP\fB, void \fP\fI*memory\fP\fB, png_alloc_size_t * PNG_RESTRICT \fP\fImemory_bytes\fP\fB, int \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fP\fIrow_stride\fP\fB, const void \fI*colormap)\fP\fB);\fP
\fBint png_image_write_to_stdio (png_imagep \fP\fIimage\fP\fB, FILE \fP\fI*file\fP\fB, int \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fP\fIrow_stride\fP\fB, void \fI*colormap)\fP\fB);\fP
\fBvoid png_info_init_3 (png_infopp \fP\fIinfo_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP
@ -508,7 +510,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.21 - January 15, 2016
libpng version 1.6.23 - June 9, 2016
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2016 Glenn Randers-Pehrson
@ -519,7 +521,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.6.21 - January 15, 2016
libpng versions 0.97, January 1998, through 1.6.23 - June 9, 2016
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2016 Glenn Randers-Pehrson
@ -3350,7 +3352,7 @@ filter types.
PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG |
PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
PNG_ALL_FILTERS);
PNG_ALL_FILTERS | PNG_FAST_FILTERS);
If an application wants to start and stop using particular filters during
compression, it should start out with all of the filters (to ensure that
@ -4611,6 +4613,13 @@ be written:
Write the image to the named file.
int png_image_write_to_memory (png_imagep image, void *memory,
png_alloc_size_t * PNG_RESTRICT memory_bytes,
int convert_to_8_bit, const void *buffer, ptrdiff_t row_stride,
const void *colormap));
Write the image to memory.
int png_image_write_to_stdio(png_imagep image, FILE *file,
int convert_to_8_bit, const void *buffer,
png_int_32 row_stride, const void *colormap)
@ -4888,8 +4897,9 @@ for any images with bit depths less than 8 bits/pixel.
The 'method' parameter sets the main filtering method, which is
currently only '0' in the PNG 1.2 specification. The 'filters'
parameter sets which filter(s), if any, should be used for each
scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
to turn filtering on and off, respectively.
scanline. Possible values are PNG_ALL_FILTERS, PNG_NO_FILTERS,
or PNG_FAST_FILTERS to turn filtering on and off, or to turn on
just the fast-decoding subset of filters, respectively.
Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
@ -4903,12 +4913,19 @@ means the first row must always be adaptively filtered, because libpng
currently does not allocate the filter buffers until png_write_row()
is called for the first time.)
filters = PNG_FILTER_NONE | PNG_FILTER_SUB
filters = PNG_NO_FILTERS;
filters = PNG_ALL_FILTERS;
filters = PNG_FAST_FILTERS;
or
filters = PNG_FILTER_NONE | PNG_FILTER_SUB |
PNG_FILTER_UP | PNG_FILTER_AVG |
PNG_FILTER_PAETH | PNG_ALL_FILTERS;
PNG_FILTER_PAETH;
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
filters);
The second parameter can also be
PNG_INTRAPIXEL_DIFFERENCING if you are
writing a PNG to be embedded in a MNG
@ -5283,7 +5300,8 @@ There are no substantial API changes between the non-deprecated parts of
the 1.4.5 API and the 1.5.0 API; however, the ability to directly access
members of the main libpng control structures, png_struct and png_info,
deprecated in earlier versions of libpng, has been completely removed from
libpng 1.5.
libpng 1.5, and new private "pngstruct.h", "pnginfo.h", and "pngdebug.h"
header files were created.
We no longer include zlib.h in png.h. The include statement has been moved
to pngstruct.h, where it is not accessible by applications. Applications that
@ -5523,6 +5541,7 @@ includes the following:
png_image_free()
write functions
png_image_write_to_file()
png_image_write_to_memory()
png_image_write_to_stdio()
Starting with libpng-1.6.0, you can configure libpng to prefix all exported
@ -5836,7 +5855,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.6.21 are Y2K compliant. It is my belief that earlier
upward through 1.6.23 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
@ -5934,11 +5953,11 @@ the first widely used release:
...
1.0.19 10 10019 10.so.0.19[.0]
...
1.2.53 13 10253 12.so.0.53[.0]
1.2.56 13 10256 12.so.0.56[.0]
...
1.5.23 15 10523 15.so.15.23[.0]
1.5.27 15 10527 15.so.15.27[.0]
...
1.6.21 16 10621 16.so.16.21[.0]
1.6.23 16 10623 16.so.16.23[.0]
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@ -5994,7 +6013,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.6.21 - January 15, 2016:
Libpng version 1.6.23 - June 9, 2016:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@ -6019,7 +6038,7 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
derived from libpng-1.0.6, and are distributed according to the same
disclaimer and license as libpng-1.0.6 with the following individuals
@ -6041,6 +6060,10 @@ and with the following additions to the disclaimer:
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
Some files in the "contrib" directory and some configure-generated
files that are distributed with libpng have other copyright owners and
are released under other open source licenses.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
libpng-0.96, and are distributed according to the same disclaimer and
@ -6064,6 +6087,9 @@ Contributing Authors:
Greg Roelofs
Tom Tanner
Some files in the "scripts" directory have other copyright owners
but are released under this license.
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -6104,6 +6130,29 @@ appreciated.
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
TRADEMARK:
The name "libpng" has not been registered by the Copyright owner
as a trademark in any jurisdiction. However, because libpng has
been distributed and maintained world-wide, continually since 1995,
the Copyright owner claims "common-law trademark protection" in any
jurisdiction where common-law trademark is recognized.
OSI CERTIFICATION:
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
a certification mark of the Open Source Initiative. OSI has not addressed
the additional disclaimers inserted at version 1.0.7.
EXPORT CONTROL:
The Copyright owner believes that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because
it is open source, publicly available software, that does not contain
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
734.7(b).
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
@ -6112,13 +6161,9 @@ boxes and the like:
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
a certification mark of the Open Source Initiative. OSI has not addressed
the additional disclaimers inserted at version 1.0.7.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
January 15, 2016
June 9, 2016
.\" end of man page

View File

@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "January 15, 2016"
.TH LIBPNGPF 3 "June 9, 2016"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.21
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.23
(private functions)
.SH SYNOPSIS
\fB#include \fI"pngpriv.h"

View File

@ -1,4 +1,4 @@
.TH PNG 5 "January 15, 2016"
.TH PNG 5 "June 9, 2016"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
@ -35,7 +35,7 @@ PNG 1.0 specification, October 1996:
RFC 2083
.IP
.br
ftp://ds.internic.net/rfc/rfc2083.txt
http://www.ietf.org/rfc/rfc2083.txt
.br
or (as a W3C Recommendation) at
.br

View File

@ -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_21 Your_png_h_is_not_version_1_6_21;
typedef png_libpng_version_1_6_23 Your_png_h_is_not_version_1_6_23;
/* 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
@ -775,14 +775,14 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.6.21 - January 15, 2016" PNG_STRING_NEWLINE \
"libpng version 1.6.23 - June 9, 2016" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2016 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.21 - January 15, 2016\
return "libpng version 1.6.23 - June 9, 2016\
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";

View File

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.6.21, January 15, 2016
* libpng version 1.6.23, June 9, 2016
*
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -12,7 +12,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.21, January 15, 2016:
* libpng versions 0.97, January 1998, through 1.6.23, June 9, 2016:
* Glenn Randers-Pehrson.
* See also "Contributing Authors", below.
*/
@ -25,7 +25,11 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are
* Some files in the "contrib" directory and some configure-generated
* files that are distributed with libpng have other copyright owners and
* are released under other open source licenses.
*
* libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
* derived from libpng-1.0.6, and are distributed according to the same
* disclaimer and license as libpng-1.0.6 with the following individuals
@ -47,6 +51,10 @@
* risk of satisfactory quality, performance, accuracy, and effort is with
* the user.
*
* Some files in the "contrib" directory have other copyright owners and
* are released under other open source licenses.
*
*
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
* libpng-0.96, and are distributed according to the same disclaimer and
@ -57,6 +65,9 @@
* Glenn Randers-Pehrson
* Willem van Schaik
*
* Some files in the "scripts" directory have different copyright owners
* but are also released under this license.
*
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
* and are distributed according to the same disclaimer and license as
@ -70,6 +81,9 @@
* Greg Roelofs
* Tom Tanner
*
* Some files in the "scripts" directory have other copyright owners
* but are released under this license.
*
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
*
@ -109,6 +123,29 @@
* appreciated.
*
* END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
*
* TRADEMARK:
*
* The name "libpng" has not been registered by the Copyright owner
* as a trademark in any jurisdiction. However, because libpng has
* been distributed and maintained world-wide, continually since 1995,
* the Copyright owner claims "common-law trademark protection" in any
* jurisdiction where common-law trademark is recognized.
*
* OSI CERTIFICATION:
*
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
* a certification mark of the Open Source Initiative. OSI has not addressed
* the additional disclaimers inserted at version 1.0.7.
*
* EXPORT CONTROL:
*
* The Copyright owner believes that the Export Control Classification
* Number (ECCN) for libpng is EAR99, which means not subject to export
* controls or International Traffic in Arms Regulations (ITAR) because
* it is open source, publicly available software, that does not contain
* any encryption software. See the EAR, paragraphs 734.3(b)(3) and
* 734.7(b).
*/
/*
@ -121,12 +158,6 @@
* files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
*/
/*
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
* a certification mark of the Open Source Initiative. OSI has not addressed
* the additional disclaimers inserted at version 1.0.7.
*/
/*
* The contributing authors would like to thank all those who helped
* with testing, bug fixes, and patience. This wouldn't have been
@ -182,11 +213,11 @@
* ...
* 1.0.19 10 10019 10.so.0.19[.0]
* ...
* 1.2.53 13 10253 12.so.0.53[.0]
* 1.2.56 13 10256 12.so.0.56[.0]
* ...
* 1.5.23 15 10523 15.so.15.23[.0]
* 1.5.27 15 10527 15.so.15.27[.0]
* ...
* 1.6.21 16 10621 16.so.16.21[.0]
* 1.6.23 16 10623 16.so.16.23[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -214,13 +245,13 @@
* Y2K compliance in libpng:
* =========================
*
* January 15, 2016
* June 9, 2016
*
* 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.21 are Y2K compliant. It is my belief that
* upward through 1.6.23 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
@ -282,9 +313,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.21"
#define PNG_LIBPNG_VER_STRING "1.6.23"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.6.21 - January 15, 2016\n"
" libpng version 1.6.23 - June 9, 2016\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@ -292,7 +323,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 21
#define PNG_LIBPNG_VER_RELEASE 23
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
@ -323,7 +354,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 10621 /* 1.6.21 */
#define PNG_LIBPNG_VER 10623 /* 1.6.23 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@ -433,7 +464,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_21;
typedef char* png_libpng_version_1_6_23;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@ -734,24 +765,22 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
* data in the info_struct to be written into the output file. The values
* of the PNG_INFO_<chunk> defines should NOT be changed.
*/
#define PNG_INFO_gAMA 0x0001
#define PNG_INFO_sBIT 0x0002
#define PNG_INFO_cHRM 0x0004
#define PNG_INFO_PLTE 0x0008
#define PNG_INFO_tRNS 0x0010
#define PNG_INFO_bKGD 0x0020
#define PNG_INFO_hIST 0x0040
#define PNG_INFO_pHYs 0x0080
#define PNG_INFO_oFFs 0x0100
#define PNG_INFO_tIME 0x0200
#define PNG_INFO_pCAL 0x0400
#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
#if INT_MAX >= 0x8000 /* else this might break */
#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */
#endif
#define PNG_INFO_gAMA 0x0001U
#define PNG_INFO_sBIT 0x0002U
#define PNG_INFO_cHRM 0x0004U
#define PNG_INFO_PLTE 0x0008U
#define PNG_INFO_tRNS 0x0010U
#define PNG_INFO_bKGD 0x0020U
#define PNG_INFO_hIST 0x0040U
#define PNG_INFO_pHYs 0x0080U
#define PNG_INFO_oFFs 0x0100U
#define PNG_INFO_tIME 0x0200U
#define PNG_INFO_pCAL 0x0400U
#define PNG_INFO_sRGB 0x0800U /* GR-P, 0.96a */
#define PNG_INFO_iCCP 0x1000U /* ESR, 1.0.6 */
#define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */
#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */
#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */
/* This is used for the transformation routines, as some of them
* change these values for the row. It also should enable using
@ -1322,7 +1351,7 @@ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */
/* Strip the second byte of information from a 16-bit depth file. */
PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
#endif
@ -1473,8 +1502,8 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
#define PNG_FILTER_UP 0x20
#define PNG_FILTER_AVG 0x40
#define PNG_FILTER_PAETH 0x80
#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
PNG_FILTER_AVG | PNG_FILTER_PAETH)
#define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP)
#define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH)
/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
* These defines should NOT be changed.
@ -1751,21 +1780,21 @@ PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
#define PNG_SET_WILL_FREE_DATA 1
#define PNG_USER_WILL_FREE_DATA 2
/* Flags for png_ptr->free_me and info_ptr->free_me */
#define PNG_FREE_HIST 0x0008
#define PNG_FREE_ICCP 0x0010
#define PNG_FREE_SPLT 0x0020
#define PNG_FREE_ROWS 0x0040
#define PNG_FREE_PCAL 0x0080
#define PNG_FREE_SCAL 0x0100
#define PNG_FREE_HIST 0x0008U
#define PNG_FREE_ICCP 0x0010U
#define PNG_FREE_SPLT 0x0020U
#define PNG_FREE_ROWS 0x0040U
#define PNG_FREE_PCAL 0x0080U
#define PNG_FREE_SCAL 0x0100U
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_FREE_UNKN 0x0200
# define PNG_FREE_UNKN 0x0200U
#endif
/* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */
#define PNG_FREE_PLTE 0x1000
#define PNG_FREE_TRNS 0x2000
#define PNG_FREE_TEXT 0x4000
#define PNG_FREE_ALL 0x7fff
#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
/* PNG_FREE_LIST 0x0400U removed in 1.6.0 because it is ignored */
#define PNG_FREE_PLTE 0x1000U
#define PNG_FREE_TRNS 0x2000U
#define PNG_FREE_TEXT 0x4000U
#define PNG_FREE_ALL 0x7fffU
#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
#ifdef PNG_USER_MEM_SUPPORTED
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
@ -2889,12 +2918,19 @@ typedef struct
* is the minimum 'row stride', the minimum count of components between each
* row. For a color-mapped image this is the minimum number of bytes in a
* row.
*
* WARNING: this macro overflows for some images with more than one component
* and very large image widths. libpng will refuse to process an image where
* this macro would overflow.
*/
#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
(PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
/* Return the size, in bytes, of an image buffer given a png_image and a row
* stride - the number of components to leave space for in each row.
*
* WARNING: this macro overflows a 32-bit integer for some large PNG images,
* libpng will refuse to process an image where such an overflow would occur.
*/
#define PNG_IMAGE_SIZE(image)\
@ -3015,7 +3051,6 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
#endif /* SIMPLIFIED_READ */
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
#ifdef PNG_STDIO_SUPPORTED
/* WRITE APIS
* ----------
* For write you must initialize a png_image structure to describe the image to
@ -3032,6 +3067,7 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
* values do not correspond to the colors in sRGB.
* colormap_entries: set to the number of entries in the color-map (0 to 256)
*/
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
const char *file, int convert_to_8bit, const void *buffer,
png_int_32 row_stride, const void *colormap));
@ -3041,8 +3077,9 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
const void *colormap));
/* Write the image to the given (FILE*). */
#endif /* SIMPLIFIED_WRITE_STDIO */
/* With both write APIs if image is in one of the linear formats with 16-bit
/* With all write APIs if image is in one of the linear formats with 16-bit
* data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
* gamma encoded according to the sRGB specification, otherwise a 16-bit linear
* encoded PNG file is written.
@ -3054,13 +3091,103 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
*
* With all APIs row_stride is handled as in the read APIs - it is the spacing
* from one row to the next in component sized units (1 or 2 bytes) and if
* negative indicates a bottom-up row layout in the buffer. If row_stride is zero,
* libpng will calculate it for you from the image width and number of channels.
* negative indicates a bottom-up row layout in the buffer. If row_stride is
* zero, libpng will calculate it for you from the image width and number of
* channels.
*
* Note that the write API does not support interlacing, sub-8-bit pixels, indexed
* PNG (color_type 3) or most ancillary chunks.
* Note that the write API does not support interlacing, sub-8-bit pixels or
* most ancillary chunks. If you need to write text chunks (e.g. for copyright
* notices) you need to use one of the other APIs.
*/
#endif /* STDIO */
PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit,
const void *buffer, png_int_32 row_stride, const void *colormap));
/* Write the image to the given memory buffer. The function both writes the
* whole PNG data stream to *memory and updates *memory_bytes with the count
* of bytes written.
*
* 'memory' may be NULL. In this case *memory_bytes is not read however on
* success the number of bytes which would have been written will still be
* stored in *memory_bytes. On failure *memory_bytes will contain 0.
*
* If 'memory' is not NULL it must point to memory[*memory_bytes] of
* writeable memory.
*
* If the function returns success memory[*memory_bytes] (if 'memory' is not
* NULL) contains the written PNG data. *memory_bytes will always be less
* than or equal to the original value.
*
* If the function returns false and *memory_bytes was not changed an error
* occured during write. If *memory_bytes was changed, or is not 0 if
* 'memory' was NULL, the write would have succeeded but for the memory
* buffer being too small. *memory_bytes contains the required number of
* bytes and will be bigger that the original value.
*/
#define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\
row_stride, colormap)\
png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\
row_stride, colormap)
/* Return the amount of memory in 'size' required to compress this image.
* The png_image structure 'image' must be filled in as in the above
* function and must not be changed before the actual write call, the buffer
* and all other parameters must also be identical to that in the final
* write call. The 'size' variable need not be initialized.
*
* NOTE: the macro returns true/false, if false is returned 'size' will be
* set to zero and the write failed and probably will fail if tried again.
*/
/* You can pre-allocate the buffer by making sure it is of sufficient size
* regardless of the amount of compression achieved. The buffer size will
* always be bigger than the original image and it will never be filled. The
* following macros are provided to assist in allocating the buffer.
*/
#define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height)
/* The number of uncompressed bytes in the PNG byte encoding of the image;
* uncompressing the PNG IDAT data will give this number of bytes.
*
* NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this
* macro can because of the extra bytes used in the PNG byte encoding. You
* need to avoid this macro if your image size approaches 2^30 in width or
* height. The same goes for the remainder of these macros; they all produce
* bigger numbers than the actual in-memory image size.
*/
#ifndef PNG_ZLIB_MAX_SIZE
# define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U)
/* An upper bound on the number of compressed bytes given 'b' uncompressed
* bytes. This is based on deflateBounds() in zlib; different
* implementations of zlib compression may conceivably produce more data so
* if your zlib implementation is not zlib itself redefine this macro
* appropriately.
*/
#endif
#define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\
PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image))
/* An upper bound on the size of the data in the PNG IDAT chunks. */
#define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
(((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
12U+3U*(image).colormap_entries/*PLTE data*/+\
(((image).format&PNG_FORMAT_FLAG_ALPHA)?\
12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
/* A helper for the following macro; if your compiler cannot handle the
* following macro use this one with the result of
* PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most
* compilers should handle this just fine.)
*/
#define PNG_IMAGE_PNG_SIZE_MAX(image)\
PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image))
/* An upper bound on the total length of the PNG data stream for 'image'.
* The result is of type png_alloc_size_t, on 32-bit systems this may
* overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will
* run out of buffer space but return a corrected size which should work.
*/
#endif /* SIMPLIFIED_WRITE */
/*******************************************************************************
* END OF SIMPLIFIED API
@ -3118,7 +3245,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
* one to use is one more than this.)
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
PNG_EXPORT_LAST_ORDINAL(244);
PNG_EXPORT_LAST_ORDINAL(245);
#endif
#ifdef __cplusplus

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.6.21, January 15, 2016
* libpng version 1.6.23, June 9, 2016
*
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -44,7 +44,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
if (png_ptr != NULL)
{
if ((png_ptr->flags &
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
{
if (*error_message == PNG_LITERAL_SHARP)
{

View File

@ -456,11 +456,11 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
return (retval);
}
#endif /* pHYs */
#endif /* INCH_CONVERSIONS */
#endif /* INCH_CONVERSIONS */
/* png_get_channels really belongs in here, too, but it's been around longer */
#endif /* EASY_ACCESS */
#endif /* EASY_ACCESS */
png_byte PNGAPI
@ -1142,19 +1142,19 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
return 0;
#ifdef PNG_WRITE_SUPPORTED
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
#endif
{
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
return png_ptr->IDAT_read_size;
return png_ptr->IDAT_read_size;
#else
return PNG_IDAT_READ_SIZE;
return PNG_IDAT_READ_SIZE;
#endif
}
#ifdef PNG_WRITE_SUPPORTED
else
return png_ptr->zbuffer_size;
else
return png_ptr->zbuffer_size;
#endif
}

View File

@ -1,6 +1,6 @@
/* pnglibconf.h - library build configuration */
/* libpng version 1.6.21, January 15, 2016 */
/* libpng version 1.6.23, June 9, 2016 */
/* Copyright (c) 1998-2016 Glenn Randers-Pehrson */
@ -107,6 +107,7 @@
#define PNG_SIMPLIFIED_READ_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
#define PNG_STDIO_SUPPORTED
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED

View File

@ -1,8 +1,8 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.6.18 [July 23, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.23 [June 9, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -210,12 +210,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
(png_ptr->mode & PNG_HAVE_PLTE) == 0)
png_error(png_ptr, "Missing PLTE before IDAT");
png_ptr->mode |= PNG_HAVE_IDAT;
png_ptr->process_mode = PNG_READ_IDAT_MODE;
if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
if (png_ptr->push_length == 0)
return;
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
if (png_ptr->push_length == 0)
return;
png_ptr->mode |= PNG_HAVE_IDAT;
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
@ -499,7 +501,10 @@ png_push_save_buffer(png_structrp png_ptr)
png_error(png_ptr, "Insufficient memory for save_buffer");
}
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
if (old_buffer)
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
else if (png_ptr->save_buffer_size)
png_error(png_ptr, "save_buffer error");
png_free(png_ptr, old_buffer);
png_ptr->save_buffer_max = new_max;
}

View File

@ -1,8 +1,8 @@
/* pngpriv.h - private declarations for use inside libpng
*
* Last changed in libpng 1.6.21 [January 15, 2016]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.22 [May 26, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*

View File

@ -1,8 +1,8 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.6.17 [March 26, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.23 [June 9, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -127,7 +127,10 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
}
else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
png_ptr->mode |= PNG_AFTER_IDAT;
}
/* This should be a binary subdivision search or a hash for
* matching the chunk name rather than a linear search.
@ -785,6 +788,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
png_uint_32 length = png_read_chunk_header(png_ptr);
png_uint_32 chunk_name = png_ptr->chunk_name;
if (chunk_name != png_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
if (chunk_name == png_IEND)
png_handle_IEND(png_ptr, info_ptr, length);
@ -799,9 +805,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
{
if (chunk_name == png_IDAT)
{
if ((length > 0) ||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|| (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, ".Too many IDATs found");
}
png_handle_unknown(png_ptr, info_ptr, length, keep);
if (chunk_name == png_PLTE)
@ -812,10 +818,14 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
else if (chunk_name == png_IDAT)
{
/* Zero length IDATs are legal after the last IDAT has been
* read, but not after other chunks have been read.
* read, but not after other chunks have been read. 1.6 does not
* always read all the deflate data; specifically it cannot be relied
* upon to read the Adler32 at the end. If it doesn't ignore IDAT
* chunks which are longer than zero as well:
*/
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|| (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "..Too many IDATs found");
png_crc_finish(png_ptr, length);
}
@ -3848,16 +3858,16 @@ png_image_read_direct(png_voidp argument)
else
filler = 255;
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
{
where = PNG_FILLER_BEFORE;
change &= ~PNG_FORMAT_FLAG_AFIRST;
}
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
{
where = PNG_FILLER_BEFORE;
change &= ~PNG_FORMAT_FLAG_AFIRST;
}
else
# endif
where = PNG_FILLER_AFTER;
else
#endif
where = PNG_FILLER_AFTER;
png_set_add_alpha(png_ptr, filler, where);
}
@ -3965,12 +3975,12 @@ png_image_read_direct(png_voidp argument)
if (info_ptr->bit_depth == 16)
info_format |= PNG_FORMAT_FLAG_LINEAR;
# ifdef PNG_FORMAT_BGR_SUPPORTED
if ((png_ptr->transformations & PNG_BGR) != 0)
info_format |= PNG_FORMAT_FLAG_BGR;
# endif
#ifdef PNG_FORMAT_BGR_SUPPORTED
if ((png_ptr->transformations & PNG_BGR) != 0)
info_format |= PNG_FORMAT_FLAG_BGR;
#endif
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
if (do_local_background == 2)
{
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
@ -4071,58 +4081,84 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
{
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
png_uint_32 check;
/* Check for row_stride overflow. This check is not performed on the
* original PNG format because it may not occur in the output PNG format
* and libpng deals with the issues of reading the original.
*/
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
if (row_stride == 0)
row_stride = PNG_IMAGE_ROW_STRIDE(*image);
if (row_stride < 0)
check = -row_stride;
else
check = row_stride;
if (image->opaque != NULL && buffer != NULL &&
check >= PNG_IMAGE_ROW_STRIDE(*image))
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
{
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
(image->colormap_entries > 0 && colormap != NULL))
png_uint_32 check;
const png_uint_32 png_row_stride = image->width * channels;
if (row_stride == 0)
row_stride = (png_int_32)/*SAFE*/png_row_stride;
if (row_stride < 0)
check = -row_stride;
else
check = row_stride;
if (image->opaque != NULL && buffer != NULL && check >= png_row_stride)
{
int result;
png_image_read_control display;
memset(&display, 0, (sizeof display));
display.image = image;
display.buffer = buffer;
display.row_stride = row_stride;
display.colormap = colormap;
display.background = background;
display.local_row = NULL;
/* Choose the correct 'end' routine; for the color-map case all the
* setup has already been done.
/* Now check for overflow of the image buffer calculation; this
* limits the whole image size to 32 bits for API compatibility with
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
*/
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
result =
png_safe_execute(image, png_image_read_colormap, &display) &&
png_safe_execute(image, png_image_read_colormapped, &display);
if (image->height <= 0xFFFFFFFF/png_row_stride)
{
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
(image->colormap_entries > 0 && colormap != NULL))
{
int result;
png_image_read_control display;
memset(&display, 0, (sizeof display));
display.image = image;
display.buffer = buffer;
display.row_stride = row_stride;
display.colormap = colormap;
display.background = background;
display.local_row = NULL;
/* Choose the correct 'end' routine; for the color-map case
* all the setup has already been done.
*/
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
result = png_safe_execute(image,
png_image_read_colormap, &display) &&
png_safe_execute(image,
png_image_read_colormapped, &display);
else
result =
png_safe_execute(image,
png_image_read_direct, &display);
png_image_free(image);
return result;
}
else
return png_image_error(image,
"png_image_finish_read[color-map]: no color-map");
}
else
result =
png_safe_execute(image, png_image_read_direct, &display);
png_image_free(image);
return result;
return png_image_error(image,
"png_image_finish_read: image too large");
}
else
return png_image_error(image,
"png_image_finish_read[color-map]: no color-map");
"png_image_finish_read: invalid argument");
}
else
return png_image_error(image,
"png_image_finish_read: invalid argument");
"png_image_finish_read: row_stride too large");
}
else if (image != NULL)

View File

@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.6.19 [November 12, 2015]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.22 [May 26, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -159,7 +159,7 @@ png_set_background(png_structrp png_ptr,
png_set_background_fixed(png_ptr, background_color, background_gamma_code,
need_expand, png_fixed(png_ptr, background_gamma, "png_set_background"));
}
# endif /* FLOATING_POINT */
# endif /* FLOATING_POINT */
#endif /* READ_BACKGROUND */
/* Scale 16-bit depth files to 8-bit depth. If both of these are set then the
@ -289,9 +289,12 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
* is expected to be 1 or greater, but this range test allows for some
* viewing correction values. The intent is to weed out users of this API
* who use the inverse of the gamma value accidentally! Since some of these
* values are reasonable this may have to be changed.
* values are reasonable this may have to be changed:
*
* 1.6.x: changed from 0.07..3 to 0.01..100 (to accomodate the optimal 16-bit
* gamma of 36, and its reciprocal.)
*/
if (output_gamma < 70000 || output_gamma > 300000)
if (output_gamma < 1000 || output_gamma > 10000000)
png_error(png_ptr, "output gamma out of expected range");
/* The default file gamma is the inverse of the output gamma; the output
@ -1912,7 +1915,7 @@ png_init_read_transformations(png_structrp png_ptr)
png_ptr->palette[i].blue = (png_byte)component;
}
}
#endif /* READ_SHIFT */
#endif /* READ_SHIFT */
}
/* Modify the info structure to reflect the transformations. The

View File

@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.6.21 [January 15, 2016]
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.23 [June 9, 2016]
* Copyright (c) 1998-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -952,12 +952,14 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep,
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
{
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
info_ptr->trans_alpha = png_voidcast(png_bytep,
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
}
png_ptr->trans_alpha = info_ptr->trans_alpha;
}
if (trans_color != NULL)

View File

@ -43,6 +43,15 @@
#include "png.h"
/* 1.6.1 added support for the configure test harness, which uses 77 to indicate
* a skipped test, in earlier versions we need to succeed on a skipped test, so:
*/
#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
# define SKIP 77
#else
# define SKIP 0
#endif
/* Known chunks that exist in pngtest.png must be supported or pngtest will fail
* simply as a result of re-ordering them. This may be fixed in 1.7
*
@ -2065,9 +2074,9 @@ main(void)
fprintf(STDERR,
" test ignored because libpng was not built with read support\n");
/* And skip this test */
return PNG_LIBPNG_VER < 10600 ? 0 : 77;
return SKIP;
}
#endif
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_21 Your_png_h_is_not_version_1_6_21;
typedef png_libpng_version_1_6_23 Your_png_h_is_not_version_1_6_23;

View File

@ -12,9 +12,9 @@
*/
#include "pngpriv.h"
#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
# include <errno.h>
#endif
#endif /* SIMPLIFIED_WRITE_STDIO */
#ifdef PNG_WRITE_SUPPORTED
@ -1452,7 +1452,6 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
# ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */
/* Initialize the write structure - general purpose utility. */
static int
png_image_write_init(png_imagep image)
@ -1504,6 +1503,10 @@ typedef struct
png_const_voidp first_row;
ptrdiff_t row_bytes;
png_voidp local_row;
/* Byte count for memory writing */
png_bytep memory;
png_alloc_size_t memory_bytes; /* not used for STDIO */
png_alloc_size_t output_bytes; /* running total */
} png_image_write_control;
/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to
@ -1931,9 +1934,43 @@ png_image_write_main(png_voidp argument)
png_set_benign_errors(png_ptr, 0/*error*/);
# endif
/* Default the 'row_stride' parameter if required. */
if (display->row_stride == 0)
display->row_stride = PNG_IMAGE_ROW_STRIDE(*image);
/* Default the 'row_stride' parameter if required, also check the row stride
* and total image size to ensure that they are within the system limits.
*/
{
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
{
png_uint_32 check;
const png_uint_32 png_row_stride = image->width * channels;
if (display->row_stride == 0)
display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
if (display->row_stride < 0)
check = -display->row_stride;
else
check = display->row_stride;
if (check >= png_row_stride)
{
/* Now check for overflow of the image buffer calculation; this
* limits the whole image size to 32 bits for API compatibility with
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
*/
if (image->height > 0xFFFFFFFF/png_row_stride)
png_error(image->opaque->png_ptr, "memory image too large");
}
else
png_error(image->opaque->png_ptr, "supplied row stride too small");
}
else
png_error(image->opaque->png_ptr, "image row stride too large");
}
/* Set the required transforms then write the rows in the correct order. */
if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0)
@ -2110,6 +2147,122 @@ png_image_write_main(png_voidp argument)
return 1;
}
static void (PNGCBAPI
image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data,
png_size_t size)
{
png_image_write_control *display = png_voidcast(png_image_write_control*,
png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
const png_alloc_size_t ob = display->output_bytes;
/* Check for overflow; this should never happen: */
if (size <= ((png_alloc_size_t)-1) - ob)
{
/* I don't think libpng ever does this, but just in case: */
if (size > 0)
{
if (display->memory_bytes >= ob+size) /* writing */
memcpy(display->memory+ob, data, size);
/* Always update the size: */
display->output_bytes = ob+size;
}
}
else
png_error(png_ptr, "png_image_write_to_memory: PNG too big");
}
static void (PNGCBAPI
image_memory_flush)(png_structp png_ptr)
{
PNG_UNUSED(png_ptr)
}
static int
png_image_write_memory(png_voidp argument)
{
png_image_write_control *display = png_voidcast(png_image_write_control*,
argument);
/* The rest of the memory-specific init and write_main in an error protected
* environment. This case needs to use callbacks for the write operations
* since libpng has no built in support for writing to memory.
*/
png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/,
image_memory_write, image_memory_flush);
return png_image_write_main(display);
}
int PNGAPI
png_image_write_to_memory(png_imagep image, void *memory,
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit,
const void *buffer, png_int_32 row_stride, const void *colormap)
{
/* Write the image to the given buffer, or count the bytes if it is NULL */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
if (memory_bytes != NULL && buffer != NULL)
{
/* This is to give the caller an easier error detection in the NULL
* case and guard against uninitialized variable problems:
*/
if (memory == NULL)
*memory_bytes = 0;
if (png_image_write_init(image) != 0)
{
png_image_write_control display;
int result;
memset(&display, 0, (sizeof display));
display.image = image;
display.buffer = buffer;
display.row_stride = row_stride;
display.colormap = colormap;
display.convert_to_8bit = convert_to_8bit;
display.memory = png_voidcast(png_bytep, memory);
display.memory_bytes = *memory_bytes;
display.output_bytes = 0;
result = png_safe_execute(image, png_image_write_memory, &display);
png_image_free(image);
/* write_memory returns true even if we ran out of buffer. */
if (result)
{
/* On out-of-buffer this function returns '0' but still updates
* memory_bytes:
*/
if (memory != NULL && display.output_bytes > *memory_bytes)
result = 0;
*memory_bytes = display.output_bytes;
}
return result;
}
else
return 0;
}
else
return png_image_error(image,
"png_image_write_to_memory: invalid argument");
}
else if (image != NULL)
return png_image_error(image,
"png_image_write_to_memory: incorrect PNG_IMAGE_VERSION");
else
return 0;
}
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
int PNGAPI
png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
const void *buffer, png_int_32 row_stride, const void *colormap)
@ -2117,7 +2270,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
/* Write the image to the given (FILE*). */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
if (file != NULL)
if (file != NULL && buffer != NULL)
{
if (png_image_write_init(image) != 0)
{
@ -2167,7 +2320,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
/* Write the image to the named file. */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
if (file_name != NULL)
if (file_name != NULL && buffer != NULL)
{
FILE *fp = fopen(file_name, "wb");
@ -2225,6 +2378,6 @@ png_image_write_to_file(png_imagep image, const char *file_name,
else
return 0;
}
# endif /* STDIO */
#endif /* SIMPLIFIED_WRITE_STDIO */
#endif /* SIMPLIFIED_WRITE */
#endif /* WRITE */

View File

@ -1,8 +1,8 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.6.21 [January 15, 2016]
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
* Last changed in libpng 1.6.22 [May 26, 2016]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -23,10 +23,10 @@
void PNGAPI
png_save_uint_32(png_bytep buf, png_uint_32 i)
{
buf[0] = (png_byte)(i >> 24);
buf[1] = (png_byte)(i >> 16);
buf[2] = (png_byte)(i >> 8);
buf[3] = (png_byte)(i );
buf[0] = (png_byte)((i >> 24) & 0xffU);
buf[1] = (png_byte)((i >> 16) & 0xffU);
buf[2] = (png_byte)((i >> 8) & 0xffU);
buf[3] = (png_byte)( i & 0xffU);
}
/* Place a 16-bit number into a buffer in PNG byte order.
@ -36,8 +36,8 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
void PNGAPI
png_save_uint_16(png_bytep buf, unsigned int i)
{
buf[0] = (png_byte)(i >> 8);
buf[1] = (png_byte)(i );
buf[0] = (png_byte)((i >> 8) & 0xffU);
buf[1] = (png_byte)( i & 0xffU);
}
#endif