Merge tag 'v1.6.37' into wx
This commit is contained in:
commit
d8030c38a2
63
ANNOUNCE
63
ANNOUNCE
@ -1,48 +1,47 @@
|
||||
Libpng 1.6.35 - July 15, 2018
|
||||
libpng 1.6.37 - April 14, 2019
|
||||
==============================
|
||||
|
||||
This is a public release of libpng, intended for use in production code.
|
||||
|
||||
Files available for download:
|
||||
|
||||
Files available for download
|
||||
----------------------------
|
||||
|
||||
Source files with LF line endings (for Unix/Linux):
|
||||
|
||||
libpng-1.6.35.tar.xz (LZMA-compressed, recommended)
|
||||
libpng-1.6.35.tar.gz
|
||||
* libpng-1.6.37.tar.xz (LZMA-compressed, recommended)
|
||||
* libpng-1.6.37.tar.gz
|
||||
|
||||
Source files with CRLF line endings (for Windows):
|
||||
|
||||
lp1635.7z (LZMA-compressed, recommended)
|
||||
lp1635.zip
|
||||
* lp1637.7z (LZMA-compressed, recommended)
|
||||
* lp1637.zip
|
||||
|
||||
Other information:
|
||||
|
||||
libpng-1.6.35-README.txt
|
||||
libpng-1.6.35-LICENSE.txt
|
||||
* README.md
|
||||
* LICENSE.md
|
||||
* AUTHORS.md
|
||||
* TRADEMARK.md
|
||||
|
||||
Changes since the last public release (1.6.34):
|
||||
|
||||
Restored 21 of the contrib/pngsuite/i*.png, which do not cause test
|
||||
failures. Placed the remainder in contrib/pngsuite/interlaced/i*.png.
|
||||
Added calls to png_set_*() transforms commonly used by browsers to
|
||||
the fuzzer.
|
||||
Removed some unnecessary brackets in pngrtran.c
|
||||
Fixed miscellaneous typos (Patch by github user "luzpaz").
|
||||
Change "ASM C" to "C ASM" in CMakeLists.txt
|
||||
Fixed incorrect handling of bKGD chunk in sub-8-bit files (Cosmin)
|
||||
Added hardware optimization directories to zip and 7z distributions.
|
||||
Fixed incorrect bitmask for options.
|
||||
Fixed many spelling typos.
|
||||
Make png_get_iCCP consistent with man page (allow compression-type argument
|
||||
to be NULL, bug report by Lenard Szolnoki).
|
||||
Replaced the remaining uses of png_size_t with size_t (Cosmin)
|
||||
Fixed the calculation of row_factor in png_check_chunk_length
|
||||
(reported by Thuan Pham in SourceForge issue #278)
|
||||
Added missing parentheses to a macro definition
|
||||
(suggested by "irwir" in GitHub issue #216)
|
||||
Changes since the previous public release (version 1.6.36)
|
||||
----------------------------------------------------------
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
* Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
|
||||
* Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
|
||||
* Fixed a memory leak in pngtest.c.
|
||||
* Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
|
||||
contrib/pngminus; refactor.
|
||||
* Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
|
||||
(Contributed by Willem van Schaik)
|
||||
* Fixed a typo in the libpng license v2.
|
||||
(Contributed by Miguel Ojeda)
|
||||
* Added makefiles for AddressSanitizer-enabled builds.
|
||||
* Cleaned up various makefiles.
|
||||
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
|
||||
Subscription is required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe).
|
||||
|
||||
Glenn R-P
|
||||
to subscribe.
|
||||
|
45
AUTHORS
Normal file
45
AUTHORS
Normal file
@ -0,0 +1,45 @@
|
||||
PNG REFERENCE LIBRARY AUTHORS
|
||||
=============================
|
||||
|
||||
This is the list of PNG Reference Library ("libpng") Contributing
|
||||
Authors, for copyright and licensing purposes.
|
||||
|
||||
* Andreas Dilger
|
||||
* Cosmin Truta
|
||||
* Dave Martindale
|
||||
* Eric S. Raymond
|
||||
* Gilles Vollant
|
||||
* Glenn Randers-Pehrson
|
||||
* Greg Roelofs
|
||||
* Guy Eric Schalnat
|
||||
* James Yu
|
||||
* John Bowler
|
||||
* Kevin Bracey
|
||||
* Magnus Holmgren
|
||||
* Mandar Sahastrabuddhe
|
||||
* Mans Rullgard
|
||||
* Matt Sarett
|
||||
* Mike Klein
|
||||
* Paul Schmidt
|
||||
* Sam Bushell
|
||||
* Samuel Williams
|
||||
* Simon-Pierre Cadieux
|
||||
* Tim Wegner
|
||||
* Tom Lane
|
||||
* Tom Tanner
|
||||
* Vadim Barkov
|
||||
* Willem van Schaik
|
||||
* Zhijie Liang
|
||||
* Arm Holdings
|
||||
- Richard Townsend
|
||||
* Google Inc.
|
||||
- Matt Sarett
|
||||
- Mike Klein
|
||||
|
||||
The build projects, the build scripts, the test scripts, and other
|
||||
files in the "projects", "scripts" and "tests" directories, have other
|
||||
copyright owners, but are released under the libpng license.
|
||||
|
||||
Some files in the "contrib" directory, and some tools-generated files
|
||||
that are distributed with libpng, have other copyright owners, and are
|
||||
released under other open source licenses.
|
48
CHANGES
48
CHANGES
@ -6063,9 +6063,47 @@ Version 1.6.35 [July 15, 2018]
|
||||
Added missing parentheses to a macro definition
|
||||
(suggested by "irwir" in GitHub issue #216)
|
||||
|
||||
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).
|
||||
Version 1.6.36 [December 1, 2018]
|
||||
Optimized png_do_expand_palette for ARM processors.
|
||||
Improved performance by around 10-22% on a recent ARM Chromebook.
|
||||
(Contributed by Richard Townsend, ARM Holdings)
|
||||
Fixed manipulation of machine-specific optimization options.
|
||||
(Contributed by Vicki Pfau)
|
||||
Used memcpy instead of manual pointer arithmetic on Intel SSE2.
|
||||
(Contributed by Samuel Williams)
|
||||
Fixed build errors with MSVC on ARM64.
|
||||
(Contributed by Zhijie Liang)
|
||||
Fixed detection of libm in CMakeLists.
|
||||
(Contributed by Cameron Cawley)
|
||||
Fixed incorrect creation of pkg-config file in CMakeLists.
|
||||
(Contributed by Kyle Bentley)
|
||||
Fixed the CMake build on Windows MSYS by avoiding symlinks.
|
||||
Fixed a build warning on OpenBSD.
|
||||
(Contributed by Theo Buehler)
|
||||
Fixed various typos in comments.
|
||||
(Contributed by "luz.paz")
|
||||
Raised the minimum required CMake version from 3.0.2 to 3.1.
|
||||
Removed yet more of the vestigial support for pre-ANSI C compilers.
|
||||
Removed ancient makefiles for ancient systems that have been broken
|
||||
across all previous libpng-1.6.x versions.
|
||||
Removed the Y2K compliance statement and the export control
|
||||
information.
|
||||
Applied various code style and documentation fixes.
|
||||
|
||||
Glenn R-P
|
||||
Version 1.6.37 [April 14, 2019]
|
||||
Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
|
||||
Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
|
||||
Fixed a memory leak in pngtest.c.
|
||||
Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
|
||||
contrib/pngminus; refactor.
|
||||
Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
|
||||
(Contributed by Willem van Schaik)
|
||||
Fixed a typo in the libpng license v2.
|
||||
(Contributed by Miguel Ojeda)
|
||||
Added makefiles for AddressSanitizer-enabled builds.
|
||||
Cleaned up various makefiles.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
|
||||
Subscription is required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe.
|
||||
|
314
CMakeLists.txt
314
CMakeLists.txt
@ -1,42 +1,32 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
# Copyright (C) 2018 Cosmin Truta
|
||||
# Copyright (C) 2007,2009-2018 Glenn Randers-Pehrson
|
||||
# Written by Christian Ehrlicher, 2007
|
||||
# Revised by Roger Lowman, 2009-2010
|
||||
# Revised by Clifford Yapp, 2011-2012
|
||||
# Revised by Clifford Yapp, 2011-2012,2017
|
||||
# Revised by Roger Leigh, 2016
|
||||
# Revised by Andreas Franek, 2016
|
||||
# Revised by Sam Serrels, 2017
|
||||
# Revised by Vadim Barkov, 2017
|
||||
# Revised by Vicky Pfau, 2018
|
||||
# Revised by Cameron Cawley, 2018
|
||||
# Revised by Cosmin Truta, 2018
|
||||
# Revised by Kyle Bentley, 2018
|
||||
|
||||
# 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 3.0.2)
|
||||
cmake_policy(VERSION 3.0.2)
|
||||
|
||||
# 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")
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
cmake_policy(VERSION 3.1)
|
||||
|
||||
project(libpng C ASM)
|
||||
enable_testing()
|
||||
|
||||
set(PNGLIB_MAJOR 1)
|
||||
set(PNGLIB_MINOR 6)
|
||||
set(PNGLIB_RELEASE 35)
|
||||
set(PNGLIB_RELEASE 37)
|
||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||
|
||||
@ -44,25 +34,19 @@ include(GNUInstallDirs)
|
||||
|
||||
# needed packages
|
||||
|
||||
#Allow users to specify location of Zlib,
|
||||
# Useful if zlib is being built alongside this as a sub-project
|
||||
# Allow users to specify location of Zlib.
|
||||
# Useful if zlib is being built alongside this as a sub-project.
|
||||
option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF)
|
||||
|
||||
IF(NOT PNG_BUILD_ZLIB)
|
||||
if(NOT PNG_BUILD_ZLIB)
|
||||
find_package(ZLIB REQUIRED)
|
||||
include_directories(${ZLIB_INCLUDE_DIR})
|
||||
ENDIF(NOT PNG_BUILD_ZLIB)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
find_library(M_LIBRARY
|
||||
NAMES m
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
if(NOT M_LIBRARY)
|
||||
message(STATUS "math lib 'libm' not found; floating point support disabled")
|
||||
endif()
|
||||
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
|
||||
find_library(M_LIBRARY m)
|
||||
else()
|
||||
# not needed on windows
|
||||
# libm is not needed and/or not available
|
||||
set(M_LIBRARY "")
|
||||
endif()
|
||||
|
||||
@ -73,16 +57,14 @@ option(PNG_TESTS "Build libpng tests" ON)
|
||||
|
||||
# Many more configuration options could be added here
|
||||
option(PNG_FRAMEWORK "Build OS X framework" OFF)
|
||||
option(PNG_DEBUG "Build with debug output" OFF)
|
||||
option(PNGARG "Disable ANSI-C prototypes" OFF)
|
||||
|
||||
option(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations" ON)
|
||||
|
||||
option(PNG_DEBUG "Build with debug output" OFF)
|
||||
option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON)
|
||||
|
||||
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
|
||||
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
|
||||
|
||||
if(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
|
||||
# set definitions and sources for arm
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
|
||||
@ -96,12 +78,13 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
|
||||
list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
" PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_ARM_NEON} STREQUAL "no")
|
||||
"PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_ARM_NEON} STREQUAL "off")
|
||||
set(libpng_arm_sources
|
||||
arm/arm_init.c
|
||||
arm/filter_neon.S
|
||||
arm/filter_neon_intrinsics.c)
|
||||
arm/filter_neon_intrinsics.c
|
||||
arm/palette_neon_intrinsics.c)
|
||||
|
||||
if(${PNG_ARM_NEON} STREQUAL "on")
|
||||
add_definitions(-DPNG_ARM_NEON_OPT=2)
|
||||
@ -115,7 +98,7 @@ endif()
|
||||
|
||||
# set definitions and sources for powerpc
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" )
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*")
|
||||
set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
|
||||
set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations:
|
||||
off: disable the optimizations.")
|
||||
@ -124,8 +107,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
|
||||
list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
" PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "no")
|
||||
"PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off")
|
||||
set(libpng_powerpc_sources
|
||||
powerpc/powerpc_init.c
|
||||
powerpc/filter_vsx_intrinsics.c)
|
||||
@ -139,7 +122,7 @@ endif()
|
||||
|
||||
# set definitions and sources for intel
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*" )
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*")
|
||||
set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
|
||||
set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations:
|
||||
off: disable the optimizations")
|
||||
@ -148,8 +131,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
|
||||
list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
" PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_INTEL_SSE} STREQUAL "no")
|
||||
"PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off")
|
||||
set(libpng_intel_sources
|
||||
intel/intel_init.c
|
||||
intel/filter_sse2_intrinsics.c)
|
||||
@ -163,7 +146,7 @@ endif()
|
||||
|
||||
# set definitions and sources for MIPS
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*" )
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*")
|
||||
set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
|
||||
set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations:
|
||||
off: disable the optimizations")
|
||||
@ -172,8 +155,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
|
||||
list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index)
|
||||
if(index EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
" PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_MIPS_MSA} STREQUAL "no")
|
||||
"PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
|
||||
elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off")
|
||||
set(libpng_mips_sources
|
||||
mips/mips_init.c
|
||||
mips/filter_msa_intrinsics.c)
|
||||
@ -184,6 +167,33 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
|
||||
add_definitions(-DPNG_MIPS_MSA_OPT=0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
else(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
|
||||
# set definitions and sources for arm
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
|
||||
add_definitions(-DPNG_ARM_NEON_OPT=0)
|
||||
endif()
|
||||
|
||||
# set definitions and sources for powerpc
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*")
|
||||
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
|
||||
endif()
|
||||
|
||||
# set definitions and sources for intel
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*")
|
||||
add_definitions(-DPNG_INTEL_SSE_OPT=0)
|
||||
endif()
|
||||
|
||||
# set definitions and sources for MIPS
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
|
||||
CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*")
|
||||
add_definitions(-DPNG_MIPS_MSA_OPT=0)
|
||||
endif()
|
||||
|
||||
endif(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
|
||||
# SET LIBNAME
|
||||
@ -241,17 +251,17 @@ function(symbol_prefix)
|
||||
foreach(line ${OUT})
|
||||
string(REGEX MATCH "^PREFIX=" found_match "${line}")
|
||||
if(found_match)
|
||||
STRING(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
|
||||
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}")
|
||||
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)
|
||||
message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
|
||||
set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(UNIX)
|
||||
@ -276,11 +286,11 @@ else()
|
||||
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.")
|
||||
if(NOT _GC_INPUT)
|
||||
message(FATAL_ERROR "generate_chk: Missing INPUT argument")
|
||||
endif()
|
||||
if (NOT _GC_OUTPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
|
||||
if(NOT _GC_OUTPUT)
|
||||
message(FATAL_ERROR "generate_chk: Missing OUTPUT argument")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${_GC_OUTPUT}"
|
||||
@ -299,11 +309,11 @@ else()
|
||||
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.")
|
||||
if(NOT _GO_INPUT)
|
||||
message(FATAL_ERROR "generate_out: Missing INPUT argument")
|
||||
endif()
|
||||
if (NOT _GO_OUTPUT)
|
||||
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
|
||||
if(NOT _GO_OUTPUT)
|
||||
message(FATAL_ERROR "generate_out: Missing OUTPUT argument")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${_GO_OUTPUT}"
|
||||
@ -322,8 +332,8 @@ else()
|
||||
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.")
|
||||
if(NOT _GSO_OUTPUT)
|
||||
message(FATAL_ERROR "generate_source: Missing OUTPUT argument")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
|
||||
@ -505,7 +515,7 @@ set(png_fix_itxt_sources
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
endif(MSVC)
|
||||
endif()
|
||||
|
||||
if(PNG_DEBUG)
|
||||
add_definitions(-DPNG_DEBUG)
|
||||
@ -585,7 +595,7 @@ if(NOT PNG_LIB_TARGETS)
|
||||
message(SEND_ERROR
|
||||
"No library variant selected to build. "
|
||||
"Please enable at least one of the following options: "
|
||||
" PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
|
||||
"PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
|
||||
endif()
|
||||
|
||||
if(PNG_SHARED AND WIN32)
|
||||
@ -598,11 +608,11 @@ function(png_add_test)
|
||||
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.")
|
||||
if(NOT _PAT_NAME)
|
||||
message(FATAL_ERROR "png_add_test: Missing NAME argument")
|
||||
endif()
|
||||
if (NOT _PAT_COMMAND)
|
||||
message(FATAL_ERROR "Invalid arguments. png_add_test requires command.")
|
||||
if(NOT _PAT_COMMAND)
|
||||
message(FATAL_ERROR "png_add_test: Missing COMMAND argument")
|
||||
endif()
|
||||
|
||||
set(TEST_OPTIONS "${_PAT_OPTIONS}")
|
||||
@ -610,19 +620,11 @@ function(png_add_test)
|
||||
|
||||
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()
|
||||
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")
|
||||
endfunction()
|
||||
|
||||
if(PNG_TESTS AND PNG_SHARED)
|
||||
@ -687,11 +689,11 @@ if(PNG_TESTS AND PNG_SHARED)
|
||||
set(TEST_PNG_VALID TRUE)
|
||||
|
||||
if(TEST_PNG_ALPHA)
|
||||
if (NOT "${alpha_type}" STREQUAL "alpha")
|
||||
if(NOT "${alpha_type}" STREQUAL "alpha")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
else()
|
||||
if ("${alpha_type}" STREQUAL "alpha")
|
||||
if("${alpha_type}" STREQUAL "alpha")
|
||||
set(TEST_PNG_VALID FALSE)
|
||||
endif()
|
||||
endif()
|
||||
@ -760,51 +762,44 @@ endif()
|
||||
# copies if different.
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(CREATE_SYMLINK DEST_FILE)
|
||||
function(create_symlink DEST_FILE)
|
||||
|
||||
cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN})
|
||||
|
||||
if(NOT S_TARGET AND NOT S_FILE)
|
||||
message(FATAL_ERROR "Specify either a TARGET or a FILE for CREATE_SYMLINK to link to.")
|
||||
endif(NOT S_TARGET AND NOT S_FILE)
|
||||
message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument")
|
||||
endif()
|
||||
|
||||
if(S_TARGET AND S_FILE)
|
||||
message(FATAL_ERROR "CREATE_SYMLINK called with both source file ${S_FILE} and build target ${S_TARGET} arguments - can only handle 1 type per call.")
|
||||
endif(S_TARGET AND S_FILE)
|
||||
message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.")
|
||||
endif()
|
||||
|
||||
if(S_FILE)
|
||||
# If we don't need to symlink something that's coming from a build target,
|
||||
# we can go ahead and symlink/copy at configure time.
|
||||
|
||||
if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
endif(S_FILE)
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(S_TARGET)
|
||||
# We need to use generator expressions, which can be a bit tricky, so for
|
||||
# simplicity make the symlink a POST_BUILD step and use the TARGET
|
||||
# signature of add_custom_command.
|
||||
|
||||
if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
|
||||
add_custom_command(TARGET ${S_TARGET} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
|
||||
)
|
||||
else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
|
||||
else()
|
||||
add_custom_command(TARGET ${S_TARGET} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E create_symlink $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
|
||||
)
|
||||
endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
|
||||
endif(S_TARGET)
|
||||
COMMAND "${CMAKE_COMMAND}" -E create_symlink $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
@ -816,103 +811,95 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
|
||||
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)
|
||||
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
endif()
|
||||
|
||||
# CREATE PKGCONFIG FILES
|
||||
# we use the same files like ./configure, so we have to set its vars
|
||||
# We use the same files like ./configure, so we have to set its vars.
|
||||
# Only do this on Windows for Cygwin - the files don't make much sense outside
|
||||
# a UNIX look alike
|
||||
# of a UNIX look-alike.
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
||||
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
|
||||
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
||||
set(LIBS "-lz -lm")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
||||
CREATE_SYMLINK(libpng.pc FILE ${PNGLIB_NAME}.pc)
|
||||
create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||
CREATE_SYMLINK(libpng-config FILE ${PNGLIB_NAME}-config)
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
create_symlink(libpng-config FILE ${PNGLIB_NAME}-config)
|
||||
endif()
|
||||
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(png PROPERTIES
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.35
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.37
|
||||
VERSION 16.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 16
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
endif()
|
||||
|
||||
# If CMake > 2.4.x, we set a variable used below to export
|
||||
# targets to an export file.
|
||||
# TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2
|
||||
if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4)
|
||||
set(PNG_EXPORT_RULE EXPORT libpng)
|
||||
elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof
|
||||
set(PNG_EXPORT_RULE EXPORT libpng)
|
||||
endif()
|
||||
|
||||
# INSTALL
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
|
||||
install(TARGETS ${PNG_LIB_TARGETS}
|
||||
${PNG_EXPORT_RULE}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
EXPORT libpng
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
if(PNG_SHARED)
|
||||
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
|
||||
if(CYGWIN OR MINGW)
|
||||
CREATE_SYMLINK(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png)
|
||||
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(CYGWIN OR MINGW)
|
||||
create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png)
|
||||
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
CREATE_SYMLINK(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png)
|
||||
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32)
|
||||
endif(PNG_SHARED)
|
||||
create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png)
|
||||
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(PNG_STATIC)
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
CREATE_SYMLINK( libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
|
||||
install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
|
||||
install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES ${libpng_public_hdrs} DESTINATION include)
|
||||
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
|
||||
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
|
||||
install(FILES ${libpng_public_hdrs} DESTINATION include)
|
||||
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
|
||||
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL)
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
DESTINATION bin)
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL )
|
||||
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL)
|
||||
install(TARGETS ${PNG_BIN_TARGETS}
|
||||
RUNTIME DESTINATION bin)
|
||||
RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
|
||||
# Install man pages
|
||||
if(NOT PNG_MAN_DIR)
|
||||
set(PNG_MAN_DIR "share/man")
|
||||
endif()
|
||||
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
|
||||
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
|
||||
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
|
||||
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
|
||||
# Install pkg-config files
|
||||
if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
||||
@ -923,12 +910,11 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
DESTINATION bin)
|
||||
endif(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# On versions of CMake that support it, create an export file CMake
|
||||
# users can include() to import our targets
|
||||
if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
|
||||
# Create an export file that CMake users can include() to import our targets.
|
||||
if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL)
|
||||
install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
|
||||
endif()
|
||||
|
||||
|
175
LICENSE
175
LICENSE
@ -1,53 +1,82 @@
|
||||
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
|
||||
=========================================
|
||||
|
||||
This copy of the libpng notices is provided for your convenience. In case of
|
||||
any discrepancy between this copy and the notices in the file png.h that is
|
||||
included in the libpng distribution, the latter shall prevail.
|
||||
PNG Reference Library License version 2
|
||||
---------------------------------------
|
||||
|
||||
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||
* Copyright (c) 1995-2019 The PNG Reference Library Authors.
|
||||
* Copyright (c) 2018-2019 Cosmin Truta.
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
|
||||
* Copyright (c) 1996-1997 Andreas Dilger.
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
|
||||
If you modify libpng you may insert additional notices immediately following
|
||||
this sentence.
|
||||
The software is supplied "as is", without warranty of any kind,
|
||||
express or implied, including, without limitation, the warranties
|
||||
of merchantability, fitness for a particular purpose, title, and
|
||||
non-infringement. In no event shall the Copyright owners, or
|
||||
anyone distributing the software, be liable for any damages or
|
||||
other liability, whether in contract, tort or otherwise, arising
|
||||
from, out of, or in connection with the software, or the use or
|
||||
other dealings in the software, even if advised of the possibility
|
||||
of such damage.
|
||||
|
||||
This code is released under the libpng license.
|
||||
Permission is hereby granted to use, copy, modify, and distribute
|
||||
this software, or portions hereof, for any purpose, without fee,
|
||||
subject to the following restrictions:
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you
|
||||
use this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated, but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
|
||||
|
||||
PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, and are distributed according to the same
|
||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
added to the list of Contributing Authors:
|
||||
|
||||
Simon-Pierre Cadieux
|
||||
Eric S. Raymond
|
||||
Mans Rullgard
|
||||
Cosmin Truta
|
||||
Gilles Vollant
|
||||
James Yu
|
||||
Mandar Sahastrabuddhe
|
||||
Google Inc.
|
||||
Vadim Barkov
|
||||
Simon-Pierre Cadieux
|
||||
Eric S. Raymond
|
||||
Mans Rullgard
|
||||
Cosmin Truta
|
||||
Gilles Vollant
|
||||
James Yu
|
||||
Mandar Sahastrabuddhe
|
||||
Google Inc.
|
||||
Vadim Barkov
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
There is no warranty against interference with your enjoyment of the
|
||||
library or against infringement. There is no warranty that our
|
||||
efforts or the library will fulfill any of your particular purposes
|
||||
or needs. This library is provided with all faults, and the entire
|
||||
risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
the user.
|
||||
There is no warranty against interference with your enjoyment of
|
||||
the library or against infringement. There is no warranty that our
|
||||
efforts or the library will fulfill any of your particular purposes
|
||||
or needs. This library is provided with all faults, and the entire
|
||||
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
|
||||
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
|
||||
license as libpng-0.96, with the following individuals added to the list
|
||||
of Contributing Authors:
|
||||
license as libpng-0.96, with the following individuals added to the
|
||||
list of Contributing Authors:
|
||||
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
|
||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||
@ -55,14 +84,14 @@ and are distributed according to the same disclaimer and license as
|
||||
libpng-0.88, with the following individuals added to the list of
|
||||
Contributing Authors:
|
||||
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
Sam Bushell
|
||||
Magnus Holmgren
|
||||
Greg Roelofs
|
||||
Tom Tanner
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
Sam Bushell
|
||||
Magnus Holmgren
|
||||
Greg Roelofs
|
||||
Tom Tanner
|
||||
|
||||
Some files in the "scripts" directory have other copyright owners
|
||||
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
|
||||
@ -71,63 +100,35 @@ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
|
||||
Andreas Dilger
|
||||
Dave Martindale
|
||||
Guy Eric Schalnat
|
||||
Paul Schmidt
|
||||
Tim Wegner
|
||||
Andreas Dilger
|
||||
Dave Martindale
|
||||
Guy Eric Schalnat
|
||||
Paul Schmidt
|
||||
Tim Wegner
|
||||
|
||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||
including, without limitation, the warranties of merchantability and of
|
||||
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||
assume no liability for direct, indirect, incidental, special, exemplary,
|
||||
or consequential damages, which may result from the use of the PNG
|
||||
Reference Library, even if advised of the possibility of such damage.
|
||||
The PNG Reference Library is supplied "AS IS". The Contributing
|
||||
Authors and Group 42, Inc. disclaim all warranties, expressed or
|
||||
implied, including, without limitation, the warranties of
|
||||
merchantability and of fitness for any purpose. The Contributing
|
||||
Authors and Group 42, Inc. assume no liability for direct, indirect,
|
||||
incidental, special, exemplary, or consequential damages, which may
|
||||
result from the use of the PNG Reference Library, even if advised of
|
||||
the possibility of such damage.
|
||||
|
||||
Permission is hereby granted to use, copy, modify, and distribute this
|
||||
source code, or portions hereof, for any purpose, without fee, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
|
||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
fee, and encourage the use of this source code as a component to
|
||||
supporting the PNG file format in commercial products. If you use this
|
||||
source code in a product, acknowledgment is not required but would be
|
||||
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).
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
July 15, 2018
|
||||
The Contributing Authors and Group 42, Inc. specifically permit,
|
||||
without fee, and encourage the use of this source code as a component
|
||||
to supporting the PNG file format in commercial products. If you use
|
||||
this source code in a product, acknowledgment is not required but would
|
||||
be appreciated.
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
|
||||
#
|
||||
# Copyright (c) 2018 Cosmin Truta
|
||||
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||
# Last changed in libpng 1.6.25 [September 1, 2016]
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@ -95,7 +95,8 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||
|
||||
if PNG_ARM_NEON
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
||||
arm/filter_neon.S arm/filter_neon_intrinsics.c
|
||||
arm/filter_neon.S arm/filter_neon_intrinsics.c \
|
||||
arm/palette_neon_intrinsics.c
|
||||
endif
|
||||
|
||||
if PNG_MIPS_MSA
|
||||
@ -147,7 +148,7 @@ pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
|
||||
# from those directories being included. This only works if the configure is
|
||||
# not done in the source directory!
|
||||
EXTRA_DIST= \
|
||||
ANNOUNCE CHANGES INSTALL LICENSE README TODO \
|
||||
ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \
|
||||
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
|
||||
${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
|
||||
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
|
||||
|
25
Makefile.in
25
Makefile.in
@ -16,8 +16,8 @@
|
||||
|
||||
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
|
||||
#
|
||||
# Copyright (c) 2018 Cosmin Truta
|
||||
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||
# Last changed in libpng 1.6.25 [September 1, 2016]
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@ -106,7 +106,8 @@ check_PROGRAMS = pngtest$(EXEEXT) pngunknown$(EXEEXT) \
|
||||
@HAVE_CLOCK_GETTIME_TRUE@am__append_1 = timepng
|
||||
bin_PROGRAMS = pngfix$(EXEEXT) png-fix-itxt$(EXEEXT)
|
||||
@PNG_ARM_NEON_TRUE@am__append_2 = arm/arm_init.c\
|
||||
@PNG_ARM_NEON_TRUE@ arm/filter_neon.S arm/filter_neon_intrinsics.c
|
||||
@PNG_ARM_NEON_TRUE@ arm/filter_neon.S arm/filter_neon_intrinsics.c \
|
||||
@PNG_ARM_NEON_TRUE@ arm/palette_neon_intrinsics.c
|
||||
|
||||
@PNG_MIPS_MSA_TRUE@am__append_3 = mips/mips_init.c\
|
||||
@PNG_MIPS_MSA_TRUE@ mips/filter_msa_intrinsics.c
|
||||
@ -183,12 +184,14 @@ am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST = png.c \
|
||||
pngwtran.c pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h \
|
||||
pngpriv.h pngstruct.h pngusr.dfa arm/arm_init.c \
|
||||
arm/filter_neon.S arm/filter_neon_intrinsics.c \
|
||||
mips/mips_init.c mips/filter_msa_intrinsics.c \
|
||||
intel/intel_init.c intel/filter_sse2_intrinsics.c \
|
||||
powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c
|
||||
arm/palette_neon_intrinsics.c mips/mips_init.c \
|
||||
mips/filter_msa_intrinsics.c intel/intel_init.c \
|
||||
intel/filter_sse2_intrinsics.c powerpc/powerpc_init.c \
|
||||
powerpc/filter_vsx_intrinsics.c
|
||||
am__dirstamp = $(am__leading_dot)dirstamp
|
||||
@PNG_ARM_NEON_TRUE@am__objects_1 = arm/arm_init.lo arm/filter_neon.lo \
|
||||
@PNG_ARM_NEON_TRUE@ arm/filter_neon_intrinsics.lo
|
||||
@PNG_ARM_NEON_TRUE@ arm/filter_neon_intrinsics.lo \
|
||||
@PNG_ARM_NEON_TRUE@ arm/palette_neon_intrinsics.lo
|
||||
@PNG_MIPS_MSA_TRUE@am__objects_2 = mips/mips_init.lo \
|
||||
@PNG_MIPS_MSA_TRUE@ mips/filter_msa_intrinsics.lo
|
||||
@PNG_INTEL_SSE_TRUE@am__objects_3 = intel/intel_init.lo \
|
||||
@ -266,6 +269,7 @@ am__depfiles_remade = ./$(DEPDIR)/png.Plo ./$(DEPDIR)/pngerror.Plo \
|
||||
./$(DEPDIR)/pngwtran.Plo ./$(DEPDIR)/pngwutil.Plo \
|
||||
arm/$(DEPDIR)/arm_init.Plo arm/$(DEPDIR)/filter_neon.Plo \
|
||||
arm/$(DEPDIR)/filter_neon_intrinsics.Plo \
|
||||
arm/$(DEPDIR)/palette_neon_intrinsics.Plo \
|
||||
contrib/libtests/$(DEPDIR)/pngimage.Po \
|
||||
contrib/libtests/$(DEPDIR)/pngstest.Po \
|
||||
contrib/libtests/$(DEPDIR)/pngunknown.Po \
|
||||
@ -530,7 +534,7 @@ TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
|
||||
$(TEST_LOG_FLAGS)
|
||||
am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in \
|
||||
$(srcdir)/config.h.in $(srcdir)/libpng-config.in \
|
||||
$(srcdir)/libpng.pc.in INSTALL README TODO compile \
|
||||
$(srcdir)/libpng.pc.in AUTHORS INSTALL README TODO compile \
|
||||
config.guess config.sub depcomp install-sh ltmain.sh missing \
|
||||
test-driver
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
@ -780,7 +784,7 @@ pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
|
||||
# from those directories being included. This only works if the configure is
|
||||
# not done in the source directory!
|
||||
EXTRA_DIST = \
|
||||
ANNOUNCE CHANGES INSTALL LICENSE README TODO \
|
||||
ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \
|
||||
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
|
||||
${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
|
||||
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
|
||||
@ -972,6 +976,8 @@ arm/arm_init.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp)
|
||||
arm/filter_neon.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp)
|
||||
arm/filter_neon_intrinsics.lo: arm/$(am__dirstamp) \
|
||||
arm/$(DEPDIR)/$(am__dirstamp)
|
||||
arm/palette_neon_intrinsics.lo: arm/$(am__dirstamp) \
|
||||
arm/$(DEPDIR)/$(am__dirstamp)
|
||||
mips/$(am__dirstamp):
|
||||
@$(MKDIR_P) mips
|
||||
@: > mips/$(am__dirstamp)
|
||||
@ -1140,6 +1146,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/arm_init.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon_intrinsics.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/palette_neon_intrinsics.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngimage.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngstest.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngunknown.Po@am__quote@ # am--include-marker
|
||||
@ -2076,6 +2083,7 @@ distclean: distclean-am
|
||||
-rm -f arm/$(DEPDIR)/arm_init.Plo
|
||||
-rm -f arm/$(DEPDIR)/filter_neon.Plo
|
||||
-rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo
|
||||
-rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo
|
||||
-rm -f contrib/libtests/$(DEPDIR)/pngimage.Po
|
||||
-rm -f contrib/libtests/$(DEPDIR)/pngstest.Po
|
||||
-rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po
|
||||
@ -2160,6 +2168,7 @@ maintainer-clean: maintainer-clean-am
|
||||
-rm -f arm/$(DEPDIR)/arm_init.Plo
|
||||
-rm -f arm/$(DEPDIR)/filter_neon.Plo
|
||||
-rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo
|
||||
-rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo
|
||||
-rm -f contrib/libtests/$(DEPDIR)/pngimage.Po
|
||||
-rm -f contrib/libtests/$(DEPDIR)/pngstest.Po
|
||||
-rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po
|
||||
|
109
README
109
README
@ -1,15 +1,16 @@
|
||||
README for libpng version 1.6.35 - July 15, 2018 (shared library 16.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
README for libpng version 1.6.37 - April 14, 2019
|
||||
=================================================
|
||||
|
||||
See the note about version numbers near the top of png.h.
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
||||
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
|
||||
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||
libpng-*.tar.xz or if you want UNIX-style line endings in the text
|
||||
files, or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been in
|
||||
extensive use and testing since mid-1995. By late 1997 it had
|
||||
fact that it's the first release fool you. The libpng library has been
|
||||
in extensive use and testing since mid-1995. By late 1997 it had
|
||||
finally gotten to the stage where there hadn't been significant
|
||||
changes to the API in some time, and people have a bad feeling about
|
||||
libraries with versions < 1.0. Version 1.0.0 was released in
|
||||
@ -60,59 +61,37 @@ the library action on the detection of chunk CRC errors. It is possible
|
||||
to set different actions based on whether the CRC error occurred in a
|
||||
critical or an ancillary chunk.
|
||||
|
||||
The changes made to the library, and bugs fixed are based on discussions
|
||||
on the PNG-implement mailing list and not on material submitted
|
||||
privately to Guy, Andreas, or Glenn. They will forward any good
|
||||
suggestions to the list.
|
||||
|
||||
For a detailed description on using libpng, read libpng-manual.txt. For
|
||||
examples of libpng in a program, see example.c and pngtest.c. For usage
|
||||
information and restrictions (what little they are) on libpng, see
|
||||
png.h. For a description on using zlib (the compression library used by
|
||||
libpng) and zlib's restrictions, see zlib.h
|
||||
For a detailed description on using libpng, read libpng-manual.txt.
|
||||
For examples of libpng in a program, see example.c and pngtest.c. For
|
||||
usage information and restrictions (what little they are) on libpng,
|
||||
see png.h. For a description on using zlib (the compression library
|
||||
used by libpng) and zlib's restrictions, see zlib.h
|
||||
|
||||
I have included a general makefile, as well as several machine and
|
||||
compiler specific ones, but you may have to modify one for your own needs.
|
||||
compiler specific ones, but you may have to modify one for your own
|
||||
needs.
|
||||
|
||||
You should use zlib 1.0.4 or later to run this, but it MAY work with
|
||||
versions as old as zlib 0.95. Even so, there are bugs in older zlib
|
||||
versions which can cause the output of invalid compression streams for
|
||||
some images. You will definitely need zlib 1.0.4 or later if you are
|
||||
taking advantage of the MS-DOS "far" structure allocation for the small
|
||||
and medium memory models. You should also note that zlib is a
|
||||
compression library that is useful for more things than just PNG files.
|
||||
You can use zlib as a drop-in replacement for fread() and fwrite() if
|
||||
you are so inclined.
|
||||
some images.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at zlib.net.
|
||||
You should also note that zlib is a compression library that is useful
|
||||
for more things than just PNG files. You can use zlib as a drop-in
|
||||
replacement for fread() and fwrite(), if you are so inclined.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at
|
||||
https://zlib.net.
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/pngdocs.html .
|
||||
|
||||
This code is currently being archived at libpng.sourceforge.io in the
|
||||
[DOWNLOAD] area, and at http://libpng.download/src . If you
|
||||
can't find it in any of those places, e-mail me, and I'll help you find it.
|
||||
[DOWNLOAD] area, and at http://libpng.download/src .
|
||||
|
||||
I am not a lawyer, but I believe that the Export Control Classification
|
||||
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||
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).
|
||||
|
||||
If you have any code changes, requests, problems, etc., please e-mail
|
||||
them to me. Also, I'd appreciate any make files or project files,
|
||||
and any modifications you needed to make to get libpng to compile,
|
||||
along with a #define variable to tell what compiler/system you are on.
|
||||
If you needed to add transformations to libpng, or wish libpng would
|
||||
provide the image in a different way, drop me a note (and code, if
|
||||
possible), so I can consider supporting the transformation.
|
||||
Finally, if you get any warning messages when compiling libpng
|
||||
(note: not zlib), and they are easy to fix, I'd appreciate the
|
||||
fix. Please mention "libpng" somewhere in the subject line. Thanks.
|
||||
|
||||
This release was created and will be supported by myself (of course
|
||||
based in a large way on Guy's and Andreas' earlier work), and the PNG
|
||||
This release, based in a large way on Glenn's, Guy's and Andreas'
|
||||
earlier work, was created and will be supported by myself and the PNG
|
||||
development group.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at
|
||||
@ -120,34 +99,21 @@ lists.sourceforge.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe).
|
||||
|
||||
You can't reach Guy, the original libpng author, at the addresses
|
||||
given in previous versions of this document. He and Andreas will
|
||||
read mail addressed to the png-implement list, however.
|
||||
|
||||
Please do not send general questions about PNG. Send them to
|
||||
png-mng-misc at lists.sf.net (subscription required; visit
|
||||
Send general questions about the PNG specification to png-mng-misc
|
||||
at lists.sourceforge.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
|
||||
subscribe). If you have a question about something
|
||||
in the PNG specification that is related to using libpng, send it
|
||||
to me. Send me any questions that start with "I was using libpng,
|
||||
and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for twenty years now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used immediately,
|
||||
it may be used later.
|
||||
subscribe).
|
||||
|
||||
Files in this distribution:
|
||||
|
||||
ANNOUNCE => Announcement of this version, with recent changes
|
||||
AUTHORS => List of contributing authors
|
||||
CHANGES => Description of changes between libpng versions
|
||||
KNOWNBUG => List of known bugs and deficiencies
|
||||
LICENSE => License to use and redistribute libpng
|
||||
README => This file
|
||||
TODO => Things not implemented in the current library
|
||||
Y2KINFO => Statement of Y2K compliance
|
||||
TRADEMARK => Trademark information
|
||||
example.c => Example code for using libpng functions
|
||||
libpng.3 => manual page for libpng (includes libpng-manual.txt)
|
||||
libpng-manual.txt => Description of libpng and its functions
|
||||
@ -208,15 +174,10 @@ Files in this distribution:
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
(see scripts/README.txt for the list of scripts)
|
||||
|
||||
Good luck, and happy coding.
|
||||
Good luck, and happy coding!
|
||||
|
||||
-Glenn Randers-Pehrson (current maintainer, since 1998)
|
||||
Internet: glennrp at users.sourceforge.net
|
||||
|
||||
-Andreas Eric Dilger (former maintainer, 1996-1997)
|
||||
Internet: adilger at enel.ucalgary.ca
|
||||
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
|
||||
|
||||
-Guy Eric Schalnat (original author and former maintainer, 1995-1996)
|
||||
(formerly of Group 42, Inc)
|
||||
Internet: gschal at infinet.com
|
||||
* Cosmin Truta (current maintainer, since 2018)
|
||||
* Glenn Randers-Pehrson (former maintainer, 1998-2018)
|
||||
* Andreas Eric Dilger (former maintainer, 1996-1997)
|
||||
* Guy Eric Schalnat (original author and former maintainer, 1995-1996)
|
||||
(formerly of Group 42, Inc.)
|
||||
|
49
TODO
49
TODO
@ -1,30 +1,23 @@
|
||||
/*
|
||||
TODO - list of things to do for libpng:
|
||||
|
||||
Final bug fixes.
|
||||
Better C++ wrapper/full C++ implementation?
|
||||
Fix problem with C++ and EXTERN "C".
|
||||
cHRM transformation.
|
||||
Remove setjmp/longjmp usage in favor of returning error codes. As a start on
|
||||
this, minimize the use of png_error(), replacing them with
|
||||
png_warning(); return(0); or similar.
|
||||
Palette creation.
|
||||
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||
Improved dithering.
|
||||
Multi-lingual error and warning message support.
|
||||
Complete sRGB transformation (presently it simply uses gamma=0.45455).
|
||||
Man pages for function calls.
|
||||
Better documentation.
|
||||
Better filter selection
|
||||
(counting huffman bits/precompression? filter inertia? filter costs?).
|
||||
Histogram creation.
|
||||
Text conversion between different code pages (Latin-1 -> Mac and DOS).
|
||||
Avoid building gamma tables whenever possible.
|
||||
Use greater precision when changing to linear gamma for compositing against
|
||||
background and doing rgb-to-gray transformation.
|
||||
Investigate pre-incremented loop counters and other loop constructions.
|
||||
Add interpolated method of handling interlacing.
|
||||
Extend pngvalid.c to validate more of the libpng transformations.
|
||||
Refactor preprocessor conditionals to compile entire statements
|
||||
|
||||
*/
|
||||
* Fix all defects (duh!)
|
||||
* Better C++ wrapper / full C++ implementation (?)
|
||||
* Fix the problems with C++ and 'extern "C"'.
|
||||
* cHRM transformation.
|
||||
* Palette creation.
|
||||
* "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||
* Improved dithering.
|
||||
* Multi-lingual error and warning message support.
|
||||
* Complete sRGB transformation. (Currently it simply uses gamma=0.45455.)
|
||||
* Man pages for function calls.
|
||||
* Better documentation.
|
||||
* Better filter selection
|
||||
(e.g., counting huffman bits/precompression; filter inertia; filter costs).
|
||||
* Histogram creation.
|
||||
* Text conversion between different code pages (e.g., Latin-1 -> Mac).
|
||||
* Avoid building gamma tables whenever possible.
|
||||
* Greater precision in changing to linear gamma for compositing against
|
||||
background, and in doing rgb-to-gray transformations.
|
||||
* Investigate pre-incremented loop counters and other loop constructions.
|
||||
* Interpolated method of handling interlacing.
|
||||
* More validations for libpng transformations.
|
||||
|
8
TRADEMARK
Normal file
8
TRADEMARK
Normal file
@ -0,0 +1,8 @@
|
||||
TRADEMARK
|
||||
=========
|
||||
|
||||
The name "libpng" has not been registered by the Copyright owners
|
||||
as a trademark in any jurisdiction. However, because libpng has
|
||||
been distributed and maintained world-wide, continually since 1995,
|
||||
the Copyright owners claim "common-law trademark protection" in any
|
||||
jurisdiction where common-law trademark is recognized.
|
@ -1,14 +1,15 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
|
||||
* called.
|
||||
*/
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
/* filter_neon.S - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2014,2017 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
@ -1,12 +1,11 @@
|
||||
|
||||
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||
* Written by James Yu <james.yu at linaro.org>, October 2013.
|
||||
* Based on filter_neon.S, written by Mans Rullgard, 2011.
|
||||
*
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@ -19,7 +18,11 @@
|
||||
/* This code requires -mfpu=neon on the command line: */
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
#include <arm_neon.h>
|
||||
#if defined(_MSC_VER) && defined(_M_ARM64)
|
||||
# include <arm64_neon.h>
|
||||
#else
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
/* libpng row pointers are not necessarily aligned to any particular boundary,
|
||||
* however this code will only work with appropriate alignment. arm/arm_init.c
|
||||
@ -33,6 +36,11 @@
|
||||
* 'type'. This is written this way just to hide the GCC strict aliasing
|
||||
* warning; note that the code is safe because there never is an alias between
|
||||
* the input and output pointers.
|
||||
*
|
||||
* When compiling with MSVC ARM64, the png_ldr macro can't be passed directly
|
||||
* to vst4_lane_u32, because of an internal compiler error inside MSVC.
|
||||
* To avoid this compiler bug, we use a temporary variable (vdest_val) to store
|
||||
* the result of png_ldr.
|
||||
*/
|
||||
#define png_ldr(type,pointer)\
|
||||
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
|
||||
@ -125,12 +133,15 @@ png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row,
|
||||
uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
uint8x8x4_t vrp = *vrpt;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
uint32x2x4_t vdest_val;
|
||||
|
||||
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
|
||||
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||
}
|
||||
|
||||
PNG_UNUSED(prev_row)
|
||||
@ -223,6 +234,7 @@ png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
uint32x2x4_t vdest_val;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
@ -240,7 +252,8 @@ png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
|
||||
vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
|
||||
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -359,6 +372,7 @@ png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
uint32x2x4_t vdest_val;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
@ -378,7 +392,8 @@ png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
||||
|
||||
vlast = vpp.val[3];
|
||||
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
149
arm/palette_neon_intrinsics.c
Normal file
149
arm/palette_neon_intrinsics.c
Normal file
@ -0,0 +1,149 @@
|
||||
|
||||
/* palette_neon_intrinsics.c - NEON optimised palette expansion functions
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
|
||||
* Written by Richard Townsend <Richard.Townsend@arm.com>, February 2017.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1
|
||||
|
||||
#if defined(_MSC_VER) && defined(_M_ARM64)
|
||||
# include <arm64_neon.h>
|
||||
#else
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
/* Build an RGBA8 palette from the separate RGB and alpha palettes. */
|
||||
void
|
||||
png_riffle_palette_neon(png_structrp png_ptr)
|
||||
{
|
||||
png_const_colorp palette = png_ptr->palette;
|
||||
png_bytep riffled_palette = png_ptr->riffled_palette;
|
||||
png_const_bytep trans_alpha = png_ptr->trans_alpha;
|
||||
int num_trans = png_ptr->num_trans;
|
||||
int i;
|
||||
|
||||
png_debug(1, "in png_riffle_palette_neon");
|
||||
|
||||
/* Initially black, opaque. */
|
||||
uint8x16x4_t w = {{
|
||||
vdupq_n_u8(0x00),
|
||||
vdupq_n_u8(0x00),
|
||||
vdupq_n_u8(0x00),
|
||||
vdupq_n_u8(0xff),
|
||||
}};
|
||||
|
||||
/* First, riffle the RGB colours into an RGBA8 palette.
|
||||
* The alpha component is set to opaque for now.
|
||||
*/
|
||||
for (i = 0; i < 256; i += 16)
|
||||
{
|
||||
uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i));
|
||||
w.val[0] = v.val[0];
|
||||
w.val[1] = v.val[1];
|
||||
w.val[2] = v.val[2];
|
||||
vst4q_u8(riffled_palette + (i << 2), w);
|
||||
}
|
||||
|
||||
/* Fix up the missing transparency values. */
|
||||
for (i = 0; i < num_trans; i++)
|
||||
riffled_palette[(i << 2) + 3] = trans_alpha[i];
|
||||
}
|
||||
|
||||
/* Expands a palettized row into RGBA8. */
|
||||
int
|
||||
png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
|
||||
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
|
||||
{
|
||||
png_uint_32 row_width = row_info->width;
|
||||
const png_uint_32 *riffled_palette =
|
||||
(const png_uint_32 *)png_ptr->riffled_palette;
|
||||
const png_int_32 pixels_per_chunk = 4;
|
||||
int i;
|
||||
|
||||
png_debug(1, "in png_do_expand_palette_rgba8_neon");
|
||||
|
||||
if (row_width < pixels_per_chunk)
|
||||
return 0;
|
||||
|
||||
/* This function originally gets the last byte of the output row.
|
||||
* The NEON part writes forward from a given position, so we have
|
||||
* to seek this back by 4 pixels x 4 bytes.
|
||||
*/
|
||||
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_uint_32)) - 1);
|
||||
|
||||
for (i = 0; i < row_width; i += pixels_per_chunk)
|
||||
{
|
||||
uint32x4_t cur;
|
||||
png_bytep sp = *ssp - i, dp = *ddp - (i << 2);
|
||||
cur = vld1q_dup_u32 (riffled_palette + *(sp - 3));
|
||||
cur = vld1q_lane_u32(riffled_palette + *(sp - 2), cur, 1);
|
||||
cur = vld1q_lane_u32(riffled_palette + *(sp - 1), cur, 2);
|
||||
cur = vld1q_lane_u32(riffled_palette + *(sp - 0), cur, 3);
|
||||
vst1q_u32((void *)dp, cur);
|
||||
}
|
||||
if (i != row_width)
|
||||
{
|
||||
/* Remove the amount that wasn't processed. */
|
||||
i -= pixels_per_chunk;
|
||||
}
|
||||
|
||||
/* Decrement output pointers. */
|
||||
*ssp = *ssp - i;
|
||||
*ddp = *ddp - (i << 2);
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Expands a palettized row into RGB8. */
|
||||
int
|
||||
png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
|
||||
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
|
||||
{
|
||||
png_uint_32 row_width = row_info->width;
|
||||
png_const_bytep palette = (png_const_bytep)png_ptr->palette;
|
||||
const png_uint_32 pixels_per_chunk = 8;
|
||||
int i;
|
||||
|
||||
png_debug(1, "in png_do_expand_palette_rgb8_neon");
|
||||
|
||||
if (row_width <= pixels_per_chunk)
|
||||
return 0;
|
||||
|
||||
/* Seeking this back by 8 pixels x 3 bytes. */
|
||||
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_color)) - 1);
|
||||
|
||||
for (i = 0; i < row_width; i += pixels_per_chunk)
|
||||
{
|
||||
uint8x8x3_t cur;
|
||||
png_bytep sp = *ssp - i, dp = *ddp - ((i << 1) + i);
|
||||
cur = vld3_dup_u8(palette + sizeof(png_color) * (*(sp - 7)));
|
||||
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 6)), cur, 1);
|
||||
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 5)), cur, 2);
|
||||
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 4)), cur, 3);
|
||||
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 3)), cur, 4);
|
||||
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 2)), cur, 5);
|
||||
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 1)), cur, 6);
|
||||
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 0)), cur, 7);
|
||||
vst3_u8((void *)dp, cur);
|
||||
}
|
||||
|
||||
if (i != row_width)
|
||||
{
|
||||
/* Remove the amount that wasn't processed. */
|
||||
i -= pixels_per_chunk;
|
||||
}
|
||||
|
||||
/* Decrement output pointers. */
|
||||
*ssp = *ssp - i;
|
||||
*ddp = *ddp - ((i << 1) + i);
|
||||
return i;
|
||||
}
|
||||
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION */
|
@ -18,9 +18,6 @@
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the `pow' function. */
|
||||
#undef HAVE_POW
|
||||
|
||||
|
37
configure
vendored
37
configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for libpng 1.6.35.
|
||||
# Generated by GNU Autoconf 2.69 for libpng 1.6.37.
|
||||
#
|
||||
# Report bugs to <png-mng-implement@lists.sourceforge.net>.
|
||||
#
|
||||
@ -590,8 +590,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='libpng'
|
||||
PACKAGE_TARNAME='libpng'
|
||||
PACKAGE_VERSION='1.6.35'
|
||||
PACKAGE_STRING='libpng 1.6.35'
|
||||
PACKAGE_VERSION='1.6.37'
|
||||
PACKAGE_STRING='libpng 1.6.37'
|
||||
PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net'
|
||||
PACKAGE_URL=''
|
||||
|
||||
@ -1372,7 +1372,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures libpng 1.6.35 to adapt to many kinds of systems.
|
||||
\`configure' configures libpng 1.6.37 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@ -1442,7 +1442,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of libpng 1.6.35:";;
|
||||
short | recursive ) echo "Configuration of libpng 1.6.37:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@ -1622,7 +1622,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
libpng configure 1.6.35
|
||||
libpng configure 1.6.37
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@ -1954,7 +1954,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by libpng $as_me 1.6.35, which was
|
||||
It was created by libpng $as_me 1.6.37, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@ -2825,7 +2825,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='libpng'
|
||||
VERSION='1.6.35'
|
||||
VERSION='1.6.37'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@ -2946,10 +2946,10 @@ fi
|
||||
|
||||
|
||||
|
||||
PNGLIB_VERSION=1.6.35
|
||||
PNGLIB_VERSION=1.6.37
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_RELEASE=35
|
||||
PNGLIB_RELEASE=37
|
||||
|
||||
|
||||
|
||||
@ -13066,19 +13066,6 @@ fi
|
||||
|
||||
fi
|
||||
|
||||
for ac_func in memset
|
||||
do :
|
||||
ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset"
|
||||
if test "x$ac_cv_func_memset" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_MEMSET 1
|
||||
_ACEOF
|
||||
|
||||
else
|
||||
as_fn_error $? "memset not found in libc" "$LINENO" 5
|
||||
fi
|
||||
done
|
||||
|
||||
for ac_func in pow
|
||||
do :
|
||||
ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow"
|
||||
@ -14367,7 +14354,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by libpng $as_me 1.6.35, which was
|
||||
This file was extended by libpng $as_me 1.6.37, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@ -14433,7 +14420,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
libpng config.status 1.6.35
|
||||
libpng config.status 1.6.37
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# configure.ac
|
||||
|
||||
# Copyright (c) 2018 Cosmin Truta
|
||||
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||
# Last changed in libpng 1.6.25 [September 1, 2016]
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@ -25,7 +25,7 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.6.35],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.6.37],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
@ -46,10 +46,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
|
||||
dnl AM_PREREQ([1.11.2])
|
||||
dnl stop configure from automagically running automake
|
||||
|
||||
PNGLIB_VERSION=1.6.35
|
||||
PNGLIB_VERSION=1.6.37
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_RELEASE=35
|
||||
PNGLIB_RELEASE=37
|
||||
|
||||
dnl End of version number stuff
|
||||
|
||||
@ -144,7 +144,6 @@ AC_C_RESTRICT
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_STRTOD
|
||||
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
|
||||
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
|
||||
|
||||
# Some later POSIX 1003.1 functions are required for test programs, failure here
|
||||
|
@ -52,6 +52,6 @@ option TEXT on
|
||||
option USER_LIMITS on
|
||||
option SET_USER_LIMITS on
|
||||
|
||||
# these are are just required for specific customizations
|
||||
# these are just required for specific customizations
|
||||
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
|
||||
option WRITE_CUSTOMIZE_COMPRESSION on
|
||||
|
@ -42,7 +42,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
|
||||
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
|
||||
|
||||
row = (png_const_bytep)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi);
|
||||
row = (png_const_bytep)(((const png_byte (*)[8])row) + bit_offset_hi);
|
||||
row += bit_offset_lo >> 3;
|
||||
bit_offset_lo &= 0x07;
|
||||
|
||||
@ -73,7 +73,7 @@ static void
|
||||
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
png_uint_32 x)
|
||||
{
|
||||
PNG_CONST unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
|
||||
switch (png_get_color_type(png_ptr, info_ptr))
|
||||
{
|
||||
@ -87,7 +87,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
*/
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
{
|
||||
PNG_CONST int index = component(row, x, 0, bit_depth, 1);
|
||||
int index = component(row, x, 0, bit_depth, 1);
|
||||
png_colorp palette = NULL;
|
||||
int num_palette = 0;
|
||||
|
||||
|
@ -146,7 +146,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
/* These byte strings were copied from png.h. If a future version
|
||||
* of readpng2.c recognizes more chunks, add them to this list.
|
||||
*/
|
||||
static PNG_CONST png_byte chunks_to_process[] = {
|
||||
static const png_byte chunks_to_process[] = {
|
||||
98, 75, 71, 68, '\0', /* bKGD */
|
||||
103, 65, 77, 65, '\0', /* gAMA */
|
||||
115, 82, 71, 66, '\0', /* sRGB */
|
||||
|
@ -661,7 +661,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
const png_uint_32 luma = colors[1];
|
||||
png_uint_32 luma = colors[1];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
@ -672,8 +672,8 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
|
||||
case 2:
|
||||
{
|
||||
const png_uint_32 luma = colors[1];
|
||||
const png_uint_32 alpha = colors[2];
|
||||
png_uint_32 luma = colors[1];
|
||||
png_uint_32 alpha = colors[2];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<size_max; ++x)
|
||||
@ -688,9 +688,9 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
|
||||
case 3:
|
||||
{
|
||||
const png_uint_32 red = colors[1];
|
||||
const png_uint_32 green = colors[2];
|
||||
const png_uint_32 blue = colors[3];
|
||||
png_uint_32 red = colors[1];
|
||||
png_uint_32 green = colors[2];
|
||||
png_uint_32 blue = colors[3];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
@ -707,10 +707,10 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
|
||||
case 4:
|
||||
{
|
||||
const png_uint_32 red = colors[1];
|
||||
const png_uint_32 green = colors[2];
|
||||
const png_uint_32 blue = colors[3];
|
||||
const png_uint_32 alpha = colors[4];
|
||||
png_uint_32 red = colors[1];
|
||||
png_uint_32 green = colors[2];
|
||||
png_uint_32 blue = colors[3];
|
||||
png_uint_32 alpha = colors[4];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
@ -812,7 +812,7 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
{
|
||||
const unsigned int size =
|
||||
unsigned int size =
|
||||
image_size_of_type(color_type, bit_depth, colors, small);
|
||||
unsigned int ysize;
|
||||
png_fixed_point real_gamma = 45455; /* For sRGB */
|
||||
@ -824,7 +824,7 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
*/
|
||||
if (small)
|
||||
{
|
||||
const unsigned int pixel_depth =
|
||||
unsigned int pixel_depth =
|
||||
pixel_depth_of_type(color_type, bit_depth);
|
||||
|
||||
if (pixel_depth <= 8U)
|
||||
@ -1378,10 +1378,10 @@ static void
|
||||
insert_sBIT(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
png_charpp params)
|
||||
{
|
||||
const int ct = png_get_color_type(png_ptr, info_ptr);
|
||||
const int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
|
||||
int ct = png_get_color_type(png_ptr, info_ptr);
|
||||
int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
|
||||
(ct & PNG_COLOR_MASK_ALPHA ? 1 : 0);
|
||||
const unsigned int maxval =
|
||||
unsigned int maxval =
|
||||
ct & PNG_COLOR_MASK_PALETTE ? 8U : png_get_bit_depth(png_ptr, info_ptr);
|
||||
png_color_8 sBIT;
|
||||
|
||||
@ -1856,7 +1856,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* Check the colors */
|
||||
{
|
||||
const unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U :
|
||||
unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U :
|
||||
(1U<<bit_depth)-1);
|
||||
unsigned int i;
|
||||
|
||||
|
@ -1446,7 +1446,7 @@ test_one_file(struct display *dp, const char *filename)
|
||||
* unsigned, because some transforms are negative on a 16-bit system.
|
||||
*/
|
||||
unsigned int active = dp->active_transforms;
|
||||
const int exhaustive = (dp->options & EXHAUSTIVE) != 0;
|
||||
int exhaustive = (dp->options & EXHAUSTIVE) != 0;
|
||||
unsigned int current = first_transform(active);
|
||||
unsigned int bad_transforms = 0;
|
||||
unsigned int bad_combo = ~0U; /* bitwise AND of failing transforms */
|
||||
@ -1572,7 +1572,7 @@ do_test(struct display *dp, const char *file)
|
||||
}
|
||||
|
||||
int
|
||||
main(const int argc, const char * const * const argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
/* For each file on the command line test it with a range of transforms */
|
||||
int option_end, ilog = 0;
|
||||
@ -1674,7 +1674,7 @@ main(const int argc, const char * const * const argv)
|
||||
/* Here on any return, including failures, except user/internal issues
|
||||
*/
|
||||
{
|
||||
const int pass = (d.options & STRICT) ?
|
||||
int pass = (d.options & STRICT) ?
|
||||
RESULT_STRICT(d.results) : RESULT_RELAXED(d.results);
|
||||
|
||||
if (!pass)
|
||||
|
@ -372,7 +372,7 @@ print_opts(png_uint_32 opts)
|
||||
*/
|
||||
#define FORMAT_COUNT 64
|
||||
#define FORMAT_MASK 0x3f
|
||||
static PNG_CONST char * PNG_CONST format_names[FORMAT_COUNT] =
|
||||
static const char * const format_names[FORMAT_COUNT] =
|
||||
{
|
||||
"sRGB-gray",
|
||||
"sRGB-gray+alpha",
|
||||
@ -2346,8 +2346,8 @@ static int
|
||||
logpixel(const Transform *transform, png_uint_32 x, png_uint_32 y,
|
||||
const Pixel *in, const Pixel *calc, const Pixel *out, const char *reason)
|
||||
{
|
||||
const png_uint_32 in_format = transform->in_image->image.format;
|
||||
const png_uint_32 out_format = transform->out_image->image.format;
|
||||
png_uint_32 in_format = transform->in_image->image.format;
|
||||
png_uint_32 out_format = transform->out_image->image.format;
|
||||
|
||||
png_uint_32 back_format = out_format & ~PNG_FORMAT_FLAG_ALPHA;
|
||||
const char *via_linear = "";
|
||||
@ -2602,12 +2602,12 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
ptrdiff_t strideb = b->stride;
|
||||
png_const_bytep rowa = a->buffer+16;
|
||||
png_const_bytep rowb = b->buffer+16;
|
||||
const png_uint_32 width = a->image.width;
|
||||
const png_uint_32 height = a->image.height;
|
||||
const png_uint_32 formata = a->image.format;
|
||||
const png_uint_32 formatb = b->image.format;
|
||||
const unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
|
||||
const unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
|
||||
png_uint_32 width = a->image.width;
|
||||
png_uint_32 height = a->image.height;
|
||||
png_uint_32 formata = a->image.format;
|
||||
png_uint_32 formatb = b->image.format;
|
||||
unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
|
||||
unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
|
||||
int alpha_added, alpha_removed;
|
||||
int bchannels;
|
||||
png_uint_32 y;
|
||||
@ -2726,7 +2726,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
result = 0;
|
||||
}
|
||||
|
||||
/* If reqested copy the error values back from the Transform. */
|
||||
/* If requested, copy the error values back from the Transform. */
|
||||
if (a->opts & ACCUMULATE)
|
||||
{
|
||||
tr.error_ptr[0] = tr.error[0];
|
||||
@ -2790,8 +2790,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
(formata & (formatb ^ PNG_FORMAT_FLAG_COLOR) & PNG_FORMAT_FLAG_COLOR)))
|
||||
{
|
||||
/* Was an alpha channel changed? */
|
||||
const png_uint_32 alpha_changed = (formata ^ formatb) &
|
||||
PNG_FORMAT_FLAG_ALPHA;
|
||||
png_uint_32 alpha_changed = (formata ^ formatb) & PNG_FORMAT_FLAG_ALPHA;
|
||||
|
||||
/* Was an alpha channel removed? (The third test.) If so the direct
|
||||
* comparison is only possible if the input alpha is opaque.
|
||||
@ -2932,7 +2931,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
}
|
||||
}
|
||||
|
||||
/* If reqested copy the error values back from the Transform. */
|
||||
/* If requested, copy the error values back from the Transform. */
|
||||
if (a->opts & ACCUMULATE)
|
||||
{
|
||||
tr.error_ptr[0] = tr.error[0];
|
||||
@ -3627,7 +3626,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (arg[0] == '-')
|
||||
{
|
||||
const int term = (arg[1] == '0' ? 0 : '\n');
|
||||
int term = (arg[1] == '0' ? 0 : '\n');
|
||||
unsigned int ich = 0;
|
||||
|
||||
/* Loop reading files, use a static buffer to simplify this and just
|
||||
|
@ -56,7 +56,7 @@
|
||||
defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
/* This deliberately lacks the PNG_CONST. */
|
||||
/* This deliberately lacks the const. */
|
||||
typedef png_byte *png_const_bytep;
|
||||
|
||||
/* This is copied from 1.5.1 png.h: */
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define _POSIX_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1 /* For floating point */
|
||||
#define _GNU_SOURCE 1 /* For the floating point exception extension */
|
||||
#define _BSD_SOURCE 1 /* For the floating point exception extension */
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@ -961,7 +962,7 @@ bits_of(png_uint_32 num)
|
||||
return b; /* 0..32 */
|
||||
}
|
||||
|
||||
/* Main interface to file storeage, after writing a new PNG file (see the API
|
||||
/* Main interface to file storage, after writing a new PNG file (see the API
|
||||
* below) call store_storefile to store the result with the given name and id.
|
||||
*/
|
||||
static void
|
||||
@ -2589,7 +2590,7 @@ static double digitize(double value, int depth, int do_round)
|
||||
* rounding and 'do_round' should be 1, if it is 0 the digitized value will
|
||||
* be truncated.
|
||||
*/
|
||||
const unsigned int digitization_factor = (1U << depth) -1;
|
||||
unsigned int digitization_factor = (1U << depth) - 1;
|
||||
|
||||
/* Limiting the range is done as a convenience to the caller - it's easier to
|
||||
* do it once here than every time at the call site.
|
||||
@ -3687,8 +3688,8 @@ init_standard_palette(png_store *ps, png_structp pp, png_infop pi, int npalette,
|
||||
|
||||
#ifdef PNG_WRITE_tRNS_SUPPORTED
|
||||
static void
|
||||
set_random_tRNS(png_structp pp, png_infop pi, const png_byte colour_type,
|
||||
const int bit_depth)
|
||||
set_random_tRNS(png_structp pp, png_infop pi, png_byte colour_type,
|
||||
int bit_depth)
|
||||
{
|
||||
/* To make this useful the tRNS color needs to match at least one pixel.
|
||||
* Random values are fine for gray, including the 16-bit case where we know
|
||||
@ -3696,7 +3697,7 @@ set_random_tRNS(png_structp pp, png_infop pi, const png_byte colour_type,
|
||||
* method as only 65536 different RGB values are generated.
|
||||
*/
|
||||
png_color_16 tRNS;
|
||||
const png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1);
|
||||
png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1);
|
||||
|
||||
R8(tRNS); /* makes unset fields random */
|
||||
|
||||
@ -4337,7 +4338,7 @@ make_size_image(png_store* const ps, png_byte const colour_type,
|
||||
|
||||
/* Make a name and get an appropriate id for the store: */
|
||||
char name[FILE_NAME_SIZE];
|
||||
const png_uint_32 id = FILEID(colour_type, bit_depth, 0/*palette*/,
|
||||
png_uint_32 id = FILEID(colour_type, bit_depth, 0/*palette*/,
|
||||
interlace_type, w, h, do_interlace);
|
||||
|
||||
standard_name_from_id(name, sizeof name, 0, id);
|
||||
@ -4413,7 +4414,7 @@ make_size_image(png_store* const ps, png_byte const colour_type,
|
||||
for (pass=0; pass<npasses; ++pass)
|
||||
{
|
||||
/* The following two are for checking the macros: */
|
||||
const png_uint_32 wPass = PNG_PASS_COLS(w, pass);
|
||||
png_uint_32 wPass = PNG_PASS_COLS(w, pass);
|
||||
|
||||
/* If do_interlace is set we don't call png_write_row for every
|
||||
* row because some of them are empty. In fact, for a 1x1 image,
|
||||
@ -4645,7 +4646,7 @@ make_error(png_store* const ps, png_byte const colour_type,
|
||||
Try
|
||||
{
|
||||
png_infop pi;
|
||||
const png_structp pp = set_store_for_write(ps, &pi, name);
|
||||
png_structp pp = set_store_for_write(ps, &pi, name);
|
||||
png_uint_32 w, h;
|
||||
gnu_volatile(pp)
|
||||
|
||||
@ -4705,7 +4706,7 @@ make_error(png_store* const ps, png_byte const colour_type,
|
||||
else
|
||||
{
|
||||
/* Now write the whole image, just to make sure that the detected, or
|
||||
* undetected, errro has not created problems inside libpng. This
|
||||
* undetected, error has not created problems inside libpng. This
|
||||
* doesn't work if there was a png_error in png_write_info because that
|
||||
* can abort before PLTE was written.
|
||||
*/
|
||||
@ -5468,14 +5469,14 @@ progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass)
|
||||
|
||||
static void
|
||||
sequential_row(standard_display *dp, png_structp pp, png_infop pi,
|
||||
const int iImage, const int iDisplay)
|
||||
int iImage, int iDisplay)
|
||||
{
|
||||
const int npasses = dp->npasses;
|
||||
const int do_interlace = dp->do_interlace &&
|
||||
int npasses = dp->npasses;
|
||||
int do_interlace = dp->do_interlace &&
|
||||
dp->interlace_type == PNG_INTERLACE_ADAM7;
|
||||
const png_uint_32 height = standard_height(pp, dp->id);
|
||||
const png_uint_32 width = standard_width(pp, dp->id);
|
||||
const png_store* ps = dp->ps;
|
||||
png_uint_32 height = standard_height(pp, dp->id);
|
||||
png_uint_32 width = standard_width(pp, dp->id);
|
||||
const png_store* ps = dp->ps;
|
||||
int pass;
|
||||
|
||||
for (pass=0; pass<npasses; ++pass)
|
||||
@ -5869,7 +5870,7 @@ test_size(png_modifier* const pm, png_byte const colour_type,
|
||||
*/
|
||||
static const png_byte hinc[] = {1, 3, 11, 1, 5};
|
||||
static const png_byte winc[] = {1, 9, 5, 7, 1};
|
||||
const int save_bdlo = bdlo;
|
||||
int save_bdlo = bdlo;
|
||||
|
||||
for (; bdlo <= bdhi; ++bdlo)
|
||||
{
|
||||
@ -6077,12 +6078,12 @@ image_pixel_init(image_pixel *this, png_const_bytep row, png_byte colour_type,
|
||||
png_byte bit_depth, png_uint_32 x, store_palette palette,
|
||||
const image_pixel *format /*from pngvalid transform of input*/)
|
||||
{
|
||||
const png_byte sample_depth = (png_byte)(colour_type ==
|
||||
PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth);
|
||||
const unsigned int max = (1U<<sample_depth)-1;
|
||||
const int swap16 = (format != 0 && format->swap16);
|
||||
const int littleendian = (format != 0 && format->littleendian);
|
||||
const int sig_bits = (format != 0 && format->sig_bits);
|
||||
png_byte sample_depth =
|
||||
(png_byte)(colour_type == PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth);
|
||||
unsigned int max = (1U<<sample_depth)-1;
|
||||
int swap16 = (format != 0 && format->swap16);
|
||||
int littleendian = (format != 0 && format->littleendian);
|
||||
int sig_bits = (format != 0 && format->sig_bits);
|
||||
|
||||
/* Initially just set everything to the same number and the alpha to opaque.
|
||||
* Note that this currently assumes a simple palette where entry x has colour
|
||||
@ -6100,7 +6101,7 @@ image_pixel_init(image_pixel *this, png_const_bytep row, png_byte colour_type,
|
||||
/* This permits the caller to default to the sample value. */
|
||||
if (palette != 0)
|
||||
{
|
||||
const unsigned int i = this->palette_index;
|
||||
unsigned int i = this->palette_index;
|
||||
|
||||
this->red = palette[i].red;
|
||||
this->green = palette[i].green;
|
||||
@ -6431,8 +6432,8 @@ static void
|
||||
image_transform_mod_end(const image_transform *this, image_pixel *that,
|
||||
png_const_structp pp, const transform_display *display)
|
||||
{
|
||||
const unsigned int scale = (1U<<that->sample_depth)-1;
|
||||
const int sig_bits = that->sig_bits;
|
||||
unsigned int scale = (1U<<that->sample_depth)-1;
|
||||
int sig_bits = that->sig_bits;
|
||||
|
||||
UNUSED(this)
|
||||
UNUSED(pp)
|
||||
@ -6755,19 +6756,19 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
|
||||
{
|
||||
/* Constants for the loop below: */
|
||||
const png_store* const ps = dp->this.ps;
|
||||
const png_byte in_ct = dp->this.colour_type;
|
||||
const png_byte in_bd = dp->this.bit_depth;
|
||||
const png_uint_32 w = dp->this.w;
|
||||
const png_uint_32 h = dp->this.h;
|
||||
const png_byte out_ct = dp->output_colour_type;
|
||||
const png_byte out_bd = dp->output_bit_depth;
|
||||
const png_byte sample_depth = (png_byte)(out_ct ==
|
||||
PNG_COLOR_TYPE_PALETTE ? 8 : out_bd);
|
||||
const png_byte red_sBIT = dp->this.red_sBIT;
|
||||
const png_byte green_sBIT = dp->this.green_sBIT;
|
||||
const png_byte blue_sBIT = dp->this.blue_sBIT;
|
||||
const png_byte alpha_sBIT = dp->this.alpha_sBIT;
|
||||
const int have_tRNS = dp->this.is_transparent;
|
||||
png_byte in_ct = dp->this.colour_type;
|
||||
png_byte in_bd = dp->this.bit_depth;
|
||||
png_uint_32 w = dp->this.w;
|
||||
png_uint_32 h = dp->this.h;
|
||||
png_byte out_ct = dp->output_colour_type;
|
||||
png_byte out_bd = dp->output_bit_depth;
|
||||
png_byte sample_depth =
|
||||
(png_byte)(out_ct == PNG_COLOR_TYPE_PALETTE ? 8 : out_bd);
|
||||
png_byte red_sBIT = dp->this.red_sBIT;
|
||||
png_byte green_sBIT = dp->this.green_sBIT;
|
||||
png_byte blue_sBIT = dp->this.blue_sBIT;
|
||||
png_byte alpha_sBIT = dp->this.alpha_sBIT;
|
||||
int have_tRNS = dp->this.is_transparent;
|
||||
double digitization_error;
|
||||
|
||||
store_palette out_palette;
|
||||
@ -6928,7 +6929,7 @@ transform_end(png_structp ppIn, png_infop pi)
|
||||
|
||||
/* A single test run. */
|
||||
static void
|
||||
transform_test(png_modifier *pmIn, const png_uint_32 idIn,
|
||||
transform_test(png_modifier *pmIn, png_uint_32 idIn,
|
||||
const image_transform* transform_listIn, const char * const name)
|
||||
{
|
||||
transform_display d;
|
||||
@ -7763,7 +7764,7 @@ static void
|
||||
image_transform_png_set_rgb_to_gray_set(const image_transform *this,
|
||||
transform_display *that, png_structp pp, png_infop pi)
|
||||
{
|
||||
const int error_action = 1; /* no error, no defines in png.h */
|
||||
int error_action = 1; /* no error, no defines in png.h */
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_set_rgb_to_gray(pp, error_action, data.red_to_set, data.green_to_set);
|
||||
@ -7904,10 +7905,10 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
|
||||
# if DIGITIZE
|
||||
{
|
||||
png_modifier *pm = display->pm;
|
||||
const unsigned int sample_depth = that->sample_depth;
|
||||
const unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 :
|
||||
unsigned int sample_depth = that->sample_depth;
|
||||
unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 :
|
||||
sample_depth);
|
||||
const unsigned int gamma_depth =
|
||||
unsigned int gamma_depth =
|
||||
(sample_depth == 16 ?
|
||||
display->max_gamma_8 :
|
||||
(pm->assume_16_bit_calculations ?
|
||||
@ -8001,7 +8002,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
|
||||
b * data.blue_coefficient;
|
||||
|
||||
{
|
||||
const int do_round = data.gamma != 1 || calc_depth == 16;
|
||||
int do_round = data.gamma != 1 || calc_depth == 16;
|
||||
const double ce = 2. / 32768;
|
||||
|
||||
graylo = DD(rlo * (data.red_coefficient-ce) +
|
||||
@ -8625,7 +8626,7 @@ image_transform_png_set_filler_mod(const image_transform *this,
|
||||
(that->colour_type == PNG_COLOR_TYPE_RGB ||
|
||||
that->colour_type == PNG_COLOR_TYPE_GRAY))
|
||||
{
|
||||
const unsigned int max = (1U << that->bit_depth)-1;
|
||||
unsigned int max = (1U << that->bit_depth)-1;
|
||||
that->alpha = data.filler & max;
|
||||
that->alphaf = ((double)that->alpha) / max;
|
||||
that->alphae = 0;
|
||||
@ -8692,7 +8693,7 @@ image_transform_png_set_add_alpha_mod(const image_transform *this,
|
||||
(that->colour_type == PNG_COLOR_TYPE_RGB ||
|
||||
that->colour_type == PNG_COLOR_TYPE_GRAY))
|
||||
{
|
||||
const unsigned int max = (1U << that->bit_depth)-1;
|
||||
unsigned int max = (1U << that->bit_depth)-1;
|
||||
that->alpha = data.filler & max;
|
||||
that->alphaf = ((double)that->alpha) / max;
|
||||
that->alphae = 0;
|
||||
@ -8883,7 +8884,7 @@ image_transform_png_set_shift_set(const image_transform *this,
|
||||
* field is randomized independently. This acts as a check that
|
||||
* libpng does use the correct field.
|
||||
*/
|
||||
const unsigned int depth = that->this.bit_depth;
|
||||
unsigned int depth = that->this.bit_depth;
|
||||
|
||||
data.red = (png_byte)/*SAFE*/(random_mod(depth)+1);
|
||||
data.green = (png_byte)/*SAFE*/(random_mod(depth)+1);
|
||||
@ -9298,12 +9299,12 @@ gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi)
|
||||
int mode = dp->do_background - ALPHA_MODE_OFFSET;
|
||||
|
||||
/* The gamma value is the output gamma, and is in the standard,
|
||||
* non-inverted, represenation. It provides a default for the PNG file
|
||||
* non-inverted, representation. It provides a default for the PNG file
|
||||
* gamma, but since the file has a gAMA chunk this does not matter.
|
||||
*/
|
||||
const double sg = dp->screen_gamma;
|
||||
# ifndef PNG_FLOATING_POINT_SUPPORTED
|
||||
const png_fixed_point g = fix(sg);
|
||||
png_fixed_point g = fix(sg);
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@ -9351,7 +9352,7 @@ gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi)
|
||||
*/
|
||||
const double bg = dp->background_gamma;
|
||||
# ifndef PNG_FLOATING_POINT_SUPPORTED
|
||||
const png_fixed_point g = fix(bg);
|
||||
png_fixed_point g = fix(bg);
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@ -9425,7 +9426,7 @@ static void
|
||||
init_validate_info(validate_info *vi, gamma_display *dp, png_const_structp pp,
|
||||
int in_depth, int out_depth)
|
||||
{
|
||||
const unsigned int outmax = (1U<<out_depth)-1;
|
||||
unsigned int outmax = (1U<<out_depth)-1;
|
||||
|
||||
vi->pp = pp;
|
||||
vi->dp = dp;
|
||||
@ -9587,14 +9588,14 @@ gamma_component_compose(int do_background, double input_sample, double alpha,
|
||||
/* This API returns the encoded *input* component, in the range 0..1 */
|
||||
static double
|
||||
gamma_component_validate(const char *name, const validate_info *vi,
|
||||
const unsigned int id, const unsigned int od,
|
||||
unsigned int id, unsigned int od,
|
||||
const double alpha /* <0 for the alpha channel itself */,
|
||||
const double background /* component background value */)
|
||||
{
|
||||
const unsigned int isbit = id >> vi->isbit_shift;
|
||||
const unsigned int sbit_max = vi->sbit_max;
|
||||
const unsigned int outmax = vi->outmax;
|
||||
const int do_background = vi->do_background;
|
||||
unsigned int isbit = id >> vi->isbit_shift;
|
||||
unsigned int sbit_max = vi->sbit_max;
|
||||
unsigned int outmax = vi->outmax;
|
||||
int do_background = vi->do_background;
|
||||
|
||||
double i;
|
||||
|
||||
@ -10160,13 +10161,13 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
{
|
||||
/* Get some constants derived from the input and output file formats: */
|
||||
const png_store* const ps = dp->this.ps;
|
||||
const png_byte in_ct = dp->this.colour_type;
|
||||
const png_byte in_bd = dp->this.bit_depth;
|
||||
const png_uint_32 w = dp->this.w;
|
||||
const png_uint_32 h = dp->this.h;
|
||||
png_byte in_ct = dp->this.colour_type;
|
||||
png_byte in_bd = dp->this.bit_depth;
|
||||
png_uint_32 w = dp->this.w;
|
||||
png_uint_32 h = dp->this.h;
|
||||
const size_t cbRow = dp->this.cbRow;
|
||||
const png_byte out_ct = png_get_color_type(pp, pi);
|
||||
const png_byte out_bd = png_get_bit_depth(pp, pi);
|
||||
png_byte out_ct = png_get_color_type(pp, pi);
|
||||
png_byte out_bd = png_get_bit_depth(pp, pi);
|
||||
|
||||
/* There are three sources of error, firstly the quantization in the
|
||||
* file encoding, determined by sbit and/or the file depth, secondly
|
||||
@ -10207,11 +10208,11 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
* The basic tests below do not do this, however if 'use_input_precision'
|
||||
* is set a subsequent test is performed above.
|
||||
*/
|
||||
const unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
|
||||
unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
|
||||
int processing;
|
||||
png_uint_32 y;
|
||||
const store_palette_entry *in_palette = dp->this.palette;
|
||||
const int in_is_transparent = dp->this.is_transparent;
|
||||
int in_is_transparent = dp->this.is_transparent;
|
||||
int process_tRNS;
|
||||
int out_npalette = -1;
|
||||
int out_is_transparent = 0; /* Just refers to the palette case */
|
||||
@ -10259,9 +10260,9 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
double alpha = 1; /* serves as a flag value */
|
||||
|
||||
/* Record the palette index for index images. */
|
||||
const unsigned int in_index =
|
||||
unsigned int in_index =
|
||||
in_ct == 3 ? sample(std, 3, in_bd, x, 0, 0, 0) : 256;
|
||||
const unsigned int out_index =
|
||||
unsigned int out_index =
|
||||
out_ct == 3 ? sample(std, 3, out_bd, x, 0, 0, 0) : 256;
|
||||
|
||||
/* Handle input alpha - png_set_background will cause the output
|
||||
@ -10270,7 +10271,7 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
if ((in_ct & PNG_COLOR_MASK_ALPHA) != 0 ||
|
||||
(in_ct == 3 && in_is_transparent))
|
||||
{
|
||||
const unsigned int input_alpha = in_ct == 3 ?
|
||||
unsigned int input_alpha = in_ct == 3 ?
|
||||
dp->this.palette[in_index].alpha :
|
||||
sample(std, in_ct, in_bd, x, samples_per_pixel, 0, 0);
|
||||
|
||||
@ -10395,14 +10396,14 @@ gamma_end(png_structp ppIn, png_infop pi)
|
||||
* maxpc: maximum percentage error (as a percentage)
|
||||
*/
|
||||
static void
|
||||
gamma_test(png_modifier *pmIn, const png_byte colour_typeIn,
|
||||
const png_byte bit_depthIn, const int palette_numberIn,
|
||||
const int interlace_typeIn,
|
||||
gamma_test(png_modifier *pmIn, png_byte colour_typeIn,
|
||||
png_byte bit_depthIn, int palette_numberIn,
|
||||
int interlace_typeIn,
|
||||
const double file_gammaIn, const double screen_gammaIn,
|
||||
const png_byte sbitIn, const int threshold_testIn,
|
||||
png_byte sbitIn, int threshold_testIn,
|
||||
const char *name,
|
||||
const int use_input_precisionIn, const int scale16In,
|
||||
const int expand16In, const int do_backgroundIn,
|
||||
int use_input_precisionIn, int scale16In,
|
||||
int expand16In, int do_backgroundIn,
|
||||
const png_color_16 *bkgd_colorIn, double bkgd_gammaIn)
|
||||
{
|
||||
gamma_display d;
|
||||
@ -10606,11 +10607,11 @@ perform_gamma_threshold_tests(png_modifier *pm)
|
||||
}
|
||||
|
||||
static void gamma_transform_test(png_modifier *pm,
|
||||
const png_byte colour_type, const png_byte bit_depth,
|
||||
const int palette_number,
|
||||
const int interlace_type, const double file_gamma,
|
||||
const double screen_gamma, const png_byte sbit,
|
||||
const int use_input_precision, const int scale16)
|
||||
png_byte colour_type, png_byte bit_depth,
|
||||
int palette_number,
|
||||
int interlace_type, const double file_gamma,
|
||||
const double screen_gamma, png_byte sbit,
|
||||
int use_input_precision, int scale16)
|
||||
{
|
||||
size_t pos = 0;
|
||||
char name[64];
|
||||
@ -10767,12 +10768,12 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
static void gamma_composition_test(png_modifier *pm,
|
||||
const png_byte colour_type, const png_byte bit_depth,
|
||||
const int palette_number,
|
||||
const int interlace_type, const double file_gamma,
|
||||
png_byte colour_type, png_byte bit_depth,
|
||||
int palette_number,
|
||||
int interlace_type, const double file_gamma,
|
||||
const double screen_gamma,
|
||||
const int use_input_precision, const int do_background,
|
||||
const int expand_16)
|
||||
int use_input_precision, int do_background,
|
||||
int expand_16)
|
||||
{
|
||||
size_t pos = 0;
|
||||
png_const_charp base;
|
||||
|
@ -331,8 +331,8 @@ static int check_one_character(checkfp_command *co, checkfp_control c, int ch)
|
||||
*/
|
||||
size_t index = 0;
|
||||
const char test = (char)ch;
|
||||
const int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||
const int character_accepted = (index == 1);
|
||||
int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||
int character_accepted = (index == 1);
|
||||
|
||||
if (c.check_state != exponent && isdigit(ch) && ch != '0')
|
||||
c.is_zero = 0;
|
||||
|
13
contrib/pngminus/CHANGES.txt
Normal file
13
contrib/pngminus/CHANGES.txt
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||
copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||
|
||||
version 1.0 - 1999.10.15 - First version.
|
||||
1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
|
||||
1.2 - 2017.04.22 - Add buffer-size check
|
||||
1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
|
||||
(Glenn Randers-Pehrson)
|
||||
1.4 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
|
||||
1.5 - 2018.08.05 - Fix buffer overflow in tokenizer (Cosmin Truta)
|
||||
1.6 - 2018.08.05 - Improve portability and fix style (Cosmin Truta)
|
||||
1.7 - 2019.01.22 - Change license to MIT (Willem van Schaik)
|
24
contrib/pngminus/CMakeLists.txt
Normal file
24
contrib/pngminus/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
cmake_policy(VERSION 3.1)
|
||||
|
||||
project(PNGMINUS C)
|
||||
|
||||
option(PNGMINUS_USE_STATIC_LIBRARIES "Use the static library builds" ON)
|
||||
|
||||
# libpng
|
||||
add_subdirectory(../.. libpng)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/libpng)
|
||||
if(PNGMINUS_USE_STATIC_LIBRARIES)
|
||||
set(PNGMINUS_PNG_LIBRARY png_static)
|
||||
else()
|
||||
set(PNGMINUS_PNG_LIBRARY png)
|
||||
endif()
|
||||
|
||||
# png2pnm
|
||||
add_executable(png2pnm png2pnm.c)
|
||||
target_link_libraries(png2pnm ${PNGMINUS_PNG_LIBRARY})
|
||||
|
||||
# pnm2png
|
||||
add_executable(pnm2png pnm2png.c)
|
||||
target_link_libraries(pnm2png ${PNGMINUS_PNG_LIBRARY})
|
22
contrib/pngminus/LICENSE.txt
Normal file
22
contrib/pngminus/LICENSE.txt
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||
|
||||
copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or
|
||||
implied, including but not limited to the warranties of merchantability,
|
||||
fitness for a particular purpose and noninfringement. In no event shall the
|
||||
authors or copyight holders be liable for any claim, damages or other
|
||||
liability, whether in an action of contract, tort or otherwise, arising from,
|
||||
out of or in connection with the software or the use or other dealings in the
|
||||
software.
|
62
contrib/pngminus/Makefile
Normal file
62
contrib/pngminus/Makefile
Normal file
@ -0,0 +1,62 @@
|
||||
# Makefile for PngMinus (png2pnm and pnm2png)
|
||||
# Linux / Unix
|
||||
|
||||
#CC = cc
|
||||
CC = gcc
|
||||
LD = $(CC)
|
||||
|
||||
RM = rm -f
|
||||
|
||||
PNGINC = -I../..
|
||||
PNGLIB_SHARED = -L../.. -lpng
|
||||
PNGLIB_STATIC = ../../libpng.a
|
||||
|
||||
# Uncomment the following if you have a custom zlib build at ../../../zlib
|
||||
#ZINC = -I../../../zlib
|
||||
#ZLIB_SHARED = -L../../../zlib -lz
|
||||
#ZLIB_STATIC = ../../../zlib/libz.a
|
||||
|
||||
# Use the system zlib otherwise
|
||||
ZLIB_SHARED = -lz
|
||||
ZLIB_STATIC = -lz
|
||||
|
||||
CPPFLAGS = $(PNGINC) $(ZINC)
|
||||
CFLAGS =
|
||||
LDFLAGS =
|
||||
LIBS_SHARED = $(PNGLIB_SHARED) $(ZLIB_SHARED)
|
||||
LIBS_STATIC = $(PNGLIB_STATIC) $(ZLIB_STATIC)
|
||||
|
||||
EXEEXT =
|
||||
#EXEEXT = .exe
|
||||
|
||||
# dependencies
|
||||
|
||||
all: png2pnm$(EXEEXT) pnm2png$(EXEEXT) png2pnm-static$(EXEEXT) pnm2png-static$(EXEEXT)
|
||||
|
||||
png2pnm.o: png2pnm.c
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm.c
|
||||
|
||||
pnm2png.o: pnm2png.c
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png.c
|
||||
|
||||
png2pnm$(EXEEXT): png2pnm.o
|
||||
$(LD) $(LDFLAGS) -o png2pnm$(EXEEXT) png2pnm.o $(LIBS_SHARED) -lm
|
||||
|
||||
pnm2png$(EXEEXT): pnm2png.o
|
||||
$(LD) $(LDFLAGS) -o pnm2png$(EXEEXT) pnm2png.o $(LIBS_SHARED) -lm
|
||||
|
||||
png2pnm-static$(EXEEXT): png2pnm.o
|
||||
$(LD) $(LDFLAGS) -o png2pnm-static$(EXEEXT) png2pnm.o $(LIBS_STATIC) -lm
|
||||
|
||||
pnm2png-static$(EXEEXT): pnm2png.o
|
||||
$(LD) $(LDFLAGS) -o pnm2png-static$(EXEEXT) pnm2png.o $(LIBS_STATIC) -lm
|
||||
|
||||
clean:
|
||||
$(RM) png2pnm.o
|
||||
$(RM) pnm2png.o
|
||||
$(RM) png2pnm$(EXEEXT)
|
||||
$(RM) pnm2png$(EXEEXT)
|
||||
$(RM) png2pnm-static$(EXEEXT)
|
||||
$(RM) pnm2png-static$(EXEEXT)
|
||||
|
||||
# End of makefile for png2pnm / pnm2png
|
@ -1,26 +1,16 @@
|
||||
PngMinus
|
||||
--------
|
||||
(copyright Willem van Schaik, 1999)
|
||||
(copyright Willem van Schaik, 1999-2019)
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and
|
||||
its documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and
|
||||
that both that copyright notice and this permission notice appear in
|
||||
supporting documentation. This software is provided "as is" without
|
||||
express or implied warranty.
|
||||
|
||||
|
||||
Some history
|
||||
------------
|
||||
Soon after the creation of PNG in 1995, the need was felt for a set of
|
||||
pnmtopng / pngtopnm utilities. Independently Alexander Lehmann and I
|
||||
(Willem van Schaik) started such a project. Luckily we discovered this
|
||||
and merged the two together into pnmtopng.tar.gz, which is available
|
||||
from a/o ftp://ftp.simplesystems.org/pub/libpng/png/.
|
||||
and merged the two, which later became part of NetPBM, available from
|
||||
SourceForge.
|
||||
|
||||
These two utilities have many, many options and make use of most of the
|
||||
features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes
|
||||
@ -35,8 +25,8 @@ makes the whole setup a bit bulky. But that's unavoidable given the many
|
||||
features of pnmtopng.
|
||||
|
||||
|
||||
What now
|
||||
--------
|
||||
What now (1999)
|
||||
---------------
|
||||
At this moment libpng is in a very stable state and can do much of the
|
||||
work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new
|
||||
interface of libpng. Hence, it is time for a rewrite from the ground up
|
||||
@ -49,8 +39,8 @@ a small prototype that contains only the basic functionality. It doesn't
|
||||
have any of the options to read or write special chunks and it will do
|
||||
no gamma correction. But this makes it also a simple program that is
|
||||
quite easy to understand and can serve well as a template for other
|
||||
software developments. (By now there are of course a couple of programs,
|
||||
like Greg Roelofs' rpng/wpng, that can be used just as good.)
|
||||
software developments. By now there are of course a couple of programs,
|
||||
like Greg Roelofs' rpng/wpng, that can be used just as good.
|
||||
|
||||
|
||||
Can and can not
|
||||
@ -60,7 +50,8 @@ PngMinus. Because I started this development in good-old Turbo-C, I
|
||||
avoided the use the netpbm library, which requires DOS extenders. Again,
|
||||
another reason to call it PngMinus (minus netpbm :-). So, part of the
|
||||
program are some elementary routines to read / write pgm- and ppm-files.
|
||||
It does not read b&w pbm-files.
|
||||
It does not handle B&W pbm-files, but instead you could do pgm with bit-
|
||||
depth 1.
|
||||
|
||||
The downside of this approach is that you can not use them on images
|
||||
that require blocks of memory bigger than 64k (the DOS version). For
|
||||
@ -96,58 +87,34 @@ To list the options type "png2pnm -h" or "pnm2png -h".
|
||||
|
||||
Just like Scandinavian furniture
|
||||
--------------------------------
|
||||
You have to put it together yourself. I did test the software under
|
||||
MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both
|
||||
cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK,
|
||||
however some older libpng versions have a bug in pngmem.c when using
|
||||
Turbo-C 3.0 (see below).
|
||||
You have to put it together yourself. I developed the software on MS-DOS
|
||||
with Turbo-C 3.0 and RedHat Linux 4.2 with gcc. In both cases I used
|
||||
libpng-1.0.4 and zlib-1.1.3. By now (2019) it is twenty years later and
|
||||
more current versions are OK.
|
||||
|
||||
You can build it using one of the two makefiles (make -f makefile.###)
|
||||
or use the batch/script files pngminus.bat / pngminus.sh. This assumes
|
||||
that you have built the libraries in ../libpng and ../zlib. Using Linux,
|
||||
make sure that you have built libpng with makefile.std and not
|
||||
makefile.linux (also called .lnx in earlier versions of libpng). The
|
||||
latter creates a .so shared-library, while the PngMinus makefile assumes
|
||||
a normal .a static library.
|
||||
The makefile assumes that the libpng libraries can be found in ../.. and
|
||||
libz in ../../../zlib. But you can change this to for example ../libpng
|
||||
and ../zlib. The makefile creates two versions of each program, one with
|
||||
static library support and the other using shared libraries.
|
||||
|
||||
If you create a ../pngsuite directory and then store the basn####.png
|
||||
files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can
|
||||
test in one go the proper functioning of PngMinus, see png2pnm.bat and
|
||||
pnm2png.bat (or the .sh versions).
|
||||
test the proper functioning of PngMinus by running pngminus.sh.
|
||||
|
||||
|
||||
Warranty
|
||||
-------
|
||||
Please, remember that this was just a small experiment to learn a few
|
||||
things. It will have many unforeseen features <vbg>. Who said bugs? Use
|
||||
it when you are in need for something simple or when you want to start
|
||||
developing your own stuff.
|
||||
|
||||
|
||||
The Turbo bug
|
||||
-------------
|
||||
** pngmem.old
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr += 16L;
|
||||
** pngmem.c
|
||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr = hptr + 16L;
|
||||
**
|
||||
|
||||
** pngmem.old
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr += (png_uint_32)65536L;
|
||||
** pngmem.c
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
hptr = hptr + 65536L;
|
||||
**
|
||||
things. It will have many unforeseen features <vbg> ... who said bugs? Use
|
||||
it when you are in need for something simple or when you want a starting
|
||||
point for developing your own stuff.
|
||||
|
||||
|
||||
The end
|
||||
-------
|
||||
Willem van Schaik
|
||||
mailto:willem at schaik.com
|
||||
mailto:willem at schaik dot com
|
||||
http://www.schaik.com/png/
|
||||
-------
|
||||
Oct 1999
|
||||
|
||||
Oct 1999, Jan 2019
|
||||
|
@ -1,66 +0,0 @@
|
||||
# Makefile for PngMinus (png2pnm and pnm2png)
|
||||
# Linux / Unix
|
||||
|
||||
#CC=cc
|
||||
CC=gcc
|
||||
LD=$(CC)
|
||||
|
||||
RM=rm -f
|
||||
|
||||
#PNGPATH = /usr/local
|
||||
#PNGINC = -I$(PNGPATH)/include/libpng16
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng16
|
||||
#PNGLIBS = $(PNGPATH)/lib/libpng16.a
|
||||
PNGINC = -I../..
|
||||
PNGLIB = -L../.. -lpng
|
||||
PNGLIBS = ../../libpng.a
|
||||
|
||||
#ZPATH = /usr/local
|
||||
#ZINC = -I$(ZPATH)/include
|
||||
#ZLIB = -L$(ZPATH)/lib -lz
|
||||
#ZLIBS = $(ZPATH)/lib/libz.a
|
||||
ZINC = -I../../../zlib
|
||||
ZLIB = -L../../../zlib -lz
|
||||
ZLIBS = ../../../zlib/libz.a
|
||||
|
||||
CPPFLAGS=$(PNGINC) $(ZINC)
|
||||
CFLAGS=
|
||||
LDLIBS=$(PNGLIB) $(ZLIB)
|
||||
LDLIBSS=$(PNGLIBS) $(ZLIBS)
|
||||
C=.c
|
||||
O=.o
|
||||
L=.a
|
||||
E=
|
||||
|
||||
# dependencies
|
||||
|
||||
#all: png2pnm$(E) pnm2png$(E)
|
||||
all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E)
|
||||
|
||||
png2pnm$(O): png2pnm$(C)
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
|
||||
|
||||
png2pnm$(E): png2pnm$(O)
|
||||
$(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
|
||||
|
||||
png2pnm-static$(E): png2pnm$(O)
|
||||
$(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
|
||||
|
||||
pnm2png$(O): pnm2png$(C)
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
|
||||
|
||||
pnm2png$(E): pnm2png$(O)
|
||||
$(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
|
||||
|
||||
pnm2png-static$(E): pnm2png$(O)
|
||||
$(LD) $(LDFLAGS) -o pnm2png-static$(E) pnm2png$(O) $(LDLIBSS) -lm
|
||||
|
||||
clean:
|
||||
$(RM) png2pnm$(O)
|
||||
$(RM) pnm2png$(O)
|
||||
$(RM) png2pnm$(E)
|
||||
$(RM) pnm2png$(E)
|
||||
$(RM) png2pnm-static$(E)
|
||||
$(RM) pnm2png-static$(E)
|
||||
|
||||
# End of makefile for png2pnm / pnm2png
|
@ -1,38 +0,0 @@
|
||||
# Makefile for PngMinus (png2pnm and pnm2png)
|
||||
# TurboC++ 3.0
|
||||
|
||||
CC=tcc -Ic:\tc3\inc
|
||||
LD=tcc -Lc:\tc3\lib
|
||||
LB=tlib
|
||||
RM=del
|
||||
CP=copy
|
||||
MODEL=l
|
||||
CPPFLAGS=-I..\libpng -I..\zlib
|
||||
CFLAGS=-O -m$(MODEL)
|
||||
LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib
|
||||
C=.c
|
||||
O=.obj
|
||||
L=.lib
|
||||
E=.exe
|
||||
|
||||
# dependencies
|
||||
|
||||
all: png2pnm$(E) pnm2png$(E)
|
||||
|
||||
png2pnm$(O): png2pnm$(C)
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
|
||||
|
||||
png2pnm$(E): png2pnm$(O)
|
||||
$(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L)
|
||||
|
||||
pnm2png$(O): pnm2png$(C)
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
|
||||
|
||||
pnm2png$(E): pnm2png$(O)
|
||||
$(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L)
|
||||
|
||||
clean:
|
||||
$(RM) *$(O)
|
||||
$(RM) *$(E)
|
||||
|
||||
# End of makefile for png2pnm / pnm2png
|
@ -1,28 +1,14 @@
|
||||
/*
|
||||
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file
|
||||
* copyright (C) 1999,2017 by Willem van Schaik <willem at schaik.com>
|
||||
* copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||
*
|
||||
* version 1.0 - 1999.10.15 - First version.
|
||||
* 1.1 - 2017.04.22 - Add buffer-size check (Glenn Randers-Pehrson)
|
||||
* 1.2 - 2017.08.24 - Fix potential overflow in buffer-size check
|
||||
* (Glenn Randers-Pehrson)
|
||||
* 1.3 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear in
|
||||
* supporting documentation. This software is provided "as is" without
|
||||
* express or implied warranty.
|
||||
* This software is released under the MIT license. For conditions of
|
||||
* distribution and use, see the LICENSE file part of this package.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL unsigned char
|
||||
@ -34,45 +20,25 @@
|
||||
#define FALSE (BOOL) 0
|
||||
#endif
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#define STDIN 0
|
||||
#define STDOUT 1
|
||||
#define STDERR 2
|
||||
#endif
|
||||
|
||||
/* to make png2pnm verbose so we can find problems (needs to be before png.h) */
|
||||
/* make png2pnm verbose so we can find problems (needs to be before png.h) */
|
||||
#ifndef PNG_DEBUG
|
||||
#define PNG_DEBUG 0
|
||||
#endif
|
||||
|
||||
|
||||
#include "png.h"
|
||||
|
||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||
#endif
|
||||
|
||||
#ifndef PNGMINUS_UNUSED
|
||||
/* Unused formal parameter warnings are silenced using the following macro
|
||||
* which is expected to have no bad effects on performance (optimizing
|
||||
* compilers will probably remove it entirely).
|
||||
*/
|
||||
# define PNGMINUS_UNUSED(param) (void)param
|
||||
#endif
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
int main (int argc, char *argv[]);
|
||||
void usage ();
|
||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw,
|
||||
BOOL alpha);
|
||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
BOOL raw, BOOL alpha);
|
||||
|
||||
/*
|
||||
* main
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
FILE *fp_rd = stdin;
|
||||
FILE *fp_wr = stdout;
|
||||
@ -99,21 +65,21 @@ int main(int argc, char *argv[])
|
||||
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: can not create alpha-channel file %s\n",
|
||||
argv[argi]);
|
||||
fprintf (stderr, "Error: cannot create alpha-channel file %s\n",
|
||||
argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
usage ();
|
||||
exit (0);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
||||
usage();
|
||||
exit(1);
|
||||
usage ();
|
||||
exit (1);
|
||||
break;
|
||||
} /* end switch */
|
||||
}
|
||||
@ -121,9 +87,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if ((fp_rd = fopen (argv[argi], "rb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: file %s does not exist\n", argv[argi]);
|
||||
exit (1);
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: file %s does not exist\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
else if (fp_wr == stdout)
|
||||
@ -131,7 +97,7 @@ int main(int argc, char *argv[])
|
||||
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: can not create file %s\n", argv[argi]);
|
||||
fprintf (stderr, "Error: cannot create file %s\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
@ -139,21 +105,17 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: too many parameters\n");
|
||||
usage();
|
||||
exit(1);
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
} /* end for */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#if defined(O_BINARY) && (O_BINARY != 0)
|
||||
/* set stdin/stdout if required to binary */
|
||||
if (fp_rd == stdin)
|
||||
{
|
||||
setmode (STDIN, O_BINARY);
|
||||
}
|
||||
setmode (fileno (stdin), O_BINARY);
|
||||
if ((raw) && (fp_wr == stdout))
|
||||
{
|
||||
setmode (STDOUT, O_BINARY);
|
||||
}
|
||||
setmode (fileno (stdout), O_BINARY);
|
||||
#endif
|
||||
|
||||
/* call the conversion program itself */
|
||||
@ -161,7 +123,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
|
||||
exit(1);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* close input file */
|
||||
@ -179,23 +141,18 @@ int main(int argc, char *argv[])
|
||||
* usage
|
||||
*/
|
||||
|
||||
void usage()
|
||||
void usage ()
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, " by Willem van Schaik, 1999\n");
|
||||
#ifdef __TURBOC__
|
||||
fprintf (stderr, " for Turbo-C and Borland-C compilers\n");
|
||||
#else
|
||||
fprintf (stderr, " for Linux (and Unix) compilers\n");
|
||||
#endif
|
||||
fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n");
|
||||
fprintf (stderr, " or: ... | png2pnm [options]\n");
|
||||
fprintf (stderr, "Options:\n");
|
||||
fprintf (stderr,
|
||||
" -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
|
||||
" -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
|
||||
fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
|
||||
fprintf (stderr,
|
||||
" -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
|
||||
" -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
|
||||
fprintf (stderr, " -h | -? print this help-information\n");
|
||||
}
|
||||
|
||||
@ -204,10 +161,10 @@ void usage()
|
||||
*/
|
||||
|
||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
volatile BOOL raw, BOOL alpha)
|
||||
BOOL raw, BOOL alpha)
|
||||
{
|
||||
png_struct *png_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_byte buf[8];
|
||||
png_byte *png_pixels = NULL;
|
||||
png_byte **row_pointers = NULL;
|
||||
@ -231,24 +188,24 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
return FALSE;
|
||||
|
||||
ret = png_sig_cmp (buf, 0, 8);
|
||||
if (ret)
|
||||
if (ret != 0)
|
||||
return FALSE;
|
||||
|
||||
/* create png and info structures */
|
||||
|
||||
png_ptr = png_create_read_struct (png_get_libpng_ver(NULL),
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL);
|
||||
if (!png_ptr)
|
||||
return FALSE; /* out of memory */
|
||||
return FALSE; /* out of memory */
|
||||
|
||||
info_ptr = png_create_info_struct (png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, NULL, NULL);
|
||||
return FALSE; /* out of memory */
|
||||
return FALSE; /* out of memory */
|
||||
}
|
||||
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
if (setjmp (png_jmpbuf (png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
return FALSE;
|
||||
@ -256,15 +213,14 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
|
||||
/* set up the input control for C streams */
|
||||
png_init_io (png_ptr, png_file);
|
||||
png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */
|
||||
png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */
|
||||
|
||||
/* read the file information */
|
||||
png_read_info (png_ptr, info_ptr);
|
||||
|
||||
/* get size and bit-depth of the PNG-image */
|
||||
png_get_IHDR (png_ptr, info_ptr,
|
||||
&width, &height, &bit_depth, &color_type,
|
||||
NULL, NULL, NULL);
|
||||
png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
/* set-up the transformations */
|
||||
|
||||
@ -284,7 +240,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
png_set_strip_16 (png_ptr);
|
||||
/* transform grayscale images into full-color */
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb (png_ptr);
|
||||
/* only if file has a file gamma, we do a correction */
|
||||
if (png_get_gAMA (png_ptr, info_ptr, &file_gamma))
|
||||
@ -298,14 +254,14 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
|
||||
/* get the new color-type and bit-depth (after expansion/stripping) */
|
||||
png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL);
|
||||
|
||||
/* check for 16-bit files */
|
||||
if (bit_depth == 16)
|
||||
{
|
||||
raw = FALSE;
|
||||
#ifdef __TURBOC__
|
||||
pnm_file->flags &= ~((unsigned) _F_BIN);
|
||||
#if defined(O_BINARY) && (O_BINARY != 0)
|
||||
setmode (fileno (pnm_file), O_BINARY);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -333,25 +289,25 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = png_get_rowbytes (png_ptr, info_ptr);
|
||||
|
||||
if ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes))
|
||||
if ((row_bytes == 0) ||
|
||||
((size_t) height > (size_t) (-1) / (size_t) row_bytes))
|
||||
{
|
||||
/* too big */
|
||||
/* too big */
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
if ((png_pixels = (png_byte *)
|
||||
malloc ((size_t)row_bytes * (size_t)height * sizeof (png_byte))) == NULL)
|
||||
malloc ((size_t) row_bytes * (size_t) height)) == NULL)
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((row_pointers = (png_byte **)
|
||||
malloc ((size_t)height * sizeof (png_bytep))) == NULL)
|
||||
malloc ((size_t) height * sizeof (png_byte *))) == NULL)
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -366,7 +322,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
png_read_end (png_ptr, info_ptr);
|
||||
|
||||
/* clean up after the read, and free any memory allocated - REQUIRED */
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL);
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
|
||||
/* write header of PNM file */
|
||||
|
||||
@ -406,14 +362,21 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
{
|
||||
if (raw)
|
||||
fputc ((int) *pix_ptr++ , pnm_file);
|
||||
{
|
||||
fputc ((int) *pix_ptr++, pnm_file);
|
||||
}
|
||||
else
|
||||
if (bit_depth == 16){
|
||||
{
|
||||
if (bit_depth == 16)
|
||||
{
|
||||
dep_16 = (long) *pix_ptr++;
|
||||
fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (pnm_file, "%ld ", (long) *pix_ptr++);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (alpha_present)
|
||||
{
|
||||
@ -426,17 +389,23 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
else /* output alpha-channel as pgm file */
|
||||
{
|
||||
if (raw)
|
||||
fputc ((int) *pix_ptr++ , alpha_file);
|
||||
{
|
||||
fputc ((int) *pix_ptr++, alpha_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bit_depth == 16)
|
||||
{
|
||||
dep_16 = (long) *pix_ptr++;
|
||||
fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* if alpha_present */
|
||||
} /* end if alpha_present */
|
||||
|
||||
if (!raw)
|
||||
if (col % 4 == 3)
|
||||
@ -448,13 +417,11 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
fprintf (pnm_file, "\n");
|
||||
} /* end for row */
|
||||
|
||||
if (row_pointers != (unsigned char**) NULL)
|
||||
if (row_pointers != NULL)
|
||||
free (row_pointers);
|
||||
if (png_pixels != (unsigned char*) NULL)
|
||||
if (png_pixels != NULL)
|
||||
free (png_pixels);
|
||||
|
||||
PNGMINUS_UNUSED(raw); /* to quiet a Coverity defect */
|
||||
return TRUE;
|
||||
|
||||
} /* end of source */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
make -f makefile.tc3
|
||||
make
|
||||
call png2pnm.bat
|
||||
call pnm2png.bat
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
make -f makefile.std
|
||||
make
|
||||
sh png2pnm.sh
|
||||
sh pnm2png.sh
|
||||
|
||||
|
@ -1,29 +1,14 @@
|
||||
/*
|
||||
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||
* copyright (C) 1999,2015,2017 by Willem van Schaik <willem at schaik.com>
|
||||
* copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||
*
|
||||
* version 1.0 - 1999.10.15 - First version.
|
||||
* version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
|
||||
* version 1.2 - 2017.04.22 - Add buffer-size check
|
||||
* 1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
|
||||
* (Glenn Randers-Pehrson)
|
||||
* 1.4 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear in
|
||||
* supporting documentation. This software is provided "as is" without
|
||||
* express or implied warranty.
|
||||
* This software is released under the MIT license. For conditions of
|
||||
* distribution and use, see the LICENSE file part of this package.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL unsigned char
|
||||
@ -35,38 +20,20 @@
|
||||
#define FALSE (BOOL) 0
|
||||
#endif
|
||||
|
||||
#define STDIN 0
|
||||
#define STDOUT 1
|
||||
#define STDERR 2
|
||||
|
||||
/* to make pnm2png verbose so we can find problems (needs to be before png.h) */
|
||||
/* make pnm2png verbose so we can find problems (needs to be before png.h) */
|
||||
#ifndef PNG_DEBUG
|
||||
#define PNG_DEBUG 0
|
||||
#endif
|
||||
|
||||
#include "png.h"
|
||||
|
||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||
#endif
|
||||
|
||||
#ifndef PNGMINUS_UNUSED
|
||||
/* Unused formal parameter warnings are silenced using the following macro
|
||||
* which is expected to have no bad effects on performance (optimizing
|
||||
* compilers will probably remove it entirely).
|
||||
*/
|
||||
# define PNGMINUS_UNUSED(param) (void)param
|
||||
#endif
|
||||
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
int main (int argc, char *argv[]);
|
||||
void usage ();
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
BOOL alpha);
|
||||
void get_token(FILE *pnm_file, char *token);
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
|
||||
BOOL interlace, BOOL alpha);
|
||||
void get_token (FILE *pnm_file, char *token_buf, size_t token_buf_size);
|
||||
png_uint_32 get_data (FILE *pnm_file, int depth);
|
||||
png_uint_32 get_value (FILE *pnm_file, int depth);
|
||||
|
||||
@ -74,7 +41,7 @@ png_uint_32 get_value (FILE *pnm_file, int depth);
|
||||
* main
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
FILE *fp_rd = stdin;
|
||||
FILE *fp_al = NULL;
|
||||
@ -99,20 +66,20 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: alpha-channel file %s does not exist\n",
|
||||
argv[argi]);
|
||||
argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
usage ();
|
||||
exit (0);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
||||
usage();
|
||||
exit(1);
|
||||
usage ();
|
||||
exit (1);
|
||||
break;
|
||||
} /* end switch */
|
||||
}
|
||||
@ -130,7 +97,7 @@ int main(int argc, char *argv[])
|
||||
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: can not create PNG-file %s\n", argv[argi]);
|
||||
fprintf (stderr, "Error: cannot create PNG-file %s\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
@ -138,21 +105,19 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: too many parameters\n");
|
||||
usage();
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
} /* end for */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
/* set stdin/stdout to binary, we're reading the PNM always! in binary format */
|
||||
#if defined(O_BINARY) && (O_BINARY != 0)
|
||||
/* set stdin/stdout to binary,
|
||||
* we're reading the PNM always! in binary format
|
||||
*/
|
||||
if (fp_rd == stdin)
|
||||
{
|
||||
setmode (STDIN, O_BINARY);
|
||||
}
|
||||
setmode (fileno (stdin), O_BINARY);
|
||||
if (fp_wr == stdout)
|
||||
{
|
||||
setmode (STDOUT, O_BINARY);
|
||||
}
|
||||
setmode (fileno (stdout), O_BINARY);
|
||||
#endif
|
||||
|
||||
/* call the conversion program itself */
|
||||
@ -178,15 +143,10 @@ int main(int argc, char *argv[])
|
||||
* usage
|
||||
*/
|
||||
|
||||
void usage()
|
||||
void usage ()
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, " by Willem van Schaik, 1999\n");
|
||||
#ifdef __TURBOC__
|
||||
fprintf (stderr, " for Turbo-C and Borland-C compilers\n");
|
||||
#else
|
||||
fprintf (stderr, " for Linux (and Unix) compilers\n");
|
||||
#endif
|
||||
fprintf (stderr, "Usage: pnm2png [options] <file>.<pnm> [<file>.png]\n");
|
||||
fprintf (stderr, " or: ... | pnm2png [options]\n");
|
||||
fprintf (stderr, "Options:\n");
|
||||
@ -200,31 +160,31 @@ void usage()
|
||||
* pnm2png
|
||||
*/
|
||||
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
BOOL alpha)
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
|
||||
BOOL interlace, BOOL alpha)
|
||||
{
|
||||
png_struct *png_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_byte *png_pixels = NULL;
|
||||
png_byte **row_pointers = NULL;
|
||||
png_byte *pix_ptr = NULL;
|
||||
volatile png_uint_32 row_bytes;
|
||||
volatile png_uint_32 row_bytes;
|
||||
|
||||
char type_token[16];
|
||||
char width_token[16];
|
||||
char height_token[16];
|
||||
char maxval_token[16];
|
||||
volatile int color_type=1;
|
||||
unsigned long ul_width=0, ul_alpha_width=0;
|
||||
unsigned long ul_height=0, ul_alpha_height=0;
|
||||
unsigned long ul_maxval=0;
|
||||
volatile png_uint_32 width=0, height=0;
|
||||
volatile png_uint_32 alpha_width=0, alpha_height=0;
|
||||
volatile int color_type = 1;
|
||||
unsigned long ul_width = 0, ul_alpha_width = 0;
|
||||
unsigned long ul_height = 0, ul_alpha_height = 0;
|
||||
unsigned long ul_maxval = 0;
|
||||
volatile png_uint_32 width = 0, height = 0;
|
||||
volatile png_uint_32 alpha_width = 0, alpha_height = 0;
|
||||
png_uint_32 maxval;
|
||||
volatile int bit_depth = 0;
|
||||
int channels=0;
|
||||
volatile int bit_depth = 0;
|
||||
int channels = 0;
|
||||
int alpha_depth = 0;
|
||||
int alpha_present=0;
|
||||
int alpha_present = 0;
|
||||
int row, col;
|
||||
BOOL raw, alpha_raw = FALSE;
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
@ -235,7 +195,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
|
||||
/* read header of PNM file */
|
||||
|
||||
get_token(pnm_file, type_token);
|
||||
get_token (pnm_file, type_token, sizeof (type_token));
|
||||
if (type_token[0] != 'P')
|
||||
{
|
||||
return FALSE;
|
||||
@ -245,30 +205,31 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
raw = (type_token[1] == '4');
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
get_token(pnm_file, width_token);
|
||||
get_token (pnm_file, width_token, sizeof (width_token));
|
||||
sscanf (width_token, "%lu", &ul_width);
|
||||
width = (png_uint_32) ul_width;
|
||||
get_token(pnm_file, height_token);
|
||||
get_token (pnm_file, height_token, sizeof (height_token));
|
||||
sscanf (height_token, "%lu", &ul_height);
|
||||
height = (png_uint_32) ul_height;
|
||||
bit_depth = 1;
|
||||
packed_bitmap = TRUE;
|
||||
#else
|
||||
fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n");
|
||||
fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and\n");
|
||||
fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||
{
|
||||
raw = (type_token[1] == '5');
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
get_token(pnm_file, width_token);
|
||||
get_token (pnm_file, width_token, sizeof (width_token));
|
||||
sscanf (width_token, "%lu", &ul_width);
|
||||
width = (png_uint_32) ul_width;
|
||||
get_token(pnm_file, height_token);
|
||||
get_token (pnm_file, height_token, sizeof (height_token));
|
||||
sscanf (height_token, "%lu", &ul_height);
|
||||
height = (png_uint_32) ul_height;
|
||||
get_token(pnm_file, maxval_token);
|
||||
get_token (pnm_file, maxval_token, sizeof (maxval_token));
|
||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||
maxval = (png_uint_32) ul_maxval;
|
||||
|
||||
@ -280,20 +241,22 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
bit_depth = 4;
|
||||
else if (maxval <= 255)
|
||||
bit_depth = 8;
|
||||
else /* if (maxval <= 65535) */
|
||||
else if (maxval <= 65535U)
|
||||
bit_depth = 16;
|
||||
else /* maxval > 65535U */
|
||||
return FALSE;
|
||||
}
|
||||
else if ((type_token[1] == '3') || (type_token[1] == '6'))
|
||||
{
|
||||
raw = (type_token[1] == '6');
|
||||
color_type = PNG_COLOR_TYPE_RGB;
|
||||
get_token(pnm_file, width_token);
|
||||
get_token (pnm_file, width_token, sizeof (width_token));
|
||||
sscanf (width_token, "%lu", &ul_width);
|
||||
width = (png_uint_32) ul_width;
|
||||
get_token(pnm_file, height_token);
|
||||
get_token (pnm_file, height_token, sizeof (height_token));
|
||||
sscanf (height_token, "%lu", &ul_height);
|
||||
height = (png_uint_32) ul_height;
|
||||
get_token(pnm_file, maxval_token);
|
||||
get_token (pnm_file, maxval_token, sizeof (maxval_token));
|
||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||
maxval = (png_uint_32) ul_maxval;
|
||||
if (maxval <= 1)
|
||||
@ -304,8 +267,10 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
bit_depth = 4;
|
||||
else if (maxval <= 255)
|
||||
bit_depth = 8;
|
||||
else /* if (maxval <= 65535) */
|
||||
else if (maxval <= 65535U)
|
||||
bit_depth = 16;
|
||||
else /* maxval > 65535U */
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -321,7 +286,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
if (color_type == PNG_COLOR_TYPE_RGB)
|
||||
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
|
||||
get_token(alpha_file, type_token);
|
||||
get_token (alpha_file, type_token, sizeof (type_token));
|
||||
if (type_token[0] != 'P')
|
||||
{
|
||||
return FALSE;
|
||||
@ -329,17 +294,17 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||
{
|
||||
alpha_raw = (type_token[1] == '5');
|
||||
get_token(alpha_file, width_token);
|
||||
get_token (alpha_file, width_token, sizeof (width_token));
|
||||
sscanf (width_token, "%lu", &ul_alpha_width);
|
||||
alpha_width=(png_uint_32) ul_alpha_width;
|
||||
alpha_width = (png_uint_32) ul_alpha_width;
|
||||
if (alpha_width != width)
|
||||
return FALSE;
|
||||
get_token(alpha_file, height_token);
|
||||
get_token (alpha_file, height_token, sizeof (height_token));
|
||||
sscanf (height_token, "%lu", &ul_alpha_height);
|
||||
alpha_height = (png_uint_32) ul_alpha_height;
|
||||
if (alpha_height != height)
|
||||
return FALSE;
|
||||
get_token(alpha_file, maxval_token);
|
||||
get_token (alpha_file, maxval_token, sizeof (maxval_token));
|
||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||
maxval = (png_uint_32) ul_maxval;
|
||||
if (maxval <= 1)
|
||||
@ -350,8 +315,10 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
alpha_depth = 4;
|
||||
else if (maxval <= 255)
|
||||
alpha_depth = 8;
|
||||
else /* if (maxval <= 65535) */
|
||||
else if (maxval <= 65535U)
|
||||
alpha_depth = 16;
|
||||
else /* maxval > 65535U */
|
||||
return FALSE;
|
||||
if (alpha_depth != bit_depth)
|
||||
return FALSE;
|
||||
}
|
||||
@ -379,21 +346,29 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap)
|
||||
{
|
||||
/* row data is as many bytes as can fit width x channels x bit_depth */
|
||||
row_bytes = (width * channels * bit_depth + 7) / 8;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
|
||||
if ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes))
|
||||
{
|
||||
/* too big */
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
}
|
||||
|
||||
if ((row_bytes == 0) ||
|
||||
((size_t) height > (size_t) (-1) / (size_t) row_bytes))
|
||||
{
|
||||
/* too big */
|
||||
return FALSE;
|
||||
}
|
||||
if ((png_pixels = (png_byte *)
|
||||
malloc ((size_t)row_bytes * (size_t)height * sizeof (png_byte))) == NULL)
|
||||
malloc ((size_t) row_bytes * (size_t) height)) == NULL)
|
||||
{
|
||||
/* out of memory */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* read data from PNM file */
|
||||
pix_ptr = png_pixels;
|
||||
@ -404,9 +379,12 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
if (packed_bitmap)
|
||||
{
|
||||
for (i = 0; i < (int) row_bytes; i++)
|
||||
{
|
||||
/* png supports this format natively so no conversion is needed */
|
||||
*pix_ptr++ = get_data (pnm_file, 8);
|
||||
} else
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for (col = 0; col < (int) width; col++)
|
||||
@ -414,10 +392,15 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
{
|
||||
if (raw)
|
||||
{
|
||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bit_depth <= 8)
|
||||
{
|
||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (pnm_file, bit_depth);
|
||||
@ -426,41 +409,46 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
||||
pix_ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (alpha) /* read alpha-channel from pgm file */
|
||||
{
|
||||
if (alpha_raw)
|
||||
{
|
||||
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alpha_depth <= 8)
|
||||
{
|
||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||
}
|
||||
} /* if alpha */
|
||||
} /* if packed_bitmap */
|
||||
}
|
||||
} /* end if alpha */
|
||||
} /* end if packed_bitmap */
|
||||
} /* end for col */
|
||||
} /* end for row */
|
||||
|
||||
/* prepare the standard PNG structures */
|
||||
png_ptr = png_create_write_struct (png_get_libpng_ver(NULL), NULL, NULL,
|
||||
NULL);
|
||||
png_ptr = png_create_write_struct (png_get_libpng_ver(NULL),
|
||||
NULL, NULL, NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
info_ptr = png_create_info_struct (png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
png_destroy_write_struct (&png_ptr, NULL);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -472,12 +460,10 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
}
|
||||
#endif
|
||||
|
||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
if (setjmp (png_jmpbuf (png_ptr)))
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -486,21 +472,20 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
|
||||
/* we're going to write more or less the same PNG as the input file */
|
||||
png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type,
|
||||
(!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
(!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* write the file header information */
|
||||
png_write_info (png_ptr, info_ptr);
|
||||
|
||||
/* if needed we will allocate memory for an new array of row-pointers */
|
||||
if (row_pointers == (unsigned char**) NULL)
|
||||
if (row_pointers == NULL)
|
||||
{
|
||||
if ((row_pointers = (png_byte **)
|
||||
malloc (height * sizeof (png_bytep))) == NULL)
|
||||
malloc (height * sizeof (png_byte *))) == NULL)
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -518,62 +503,60 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||
|
||||
if (row_pointers != (unsigned char**) NULL)
|
||||
if (row_pointers != NULL)
|
||||
free (row_pointers);
|
||||
if (png_pixels != (unsigned char*) NULL)
|
||||
if (png_pixels != NULL)
|
||||
free (png_pixels);
|
||||
|
||||
PNGMINUS_UNUSED(raw); /* Quiet a Coverity defect */
|
||||
|
||||
return TRUE;
|
||||
} /* end of pnm2png */
|
||||
|
||||
/*
|
||||
* get_token() - gets the first string after whitespace
|
||||
* get_token - gets the first string after whitespace
|
||||
*/
|
||||
|
||||
void get_token(FILE *pnm_file, char *token)
|
||||
void get_token (FILE *pnm_file, char *token_buf, size_t token_buf_size)
|
||||
{
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
int ret;
|
||||
|
||||
/* remove white-space and comment lines */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
ret = fgetc (pnm_file);
|
||||
if (ret == '#')
|
||||
{
|
||||
/* the rest of this line is a comment */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
ret = fgetc (pnm_file);
|
||||
}
|
||||
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
|
||||
}
|
||||
if (ret == EOF) break;
|
||||
token[i] = (unsigned char) ret;
|
||||
token_buf[i] = (char) ret;
|
||||
}
|
||||
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
|
||||
while ((ret == '\n') || (ret == '\r') || (ret == ' '));
|
||||
|
||||
/* read string */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
ret = fgetc (pnm_file);
|
||||
if (ret == EOF) break;
|
||||
i++;
|
||||
token[i] = (unsigned char) ret;
|
||||
if (++i == token_buf_size - 1) break;
|
||||
token_buf[i] = (char) ret;
|
||||
}
|
||||
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
||||
while ((ret != '\n') && (ret != '\r') && (ret != ' '));
|
||||
|
||||
token[i] = '\0';
|
||||
token_buf[i] = '\0';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_data() - takes first byte and converts into next pixel value,
|
||||
* taking as much bits as defined by bit-depth and
|
||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
||||
* get_data - takes first byte and converts into next pixel value,
|
||||
* taking as much bits as defined by bit-depth and
|
||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
||||
*/
|
||||
|
||||
png_uint_32 get_data (FILE *pnm_file, int depth)
|
||||
@ -605,14 +588,14 @@ png_uint_32 get_data (FILE *pnm_file, int depth)
|
||||
}
|
||||
|
||||
/*
|
||||
* get_value() - takes first (numeric) string and converts into number,
|
||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
||||
* get_value - takes first (numeric) string and converts into number,
|
||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
||||
*/
|
||||
|
||||
png_uint_32 get_value (FILE *pnm_file, int depth)
|
||||
{
|
||||
static png_uint_32 mask = 0;
|
||||
png_byte token[16];
|
||||
char token[16];
|
||||
unsigned long ul_ret_value;
|
||||
png_uint_32 ret_value;
|
||||
int i = 0;
|
||||
@ -621,8 +604,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
||||
for (i = 0; i < depth; i++)
|
||||
mask = (mask << 1) | 0x01;
|
||||
|
||||
get_token (pnm_file, (char *) token);
|
||||
sscanf ((const char *) token, "%lu", &ul_ret_value);
|
||||
get_token (pnm_file, token, sizeof (token));
|
||||
sscanf (token, "%lu", &ul_ret_value);
|
||||
ret_value = (png_uint_32) ul_ret_value;
|
||||
|
||||
ret_value &= mask;
|
||||
@ -635,4 +618,3 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
||||
}
|
||||
|
||||
/* end of source */
|
||||
|
||||
|
@ -23,14 +23,12 @@
|
||||
static int
|
||||
png_have_vsx(png_structp png_ptr)
|
||||
{
|
||||
|
||||
const unsigned long auxv = getauxval( AT_HWCAP );
|
||||
unsigned long auxv = getauxval(AT_HWCAP);
|
||||
|
||||
PNG_UNUSED(png_ptr)
|
||||
|
||||
if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX ))
|
||||
if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (!test_only)
|
||||
{
|
||||
printf("PNG_CONST png_uint_16 png_sRGB_table[256] =\n{\n ");
|
||||
printf("const png_uint_16 png_sRGB_table[256] =\n{\n ");
|
||||
for (i=0; i<255; )
|
||||
{
|
||||
do
|
||||
@ -401,7 +401,7 @@ main(int argc, char **argv)
|
||||
printf("%d\n};\n\n", png_sRGB_table[i]);
|
||||
|
||||
|
||||
printf("PNG_CONST png_uint_16 png_sRGB_base[512] =\n{\n ");
|
||||
printf("const png_uint_16 png_sRGB_base[512] =\n{\n ");
|
||||
for (i=0; i<511; )
|
||||
{
|
||||
do
|
||||
@ -413,7 +413,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
printf("%d\n};\n\n", png_sRGB_base[i]);
|
||||
|
||||
printf("PNG_CONST png_byte png_sRGB_delta[512] =\n{\n ");
|
||||
printf("const png_byte png_sRGB_delta[512] =\n{\n ");
|
||||
for (i=0; i<511; )
|
||||
{
|
||||
do
|
||||
|
@ -735,7 +735,7 @@ option_index(struct display *dp, const char *opt, size_t len)
|
||||
static int
|
||||
get_option(struct display *dp, const char *opt, int *value)
|
||||
{
|
||||
const png_byte i = option_index(dp, opt, strlen(opt));
|
||||
png_byte i = option_index(dp, opt, strlen(opt));
|
||||
|
||||
if (dp->entry[i]) /* option was set on command line */
|
||||
{
|
||||
@ -789,7 +789,7 @@ record_opt(struct display *dp, png_byte opt, const char *entry_name)
|
||||
* numerical value.
|
||||
*/
|
||||
{
|
||||
const unsigned int sp = dp->csp; /* stack entry of next searched option */
|
||||
unsigned int sp = dp->csp; /* stack entry of next searched option */
|
||||
|
||||
if (sp >= dp->tsp)
|
||||
{
|
||||
@ -797,7 +797,7 @@ record_opt(struct display *dp, png_byte opt, const char *entry_name)
|
||||
* searched entry or the start of the dp->curr buffer if there is nothing
|
||||
* on the stack yet (sp == 0).
|
||||
*/
|
||||
const int offset = set_opt_string_(dp, sp, opt, entry_name);
|
||||
int offset = set_opt_string_(dp, sp, opt, entry_name);
|
||||
|
||||
if (sp > 0)
|
||||
dp->stack[sp-1].opt_string_end = offset;
|
||||
@ -1222,7 +1222,7 @@ advance_opt(struct display *dp, png_byte opt, int search)
|
||||
}
|
||||
|
||||
static int
|
||||
getallopts_(struct display *dp, const png_byte opt, int *value, int record)
|
||||
getallopts_(struct display *dp, png_byte opt, int *value, int record)
|
||||
/* Like getop but iterate over all the values if the option was set to "all".
|
||||
*/
|
||||
{
|
||||
@ -1259,7 +1259,7 @@ getsearchopts(struct display *dp, const char *opt_str, int *value)
|
||||
/* As above except that if the option was not set try a search */
|
||||
{
|
||||
png_byte istrat;
|
||||
const png_byte opt = option_index(dp, opt_str, strlen(opt_str));
|
||||
png_byte opt = option_index(dp, opt_str, strlen(opt_str));
|
||||
int record = options[opt].search;
|
||||
const char *entry_name;
|
||||
|
||||
@ -2220,7 +2220,7 @@ cp_one_file(struct display *dp, const char *filename, const char *destname)
|
||||
strcpy(dp->best, dp->curr);
|
||||
dp->best_size = dp->write_size;
|
||||
|
||||
if (dp->nsp > 0) /* interating over lists */
|
||||
if (dp->nsp > 0) /* iterating over lists */
|
||||
{
|
||||
char *tmpname, tmpbuf[(sizeof dp->namebuf) + 4];
|
||||
assert(dp->curr[0] == ' ' && dp->tsp > 0);
|
||||
@ -2302,7 +2302,7 @@ cppng(struct display *dp, const char *file, const char *gv dest)
|
||||
}
|
||||
|
||||
int
|
||||
main(const int argc, const char * const * const argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
/* For each file on the command line test it with a range of transforms */
|
||||
int option_end;
|
||||
@ -2379,7 +2379,7 @@ main(const int argc, const char * const * const argv)
|
||||
/* Here on any return, including failures, except user/internal issues
|
||||
*/
|
||||
{
|
||||
const int pass = (d.options & STRICT) ?
|
||||
int pass = (d.options & STRICT) ?
|
||||
RESULT_STRICT(d.results) : RESULT_RELAXED(d.results);
|
||||
|
||||
if (!pass)
|
||||
|
@ -772,7 +772,7 @@ skip_chunk_type(const struct global *global, png_uint_32 type)
|
||||
return 0;
|
||||
|
||||
/* Chunks that specify gamma encoding which should therefore only be
|
||||
* removed the the user insists:
|
||||
* removed if the user insists:
|
||||
*/
|
||||
case png_gAMA: case png_sRGB:
|
||||
if (global->skip >= SKIP_ALL)
|
||||
@ -2514,7 +2514,7 @@ zlib_run(struct zlib *zlib)
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
const unsigned int count = list->count;
|
||||
unsigned int count = list->count;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i<count; ++i)
|
||||
@ -2791,7 +2791,7 @@ process_chunk(struct file *file, png_uint_32 file_crc, png_uint_32 next_length,
|
||||
* to read_chunk.
|
||||
*/
|
||||
{
|
||||
const png_uint_32 type = file->type;
|
||||
png_uint_32 type = file->type;
|
||||
|
||||
if (file->global->verbose > 1)
|
||||
{
|
||||
@ -3152,7 +3152,7 @@ read_chunk(struct file *file)
|
||||
}
|
||||
}
|
||||
|
||||
/* Control gets to here if the the stream seems invalid or damaged in some
|
||||
/* Control gets to here if the stream seems invalid or damaged in some
|
||||
* way. Either there was a problem reading all the expected data (this
|
||||
* chunk's data, its CRC and the length and type of the next chunk) or the
|
||||
* next chunk length/type are invalid. Notice that the cases that end up
|
||||
@ -3710,7 +3710,7 @@ usage(const char *prog)
|
||||
" practice most programs will ignore it.",
|
||||
" bKGD [transform]: This is used by libpng transforms."
|
||||
" --max=<number>:",
|
||||
" Use IDAT chunks sized <number>. If no number is given the the IDAT",
|
||||
" Use IDAT chunks sized <number>. If no number is given the IDAT",
|
||||
" chunks will be the maximum size permitted; 2^31-1 bytes. If the option",
|
||||
" is omitted the original chunk sizes will not be changed. When the",
|
||||
" option is given --strip=unsafe is set automatically. This may be",
|
||||
|
431
example.c
431
example.c
@ -2,19 +2,20 @@
|
||||
#if 0 /* in case someone actually tries to compile this */
|
||||
|
||||
/* example.c - an example of using libpng
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
*
|
||||
* Maintained 2018 Cosmin Truta
|
||||
* Maintained 1998-2016 Glenn Randers-Pehrson
|
||||
* Maintained 1996, 1997 Andreas Dilger)
|
||||
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
* Maintained 1996-1997 Andreas Dilger
|
||||
* Written 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* To the extent possible under law, the authors have waived
|
||||
* all copyright and related or neighboring rights to this file.
|
||||
* This work is published from: United States, Canada.
|
||||
*/
|
||||
|
||||
/* This is an example of how to use libpng to read and write PNG files.
|
||||
* The file libpng-manual.txt is much more verbose then this. If you have not
|
||||
* read it, do so first. This was designed to be a starting point of an
|
||||
* The file libpng-manual.txt is much more verbose then this. If you have
|
||||
* not read it, do so first. This was designed to be a starting point of an
|
||||
* implementation. This is not officially part of libpng, is hereby placed
|
||||
* in the public domain, and therefore does not require a copyright notice.
|
||||
*
|
||||
@ -25,16 +26,17 @@
|
||||
* see also the programs in the contrib directory.
|
||||
*/
|
||||
|
||||
/* The simple, but restricted, approach to reading a PNG file or data stream
|
||||
* just requires two function calls, as in the following complete program.
|
||||
* Writing a file just needs one function call, so long as the data has an
|
||||
/* The simple, but restricted approach to reading a PNG file or data stream
|
||||
* requires just two function calls, as in the following complete program.
|
||||
* Writing a file needs just one function call, so long as the data has an
|
||||
* appropriate layout.
|
||||
*
|
||||
* The following code reads PNG image data from a file and writes it, in a
|
||||
* potentially new format, to a new file. While this code will compile there is
|
||||
* minimal (insufficient) error checking; for a more realistic version look at
|
||||
* contrib/examples/pngtopng.c
|
||||
* potentially new format, to a new file. While this code will compile, there
|
||||
* is minimal (insufficient) error checking. For a more realistic version,
|
||||
* see contrib/examples/pngtopng.c
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -69,28 +71,28 @@ int main(int argc, const char **argv)
|
||||
*/
|
||||
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||
|
||||
/* If enough memory was available read the image in the desired format
|
||||
* then write the result out to the new file. 'background' is not
|
||||
* necessary when reading the image because the alpha channel is
|
||||
/* If enough memory was available, read the image in the desired
|
||||
* format, then write the result out to the new file. 'background' is
|
||||
* not necessary when reading the image, because the alpha channel is
|
||||
* preserved; if it were to be removed, for example if we requested
|
||||
* PNG_FORMAT_RGB, then either a solid background color would have to
|
||||
* be supplied or the output buffer would have to be initialized to the
|
||||
* actual background of the image.
|
||||
* be supplied, or the output buffer would have to be initialized to
|
||||
* the actual background of the image.
|
||||
*
|
||||
* The fourth argument to png_image_finish_read is the 'row_stride' -
|
||||
* this is the number of components allocated for the image in each
|
||||
* row. It has to be at least as big as the value returned by
|
||||
* PNG_IMAGE_ROW_STRIDE, but if you just allocate space for the
|
||||
* default, minimum, size using PNG_IMAGE_SIZE as above you can pass
|
||||
* default, minimum size, using PNG_IMAGE_SIZE as above, you can pass
|
||||
* zero.
|
||||
*
|
||||
* The final argument is a pointer to a buffer for the colormap;
|
||||
* colormaps have exactly the same format as a row of image pixels (so
|
||||
* you choose what format to make the colormap by setting
|
||||
* colormaps have exactly the same format as a row of image pixels
|
||||
* (so you choose what format to make the colormap by setting
|
||||
* image.format). A colormap is only returned if
|
||||
* PNG_FORMAT_FLAG_COLORMAP is also set in image.format, so in this
|
||||
* case NULL is passed as the final argument. If you do want to force
|
||||
* all images into an index/color-mapped format then you can use:
|
||||
* all images into an index/color-mapped format, then you can use:
|
||||
*
|
||||
* PNG_IMAGE_COLORMAP_SIZE(image)
|
||||
*
|
||||
@ -112,17 +114,15 @@ int main(int argc, const char **argv)
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Calling png_image_free is optional unless the simplified API was
|
||||
* not run to completion. In this case if there wasn't enough
|
||||
* memory for 'buffer' we didn't complete the read, so we must free
|
||||
* the image:
|
||||
* not run to completion. In this case, if there wasn't enough
|
||||
* memory for 'buffer', we didn't complete the read, so we must
|
||||
* free the image:
|
||||
*/
|
||||
if (buffer == NULL)
|
||||
png_image_free(&image);
|
||||
|
||||
else
|
||||
free(buffer);
|
||||
}
|
||||
@ -131,65 +131,67 @@ int main(int argc, const char **argv)
|
||||
* textual message in the 'png_image' structure:
|
||||
*/
|
||||
fprintf(stderr, "pngtopng: error: %s\n", image.message);
|
||||
exit (1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "pngtopng: usage: pngtopng input-file output-file\n");
|
||||
exit(1);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* That's it ;-) Of course you probably want to do more with PNG files than
|
||||
* just converting them all to 32-bit RGBA PNG files; you can do that between
|
||||
* the call to png_image_finish_read and png_image_write_to_file. You can also
|
||||
* ask for the image data to be presented in a number of different formats. You
|
||||
* do this by simply changing the 'format' parameter set before allocating the
|
||||
* buffer.
|
||||
* ask for the image data to be presented in a number of different formats.
|
||||
* You do this by simply changing the 'format' parameter set before allocating
|
||||
* the buffer.
|
||||
*
|
||||
* The format parameter consists of five flags that define various aspects of
|
||||
* the image, you can simply add these together to get the format or you can use
|
||||
* one of the predefined macros from png.h (as above):
|
||||
* the image. You can simply add these together to get the format, or you can
|
||||
* use one of the predefined macros from png.h (as above):
|
||||
*
|
||||
* PNG_FORMAT_FLAG_COLOR: if set the image will have three color components per
|
||||
* pixel (red, green and blue), if not set the image will just have one
|
||||
* PNG_FORMAT_FLAG_COLOR: if set, the image will have three color components
|
||||
* per pixel (red, green and blue); if not set, the image will just have one
|
||||
* luminance (grayscale) component.
|
||||
*
|
||||
* PNG_FORMAT_FLAG_ALPHA: if set each pixel in the image will have an additional
|
||||
* alpha value; a linear value that describes the degree the image pixel
|
||||
* covers (overwrites) the contents of the existing pixel on the display.
|
||||
* PNG_FORMAT_FLAG_ALPHA: if set, each pixel in the image will have an
|
||||
* additional alpha value; a linear value that describes the degree the
|
||||
* image pixel covers (overwrites) the contents of the existing pixel on the
|
||||
* display.
|
||||
*
|
||||
* PNG_FORMAT_FLAG_LINEAR: if set the components of each pixel will be returned
|
||||
* as a series of 16-bit linear values, if not set the components will be
|
||||
* returned as a series of 8-bit values encoded according to the 'sRGB'
|
||||
* standard. The 8-bit format is the normal format for images intended for
|
||||
* direct display, because almost all display devices do the inverse of the
|
||||
* sRGB transformation to the data they receive. The 16-bit format is more
|
||||
* common for scientific data and image data that must be further processed;
|
||||
* because it is linear simple math can be done on the component values.
|
||||
* Regardless of the setting of this flag the alpha channel is always linear,
|
||||
* although it will be 8 bits or 16 bits wide as specified by the flag.
|
||||
* PNG_FORMAT_FLAG_LINEAR: if set, the components of each pixel will be
|
||||
* returned as a series of 16-bit linear values; if not set, the components
|
||||
* will be returned as a series of 8-bit values encoded according to the
|
||||
* sRGB standard. The 8-bit format is the normal format for images intended
|
||||
* for direct display, because almost all display devices do the inverse of
|
||||
* the sRGB transformation to the data they receive. The 16-bit format is
|
||||
* more common for scientific data and image data that must be further
|
||||
* processed; because it is linear, simple math can be done on the component
|
||||
* values. Regardless of the setting of this flag, the alpha channel is
|
||||
* always linear, although it will be 8 bits or 16 bits wide as specified by
|
||||
* the flag.
|
||||
*
|
||||
* PNG_FORMAT_FLAG_BGR: if set the components of a color pixel will be returned
|
||||
* in the order blue, then green, then red. If not set the pixel components
|
||||
* are in the order red, then green, then blue.
|
||||
* PNG_FORMAT_FLAG_BGR: if set, the components of a color pixel will be
|
||||
* returned in the order blue, then green, then red. If not set, the pixel
|
||||
* components are in the order red, then green, then blue.
|
||||
*
|
||||
* PNG_FORMAT_FLAG_AFIRST: if set the alpha channel (if present) precedes the
|
||||
* color or grayscale components. If not set the alpha channel follows the
|
||||
* PNG_FORMAT_FLAG_AFIRST: if set, the alpha channel (if present) precedes the
|
||||
* color or grayscale components. If not set, the alpha channel follows the
|
||||
* components.
|
||||
*
|
||||
* You do not have to read directly from a file. You can read from memory or,
|
||||
* on systems that support it, from a <stdio.h> FILE*. This is controlled by
|
||||
* the particular png_image_read_from_ function you call at the start. Likewise
|
||||
* on write you can write to a FILE* if your system supports it. Check the
|
||||
* macro PNG_STDIO_SUPPORTED to see if stdio support has been included in your
|
||||
* libpng build.
|
||||
* the particular png_image_read_from_ function you call at the start.
|
||||
* Likewise, on write, you can write to a FILE* if your system supports it.
|
||||
* Check the macro PNG_STDIO_SUPPORTED to see if stdio support has been
|
||||
* included in your libpng build.
|
||||
*
|
||||
* If you read 16-bit (PNG_FORMAT_FLAG_LINEAR) data you may need to write it in
|
||||
* the 8-bit format for display. You do this by setting the convert_to_8bit
|
||||
* If you read 16-bit (PNG_FORMAT_FLAG_LINEAR) data, you may need to write it
|
||||
* in the 8-bit format for display. You do this by setting the convert_to_8bit
|
||||
* flag to 'true'.
|
||||
*
|
||||
* Don't repeatedly convert between the 8-bit and 16-bit forms. There is
|
||||
* significant data loss when 16-bit data is converted to the 8-bit encoding and
|
||||
* the current libpng implementation of conversion to 16-bit is also
|
||||
* significant data loss when 16-bit data is converted to the 8-bit encoding,
|
||||
* and the current libpng implementation of conversion to 16-bit is also
|
||||
* significantly lossy. The latter will be fixed in the future, but the former
|
||||
* is unavoidable - the 8-bit format just doesn't have enough resolution.
|
||||
*/
|
||||
@ -200,10 +202,10 @@ int main(int argc, const char **argv)
|
||||
* interfaces.
|
||||
*
|
||||
* All these interfaces require that you do your own error handling - your
|
||||
* program must be able to arrange for control to return to your own code any
|
||||
* time libpng encounters a problem. There are several ways to do this, but the
|
||||
* standard way is to use the ANSI-C (C90) <setjmp.h> interface to establish a
|
||||
* return point within your own code. You must do this if you do not use the
|
||||
* program must be able to arrange for control to return to your own code, any
|
||||
* time libpng encounters a problem. There are several ways to do this, but
|
||||
* the standard way is to use the <setjmp.h> interface to establish a return
|
||||
* point within your own code. You must do this if you do not use the
|
||||
* simplified interface (above).
|
||||
*
|
||||
* The first step is to include the header files you need, including the libpng
|
||||
@ -215,7 +217,7 @@ int main(int argc, const char **argv)
|
||||
/* The png_jmpbuf() macro, used in error handling, became available in
|
||||
* libpng version 1.0.6. If you want to be able to run your code with older
|
||||
* versions of libpng, you must define the macro yourself (but only if it
|
||||
* is not already defined by libpng!).
|
||||
* is not already defined by libpng!)
|
||||
*/
|
||||
|
||||
#ifndef png_jmpbuf
|
||||
@ -223,10 +225,10 @@ int main(int argc, const char **argv)
|
||||
#endif
|
||||
|
||||
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
|
||||
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
|
||||
* returns zero if the image is a PNG, and nonzero otherwise.
|
||||
*
|
||||
* The function check_if_png() shown here, but not used, returns nonzero (true)
|
||||
* if the file can be opened and is a PNG, 0 (false) otherwise.
|
||||
* if the file can be opened and is a PNG, and 0 (false) otherwise.
|
||||
*
|
||||
* If this call is successful, and you are going to keep the file open,
|
||||
* you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once
|
||||
@ -239,7 +241,7 @@ int main(int argc, const char **argv)
|
||||
*
|
||||
* Many applications already read the first 2 or 4 bytes from the start
|
||||
* of the image to determine the file type, so it would be easiest just
|
||||
* to pass the bytes to png_sig_cmp() or even skip that if you know
|
||||
* to pass the bytes to png_sig_cmp(), or even skip that if you know
|
||||
* you have a PNG file, and call png_set_sig_bytes().
|
||||
*/
|
||||
#define PNG_BYTES_TO_CHECK 4
|
||||
@ -251,13 +253,13 @@ int check_if_png(char *file_name, FILE **fp)
|
||||
if ((*fp = fopen(file_name, "rb")) == NULL)
|
||||
return 0;
|
||||
|
||||
/* Read in some of the signature bytes */
|
||||
/* Read in some of the signature bytes. */
|
||||
if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)
|
||||
return 0;
|
||||
|
||||
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
|
||||
Return nonzero (true) if they match */
|
||||
|
||||
* Return nonzero (true) if they match.
|
||||
*/
|
||||
return(!png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK));
|
||||
}
|
||||
|
||||
@ -268,7 +270,7 @@ int check_if_png(char *file_name, FILE **fp)
|
||||
* some or all of the magic bytes read - see comments above).
|
||||
*/
|
||||
#ifdef open_file /* prototype 1 */
|
||||
void read_png(char *file_name) /* We need to open the file */
|
||||
void read_png(char *file_name) /* We need to open the file */
|
||||
{
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
@ -281,7 +283,7 @@ void read_png(char *file_name) /* We need to open the file */
|
||||
return (ERROR);
|
||||
|
||||
#else no_open_file /* prototype 2 */
|
||||
void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
{
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
@ -293,7 +295,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
* functions. If you want to use the default stderr and longjump method,
|
||||
* you can supply NULL for the last three parameters. We also supply the
|
||||
* the compiler header file version, so that we know if the application
|
||||
* was compiled with a compatible version of the library. REQUIRED
|
||||
* was compiled with a compatible version of the library. REQUIRED.
|
||||
*/
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||
@ -317,35 +319,33 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
* the normal method of doing things with libpng). REQUIRED unless you
|
||||
* set up your own error handlers in the png_create_read_struct() earlier.
|
||||
*/
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
/* Free all of the memory associated with the png_ptr and info_ptr */
|
||||
/* Free all of the memory associated with the png_ptr and info_ptr. */
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
fclose(fp);
|
||||
/* If we get here, we had a problem reading the file */
|
||||
/* If we get here, we had a problem reading the file. */
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* One of the following I/O initialization methods is REQUIRED */
|
||||
/* One of the following I/O initialization methods is REQUIRED. */
|
||||
#ifdef streams /* PNG file I/O method 1 */
|
||||
/* Set up the input control if you are using standard C streams */
|
||||
/* Set up the input control if you are using standard C streams. */
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
#else no_streams /* PNG file I/O method 2 */
|
||||
/* If you are using replacement read functions, instead of calling
|
||||
* png_init_io() here you would call:
|
||||
* png_init_io(), you would call:
|
||||
*/
|
||||
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
|
||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||
/* where user_io_ptr is a structure you want available to the callbacks. */
|
||||
#endif no_streams /* Use only one I/O method! */
|
||||
|
||||
/* If we have already read some of the signature */
|
||||
png_set_sig_bytes(png_ptr, sig_read);
|
||||
|
||||
#ifdef hilevel
|
||||
/*
|
||||
* If you have enough memory to read in the entire image at once,
|
||||
/* If you have enough memory to read in the entire image at once,
|
||||
* and you need to specify only transforms that can be controlled
|
||||
* with one of the PNG_TRANSFORM_* bits (this presently excludes
|
||||
* quantizing, filling, setting background, and doing gamma
|
||||
@ -355,10 +355,10 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
png_read_png(png_ptr, info_ptr, png_transforms, NULL);
|
||||
|
||||
#else
|
||||
/* OK, you're doing it the hard way, with the lower-level functions */
|
||||
/* OK, you're doing it the hard way, with the lower-level functions. */
|
||||
|
||||
/* The call to png_read_info() gives us all of the information from the
|
||||
* PNG file before the first IDAT (image data chunk). REQUIRED
|
||||
* PNG file before the first IDAT (image data chunk). REQUIRED.
|
||||
*/
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
@ -386,20 +386,21 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
*/
|
||||
png_set_strip_alpha(png_ptr);
|
||||
|
||||
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
|
||||
/* Extract multiple pixels with bit depths of 1, 2 or 4 from a single
|
||||
* byte into separate bytes (useful for paletted and grayscale images).
|
||||
*/
|
||||
png_set_packing(png_ptr);
|
||||
|
||||
/* Change the order of packed pixels to least significant bit first
|
||||
* (not useful if you are using png_set_packing). */
|
||||
* (not useful if you are using png_set_packing).
|
||||
*/
|
||||
png_set_packswap(png_ptr);
|
||||
|
||||
/* Expand paletted colors into true RGB triplets */
|
||||
/* Expand paletted colors into true RGB triplets. */
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_palette_to_rgb(png_ptr);
|
||||
|
||||
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
|
||||
/* Expand grayscale images to the full 8 bits from 1, 2 or 4 bits/pixel. */
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
||||
png_set_expand_gray_1_2_4_to_8(png_ptr);
|
||||
|
||||
@ -410,12 +411,11 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
png_set_tRNS_to_alpha(png_ptr);
|
||||
|
||||
/* Set the background color to draw transparent and alpha images over.
|
||||
* It is possible to set the red, green, and blue components directly
|
||||
* for paletted images instead of supplying a palette index. Note that
|
||||
* It is possible to set the red, green and blue components directly
|
||||
* for paletted images, instead of supplying a palette index. Note that,
|
||||
* even if the PNG file supplies a background, you are not required to
|
||||
* use it - you should use the (solid) application background if it has one.
|
||||
*/
|
||||
|
||||
png_color_16 my_background, *image_background;
|
||||
|
||||
if (png_get_bKGD(png_ptr, info_ptr, &image_background) != 0)
|
||||
@ -425,32 +425,29 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
png_set_background(png_ptr, &my_background,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
||||
|
||||
/* Some suggestions as to how to get a screen gamma value
|
||||
/* Some suggestions as to how to get a screen gamma value.
|
||||
*
|
||||
* Note that screen gamma is the display_exponent, which includes
|
||||
* the CRT_exponent and any correction for viewing conditions
|
||||
* the CRT_exponent and any correction for viewing conditions.
|
||||
*/
|
||||
if (/* We have a user-defined screen gamma value */)
|
||||
{
|
||||
screen_gamma = user-defined screen_gamma;
|
||||
}
|
||||
/* This is one way that applications share the same screen gamma value */
|
||||
/* This is one way that applications share the same screen gamma value. */
|
||||
else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL)
|
||||
{
|
||||
screen_gamma = atof(gamma_str);
|
||||
}
|
||||
/* If we don't have another value */
|
||||
else
|
||||
{
|
||||
screen_gamma = PNG_DEFAULT_sRGB; /* A good guess for a PC monitor
|
||||
in a dimly lit room */
|
||||
screen_gamma = PNG_GAMMA_MAC_18 or 1.0; /* Good guesses for Mac systems */
|
||||
screen_gamma = PNG_DEFAULT_sRGB; /* A good guess for a PC monitor
|
||||
in a dimly lit room */
|
||||
screen_gamma = PNG_GAMMA_MAC_18 or 1.0; /* Good guesses for Mac
|
||||
systems */
|
||||
}
|
||||
|
||||
/* Tell libpng to handle the gamma conversion for you. The final call
|
||||
* is a good guess for PC generated images, but it should be configurable
|
||||
* by the user at run time by the user. It is strongly suggested that
|
||||
* your application support gamma correction.
|
||||
* by the user at run time. Gamma correction support in your application
|
||||
* is strongly recommended.
|
||||
*/
|
||||
|
||||
int intent;
|
||||
@ -467,7 +464,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
/* Quantize RGB files down to 8-bit palette or reduce palettes
|
||||
/* Quantize RGB files down to 8-bit palette, or reduce palettes
|
||||
* to the number of colors available on your screen.
|
||||
*/
|
||||
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
@ -475,29 +472,26 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
int num_palette;
|
||||
png_colorp palette;
|
||||
|
||||
/* This reduces the image to the application supplied palette */
|
||||
/* This reduces the image to the application-supplied palette. */
|
||||
if (/* We have our own palette */)
|
||||
{
|
||||
/* An array of colors to which the image should be quantized */
|
||||
/* An array of colors to which the image should be quantized. */
|
||||
png_color std_color_cube[MAX_SCREEN_COLORS];
|
||||
|
||||
png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
|
||||
MAX_SCREEN_COLORS, NULL, 0);
|
||||
}
|
||||
/* This reduces the image to the palette supplied in the file */
|
||||
/* This reduces the image to the palette supplied in the file. */
|
||||
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) != 0)
|
||||
{
|
||||
png_uint_16p histogram = NULL;
|
||||
|
||||
png_get_hIST(png_ptr, info_ptr, &histogram);
|
||||
|
||||
png_set_quantize(png_ptr, palette, num_palette,
|
||||
max_screen_colors, histogram, 0);
|
||||
}
|
||||
}
|
||||
#endif /* READ_QUANTIZE */
|
||||
|
||||
/* Invert monochrome files to have 0 as white and 1 as black */
|
||||
/* Invert monochrome files to have 0 as white and 1 as black. */
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
/* If you want to shift the pixel values from the range [0,255] or
|
||||
@ -507,22 +501,21 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT) != 0)
|
||||
{
|
||||
png_color_8p sig_bit_p;
|
||||
|
||||
png_get_sBIT(png_ptr, info_ptr, &sig_bit_p);
|
||||
png_set_shift(png_ptr, sig_bit_p);
|
||||
}
|
||||
|
||||
/* Flip the RGB pixels to BGR (or RGBA to BGRA) */
|
||||
/* Flip the RGB pixels to BGR (or RGBA to BGRA). */
|
||||
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
png_set_bgr(png_ptr);
|
||||
|
||||
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
|
||||
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR). */
|
||||
png_set_swap_alpha(png_ptr);
|
||||
|
||||
/* Swap bytes of 16-bit files to least significant byte first */
|
||||
/* Swap bytes of 16-bit files to least significant byte first. */
|
||||
png_set_swap(png_ptr);
|
||||
|
||||
/* Add filler (or alpha) byte (before/after each RGB triplet) */
|
||||
/* Add filler (or alpha) byte (before/after each RGB triplet). */
|
||||
png_set_filler(png_ptr, 0xffff, PNG_FILLER_AFTER);
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
@ -535,40 +528,31 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
number_passes = 1;
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
|
||||
/* Optional call to gamma correct and add the background to the palette
|
||||
* and update info structure. REQUIRED if you are expecting libpng to
|
||||
* update the palette for you (ie you selected such a transform above).
|
||||
* update the palette for you (i.e. you selected such a transform above).
|
||||
*/
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
/* Allocate the memory to hold the image using the fields of info_ptr. */
|
||||
|
||||
/* The easiest way to read the image: */
|
||||
png_bytep row_pointers[height];
|
||||
|
||||
/* Clear the pointer array */
|
||||
for (row = 0; row < height; row++)
|
||||
row_pointers[row] = NULL;
|
||||
|
||||
row_pointers[row] = NULL; /* Clear the pointer array */
|
||||
for (row = 0; row < height; row++)
|
||||
row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
|
||||
info_ptr));
|
||||
|
||||
/* Now it's time to read the image. One of these methods is REQUIRED */
|
||||
/* Now it's time to read the image. One of these methods is REQUIRED. */
|
||||
#ifdef entire /* Read the entire image in one go */
|
||||
png_read_image(png_ptr, row_pointers);
|
||||
|
||||
#else no_entire /* Read the image one or more scanlines at a time */
|
||||
/* The other way to read images - deal with interlacing: */
|
||||
|
||||
for (pass = 0; pass < number_passes; pass++)
|
||||
{
|
||||
#ifdef single /* Read the image a single row at a time */
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
png_read_rows(png_ptr, &row_pointers[y], NULL, 1);
|
||||
}
|
||||
|
||||
#else no_single /* Read the image several rows at a time */
|
||||
for (y = 0; y < height; y += number_of_rows)
|
||||
@ -582,24 +566,24 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
#endif no_sparkle /* Use only one of these two methods */
|
||||
}
|
||||
|
||||
/* If you want to display the image after every pass, do so here */
|
||||
/* If you want to display the image after every pass, do so here. */
|
||||
#endif no_single /* Use only one of these two methods */
|
||||
}
|
||||
#endif no_entire /* Use only one of these two methods */
|
||||
|
||||
/* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||
/* Read rest of file, and get additional chunks in info_ptr. REQUIRED. */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
#endif hilevel
|
||||
|
||||
/* At this point you have read the entire image */
|
||||
/* At this point you have read the entire image. */
|
||||
|
||||
/* Clean up after the read, and free any memory allocated - REQUIRED */
|
||||
/* Clean up after the read, and free any memory allocated. REQUIRED. */
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
|
||||
/* Close the file */
|
||||
/* Close the file. */
|
||||
fclose(fp);
|
||||
|
||||
/* That's it */
|
||||
/* That's it! */
|
||||
return (OK);
|
||||
}
|
||||
|
||||
@ -611,34 +595,30 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
* functions. If you want to use the default stderr and longjump method,
|
||||
* you can supply NULL for the last three parameters. We also check that
|
||||
* the library version is compatible in case we are using dynamically
|
||||
* the library version is compatible, in case we are using dynamically
|
||||
* linked libraries.
|
||||
*/
|
||||
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||
|
||||
if (*png_ptr == NULL)
|
||||
{
|
||||
*info_ptr = NULL;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
*info_ptr = png_create_info_struct(png_ptr);
|
||||
|
||||
if (*info_ptr == NULL)
|
||||
{
|
||||
png_destroy_read_struct(png_ptr, info_ptr, NULL);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if (setjmp(png_jmpbuf((*png_ptr))))
|
||||
{
|
||||
png_destroy_read_struct(png_ptr, info_ptr, NULL);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* This one's new. You will need to provide all three
|
||||
* function callbacks, even if you aren't using them all.
|
||||
/* You will need to provide all three function callbacks,
|
||||
* even if you aren't using all of them.
|
||||
* If you aren't using all functions, you can specify NULL
|
||||
* parameters. Even when all three functions are NULL,
|
||||
* you need to call png_set_progressive_read_fn().
|
||||
@ -651,7 +631,6 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
*/
|
||||
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
|
||||
info_callback, row_callback, end_callback);
|
||||
|
||||
return (OK);
|
||||
}
|
||||
|
||||
@ -661,18 +640,18 @@ process_data(png_structp *png_ptr, png_infop *info_ptr,
|
||||
{
|
||||
if (setjmp(png_jmpbuf((*png_ptr))))
|
||||
{
|
||||
/* Free the png_ptr and info_ptr memory on error */
|
||||
/* Free the png_ptr and info_ptr memory on error. */
|
||||
png_destroy_read_struct(png_ptr, info_ptr, NULL);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* This one's new also. Simply give it chunks of data as
|
||||
* they arrive from the data stream (in order, of course).
|
||||
/* Give chunks of data as they arrive from the data stream
|
||||
* (in order, of course).
|
||||
* On segmented machines, don't give it any more than 64K.
|
||||
* The library seems to run fine with sizes of 4K, although
|
||||
* you can give it much less if necessary (I assume you can
|
||||
* you can give it much less if necessary. (I assume you can
|
||||
* give it chunks of 1 byte, but I haven't tried with less
|
||||
* than 256 bytes yet). When this function returns, you may
|
||||
* than 256 bytes yet.) When this function returns, you may
|
||||
* want to display any rows that were generated in the row
|
||||
* callback, if you aren't already displaying them there.
|
||||
*/
|
||||
@ -694,8 +673,7 @@ info_callback(png_structp png_ptr, png_infop info)
|
||||
row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
png_uint_32 row_num, int pass)
|
||||
{
|
||||
/*
|
||||
* This function is called for every row in the image. If the
|
||||
/* This function is called for every row in the image. If the
|
||||
* image is interlaced, and you turned on the interlace handler,
|
||||
* this function will be called for every row in every pass.
|
||||
*
|
||||
@ -706,25 +684,22 @@ row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
* The new row data pointer "new_row" may be NULL, indicating there is
|
||||
* no new data to be replaced (in cases of interlace loading).
|
||||
*
|
||||
* If new_row is not NULL then you need to call
|
||||
* png_progressive_combine_row() to replace the corresponding row as
|
||||
* If new_row is not NULL, then you need to call
|
||||
* png_progressive_combine_row(), to replace the corresponding row as
|
||||
* shown below:
|
||||
*/
|
||||
|
||||
/* Get pointer to corresponding row in our
|
||||
* PNG read buffer.
|
||||
*/
|
||||
/* Get pointer to corresponding row in our PNG read buffer. */
|
||||
png_bytep old_row = ((png_bytep *)our_data)[row_num];
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* If both rows are allocated then copy the new row
|
||||
/* If both rows are allocated, then copy the new row
|
||||
* data to the corresponding row data.
|
||||
*/
|
||||
if ((old_row != NULL) && (new_row != NULL))
|
||||
png_progressive_combine_row(png_ptr, old_row, new_row);
|
||||
if (old_row != NULL && new_row != NULL)
|
||||
png_progressive_combine_row(png_ptr, old_row, new_row);
|
||||
|
||||
/*
|
||||
* The rows and passes are called in order, so you don't really
|
||||
/* The rows and passes are called in order, so you don't really
|
||||
* need the row_num and pass, but I'm supplying them because it
|
||||
* may make your life easier.
|
||||
*
|
||||
@ -735,7 +710,6 @@ row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
* (it just does the memcpy for you) if it will make the code
|
||||
* easier. Thus, you can just do this for all cases:
|
||||
*/
|
||||
|
||||
png_progressive_combine_row(png_ptr, old_row, new_row);
|
||||
|
||||
/* where old_row is what was displayed for previous rows. Note
|
||||
@ -782,14 +756,13 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
*/
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||
|
||||
if (png_ptr == NULL)
|
||||
{
|
||||
fclose(fp);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* Allocate/initialize the image information data. REQUIRED */
|
||||
/* Allocate/initialize the image information data. REQUIRED. */
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
{
|
||||
@ -798,30 +771,30 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* Set error handling. REQUIRED if you aren't supplying your own
|
||||
/* Set up error handling. REQUIRED if you aren't supplying your own
|
||||
* error handling functions in the png_create_write_struct() call.
|
||||
*/
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
/* If we get here, we had a problem writing the file */
|
||||
/* If we get here, we had a problem writing the file. */
|
||||
fclose(fp);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
/* One of the following I/O initialization functions is REQUIRED */
|
||||
/* One of the following I/O initialization functions is REQUIRED. */
|
||||
|
||||
#ifdef streams /* I/O initialization method 1 */
|
||||
/* Set up the output control if you are using standard C streams */
|
||||
/* Set up the output control if you are using standard C streams. */
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
#else no_streams /* I/O initialization method 2 */
|
||||
/* If you are using replacement write functions, instead of calling
|
||||
* png_init_io() here you would call
|
||||
* png_init_io(), you would call:
|
||||
*/
|
||||
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
|
||||
user_IO_flush_function);
|
||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||
/* where user_io_ptr is a structure you want available to the callbacks. */
|
||||
#endif no_streams /* Only use one initialization method */
|
||||
|
||||
#ifdef hilevel
|
||||
@ -832,30 +805,32 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
png_write_png(png_ptr, info_ptr, png_transforms, NULL);
|
||||
|
||||
#else
|
||||
/* This is the hard way */
|
||||
/* This is the hard way. */
|
||||
|
||||
/* Set the image information here. Width and height are up to 2^31,
|
||||
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||
* bit_depth is one of 1, 2, 4, 8 or 16, but valid values also depend on
|
||||
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
|
||||
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
|
||||
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
||||
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
|
||||
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
|
||||
* REQUIRED.
|
||||
*/
|
||||
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,
|
||||
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
|
||||
PNG_COLOR_TYPE_???, PNG_INTERLACE_????,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* Set the palette if there is one. REQUIRED for indexed-color images */
|
||||
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
|
||||
* (sizeof (png_color)));
|
||||
/* Set the palette if there is one. REQUIRED for indexed-color images. */
|
||||
palette = (png_colorp)png_malloc(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)));
|
||||
/* ... Set palette colors ... */
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
|
||||
/* You must not free palette here, because png_set_PLTE only makes a link to
|
||||
* the palette that you malloced. Wait until you are about to destroy
|
||||
/* You must not free palette here, because png_set_PLTE only makes a link
|
||||
* to the palette that you allocated. Wait until you are about to destroy
|
||||
* the png structure.
|
||||
*/
|
||||
|
||||
/* Optional significant bit (sBIT) chunk */
|
||||
/* Optional significant bit (sBIT) chunk. */
|
||||
png_color_8 sig_bit;
|
||||
|
||||
/* If we are dealing with a grayscale image then */
|
||||
@ -871,18 +846,17 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
|
||||
png_set_sBIT(png_ptr, info_ptr, &sig_bit);
|
||||
|
||||
|
||||
/* Optional gamma chunk is strongly suggested if you have any guess
|
||||
* as to the correct gamma of the image.
|
||||
*/
|
||||
png_set_gAMA(png_ptr, info_ptr, gamma);
|
||||
|
||||
/* Optionally write comments into the image */
|
||||
/* Optionally write comments into the image. */
|
||||
{
|
||||
png_text text_ptr[3];
|
||||
|
||||
char key0[]="Title";
|
||||
char text0[]="Mona Lisa";
|
||||
char key0[] = "Title";
|
||||
char text0[] = "Mona Lisa";
|
||||
text_ptr[0].key = key0;
|
||||
text_ptr[0].text = text0;
|
||||
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
@ -890,8 +864,8 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
text_ptr[0].lang = NULL;
|
||||
text_ptr[0].lang_key = NULL;
|
||||
|
||||
char key1[]="Author";
|
||||
char text1[]="Leonardo DaVinci";
|
||||
char key1[] = "Author";
|
||||
char text1[] = "Leonardo DaVinci";
|
||||
text_ptr[1].key = key1;
|
||||
text_ptr[1].text = text1;
|
||||
text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
@ -899,8 +873,8 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
text_ptr[1].lang = NULL;
|
||||
text_ptr[1].lang_key = NULL;
|
||||
|
||||
char key2[]="Description";
|
||||
char text2[]="<long text>";
|
||||
char key2[] = "Description";
|
||||
char text2[] = "<long text>";
|
||||
text_ptr[2].key = key2;
|
||||
text_ptr[2].text = text2;
|
||||
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
@ -911,14 +885,14 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
png_set_text(write_ptr, write_info_ptr, text_ptr, 3);
|
||||
}
|
||||
|
||||
/* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */
|
||||
/* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs. */
|
||||
|
||||
/* Note that if sRGB is present the gAMA and cHRM chunks must be ignored
|
||||
/* Note that if sRGB is present, the gAMA and cHRM chunks must be ignored
|
||||
* on read and, if your application chooses to write them, they must
|
||||
* be written in accordance with the sRGB profile
|
||||
* be written in accordance with the sRGB profile.
|
||||
*/
|
||||
|
||||
/* Write the file header information. REQUIRED */
|
||||
/* Write the file header information. REQUIRED. */
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
/* If you want, you can write the info in two steps, in case you need to
|
||||
@ -942,7 +916,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* all optional. Only call them if you want them.
|
||||
*/
|
||||
|
||||
/* Invert monochrome pixels */
|
||||
/* Invert monochrome pixels. */
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
/* Shift the pixels up to a legal bit depth and fill in
|
||||
@ -950,30 +924,29 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
*/
|
||||
png_set_shift(png_ptr, &sig_bit);
|
||||
|
||||
/* Pack pixels into bytes */
|
||||
/* Pack pixels into bytes. */
|
||||
png_set_packing(png_ptr);
|
||||
|
||||
/* Swap location of alpha bytes from ARGB to RGBA */
|
||||
/* Swap location of alpha bytes from ARGB to RGBA. */
|
||||
png_set_swap_alpha(png_ptr);
|
||||
|
||||
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
|
||||
* RGB (4 channels -> 3 channels). The second parameter is not used.
|
||||
* RGB (4 channels -> 3 channels). The second parameter is not used.
|
||||
*/
|
||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||
|
||||
/* Flip BGR pixels to RGB */
|
||||
/* Flip BGR pixels to RGB. */
|
||||
png_set_bgr(png_ptr);
|
||||
|
||||
/* Swap bytes of 16-bit files to most significant byte first */
|
||||
/* Swap bytes of 16-bit files to most significant byte first. */
|
||||
png_set_swap(png_ptr);
|
||||
|
||||
/* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats */
|
||||
/* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats. */
|
||||
png_set_packswap(png_ptr);
|
||||
|
||||
/* Turn on interlace handling if you are not using png_write_image() */
|
||||
/* Turn on interlace handling if you are not using png_write_image(). */
|
||||
if (interlacing != 0)
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
|
||||
else
|
||||
number_passes = 1;
|
||||
|
||||
@ -983,29 +956,28 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
*/
|
||||
png_uint_32 k, height, width;
|
||||
|
||||
/* In this example, "image" is a one-dimensional array of bytes */
|
||||
/* In this example, "image" is a one-dimensional array of bytes. */
|
||||
|
||||
/* Guard against integer overflow */
|
||||
if (height > PNG_SIZE_MAX/(width*bytes_per_pixel)) {
|
||||
png_error(png_ptr, "Image_data buffer would be too large");
|
||||
}
|
||||
png_byte image[height*width*bytes_per_pixel];
|
||||
/* Guard against integer overflow. */
|
||||
if (height > PNG_SIZE_MAX / (width * bytes_per_pixel))
|
||||
png_error(png_ptr, "Image data buffer would be too large");
|
||||
|
||||
png_byte image[height * width * bytes_per_pixel];
|
||||
png_bytep row_pointers[height];
|
||||
|
||||
if (height > PNG_UINT_32_MAX/(sizeof (png_bytep)))
|
||||
png_error (png_ptr, "Image is too tall to process in memory");
|
||||
if (height > PNG_UINT_32_MAX / (sizeof (png_bytep)))
|
||||
png_error(png_ptr, "Image is too tall to process in memory");
|
||||
|
||||
/* Set up pointers into your "image" byte array */
|
||||
/* Set up pointers into your "image" byte array. */
|
||||
for (k = 0; k < height; k++)
|
||||
row_pointers[k] = image + k*width*bytes_per_pixel;
|
||||
row_pointers[k] = image + k * width * bytes_per_pixel;
|
||||
|
||||
/* One of the following output methods is REQUIRED */
|
||||
/* One of the following output methods is REQUIRED. */
|
||||
|
||||
#ifdef entire /* Write out the entire image data in one call */
|
||||
png_write_image(png_ptr, row_pointers);
|
||||
|
||||
/* The other way to write the image - deal with interlacing */
|
||||
/* The other way to write the image - deal with interlacing. */
|
||||
|
||||
#else no_entire /* Write out the image data by one or more scanlines */
|
||||
|
||||
@ -1017,27 +989,27 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
/* Write a few rows at a time. */
|
||||
png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows);
|
||||
|
||||
/* If you are only writing one row at a time, this works */
|
||||
/* If you are only writing one row at a time, this works. */
|
||||
for (y = 0; y < height; y++)
|
||||
png_write_rows(png_ptr, &row_pointers[y], 1);
|
||||
}
|
||||
#endif no_entire /* Use only one output method */
|
||||
|
||||
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
|
||||
* as well. Shouldn't be necessary in 1.2.0 and up as all the public
|
||||
* chunks are supported and you can use png_set_unknown_chunks() to
|
||||
* as well. Shouldn't be necessary in 1.2.0 and up, as all the public
|
||||
* chunks are supported, and you can use png_set_unknown_chunks() to
|
||||
* register unknown chunks into the info structure to be written out.
|
||||
*/
|
||||
|
||||
/* It is REQUIRED to call this to finish writing the rest of the file */
|
||||
/* It is REQUIRED to call this to finish writing the rest of the file. */
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
#endif hilevel
|
||||
|
||||
/* If you png_malloced a palette, free it here (don't free info_ptr->palette,
|
||||
* as recommended in versions 1.0.5m and earlier of this example; if
|
||||
* libpng mallocs info_ptr->palette, libpng will free it). If you
|
||||
* allocated it with malloc() instead of png_malloc(), use free() instead
|
||||
* of png_free().
|
||||
/* If you png_malloced a palette, free it here.
|
||||
* (Don't free info_ptr->palette, as shown in versions 1.0.5m and earlier of
|
||||
* this example; if libpng mallocs info_ptr->palette, libpng will free it).
|
||||
* If you allocated it with malloc() instead of png_malloc(), use free()
|
||||
* instead of png_free().
|
||||
*/
|
||||
png_free(png_ptr, palette);
|
||||
palette = NULL;
|
||||
@ -1048,19 +1020,20 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
*/
|
||||
png_free(png_ptr, trans);
|
||||
trans = NULL;
|
||||
/* Whenever you use png_free() it is a good idea to set the pointer to
|
||||
|
||||
/* Whenever you use png_free(), it is a good idea to set the pointer to
|
||||
* NULL in case your application inadvertently tries to png_free() it
|
||||
* again. When png_free() sees a NULL it returns without action, thus
|
||||
* avoiding the double-free security problem.
|
||||
* again. When png_free() sees a NULL it returns without action, avoiding
|
||||
* the double-free problem.
|
||||
*/
|
||||
|
||||
/* Clean up after the write, and free any memory allocated */
|
||||
/* Clean up after the write, and free any allocated memory. */
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
|
||||
/* Close the file */
|
||||
/* Close the file. */
|
||||
fclose(fp);
|
||||
|
||||
/* That's it */
|
||||
/* That's it! */
|
||||
return (OK);
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
|
||||
/* filter_sse2_intrinsics.c - SSE2 optimized filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2016-2017 Glenn Randers-Pehrson
|
||||
* Written by Mike Klein and Matt Sarett
|
||||
* Derived from arm/filter_neon_intrinsics.c
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@ -29,39 +28,25 @@
|
||||
*/
|
||||
|
||||
static __m128i load4(const void* p) {
|
||||
return _mm_cvtsi32_si128(*(const int*)p);
|
||||
int tmp;
|
||||
memcpy(&tmp, p, sizeof(tmp));
|
||||
return _mm_cvtsi32_si128(tmp);
|
||||
}
|
||||
|
||||
static void store4(void* p, __m128i v) {
|
||||
*(int*)p = _mm_cvtsi128_si32(v);
|
||||
int tmp = _mm_cvtsi128_si32(v);
|
||||
memcpy(p, &tmp, sizeof(int));
|
||||
}
|
||||
|
||||
static __m128i load3(const void* p) {
|
||||
/* We'll load 2 bytes, then 1 byte,
|
||||
* then mask them together, and finally load into SSE.
|
||||
*/
|
||||
const png_uint_16* p01 = (png_const_uint_16p)p;
|
||||
const png_byte* p2 = (const png_byte*)(p01+1);
|
||||
|
||||
png_uint_32 v012 = (png_uint_32)(*p01)
|
||||
| (png_uint_32)(*p2) << 16;
|
||||
return load4(&v012);
|
||||
png_uint_32 tmp = 0;
|
||||
memcpy(&tmp, p, 3);
|
||||
return _mm_cvtsi32_si128(tmp);
|
||||
}
|
||||
|
||||
static void store3(void* p, __m128i v) {
|
||||
/* We'll pull from SSE as a 32-bit int, then write
|
||||
* its bottom two bytes, then its third byte.
|
||||
*/
|
||||
png_uint_32 v012;
|
||||
png_uint_16* p01;
|
||||
png_byte* p2;
|
||||
|
||||
store4(&v012, v);
|
||||
|
||||
p01 = (png_uint_16p)p;
|
||||
p2 = (png_byte*)(p01+1);
|
||||
*p01 = (png_uint_16)v012;
|
||||
*p2 = (png_byte)(v012 >> 16);
|
||||
int tmp = _mm_cvtsi128_si32(v);
|
||||
memcpy(p, &tmp, 3);
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
|
||||
|
@ -1,12 +1,11 @@
|
||||
|
||||
/* intel_init.c - SSE2 optimized filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2016-2017 Glenn Randers-Pehrson
|
||||
* Written by Mike Klein and Matt Sarett, Google, Inc.
|
||||
* Derived from arm/arm_init.c
|
||||
*
|
||||
* Last changed in libpng 1.6.29 [March 16, 2017]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
|
@ -1,7 +1,6 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.6.35 - July 15, 2018
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 2018-2019 Cosmin Truta
|
||||
Copyright (c) 1998-2018 Glenn Randers-Pehrson
|
||||
|
||||
This document is released under the libpng license.
|
||||
@ -10,9 +9,13 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.6.35 - July 15, 2018
|
||||
libpng version 1.6.36, December 2018, through 1.6.37 - April 2019
|
||||
Updated and distributed by Cosmin Truta
|
||||
Copyright (c) 2018-2019 Cosmin Truta
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.6.35 - July 2018
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2017 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2018 Glenn Randers-Pehrson
|
||||
|
||||
libpng 1.0 beta 6 - version 0.96 - May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
@ -44,7 +47,6 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
XIII. Detecting libpng
|
||||
XIV. Source code repository
|
||||
XV. Coding style
|
||||
XVI. Y2K Compliance in libpng
|
||||
|
||||
I. Introduction
|
||||
|
||||
@ -65,7 +67,7 @@ file format in application programs.
|
||||
|
||||
The PNG specification (second edition), November 2003, is available as
|
||||
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
|
||||
<https://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
<https://www.w3.org/TR/2003/REC-PNG-20031110/>.
|
||||
The W3C and ISO documents have identical technical content.
|
||||
|
||||
The PNG-1.2 specification is available at
|
||||
@ -73,9 +75,9 @@ The PNG-1.2 specification is available at
|
||||
It is technically equivalent
|
||||
to the PNG specification (second edition) but has some additional material.
|
||||
|
||||
The PNG-1.0 specification is available as RFC 2083
|
||||
The PNG-1.0 specification is available as RFC 2083 at
|
||||
<https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
|
||||
W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
|
||||
W3C Recommendation at <https://www.w3.org/TR/REC-png-961001>.
|
||||
|
||||
Some additional chunks are described in the special-purpose public chunks
|
||||
documents at <http://www.libpng.org/pub/png/spec/register/>
|
||||
@ -4054,7 +4056,7 @@ Flags containing additional information about the image are held in
|
||||
the 'flags' field of png_image.
|
||||
|
||||
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
|
||||
This indicates the the RGB values of the in-memory bitmap do not
|
||||
This indicates that the RGB values of the in-memory bitmap do not
|
||||
correspond to the red, green and blue end-points defined by sRGB.
|
||||
|
||||
PNG_IMAGE_FLAG_FAST == 0x02
|
||||
@ -4520,7 +4522,7 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
|
||||
having level = 0 will be printed. There aren't any such statements in
|
||||
this version of libpng, but if you insert some they will be printed.
|
||||
|
||||
VII. MNG support
|
||||
VII. MNG support
|
||||
|
||||
The MNG specification (available at http://www.libpng.org/pub/mng) allows
|
||||
certain extensions to PNG for PNG images that are embedded in MNG datastreams.
|
||||
@ -4547,7 +4549,7 @@ or any other MNG chunks; your application must provide its own support for
|
||||
them. You may wish to consider using libmng (available at
|
||||
https://www.libmng.com/) instead.
|
||||
|
||||
VIII. Changes to Libpng from version 0.88
|
||||
VIII. Changes to Libpng from version 0.88
|
||||
|
||||
It should be noted that versions of libpng later than 0.96 are not
|
||||
distributed by the original libpng author, Guy Schalnat, nor by
|
||||
@ -4602,7 +4604,7 @@ application:
|
||||
|
||||
png_uint_32 application_vn = PNG_LIBPNG_VER;
|
||||
|
||||
IX. Changes to Libpng from version 1.0.x to 1.2.x
|
||||
IX. Changes to Libpng from version 1.0.x to 1.2.x
|
||||
|
||||
Support for user memory management was enabled by default. To
|
||||
accomplish this, the functions png_create_read_struct_2(),
|
||||
@ -4699,7 +4701,7 @@ which also expands tRNS to alpha was replaced with
|
||||
png_set_expand_gray_1_2_4_to_8()
|
||||
which does not. It has been deprecated since libpng-1.0.18 and 1.2.9.
|
||||
|
||||
X. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
|
||||
X. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
|
||||
|
||||
Private libpng prototypes and macro definitions were moved from
|
||||
png.h and pngconf.h into a new pngpriv.h header file.
|
||||
@ -4809,7 +4811,7 @@ was renamed to PNG_READ_QUANTIZE_SUPPORTED.
|
||||
|
||||
We removed the trailing '.' from the warning and error messages.
|
||||
|
||||
XI. Changes to Libpng from version 1.4.x to 1.5.x
|
||||
XI. Changes to Libpng from version 1.4.x to 1.5.x
|
||||
|
||||
From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
|
||||
function) incorrectly returned a value of type png_uint_32.
|
||||
@ -4872,7 +4874,7 @@ to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep.
|
||||
There are changes of form in png.h, including new and changed macros to
|
||||
declare parts of the API. Some API functions with arguments that are
|
||||
pointers to data not modified within the function have been corrected to
|
||||
declare these arguments with PNG_CONST.
|
||||
declare these arguments with const.
|
||||
|
||||
Much of the internal use of C macros to control the library build has also
|
||||
changed and some of this is visible in the exported header files, in
|
||||
@ -5067,7 +5069,7 @@ even though the default is to use the macros - this allows applications
|
||||
to choose at app buildtime whether or not to use macros (previously
|
||||
impossible because the functions weren't in the default build.)
|
||||
|
||||
XII. Changes to Libpng from version 1.5.x to 1.6.x
|
||||
XII. Changes to Libpng from version 1.5.x to 1.6.x
|
||||
|
||||
A "simplified API" has been added (see documentation in png.h and a simple
|
||||
example in contrib/examples/pngtopng.c). The new publicly visible API
|
||||
@ -5230,7 +5232,7 @@ attempt to decode the Exif profile; it simply returns a byte array
|
||||
containing the profile to the calling application which must do its own
|
||||
decoding.
|
||||
|
||||
XIII. Detecting libpng
|
||||
XIII. Detecting libpng
|
||||
|
||||
The png_get_io_ptr() function has been present since libpng-0.88, has never
|
||||
changed, and is unaffected by conditional compilation macros. It is the
|
||||
@ -5255,7 +5257,7 @@ or you can browse it with a web browser at
|
||||
https://sourceforge.net/p/libpng/code/ci/libpng16/tree/
|
||||
|
||||
Patches can be sent to png-mng-implement at lists.sourceforge.net or
|
||||
you can upload them to the libpng bug tracker at
|
||||
uploaded to the libpng bug tracker at
|
||||
|
||||
https://libpng.sourceforge.io/
|
||||
|
||||
@ -5405,58 +5407,3 @@ We do not use the TAB character for indentation in the C sources.
|
||||
Lines do not exceed 80 characters.
|
||||
|
||||
Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
XVI. Y2K Compliance in libpng
|
||||
|
||||
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.35 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
|
||||
that will hold years up to 65535. The other, which is deprecated,
|
||||
holds the date in text format, and will hold years up to 9999.
|
||||
|
||||
The integer is
|
||||
"png_uint_16 year" in png_time_struct.
|
||||
|
||||
The string is
|
||||
"char time_buffer[29]" in png_struct. This is no longer used
|
||||
in libpng-1.6.x and will be removed from libpng-1.7.0.
|
||||
|
||||
There are seven time-related functions:
|
||||
|
||||
png_convert_to_rfc_1123_buffer() in png.c
|
||||
(formerly png_convert_to_rfc_1152() in error, and
|
||||
also formerly png_convert_to_rfc_1123())
|
||||
png_convert_from_struct_tm() in pngwrite.c, called
|
||||
in pngwrite.c
|
||||
png_convert_from_time_t() in pngwrite.c
|
||||
png_get_tIME() in pngget.c
|
||||
png_handle_tIME() in pngrutil.c, called in pngread.c
|
||||
png_set_tIME() in pngset.c
|
||||
png_write_tIME() in pngwutil.c, called in pngwrite.c
|
||||
|
||||
All appear to handle dates properly in a Y2K environment. The
|
||||
png_convert_from_time_t() function calls gmtime() to convert from system
|
||||
clock time, which returns (year - 1900), which we properly convert to
|
||||
the full 4-digit year. There is a possibility that applications using
|
||||
libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
|
||||
function, or that they are incorrectly passing only a 2-digit year
|
||||
instead of "year - 1900" into the png_convert_from_struct_tm() function,
|
||||
but this is not under our control. The libpng documentation has always
|
||||
stated that it works with 4-digit years, and the APIs have been
|
||||
documented as such.
|
||||
|
||||
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
|
||||
integer to hold the year, and can hold years as large as 65535.
|
||||
|
||||
zlib, upon which libpng depends, is also Y2K compliant. It contains
|
||||
no date-related code.
|
||||
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
libpng maintainer
|
||||
PNG Development Group
|
||||
|
301
libpng.3
301
libpng.3
@ -1,11 +1,11 @@
|
||||
.TH LIBPNG 3 "July 15, 2018"
|
||||
.TH LIBPNG 3 "April 14, 2019"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
|
||||
.SH SYNOPSIS
|
||||
\fB
|
||||
#include <png.h>\fP
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37
|
||||
|
||||
\fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP
|
||||
.SH SYNOPSIS
|
||||
\fB#include <png.h>\fP
|
||||
|
||||
\fBpng_uint_32 png_access_version_number (void);\fP
|
||||
|
||||
\fBvoid png_benign_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
|
||||
|
||||
@ -35,7 +35,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
|
||||
|
||||
\fBpng_structp png_create_write_struct_2 (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
|
||||
|
||||
\fBvoid png_data_freer (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIfreer\fP\fB, png_uint_32 \fImask)\fP\fB);\fP
|
||||
\fBvoid png_data_freer (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIfreer\fP\fB, png_uint_32 \fImask\fP\fB);\fP
|
||||
|
||||
\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
|
||||
|
||||
@ -233,9 +233,9 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
|
||||
|
||||
\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_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
|
||||
\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, size_t \fIpng_info_struct_size\fP\fB);\fP
|
||||
|
||||
@ -253,9 +253,9 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
|
||||
|
||||
\fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, size_t \fIbuffer_size\fP\fB);\fP
|
||||
|
||||
\fBsize_t png_process_data_pause \fP\fI(png_structp\fP\fB, int \fIsave\fP\fB);\fP
|
||||
\fBsize_t png_process_data_pause (png_structp \fP\fIpng_ptr\fP\fB, int \fIsave\fP\fB);\fP
|
||||
|
||||
\fBpng_uint_32 png_process_data_skip \fI(png_structp\fP\fB);\fP
|
||||
\fBpng_uint_32 png_process_data_skip (png_structp \fP\fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP
|
||||
|
||||
@ -297,7 +297,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
|
||||
|
||||
\fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP
|
||||
|
||||
\fBvoid png_set_check_for_invalid_index(png_structrp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
|
||||
\fBvoid png_set_check_for_invalid_index (png_structrp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
|
||||
|
||||
\fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
|
||||
|
||||
@ -353,7 +353,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
|
||||
|
||||
\fBvoid png_set_eXIf (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fIexif\fP\fB);\fP
|
||||
|
||||
\fBvoid png_set_eXIf_1 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, const png_uint_32 \fP\fInum_exif\fP\fB, png_bytep \fIexif\fP\fB);\fP
|
||||
\fBvoid png_set_eXIf_1 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fInum_exif\fP\fB, png_bytep \fIexif\fP\fB);\fP
|
||||
|
||||
\fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP
|
||||
|
||||
@ -453,7 +453,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
|
||||
|
||||
\fBvoid png_set_text_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP
|
||||
|
||||
\fBvoid \fP\fIpng_set_text_compression_method\fP\fB, (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod)\fP\fB);\fP
|
||||
\fBvoid png_set_text_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP
|
||||
|
||||
\fBvoid png_set_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP
|
||||
|
||||
@ -515,11 +515,11 @@ the Portable Network Graphics (PNG) format image files. It uses the
|
||||
.IR zlib(3)
|
||||
compression library.
|
||||
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.35 - July 15, 2018
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 2018-2019 Cosmin Truta
|
||||
Copyright (c) 1998-2018 Glenn Randers-Pehrson
|
||||
|
||||
This document is released under the libpng license.
|
||||
@ -528,9 +528,13 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.6.35 - July 15, 2018
|
||||
libpng version 1.6.36, December 2018, through 1.6.37 - April 2019
|
||||
Updated and distributed by Cosmin Truta
|
||||
Copyright (c) 2018-2019 Cosmin Truta
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.6.35 - July 2018
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2017 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2018 Glenn Randers-Pehrson
|
||||
|
||||
libpng 1.0 beta 6 - version 0.96 - May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
@ -562,7 +566,6 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
XIII. Detecting libpng
|
||||
XIV. Source code repository
|
||||
XV. Coding style
|
||||
XVI. Y2K Compliance in libpng
|
||||
|
||||
.SH I. Introduction
|
||||
|
||||
@ -583,7 +586,7 @@ file format in application programs.
|
||||
|
||||
The PNG specification (second edition), November 2003, is available as
|
||||
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
|
||||
<https://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
<https://www.w3.org/TR/2003/REC-PNG-20031110/>.
|
||||
The W3C and ISO documents have identical technical content.
|
||||
|
||||
The PNG-1.2 specification is available at
|
||||
@ -591,9 +594,9 @@ The PNG-1.2 specification is available at
|
||||
It is technically equivalent
|
||||
to the PNG specification (second edition) but has some additional material.
|
||||
|
||||
The PNG-1.0 specification is available as RFC 2083
|
||||
The PNG-1.0 specification is available as RFC 2083 at
|
||||
<https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
|
||||
W3C Recommendation <https://www.w3.org/TR/REC-png-961001>.
|
||||
W3C Recommendation at <https://www.w3.org/TR/REC-png-961001>.
|
||||
|
||||
Some additional chunks are described in the special-purpose public chunks
|
||||
documents at <http://www.libpng.org/pub/png/spec/register/>
|
||||
@ -4572,7 +4575,7 @@ Flags containing additional information about the image are held in
|
||||
the 'flags' field of png_image.
|
||||
|
||||
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
|
||||
This indicates the the RGB values of the in-memory bitmap do not
|
||||
This indicates that the RGB values of the in-memory bitmap do not
|
||||
correspond to the red, green and blue end-points defined by sRGB.
|
||||
|
||||
PNG_IMAGE_FLAG_FAST == 0x02
|
||||
@ -5038,7 +5041,7 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
|
||||
having level = 0 will be printed. There aren't any such statements in
|
||||
this version of libpng, but if you insert some they will be printed.
|
||||
|
||||
.SH VII. MNG support
|
||||
.SH VII. MNG support
|
||||
|
||||
The MNG specification (available at http://www.libpng.org/pub/mng) allows
|
||||
certain extensions to PNG for PNG images that are embedded in MNG datastreams.
|
||||
@ -5065,7 +5068,7 @@ or any other MNG chunks; your application must provide its own support for
|
||||
them. You may wish to consider using libmng (available at
|
||||
https://www.libmng.com/) instead.
|
||||
|
||||
.SH VIII. Changes to Libpng from version 0.88
|
||||
.SH VIII. Changes to Libpng from version 0.88
|
||||
|
||||
It should be noted that versions of libpng later than 0.96 are not
|
||||
distributed by the original libpng author, Guy Schalnat, nor by
|
||||
@ -5120,7 +5123,7 @@ application:
|
||||
|
||||
png_uint_32 application_vn = PNG_LIBPNG_VER;
|
||||
|
||||
.SH IX. Changes to Libpng from version 1.0.x to 1.2.x
|
||||
.SH IX. Changes to Libpng from version 1.0.x to 1.2.x
|
||||
|
||||
Support for user memory management was enabled by default. To
|
||||
accomplish this, the functions png_create_read_struct_2(),
|
||||
@ -5217,7 +5220,7 @@ which also expands tRNS to alpha was replaced with
|
||||
png_set_expand_gray_1_2_4_to_8()
|
||||
which does not. It has been deprecated since libpng-1.0.18 and 1.2.9.
|
||||
|
||||
.SH X. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
|
||||
.SH X. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
|
||||
|
||||
Private libpng prototypes and macro definitions were moved from
|
||||
png.h and pngconf.h into a new pngpriv.h header file.
|
||||
@ -5327,7 +5330,7 @@ was renamed to PNG_READ_QUANTIZE_SUPPORTED.
|
||||
|
||||
We removed the trailing '.' from the warning and error messages.
|
||||
|
||||
.SH XI. Changes to Libpng from version 1.4.x to 1.5.x
|
||||
.SH XI. Changes to Libpng from version 1.4.x to 1.5.x
|
||||
|
||||
From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
|
||||
function) incorrectly returned a value of type png_uint_32.
|
||||
@ -5390,7 +5393,7 @@ to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep.
|
||||
There are changes of form in png.h, including new and changed macros to
|
||||
declare parts of the API. Some API functions with arguments that are
|
||||
pointers to data not modified within the function have been corrected to
|
||||
declare these arguments with PNG_CONST.
|
||||
declare these arguments with const.
|
||||
|
||||
Much of the internal use of C macros to control the library build has also
|
||||
changed and some of this is visible in the exported header files, in
|
||||
@ -5585,7 +5588,7 @@ even though the default is to use the macros - this allows applications
|
||||
to choose at app buildtime whether or not to use macros (previously
|
||||
impossible because the functions weren't in the default build.)
|
||||
|
||||
.SH XII. Changes to Libpng from version 1.5.x to 1.6.x
|
||||
.SH XII. Changes to Libpng from version 1.5.x to 1.6.x
|
||||
|
||||
A "simplified API" has been added (see documentation in png.h and a simple
|
||||
example in contrib/examples/pngtopng.c). The new publicly visible API
|
||||
@ -5748,7 +5751,7 @@ attempt to decode the Exif profile; it simply returns a byte array
|
||||
containing the profile to the calling application which must do its own
|
||||
decoding.
|
||||
|
||||
.SH XIII. Detecting libpng
|
||||
.SH XIII. Detecting libpng
|
||||
|
||||
The png_get_io_ptr() function has been present since libpng-0.88, has never
|
||||
changed, and is unaffected by conditional compilation macros. It is the
|
||||
@ -5924,61 +5927,6 @@ Lines do not exceed 80 characters.
|
||||
|
||||
Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
.SH XVI. Y2K Compliance in libpng
|
||||
|
||||
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.35 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
|
||||
that will hold years up to 65535. The other, which is deprecated,
|
||||
holds the date in text format, and will hold years up to 9999.
|
||||
|
||||
The integer is
|
||||
"png_uint_16 year" in png_time_struct.
|
||||
|
||||
The string is
|
||||
"char time_buffer[29]" in png_struct. This is no longer used
|
||||
in libpng-1.6.x and will be removed from libpng-1.7.0.
|
||||
|
||||
There are seven time-related functions:
|
||||
|
||||
png_convert_to_rfc_1123_buffer() in png.c
|
||||
(formerly png_convert_to_rfc_1152() in error, and
|
||||
also formerly png_convert_to_rfc_1123())
|
||||
png_convert_from_struct_tm() in pngwrite.c, called
|
||||
in pngwrite.c
|
||||
png_convert_from_time_t() in pngwrite.c
|
||||
png_get_tIME() in pngget.c
|
||||
png_handle_tIME() in pngrutil.c, called in pngread.c
|
||||
png_set_tIME() in pngset.c
|
||||
png_write_tIME() in pngwutil.c, called in pngwrite.c
|
||||
|
||||
All appear to handle dates properly in a Y2K environment. The
|
||||
png_convert_from_time_t() function calls gmtime() to convert from system
|
||||
clock time, which returns (year - 1900), which we properly convert to
|
||||
the full 4-digit year. There is a possibility that applications using
|
||||
libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
|
||||
function, or that they are incorrectly passing only a 2-digit year
|
||||
instead of "year - 1900" into the png_convert_from_struct_tm() function,
|
||||
but this is not under our control. The libpng documentation has always
|
||||
stated that it works with 4-digit years, and the APIs have been
|
||||
documented as such.
|
||||
|
||||
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
|
||||
integer to hold the year, and can hold years as large as 65535.
|
||||
|
||||
zlib, upon which libpng depends, is also Y2K compliant. It contains
|
||||
no date-related code.
|
||||
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
libpng maintainer
|
||||
PNG Development Group
|
||||
|
||||
.SH NOTE
|
||||
|
||||
Note about libpng version numbers:
|
||||
@ -5989,9 +5937,9 @@ on the library has not always been consistent and straightforward.
|
||||
The following table summarizes matters since version 0.89c, which was
|
||||
the first widely used release:
|
||||
|
||||
source png.h png.h shared-lib
|
||||
version string int version
|
||||
------- ------ ----- ----------
|
||||
source png.h png.h shared-lib
|
||||
version string int version
|
||||
------- ------ ----- ----------
|
||||
0.89c "1.0 beta 3" 0.89 89 1.0.89
|
||||
0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90]
|
||||
0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95]
|
||||
@ -6026,23 +5974,25 @@ the first widely used release:
|
||||
1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
|
||||
1.0.7 1 10007 (still compatible)
|
||||
...
|
||||
1.0.19 10 10019 10.so.0.19[.0]
|
||||
1.0.69 10 10069 10.so.0.69[.0]
|
||||
...
|
||||
1.2.59 13 10259 12.so.0.59[.0]
|
||||
...
|
||||
1.4.20 14 10420 14.so.0.20[.0]
|
||||
...
|
||||
1.5.30 15 10530 15.so.15.30[.0]
|
||||
...
|
||||
1.6.35 16 10635 16.so.16.35[.0]
|
||||
|
||||
Henceforth the source version will match the shared-library minor
|
||||
and patch numbers; the shared-library major version number will be
|
||||
used for changes in backward compatibility, as it is intended. The
|
||||
PNG_PNGLIB_VER macro, which is not used within libpng but is available
|
||||
for applications, is an unsigned integer of the form xyyzz corresponding
|
||||
to the source version x.y.z (leading zeros in y and z). Beta versions
|
||||
were given the previous public release number plus a letter, until
|
||||
version 1.0.6j; from then on they were given the upcoming public
|
||||
release number plus "betaNN" or "rcNN".
|
||||
Henceforth the source version will match the shared-library minor and
|
||||
patch numbers; the shared-library major version number will be used for
|
||||
changes in backward compatibility, as it is intended.
|
||||
The PNG_PNGLIB_VER macro, which is not used within libpng but is
|
||||
available for applications, is an unsigned integer of the form XYYZZ
|
||||
corresponding to the source version X.Y.Z (leading zeros in Y and Z).
|
||||
Beta versions were given the previous public release number plus a
|
||||
letter, until version 1.0.6j; from then on they were given the upcoming
|
||||
public release number plus "betaNN" or "rcNN".
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.IR libpngpf(3) ", " png(5)
|
||||
@ -6079,8 +6029,9 @@ In the case of any inconsistency between the PNG specification
|
||||
and this library, the specification takes precedence.
|
||||
|
||||
.SH AUTHORS
|
||||
This man page: Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
This man page:
|
||||
Initially created by Glenn Randers-Pehrson.
|
||||
Maintained by Cosmin Truta.
|
||||
|
||||
The contributing authors would like to thank all those who helped
|
||||
with testing, bug fixes, and patience. This wouldn't have been
|
||||
@ -6088,158 +6039,14 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.6.35 - July 15, 2018:
|
||||
Libpng:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Maintained by Glenn Randers-Pehrson.
|
||||
Maintained by Cosmin Truta.
|
||||
|
||||
Supported by the PNG development group
|
||||
.br
|
||||
png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
png-mng-implement at lists.sourceforge.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe).
|
||||
|
||||
.SH NOTICES:
|
||||
|
||||
This copy of the libpng notices is provided for your convenience. In case of
|
||||
any discrepancy between this copy and the notices in the file png.h that is
|
||||
included in the libpng distribution, the latter shall prevail.
|
||||
|
||||
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||
|
||||
If you modify libpng you may insert additional notices immediately following
|
||||
this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, and are distributed according to the same
|
||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
added to the list of Contributing Authors:
|
||||
|
||||
Simon-Pierre Cadieux
|
||||
Eric S. Raymond
|
||||
Mans Rullgard
|
||||
Cosmin Truta
|
||||
Gilles Vollant
|
||||
James Yu
|
||||
Mandar Sahastrabuddhe
|
||||
Google Inc.
|
||||
Vadim Barkov
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
There is no warranty against interference with your enjoyment of the
|
||||
library or against infringement. There is no warranty that our
|
||||
efforts or the library will fulfill any of your particular purposes
|
||||
or needs. This library is provided with all faults, and the entire
|
||||
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
|
||||
license as libpng-0.96, with the following individuals added to the list
|
||||
of Contributing Authors:
|
||||
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
|
||||
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
|
||||
libpng-0.88, with the following individuals added to the list of
|
||||
Contributing Authors:
|
||||
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
Sam Bushell
|
||||
Magnus Holmgren
|
||||
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.
|
||||
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
|
||||
Andreas Dilger
|
||||
Dave Martindale
|
||||
Guy Eric Schalnat
|
||||
Paul Schmidt
|
||||
Tim Wegner
|
||||
|
||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||
including, without limitation, the warranties of merchantability and of
|
||||
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||
assume no liability for direct, indirect, incidental, special, exemplary,
|
||||
or consequential damages, which may result from the use of the PNG
|
||||
Reference Library, even if advised of the possibility of such damage.
|
||||
|
||||
Permission is hereby granted to use, copy, modify, and distribute this
|
||||
source code, or portions hereof, for any purpose, without fee, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
|
||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
fee, and encourage the use of this source code as a component to
|
||||
supporting the PNG file format in commercial products. If you use this
|
||||
source code in a product, acknowledgment is not required but would be
|
||||
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:
|
||||
|
||||
printf("%s", png_get_copyright(NULL));
|
||||
|
||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
July 15, 2018
|
||||
|
||||
.\" end of man page
|
||||
|
12
libpngpf.3
12
libpngpf.3
@ -1,7 +1,8 @@
|
||||
.TH LIBPNGPF 3 "July 15, 2018"
|
||||
.TH LIBPNGPF 3 "April 14, 2019"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.35
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37
|
||||
(private functions)
|
||||
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
|
||||
@ -16,7 +17,8 @@ The functions previously listed here are used privately by libpng and are not
|
||||
available for use by applications. They are not "exported" to applications
|
||||
using shared libraries.
|
||||
|
||||
.SH SEE ALSO
|
||||
.SH "SEE ALSO"
|
||||
.BR "png"(5), " libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
|
||||
.SH AUTHOR
|
||||
Glenn Randers-Pehrson
|
||||
|
||||
.SH AUTHORS
|
||||
Cosmin Truta, Glenn Randers-Pehrson
|
||||
|
@ -1,14 +1,15 @@
|
||||
|
||||
/* filter_msa_intrinsics.c - MSA optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
* Written by Mandar Sahastrabuddhe, August 2016.
|
||||
* Last changed in libpng 1.6.25 [September 1, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "../pngpriv.h"
|
||||
|
@ -1,14 +1,15 @@
|
||||
|
||||
/* mips_init.c - MSA optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
* Written by Mandar Sahastrabuddhe, 2016.
|
||||
* Last changed in libpng 1.6.25 [September 1, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
|
||||
* called.
|
||||
*/
|
||||
|
66
png.5
66
png.5
@ -1,47 +1,49 @@
|
||||
.TH PNG 5 "April 1, 2017"
|
||||
.TH PNG 5 "April 14, 2019"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
|
||||
.SH DESCRIPTION
|
||||
PNG (Portable Network Graphics) is an extensible file format for the
|
||||
lossless, portable, well-compressed storage of raster images. PNG provides
|
||||
a patent-free replacement for GIF and can also replace many
|
||||
lossless, portable, well-compressed storage of raster images. PNG
|
||||
provides a patent-free replacement for GIF, and can also replace many
|
||||
common uses of TIFF. Indexed-color, grayscale, and truecolor images are
|
||||
supported, plus an optional alpha channel. Sample depths range from
|
||||
supported, plus an optional alpha channel. Sample depths range from
|
||||
1 to 16 bits.
|
||||
.br
|
||||
|
||||
PNG is designed to work well in online viewing applications, such as the
|
||||
World Wide Web, so it is fully streamable with a progressive display
|
||||
option. PNG is robust, providing both full file integrity checking and
|
||||
fast, simple detection of common transmission errors. Also, PNG can store
|
||||
gamma and chromaticity data for improved color matching on heterogeneous
|
||||
platforms.
|
||||
PNG is designed to work well in online viewing applications, such
|
||||
as the World Wide Web, so it is fully streamable with a progressive
|
||||
display option. PNG is robust, providing both full file integrity
|
||||
checking and fast, simple detection of common transmission errors.
|
||||
Also, PNG can store gamma and chromaticity data for improved color
|
||||
matching on heterogeneous platforms.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR "libpng"(3), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
|
||||
.LP
|
||||
PNG specification (second edition), November 2003:
|
||||
PNG Specification (Second Edition), November 2003:
|
||||
.IP
|
||||
.br
|
||||
<https://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
PNG 1.2 specification, July 1999:
|
||||
https://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
.LP
|
||||
PNG 1.2 Specification, July 1999:
|
||||
.IP
|
||||
.br
|
||||
https://png-mng.sourceforge.io/pub/png/spec/1.2/
|
||||
.LP
|
||||
PNG 1.0 specification, October 1996:
|
||||
PNG 1.0 Specification, October 1996:
|
||||
.IP
|
||||
.br
|
||||
RFC 2083
|
||||
.IP
|
||||
.br
|
||||
https://www.ietf.org/rfc/rfc2083.txt
|
||||
.IP
|
||||
.br
|
||||
or (as a W3C Recommendation) at
|
||||
or W3C Recommendation
|
||||
.br
|
||||
https://www.w3.org/TR/REC-png-961001
|
||||
|
||||
.SH AUTHORS
|
||||
This man page: Glenn Randers-Pehrson
|
||||
This man page: Cosmin Truta, Glenn Randers-Pehrson
|
||||
.LP
|
||||
Portable Network Graphics (PNG) Specification (Second Edition)
|
||||
Information technology - Computer graphics and image processing -
|
||||
@ -53,22 +55,30 @@ Glenn Randers-Pehrson and others (png-list).
|
||||
.LP
|
||||
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
|
||||
Thomas Boutell and others (png-list).
|
||||
.LP
|
||||
|
||||
|
||||
.SH COPYRIGHT NOTICE
|
||||
.SH COPYRIGHT
|
||||
.LP
|
||||
This man page is Copyright (c) 1998-2006 Glenn Randers-Pehrson. See png.h
|
||||
for conditions of use and distribution.
|
||||
This man page is
|
||||
.br
|
||||
Copyright (c) 2018-2019 Cosmin Truta.
|
||||
.br
|
||||
Copyright (c) 1998-2006 Glenn Randers-Pehrson.
|
||||
.br
|
||||
See png.h for conditions of use and distribution.
|
||||
.LP
|
||||
The PNG Specification (Second Edition) is
|
||||
.br
|
||||
Copyright (c) 2003 W3C. (MIT, ERCIM, Keio), All Rights Reserved.
|
||||
.LP
|
||||
The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson.
|
||||
The PNG-1.2 Specification is
|
||||
.br
|
||||
Copyright (c) 1999 Glenn Randers-Pehrson.
|
||||
.br
|
||||
See the specification for conditions of use and distribution.
|
||||
.LP
|
||||
The PNG-1.0 specification is copyright (c) 1996 Massachusetts Institute of
|
||||
Technology. See the specification for conditions of use and distribution.
|
||||
.LP
|
||||
The PNG-1.0 Specification is
|
||||
.br
|
||||
Copyright (c) 1996 Massachusetts Institute of Technology.
|
||||
.br
|
||||
See the specification for conditions of use and distribution.
|
||||
.\" end of man page
|
||||
|
||||
|
53
png.c
53
png.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -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_35 Your_png_h_is_not_version_1_6_35;
|
||||
typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37;
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* The version tests may need to be added to, but the problem warning has
|
||||
@ -736,7 +736,7 @@ png_save_int_32(png_bytep buf, png_int_32 i)
|
||||
int PNGAPI
|
||||
png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
|
||||
{
|
||||
static PNG_CONST char short_months[12][4] =
|
||||
static const char short_months[12][4] =
|
||||
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
|
||||
@ -814,20 +814,14 @@ png_get_copyright(png_const_structrp png_ptr)
|
||||
#ifdef PNG_STRING_COPYRIGHT
|
||||
return PNG_STRING_COPYRIGHT
|
||||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.35 - July 15, 2018" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.37" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2002,2004,2006-2018 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.35 - July 15, 2018\
|
||||
Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1121,7 +1115,7 @@ png_colorspace_set_gamma(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_fixed_point gAMA)
|
||||
{
|
||||
/* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
|
||||
* occur. Since the fixed point representation is asymetrical it is
|
||||
* occur. Since the fixed point representation is asymmetrical it is
|
||||
* possible for 1/gamma to overflow the limit of 21474 and this means the
|
||||
* gamma value must be at least 5/100000 and hence at most 20000.0. For
|
||||
* safety the limits here are a little narrower. The values are 0.00016 to
|
||||
@ -3134,11 +3128,11 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
|
||||
/* The total output count (max) is now 4+precision */
|
||||
|
||||
/* Check for an exponent, if we don't need one we are
|
||||
* done and just need to terminate the string. At
|
||||
* this point exp_b10==(-1) is effectively a flag - it got
|
||||
* to '-1' because of the decrement after outputting
|
||||
* the decimal point above (the exponent required is
|
||||
* *not* -1!)
|
||||
* done and just need to terminate the string. At this
|
||||
* point, exp_b10==(-1) is effectively a flag: it got
|
||||
* to '-1' because of the decrement, after outputting
|
||||
* the decimal point above. (The exponent required is
|
||||
* *not* -1.)
|
||||
*/
|
||||
if (exp_b10 >= (-1) && exp_b10 <= 2)
|
||||
{
|
||||
@ -3976,18 +3970,18 @@ png_gamma_correct(png_structrp png_ptr, unsigned int value,
|
||||
*/
|
||||
static void
|
||||
png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
|
||||
unsigned int shift, png_fixed_point gamma_val)
|
||||
{
|
||||
/* Various values derived from 'shift': */
|
||||
PNG_CONST unsigned int num = 1U << (8U - shift);
|
||||
unsigned int num = 1U << (8U - shift);
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
/* CSE the division and work round wacky GCC warnings (see the comments
|
||||
* in png_gamma_8bit_correct for where these come from.)
|
||||
*/
|
||||
PNG_CONST double fmax = 1./(((png_int_32)1 << (16U - shift))-1);
|
||||
double fmax = 1.0 / (((png_int_32)1 << (16U - shift)) - 1);
|
||||
#endif
|
||||
PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
|
||||
PNG_CONST unsigned int max_by_2 = 1U << (15U-shift);
|
||||
unsigned int max = (1U << (16U - shift)) - 1U;
|
||||
unsigned int max_by_2 = 1U << (15U - shift);
|
||||
unsigned int i;
|
||||
|
||||
png_uint_16pp table = *ptable =
|
||||
@ -4053,10 +4047,10 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
*/
|
||||
static void
|
||||
png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
|
||||
unsigned int shift, png_fixed_point gamma_val)
|
||||
{
|
||||
PNG_CONST unsigned int num = 1U << (8U - shift);
|
||||
PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
|
||||
unsigned int num = 1U << (8U - shift);
|
||||
unsigned int max = (1U << (16U - shift))-1U;
|
||||
unsigned int i;
|
||||
png_uint_32 last;
|
||||
|
||||
@ -4121,7 +4115,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
*/
|
||||
static void
|
||||
png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
|
||||
PNG_CONST png_fixed_point gamma_val)
|
||||
png_fixed_point gamma_val)
|
||||
{
|
||||
unsigned int i;
|
||||
png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
|
||||
@ -4594,8 +4588,7 @@ png_image_free(png_imagep image)
|
||||
if (image != NULL && image->opaque != NULL &&
|
||||
image->opaque->error_buf == NULL)
|
||||
{
|
||||
/* Ignore errors here: */
|
||||
(void)png_safe_execute(image, png_image_free_function, image);
|
||||
png_image_free_function(image);
|
||||
image->opaque = NULL;
|
||||
}
|
||||
}
|
||||
|
309
png.h
309
png.h
@ -1,68 +1,105 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.35, July 15, 2018
|
||||
* libpng version 1.6.37 - April 14, 2019
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license (See LICENSE, below)
|
||||
* This code is released under the libpng license. (See LICENSE, below.)
|
||||
*
|
||||
* 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.35, July 15, 2018:
|
||||
* Glenn Randers-Pehrson.
|
||||
* libpng versions 0.97, January 1998, through 1.6.35, July 2018:
|
||||
* Glenn Randers-Pehrson
|
||||
* libpng versions 1.6.36, December 2018, through 1.6.37, April 2019:
|
||||
* Cosmin Truta
|
||||
* See also "Contributing Authors", below.
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||
* COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
|
||||
* =========================================
|
||||
*
|
||||
* If you modify libpng you may insert additional notices immediately following
|
||||
* this sentence.
|
||||
* PNG Reference Library License version 2
|
||||
* ---------------------------------------
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* * Copyright (c) 1995-2019 The PNG Reference Library Authors.
|
||||
* * Copyright (c) 2018-2019 Cosmin Truta.
|
||||
* * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
|
||||
* * Copyright (c) 1996-1997 Andreas Dilger.
|
||||
* * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
|
||||
* The software is supplied "as is", without warranty of any kind,
|
||||
* express or implied, including, without limitation, the warranties
|
||||
* of merchantability, fitness for a particular purpose, title, and
|
||||
* non-infringement. In no event shall the Copyright owners, or
|
||||
* anyone distributing the software, be liable for any damages or
|
||||
* other liability, whether in contract, tort or otherwise, arising
|
||||
* from, out of, or in connection with the software, or the use or
|
||||
* other dealings in the software, even if advised of the possibility
|
||||
* of such damage.
|
||||
*
|
||||
* Permission is hereby granted to use, copy, modify, and distribute
|
||||
* this software, or portions hereof, for any purpose, without fee,
|
||||
* subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you
|
||||
* use this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated, but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must
|
||||
* not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This Copyright notice may not be removed or altered from any
|
||||
* source or altered source distribution.
|
||||
*
|
||||
*
|
||||
* PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
|
||||
* -----------------------------------------------------------------------
|
||||
*
|
||||
* libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
|
||||
* derived from libpng-1.0.6, and are distributed according to the same
|
||||
* disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
* added to the list of Contributing Authors:
|
||||
*
|
||||
* Simon-Pierre Cadieux
|
||||
* Eric S. Raymond
|
||||
* Mans Rullgard
|
||||
* Cosmin Truta
|
||||
* Gilles Vollant
|
||||
* James Yu
|
||||
* Mandar Sahastrabuddhe
|
||||
* Google Inc.
|
||||
* Vadim Barkov
|
||||
* Simon-Pierre Cadieux
|
||||
* Eric S. Raymond
|
||||
* Mans Rullgard
|
||||
* Cosmin Truta
|
||||
* Gilles Vollant
|
||||
* James Yu
|
||||
* Mandar Sahastrabuddhe
|
||||
* Google Inc.
|
||||
* Vadim Barkov
|
||||
*
|
||||
* and with the following additions to the disclaimer:
|
||||
*
|
||||
* There is no warranty against interference with your enjoyment of the
|
||||
* library or against infringement. There is no warranty that our
|
||||
* efforts or the library will fulfill any of your particular purposes
|
||||
* or needs. This library is provided with all faults, and the entire
|
||||
* risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
* the user.
|
||||
* There is no warranty against interference with your enjoyment of
|
||||
* the library or against infringement. There is no warranty that our
|
||||
* efforts or the library will fulfill any of your particular purposes
|
||||
* or needs. This library is provided with all faults, and the entire
|
||||
* 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
|
||||
* 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
|
||||
* license as libpng-0.96, with the following individuals added to the list
|
||||
* of Contributing Authors:
|
||||
* license as libpng-0.96, with the following individuals added to the
|
||||
* list of Contributing Authors:
|
||||
*
|
||||
* Tom Lane
|
||||
* Glenn Randers-Pehrson
|
||||
* Willem van Schaik
|
||||
* Tom Lane
|
||||
* Glenn Randers-Pehrson
|
||||
* Willem van Schaik
|
||||
*
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||
@ -70,14 +107,14 @@
|
||||
* libpng-0.88, with the following individuals added to the list of
|
||||
* Contributing Authors:
|
||||
*
|
||||
* John Bowler
|
||||
* Kevin Bracey
|
||||
* Sam Bushell
|
||||
* Magnus Holmgren
|
||||
* Greg Roelofs
|
||||
* Tom Tanner
|
||||
* John Bowler
|
||||
* Kevin Bracey
|
||||
* Sam Bushell
|
||||
* Magnus Holmgren
|
||||
* Greg Roelofs
|
||||
* Tom Tanner
|
||||
*
|
||||
* Some files in the "scripts" directory have other copyright owners
|
||||
* 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
|
||||
@ -86,62 +123,49 @@
|
||||
* For the purposes of this copyright and license, "Contributing Authors"
|
||||
* is defined as the following set of individuals:
|
||||
*
|
||||
* Andreas Dilger
|
||||
* Dave Martindale
|
||||
* Guy Eric Schalnat
|
||||
* Paul Schmidt
|
||||
* Tim Wegner
|
||||
* Andreas Dilger
|
||||
* Dave Martindale
|
||||
* Guy Eric Schalnat
|
||||
* Paul Schmidt
|
||||
* Tim Wegner
|
||||
*
|
||||
* The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
* and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||
* including, without limitation, the warranties of merchantability and of
|
||||
* fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||
* assume no liability for direct, indirect, incidental, special, exemplary,
|
||||
* or consequential damages, which may result from the use of the PNG
|
||||
* Reference Library, even if advised of the possibility of such damage.
|
||||
* The PNG Reference Library is supplied "AS IS". The Contributing
|
||||
* Authors and Group 42, Inc. disclaim all warranties, expressed or
|
||||
* implied, including, without limitation, the warranties of
|
||||
* merchantability and of fitness for any purpose. The Contributing
|
||||
* Authors and Group 42, Inc. assume no liability for direct, indirect,
|
||||
* incidental, special, exemplary, or consequential damages, which may
|
||||
* result from the use of the PNG Reference Library, even if advised of
|
||||
* the possibility of such damage.
|
||||
*
|
||||
* Permission is hereby granted to use, copy, modify, and distribute this
|
||||
* source code, or portions hereof, for any purpose, without fee, subject
|
||||
* to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this source code must not be misrepresented.
|
||||
* 1. The origin of this source code must not be misrepresented.
|
||||
*
|
||||
* 2. Altered versions must be plainly marked as such and must not
|
||||
* be misrepresented as being the original source.
|
||||
* 2. Altered versions must be plainly marked as such and must not
|
||||
* be misrepresented as being the original source.
|
||||
*
|
||||
* 3. This Copyright notice may not be removed or altered from any
|
||||
* source or altered source distribution.
|
||||
* 3. This Copyright notice may not be removed or altered from any
|
||||
* source or altered source distribution.
|
||||
*
|
||||
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
* fee, and encourage the use of this source code as a component to
|
||||
* supporting the PNG file format in commercial products. If you use this
|
||||
* source code in a product, acknowledgment is not required but would be
|
||||
* appreciated.
|
||||
* The Contributing Authors and Group 42, Inc. specifically permit,
|
||||
* without fee, and encourage the use of this source code as a component
|
||||
* to supporting the PNG file format in commercial products. If you use
|
||||
* this source code in a product, acknowledgment is not required but would
|
||||
* be appreciated.
|
||||
*
|
||||
* END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
||||
*
|
||||
* TRADEMARK:
|
||||
* TRADEMARK
|
||||
* =========
|
||||
*
|
||||
* The name "libpng" has not been registered by the Copyright owner
|
||||
* The name "libpng" has not been registered by the Copyright owners
|
||||
* 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
|
||||
* the Copyright owners claim "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).
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -207,23 +231,25 @@
|
||||
* 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
|
||||
* 1.0.7 1 10007 (still compatible)
|
||||
* ...
|
||||
* 1.0.19 10 10019 10.so.0.19[.0]
|
||||
* 1.0.69 10 10069 10.so.0.69[.0]
|
||||
* ...
|
||||
* 1.2.59 13 10257 12.so.0.59[.0]
|
||||
* 1.2.59 13 10259 12.so.0.59[.0]
|
||||
* ...
|
||||
* 1.5.30 15 10527 15.so.15.30[.0]
|
||||
* 1.4.20 14 10420 14.so.0.20[.0]
|
||||
* ...
|
||||
* 1.6.35 16 10635 16.so.16.35[.0]
|
||||
* 1.5.30 15 10530 15.so.15.30[.0]
|
||||
* ...
|
||||
* 1.6.37 16 10637 16.so.16.37[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
* used for changes in backward compatibility, as it is intended. The
|
||||
* PNG_LIBPNG_VER macro, which is not used within libpng but is available
|
||||
* for applications, is an unsigned integer of the form xyyzz corresponding
|
||||
* to the source version x.y.z (leading zeros in y and z). Beta versions
|
||||
* were given the previous public release number plus a letter, until
|
||||
* version 1.0.6j; from then on they were given the upcoming public
|
||||
* release number plus "betaNN" or "rcNN".
|
||||
* Henceforth the source version will match the shared-library major and
|
||||
* minor numbers; the shared-library major version number will be used for
|
||||
* changes in backward compatibility, as it is intended.
|
||||
* The PNG_LIBPNG_VER macro, which is not used within libpng but is
|
||||
* available for applications, is an unsigned integer of the form XYYZZ
|
||||
* corresponding to the source version X.Y.Z (leading zeros in Y and Z).
|
||||
* Beta versions were given the previous public release number plus a
|
||||
* letter, until version 1.0.6j; from then on they were given the upcoming
|
||||
* public release number plus "betaNN" or "rcNN".
|
||||
*
|
||||
* Binary incompatibility exists only when applications make direct access
|
||||
* to the info_ptr or png_ptr members through png.h, and the compiled
|
||||
@ -233,65 +259,8 @@
|
||||
* in binary compatibility (e.g., when a new feature is added).
|
||||
*
|
||||
* See libpng.txt or libpng.3 for more information. The PNG specification
|
||||
* is available as a W3C Recommendation and as an ISO Specification,
|
||||
* <https://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* July 15, 2018
|
||||
*
|
||||
* 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.35 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
|
||||
* that will hold years up to 65535. The other, which is deprecated,
|
||||
* holds the date in text format, and will hold years up to 9999.
|
||||
*
|
||||
* The integer is
|
||||
* "png_uint_16 year" in png_time_struct.
|
||||
*
|
||||
* The string is
|
||||
* "char time_buffer[29]" in png_struct. This is no longer used
|
||||
* in libpng-1.6.x and will be removed from libpng-1.7.0.
|
||||
*
|
||||
* There are seven time-related functions:
|
||||
* png.c: png_convert_to_rfc_1123_buffer() in png.c
|
||||
* (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
|
||||
* png_convert_to_rfc_1152() in error prior to libpng-0.98)
|
||||
* png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
|
||||
* png_convert_from_time_t() in pngwrite.c
|
||||
* png_get_tIME() in pngget.c
|
||||
* png_handle_tIME() in pngrutil.c, called in pngread.c
|
||||
* png_set_tIME() in pngset.c
|
||||
* png_write_tIME() in pngwutil.c, called in pngwrite.c
|
||||
*
|
||||
* All handle dates properly in a Y2K environment. The
|
||||
* png_convert_from_time_t() function calls gmtime() to convert from system
|
||||
* clock time, which returns (year - 1900), which we properly convert to
|
||||
* the full 4-digit year. There is a possibility that libpng applications
|
||||
* are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()
|
||||
* function, or that they are incorrectly passing only a 2-digit year
|
||||
* instead of "year - 1900" into the png_convert_from_struct_tm() function,
|
||||
* but this is not under our control. The libpng documentation has always
|
||||
* stated that it works with 4-digit years, and the APIs have been
|
||||
* documented as such.
|
||||
*
|
||||
* The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
|
||||
* integer to hold the year, and can hold years as large as 65535.
|
||||
*
|
||||
* zlib, upon which libpng depends, is also Y2K compliant. It contains
|
||||
* no date-related code.
|
||||
*
|
||||
* Glenn Randers-Pehrson
|
||||
* libpng maintainer
|
||||
* PNG Development Group
|
||||
* is available as a W3C Recommendation and as an ISO/IEC Standard; see
|
||||
* <https://www.w3.org/TR/2003/REC-PNG-20031110/>
|
||||
*/
|
||||
|
||||
#ifndef PNG_H
|
||||
@ -309,8 +278,8 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.35"
|
||||
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.35 - July 15, 2018\n"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.37"
|
||||
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
@ -318,13 +287,12 @@
|
||||
/* 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 35
|
||||
#define PNG_LIBPNG_VER_RELEASE 37
|
||||
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
/* This should be zero for a public release, or non-zero for a
|
||||
* development version. [Deprecated]
|
||||
*/
|
||||
|
||||
#define PNG_LIBPNG_VER_BUILD 02
|
||||
#define PNG_LIBPNG_VER_BUILD 0
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@ -341,15 +309,16 @@
|
||||
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
|
||||
PNG_LIBPNG_BUILD_PRIVATE */
|
||||
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
|
||||
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||
* We must not include leading zeros.
|
||||
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
|
||||
* 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
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that
|
||||
* would be octal. We must not include leading zeros.
|
||||
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here
|
||||
* (only version 1.0.0 was mis-numbered 100 instead of 10000).
|
||||
* From version 1.0.1 it is:
|
||||
* XXYYZZ, where XX=major, YY=minor, ZZ=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10635 /* 1.6.35 */
|
||||
#define PNG_LIBPNG_VER 10637 /* 1.6.37 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
@ -459,7 +428,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_35;
|
||||
typedef char* png_libpng_version_1_6_37;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
@ -2013,12 +1982,12 @@ PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
|
||||
PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_bytep *exif));
|
||||
PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, const png_bytep exif));
|
||||
png_inforp info_ptr, png_bytep exif));
|
||||
|
||||
PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif));
|
||||
PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, const png_uint_32 num_exif, const png_bytep exif));
|
||||
png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
@ -2764,7 +2733,7 @@ typedef struct
|
||||
*
|
||||
* When the simplified API needs to convert between sRGB and linear colorspaces,
|
||||
* the actual sRGB transfer curve defined in the sRGB specification (see the
|
||||
* article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
|
||||
* article at <https://en.wikipedia.org/wiki/SRGB>) is used, not the gamma=1/2.2
|
||||
* approximation used elsewhere in libpng.
|
||||
*
|
||||
* When an alpha channel is present it is expected to denote pixel coverage
|
||||
@ -2967,7 +2936,7 @@ typedef struct
|
||||
* 'flags' field of png_image.
|
||||
*/
|
||||
#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01
|
||||
/* This indicates the the RGB values of the in-memory bitmap do not
|
||||
/* This indicates that the RGB values of the in-memory bitmap do not
|
||||
* correspond to the red, green and blue end-points defined by sRGB.
|
||||
*/
|
||||
|
||||
|
18
pngconf.h
18
pngconf.h
@ -1,11 +1,12 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
/* pngconf.h - machine-configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.35, July 15, 2018
|
||||
* libpng version 1.6.37
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2016,2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -57,14 +58,13 @@
|
||||
|
||||
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||
|
||||
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
|
||||
* PNG_NO_CONST; this is no longer supported except for data declarations which
|
||||
* apparently still cause problems in 2011 on some compilers.
|
||||
/* Prior to 1.6.0, it was possible to turn off 'const' in declarations,
|
||||
* using PNG_NO_CONST. This is no longer supported.
|
||||
*/
|
||||
#define PNG_CONST const /* backward compatibility only */
|
||||
|
||||
/* This controls optimization of the reading of 16-bit and 32-bit values
|
||||
* from PNG files. It can be set on a per-app-file basis - it
|
||||
/* This controls optimization of the reading of 16-bit and 32-bit
|
||||
* values from PNG files. It can be set on a per-app-file basis: it
|
||||
* just changes whether a macro is used when the function is called.
|
||||
* The library builder sets the default; if read functions are not
|
||||
* built into the library the macro implementation is forced on.
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
12
pngerror.c
12
pngerror.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -425,7 +425,7 @@ png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
* if the character is invalid.
|
||||
*/
|
||||
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||
static PNG_CONST char png_digit[16] = {
|
||||
static const char png_digit[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
@ -885,7 +885,7 @@ PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
|
||||
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* An error is always logged here, overwriting anything (typically a warning)
|
||||
@ -920,7 +920,7 @@ png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
void /* PRIVATE */ PNGCBAPI
|
||||
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* A warning is only logged if there is no prior warning or error. */
|
||||
|
6
pngget.c
6
pngget.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
/* pnginfo.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2013,2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
6
pngmem.c
6
pngmem.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2014,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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
16
pngpread.c
16
pngpread.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -972,20 +972,20 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* Start of interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* Offset to next interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
/* Height of interlace block. This is not currently used - if you need
|
||||
* it, uncomment it here and in png.h
|
||||
static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
38
pngpriv.h
38
pngpriv.h
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -174,7 +174,10 @@
|
||||
# else /* !defined __ARM_NEON__ */
|
||||
/* The 'intrinsics' code simply won't compile without this -mfpu=neon:
|
||||
*/
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 2
|
||||
# if !defined(__aarch64__)
|
||||
/* The assembler code currently does not work on ARM64 */
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 2
|
||||
# endif /* __aarch64__ */
|
||||
# endif /* __ARM_NEON__ */
|
||||
# endif /* !PNG_ARM_NEON_IMPLEMENTATION */
|
||||
|
||||
@ -1534,10 +1537,10 @@ PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
|
||||
const png_uint_32 chunk_name),PNG_EMPTY);
|
||||
png_uint_32 chunk_name),PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
|
||||
const png_uint_32 chunk_length),PNG_EMPTY);
|
||||
png_uint_32 chunk_length),PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
|
||||
@ -2114,6 +2117,29 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
|
||||
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
|
||||
png_const_charp key, png_bytep new_key), PNG_EMPTY);
|
||||
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1
|
||||
PNG_INTERNAL_FUNCTION(void,
|
||||
png_riffle_palette_neon,
|
||||
(png_structrp),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(int,
|
||||
png_do_expand_palette_rgba8_neon,
|
||||
(png_structrp,
|
||||
png_row_infop,
|
||||
png_const_bytep,
|
||||
const png_bytepp,
|
||||
const png_bytepp),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(int,
|
||||
png_do_expand_palette_rgb8_neon,
|
||||
(png_structrp,
|
||||
png_row_infop,
|
||||
png_const_bytep,
|
||||
const png_bytepp,
|
||||
const png_bytepp),
|
||||
PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* Maintainer: Put new private prototypes here ^ */
|
||||
|
||||
#include "pngdebug.h"
|
||||
|
38
pngread.c
38
pngread.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -994,6 +994,12 @@ png_read_destroy(png_structrp png_ptr)
|
||||
png_ptr->chunk_list = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
|
||||
defined(PNG_ARM_NEON_IMPLEMENTATION)
|
||||
png_free(png_ptr, png_ptr->riffled_palette);
|
||||
png_ptr->riffled_palette = NULL;
|
||||
#endif
|
||||
|
||||
/* NOTE: the 'setjmp' buffer may still be allocated and the memory and error
|
||||
* callbacks are still set at this point. They are required to complete the
|
||||
* destruction of the png_struct itself.
|
||||
@ -1621,7 +1627,7 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
|
||||
* errors (which are unfortunately quite common.)
|
||||
*/
|
||||
{
|
||||
static PNG_CONST png_byte chunks_to_process[] = {
|
||||
static const png_byte chunks_to_process[] = {
|
||||
98, 75, 71, 68, '\0', /* bKGD */
|
||||
99, 72, 82, 77, '\0', /* cHRM */
|
||||
103, 65, 77, 65, '\0', /* gAMA */
|
||||
@ -1758,9 +1764,9 @@ png_create_colormap_entry(png_image_read_control *display,
|
||||
png_uint_32 alpha, int encoding)
|
||||
{
|
||||
png_imagep image = display->image;
|
||||
const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
P_LINEAR : P_sRGB;
|
||||
const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
|
||||
int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
|
||||
(red != green || green != blue);
|
||||
|
||||
if (ip > 255)
|
||||
@ -1869,13 +1875,13 @@ png_create_colormap_entry(png_image_read_control *display,
|
||||
/* Store the value. */
|
||||
{
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
(image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
# else
|
||||
# define afirst 0
|
||||
# endif
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
# else
|
||||
# define bgr 0
|
||||
# endif
|
||||
@ -2085,11 +2091,11 @@ png_image_read_colormap(png_voidp argument)
|
||||
{
|
||||
png_image_read_control *display =
|
||||
png_voidcast(png_image_read_control*, argument);
|
||||
const png_imagep image = display->image;
|
||||
png_imagep image = display->image;
|
||||
|
||||
const png_structrp png_ptr = image->opaque->png_ptr;
|
||||
const png_uint_32 output_format = image->format;
|
||||
const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
png_uint_32 output_format = image->format;
|
||||
int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
P_LINEAR : P_sRGB;
|
||||
|
||||
unsigned int cmap_entries;
|
||||
@ -2802,7 +2808,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
unsigned int num_trans = png_ptr->num_trans;
|
||||
png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL;
|
||||
png_const_colorp colormap = png_ptr->palette;
|
||||
const int do_background = trans != NULL &&
|
||||
int do_background = trans != NULL &&
|
||||
(output_format & PNG_FORMAT_FLAG_ALPHA) == 0;
|
||||
unsigned int i;
|
||||
|
||||
@ -3946,7 +3952,7 @@ png_image_read_direct(png_voidp argument)
|
||||
*/
|
||||
if (linear != 0)
|
||||
{
|
||||
PNG_CONST png_uint_16 le = 0x0001;
|
||||
png_uint_16 le = 0x0001;
|
||||
|
||||
if ((*(png_const_bytep) & le) != 0)
|
||||
png_set_swap(png_ptr);
|
||||
@ -4108,7 +4114,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
* 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);
|
||||
unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||
|
||||
/* The following checks just the 'row_stride' calculation to ensure it
|
||||
* fits in a signed 32-bit value. Because channels/components can be
|
||||
@ -4119,7 +4125,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
if (image->width <= 0x7fffffffU/channels) /* no overflow */
|
||||
{
|
||||
png_uint_32 check;
|
||||
const png_uint_32 png_row_stride = image->width * channels;
|
||||
png_uint_32 png_row_stride = image->width * channels;
|
||||
|
||||
if (row_stride == 0)
|
||||
row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||
|
6
pngrio.c
6
pngrio.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2016,2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
114
pngrtran.c
114
pngrtran.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -18,6 +18,17 @@
|
||||
|
||||
#include "pngpriv.h"
|
||||
|
||||
#ifdef PNG_ARM_NEON_IMPLEMENTATION
|
||||
# if PNG_ARM_NEON_IMPLEMENTATION == 1
|
||||
# define PNG_ARM_NEON_INTRINSICS_AVAILABLE
|
||||
# if defined(_MSC_VER) && defined(_M_ARM64)
|
||||
# include <arm64_neon.h>
|
||||
# else
|
||||
# include <arm_neon.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
|
||||
@ -1171,20 +1182,20 @@ png_init_palette_transformations(png_structrp png_ptr)
|
||||
png_ptr->palette[png_ptr->background.index].blue;
|
||||
|
||||
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
{
|
||||
if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
|
||||
{
|
||||
/* Invert the alpha channel (in tRNS) unless the pixels are
|
||||
* going to be expanded, in which case leave it for later
|
||||
*/
|
||||
int i, istop = png_ptr->num_trans;
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
{
|
||||
if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
|
||||
{
|
||||
/* Invert the alpha channel (in tRNS) unless the pixels are
|
||||
* going to be expanded, in which case leave it for later
|
||||
*/
|
||||
int i, istop = png_ptr->num_trans;
|
||||
|
||||
for (i=0; i<istop; i++)
|
||||
png_ptr->trans_alpha[i] = (png_byte)(255 -
|
||||
png_ptr->trans_alpha[i]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < istop; i++)
|
||||
png_ptr->trans_alpha[i] =
|
||||
(png_byte)(255 - png_ptr->trans_alpha[i]);
|
||||
}
|
||||
}
|
||||
#endif /* READ_INVERT_ALPHA */
|
||||
}
|
||||
} /* background expand and (therefore) no alpha association. */
|
||||
@ -2986,7 +2997,6 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
*/
|
||||
static int
|
||||
png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
{
|
||||
int rgb_error = 0;
|
||||
|
||||
@ -2995,12 +3005,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
PNG_CONST png_uint_32 bc = 32768 - rc - gc;
|
||||
PNG_CONST png_uint_32 row_width = row_info->width;
|
||||
PNG_CONST int have_alpha =
|
||||
(row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
|
||||
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
png_uint_32 bc = 32768 - rc - gc;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
int have_alpha = (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
|
||||
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
@ -4143,12 +4152,11 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
PNG_CONST png_bytep table = png_ptr->gamma_from_1;
|
||||
png_bytep table = png_ptr->gamma_from_1;
|
||||
|
||||
if (table != NULL)
|
||||
{
|
||||
PNG_CONST int step =
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
|
||||
int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
|
||||
|
||||
/* The alpha channel is the last component: */
|
||||
row += step - 1;
|
||||
@ -4162,13 +4170,12 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1;
|
||||
PNG_CONST int gamma_shift = png_ptr->gamma_shift;
|
||||
png_uint_16pp table = png_ptr->gamma_16_from_1;
|
||||
int gamma_shift = png_ptr->gamma_shift;
|
||||
|
||||
if (table != NULL)
|
||||
{
|
||||
PNG_CONST int step =
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
|
||||
int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
|
||||
|
||||
/* The alpha channel is the last component: */
|
||||
row += step - 2;
|
||||
@ -4199,8 +4206,9 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
* upon whether you supply trans and num_trans.
|
||||
*/
|
||||
static void
|
||||
png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)
|
||||
png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info,
|
||||
png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha,
|
||||
int num_trans)
|
||||
{
|
||||
int shift, value;
|
||||
png_bytep sp, dp;
|
||||
@ -4304,14 +4312,27 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
sp = row + (size_t)row_width - 1;
|
||||
dp = row + ((size_t)row_width << 2) - 1;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
i = 0;
|
||||
#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
|
||||
if (png_ptr->riffled_palette != NULL)
|
||||
{
|
||||
/* The RGBA optimization works with png_ptr->bit_depth == 8
|
||||
* but sometimes row_info->bit_depth has been changed to 8.
|
||||
* In these cases, the palette hasn't been riffled.
|
||||
*/
|
||||
i = png_do_expand_palette_rgba8_neon(png_ptr, row_info, row,
|
||||
&sp, &dp);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
|
||||
for (; i < row_width; i++)
|
||||
{
|
||||
if ((int)(*sp) >= num_trans)
|
||||
*dp-- = 0xff;
|
||||
|
||||
else
|
||||
*dp-- = trans_alpha[*sp];
|
||||
|
||||
*dp-- = palette[*sp].blue;
|
||||
*dp-- = palette[*sp].green;
|
||||
*dp-- = palette[*sp].red;
|
||||
@ -4328,8 +4349,15 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
sp = row + (size_t)row_width - 1;
|
||||
dp = row + (size_t)(row_width * 3) - 1;
|
||||
i = 0;
|
||||
#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
|
||||
i = png_do_expand_palette_rgb8_neon(png_ptr, row_info, row,
|
||||
&sp, &dp);
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
for (; i < row_width; i++)
|
||||
{
|
||||
*dp-- = palette[*sp].blue;
|
||||
*dp-- = palette[*sp].green;
|
||||
@ -4743,7 +4771,19 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
png_do_expand_palette(row_info, png_ptr->row_buf + 1,
|
||||
#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
|
||||
if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8))
|
||||
{
|
||||
if (png_ptr->riffled_palette == NULL)
|
||||
{
|
||||
/* Initialize the accelerated palette expansion. */
|
||||
png_ptr->riffled_palette =
|
||||
(png_bytep)png_malloc(png_ptr, 256 * 4);
|
||||
png_riffle_palette_neon(png_ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1,
|
||||
png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
|
||||
}
|
||||
|
||||
|
39
pngrutil.c
39
pngrutil.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -1461,8 +1461,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
/* We have the ICC profile header; do the basic header checks.
|
||||
*/
|
||||
const png_uint_32 profile_length =
|
||||
png_get_uint_32(profile_header);
|
||||
png_uint_32 profile_length = png_get_uint_32(profile_header);
|
||||
|
||||
if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
|
||||
keyword, profile_length) != 0)
|
||||
@ -1479,8 +1478,8 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
* profile. The header check has already validated
|
||||
* that none of this stuff will overflow.
|
||||
*/
|
||||
const png_uint_32 tag_count = png_get_uint_32(
|
||||
profile_header+128);
|
||||
png_uint_32 tag_count =
|
||||
png_get_uint_32(profile_header + 128);
|
||||
png_bytep profile = png_read_buffer(png_ptr,
|
||||
profile_length, 2/*silent*/);
|
||||
|
||||
@ -3132,7 +3131,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name)
|
||||
png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name)
|
||||
{
|
||||
int i;
|
||||
png_uint_32 cn=chunk_name;
|
||||
@ -3151,7 +3150,7 @@ png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name)
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length)
|
||||
png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
|
||||
{
|
||||
png_alloc_size_t limit = PNG_UINT_31_MAX;
|
||||
|
||||
@ -3363,7 +3362,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
/* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and
|
||||
* then pass:
|
||||
*/
|
||||
static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
|
||||
static const png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
|
||||
{
|
||||
/* Little-endian byte masks for PACKSWAP */
|
||||
{ S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) },
|
||||
@ -3374,7 +3373,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
/* display_mask has only three entries for the odd passes, so index by
|
||||
* pass>>1.
|
||||
*/
|
||||
static PNG_CONST png_uint_32 display_mask[2][3][3] =
|
||||
static const png_uint_32 display_mask[2][3][3] =
|
||||
{
|
||||
/* Little-endian byte masks for PACKSWAP */
|
||||
{ B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) },
|
||||
@ -3687,7 +3686,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
{
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
png_debug(1, "in png_do_read_interlace");
|
||||
if (row != NULL && row_info != NULL)
|
||||
@ -4329,16 +4328,16 @@ png_read_finish_row(png_structrp png_ptr)
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* Start of interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* Offset to next interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
png_debug(1, "in png_read_finish_row");
|
||||
png_ptr->row_number++;
|
||||
@ -4394,16 +4393,16 @@ png_read_start_row(png_structrp png_ptr)
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* Start of interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* Offset to next interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
unsigned int max_pixel_depth;
|
||||
size_t row_bytes;
|
||||
|
12
pngset.c
12
pngset.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -137,7 +137,7 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
||||
#ifdef PNG_eXIf_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
const png_bytep eXIf_buf)
|
||||
png_bytep eXIf_buf)
|
||||
{
|
||||
png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
|
||||
PNG_UNUSED(info_ptr)
|
||||
@ -146,7 +146,7 @@ png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
void PNGAPI
|
||||
png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
const png_uint_32 num_exif, const png_bytep eXIf_buf)
|
||||
png_uint_32 num_exif, png_bytep eXIf_buf)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -1399,7 +1399,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
/* Ignore all unknown chunks and all chunks recognized by
|
||||
* libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
|
||||
*/
|
||||
static PNG_CONST png_byte chunks_to_ignore[] = {
|
||||
static const png_byte chunks_to_ignore[] = {
|
||||
98, 75, 71, 68, '\0', /* bKGD */
|
||||
99, 72, 82, 77, '\0', /* cHRM */
|
||||
101, 88, 73, 102, '\0', /* eXIf */
|
||||
|
12
pngstruct.h
12
pngstruct.h
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -392,6 +392,12 @@ struct png_struct_def
|
||||
/* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.6.36 */
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
|
||||
defined(PNG_ARM_NEON_IMPLEMENTATION)
|
||||
png_bytep riffled_palette; /* buffer for accelerated palette expansion */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
/* Changed from png_byte to png_uint_32 at version 1.2.0 */
|
||||
|
28
pngtest.c
28
pngtest.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -449,13 +449,13 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, size_t length)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
PNG_CONST char *file_name;
|
||||
const char *file_name;
|
||||
} pngtest_error_parameters;
|
||||
|
||||
static void PNGCBAPI
|
||||
pngtest_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
PNG_CONST char *name = "UNKNOWN (ERROR!)";
|
||||
const char *name = "UNKNOWN (ERROR!)";
|
||||
pngtest_error_parameters *test =
|
||||
(pngtest_error_parameters*)png_get_error_ptr(png_ptr);
|
||||
|
||||
@ -850,7 +850,7 @@ pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
|
||||
|
||||
/* Test one file */
|
||||
static int
|
||||
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
test_one_file(const char *inname, const char *outname)
|
||||
{
|
||||
static png_FILE_p fpin;
|
||||
static png_FILE_p fpout; /* "static" prevents setjmp corruption */
|
||||
@ -957,6 +957,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
if (setjmp(png_jmpbuf(write_ptr)))
|
||||
{
|
||||
fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
|
||||
png_free(read_ptr, row_buf);
|
||||
row_buf = NULL;
|
||||
if (verbose != 0)
|
||||
fprintf(STDERR, " destroying read structs\n");
|
||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||
@ -1436,7 +1438,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
|
||||
pngtest_debug1("\t0x%08lx", (unsigned long)row_buf);
|
||||
pngtest_debug1("\t%p", row_buf);
|
||||
#endif /* SINGLE_ROWBUF_ALLOC */
|
||||
pngtest_debug("Writing row data");
|
||||
|
||||
@ -1490,7 +1492,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
|
||||
pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
|
||||
pngtest_debug2("\t%p (%lu bytes)", row_buf,
|
||||
(unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
|
||||
#endif /* !SINGLE_ROWBUF_ALLOC */
|
||||
@ -1809,11 +1811,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
/* Input and output filenames */
|
||||
#ifdef RISCOS
|
||||
static PNG_CONST char *inname = "pngtest/png";
|
||||
static PNG_CONST char *outname = "pngout/png";
|
||||
static const char *inname = "pngtest/png";
|
||||
static const char *outname = "pngout/png";
|
||||
#else
|
||||
static PNG_CONST char *inname = "pngtest.png";
|
||||
static PNG_CONST char *outname = "pngout.png";
|
||||
static const char *inname = "pngtest.png";
|
||||
static const char *outname = "pngout.png";
|
||||
#endif
|
||||
|
||||
int
|
||||
@ -2153,4 +2155,4 @@ main(void)
|
||||
#endif
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_35 Your_png_h_is_not_version_1_6_35;
|
||||
typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37;
|
||||
|
12
pngtrans.c
12
pngtrans.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -345,7 +345,7 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
static PNG_CONST png_byte onebppswaptable[256] = {
|
||||
static const png_byte onebppswaptable[256] = {
|
||||
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
|
||||
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
||||
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
|
||||
@ -380,7 +380,7 @@ static PNG_CONST png_byte onebppswaptable[256] = {
|
||||
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
||||
};
|
||||
|
||||
static PNG_CONST png_byte twobppswaptable[256] = {
|
||||
static const png_byte twobppswaptable[256] = {
|
||||
0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
|
||||
0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
|
||||
0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
|
||||
@ -415,7 +415,7 @@ static PNG_CONST png_byte twobppswaptable[256] = {
|
||||
0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
|
||||
};
|
||||
|
||||
static PNG_CONST png_byte fourbppswaptable[256] = {
|
||||
static const png_byte fourbppswaptable[256] = {
|
||||
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
|
||||
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
|
||||
0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
|
||||
|
6
pngwio.c
6
pngwio.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2014,2016,2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
34
pngwrite.c
34
pngwrite.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -469,7 +469,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
void PNGAPI
|
||||
png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime)
|
||||
png_convert_from_struct_tm(png_timep ptime, const struct tm * ttime)
|
||||
{
|
||||
png_debug(1, "in png_convert_from_struct_tm");
|
||||
|
||||
@ -1536,7 +1536,7 @@ png_write_image_16bit(png_voidp argument)
|
||||
display->first_row);
|
||||
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
|
||||
png_uint_16p row_end;
|
||||
const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
3 : 1;
|
||||
int aindex = 0;
|
||||
png_uint_32 y = image->height;
|
||||
@ -1573,7 +1573,7 @@ png_write_image_16bit(png_voidp argument)
|
||||
|
||||
while (out_ptr < row_end)
|
||||
{
|
||||
const png_uint_16 alpha = in_ptr[aindex];
|
||||
png_uint_16 alpha = in_ptr[aindex];
|
||||
png_uint_32 reciprocal = 0;
|
||||
int c;
|
||||
|
||||
@ -1695,7 +1695,7 @@ png_write_image_8bit(png_voidp argument)
|
||||
display->first_row);
|
||||
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
|
||||
png_uint_32 y = image->height;
|
||||
const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
3 : 1;
|
||||
|
||||
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
@ -1783,25 +1783,25 @@ png_write_image_8bit(png_voidp argument)
|
||||
static void
|
||||
png_image_set_PLTE(png_image_write_control *display)
|
||||
{
|
||||
const png_imagep image = display->image;
|
||||
png_imagep image = display->image;
|
||||
const void *cmap = display->colormap;
|
||||
const int entries = image->colormap_entries > 256 ? 256 :
|
||||
int entries = image->colormap_entries > 256 ? 256 :
|
||||
(int)image->colormap_entries;
|
||||
|
||||
/* NOTE: the caller must check for cmap != NULL and entries != 0 */
|
||||
const png_uint_32 format = image->format;
|
||||
const unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
|
||||
png_uint_32 format = image->format;
|
||||
unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
|
||||
|
||||
# if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
|
||||
defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
|
||||
const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
(format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
# else
|
||||
# define afirst 0
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
# else
|
||||
# define bgr 0
|
||||
# endif
|
||||
@ -1951,12 +1951,12 @@ png_image_write_main(png_voidp argument)
|
||||
* and total image size to ensure that they are within the system limits.
|
||||
*/
|
||||
{
|
||||
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||
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;
|
||||
png_uint_32 png_row_stride = image->width * channels;
|
||||
|
||||
if (display->row_stride == 0)
|
||||
display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||
@ -2052,7 +2052,7 @@ png_image_write_main(png_voidp argument)
|
||||
*/
|
||||
if (write_16bit != 0)
|
||||
{
|
||||
PNG_CONST png_uint_16 le = 0x0001;
|
||||
png_uint_16 le = 0x0001;
|
||||
|
||||
if ((*(png_const_bytep) & le) != 0)
|
||||
png_set_swap(png_ptr);
|
||||
@ -2166,7 +2166,7 @@ image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data, 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;
|
||||
png_alloc_size_t ob = display->output_bytes;
|
||||
|
||||
/* Check for overflow; this should never happen: */
|
||||
if (size <= ((png_alloc_size_t)-1) - ob)
|
||||
|
11
pngwtran.c
11
pngwtran.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2016,2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -254,8 +254,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
|
||||
const unsigned int c = i%channels;
|
||||
unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int v, out;
|
||||
|
||||
@ -283,7 +282,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (bp = row, i = 0; i < istop; i++)
|
||||
{
|
||||
const unsigned int c = i%channels;
|
||||
unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int value, v;
|
||||
|
||||
|
38
pngwutil.c
38
pngwutil.c
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.35 [July 15, 2018]
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 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.)
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -1893,16 +1893,16 @@ png_write_start_row(png_structrp png_ptr)
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* Start of interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* Offset to next interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
#endif
|
||||
|
||||
png_alloc_size_t buf_size;
|
||||
@ -2008,16 +2008,16 @@ png_write_finish_row(png_structrp png_ptr)
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* Start of interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* Offset to next interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
#endif
|
||||
|
||||
png_debug(1, "in png_write_finish_row");
|
||||
@ -2098,10 +2098,10 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
png_debug(1, "in png_do_write_interlace");
|
||||
|
||||
@ -2276,7 +2276,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
static size_t /* PRIVATE */
|
||||
png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_sub_row(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes, size_t lmins)
|
||||
{
|
||||
png_bytep rp, dp, lp;
|
||||
@ -2315,7 +2315,7 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
}
|
||||
|
||||
static void /* PRIVATE */
|
||||
png_setup_sub_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_sub_row_only(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, lp;
|
||||
@ -2380,7 +2380,7 @@ png_setup_up_row_only(png_structrp png_ptr, size_t row_bytes)
|
||||
}
|
||||
|
||||
static size_t /* PRIVATE */
|
||||
png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_avg_row(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes, size_t lmins)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
@ -2420,7 +2420,7 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
return (sum);
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_avg_row_only(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
@ -2442,7 +2442,7 @@ png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
}
|
||||
|
||||
static size_t /* PRIVATE */
|
||||
png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_paeth_row(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes, size_t lmins)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
@ -2503,7 +2503,7 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
return (sum);
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_paeth_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_paeth_row_only(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
|
@ -1,13 +1,14 @@
|
||||
/* filter_vsx_intrinsics.c - PowerPC optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2017 Glenn Randers-Pehrson
|
||||
* Written by Vadim Barkov, 2017.
|
||||
* Last changed in libpng 1.6.29 [March 16, 2017]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "../pngpriv.h"
|
||||
@ -173,7 +174,7 @@ static const vector unsigned char VSX_SHORT_TO_CHAR4_3 = {16,16,16,16,16,16,16,1
|
||||
void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 4;
|
||||
png_byte bpp = 4;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char part_vec;
|
||||
@ -230,7 +231,7 @@ void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_sub3_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 3;
|
||||
png_byte bpp = 3;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char part_vec;
|
||||
@ -294,7 +295,7 @@ void png_read_filter_row_sub3_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_avg4_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 4;
|
||||
png_byte bpp = 4;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char pp_vec;
|
||||
@ -381,7 +382,7 @@ void png_read_filter_row_avg4_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_avg3_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 3;
|
||||
png_byte bpp = 3;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char pp_vec;
|
||||
@ -499,7 +500,7 @@ void png_read_filter_row_avg3_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_paeth4_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 4;
|
||||
png_byte bpp = 4;
|
||||
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
vector unsigned char rp_vec;
|
||||
@ -619,7 +620,7 @@ void png_read_filter_row_paeth4_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_paeth3_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 3;
|
||||
png_byte bpp = 3;
|
||||
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
vector unsigned char rp_vec;
|
||||
|
@ -1,14 +1,15 @@
|
||||
|
||||
/* powerpc_init.c - POWERPC optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2017 Glenn Randers-Pehrson
|
||||
* Written by Vadim Barkov, 2017.
|
||||
* Last changed in libpng 1.6.29 [March 16, 2017]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
|
||||
* called.
|
||||
*/
|
||||
|
@ -1,76 +1,77 @@
|
||||
Instructions for building libpng using Microsoft Visual Studio
|
||||
==============================================================
|
||||
|
||||
VisualStudio instructions
|
||||
|
||||
libpng version 1.6.35 - July 15, 2018
|
||||
|
||||
Copyright (c) 2018 Cosmin Truta
|
||||
Copyright (c) 2010,2013,2015 Glenn Randers-Pehrson
|
||||
|
||||
This code is released under the libpng license.
|
||||
For conditions of distribution and use, see the disclaimer
|
||||
and license in png.h
|
||||
For conditions of distribution and use, see the disclaimer and license
|
||||
in png.h
|
||||
|
||||
This directory contains support for building libpng under MicroSoft
|
||||
VisualStudio 2010. It may also work under later versions of VisualStudio.
|
||||
You should be familiar with VisualStudio before using this directory.
|
||||
This directory contains a solution for building libpng under Microsoft
|
||||
Visual Studio 2010. It may also work under later versions of Visual
|
||||
Studio. You should be familiar with Visual Studio before using this
|
||||
solution.
|
||||
|
||||
Initial preparations
|
||||
====================
|
||||
You must enter some information in zlib.props before attempting to build
|
||||
with this 'solution'. Please read and edit zlib.props first. You will
|
||||
probably not be familiar with the contents of zlib.props - do not worry,
|
||||
it is mostly harmless.
|
||||
--------------------
|
||||
You must enter some information in zlib.props before attempting to
|
||||
build with this 'solution'. Please read and edit zlib.props first.
|
||||
You will probably not be familiar with the contents of zlib.props -
|
||||
do not worry, it is mostly harmless.
|
||||
|
||||
This is all you need to do to build the 'release' and 'release library'
|
||||
configurations.
|
||||
|
||||
Debugging
|
||||
=========
|
||||
---------
|
||||
The release configurations default to /Ox optimization. Full debugging
|
||||
information is produced (in the .pdb), but if you encounter a problem the
|
||||
optimization may make it difficult to debug. Simply rebuild with a lower
|
||||
optimization level (e.g. /Od.)
|
||||
information is produced (in the .pdb), but if you encounter a problem
|
||||
the optimization may make it difficult to debug. Simply rebuild with a
|
||||
lower optimization level (e.g. /Od.)
|
||||
|
||||
Linking your application
|
||||
========================
|
||||
Normally you should link against the 'release' configuration. This builds a
|
||||
DLL for libpng with the default runtime options used by Visual Studio 2010.
|
||||
In particular the runtime library is the "MultiThreaded DLL" version.
|
||||
If you use Visual Studio defaults to build your application you will have no
|
||||
problems.
|
||||
------------------------
|
||||
Normally you should link against the 'release' configuration. This
|
||||
builds a DLL for libpng with the default runtime options used by Visual
|
||||
Studio. In particular the runtime library is the "MultiThreaded DLL"
|
||||
version. If you use Visual Studio defaults to build your application,
|
||||
you should have no problems.
|
||||
|
||||
If you don't use the Visual Studio defaults your application must still be
|
||||
built with the default runtime option (/MD). If, for some reason, it is not
|
||||
then your application will crash inside libpng16.dll as soon as libpng
|
||||
tries to read from a file handle you pass in.
|
||||
If you don't use the Visual Studio defaults your application must still
|
||||
be built with the default runtime option (/MD). If, for some reason,
|
||||
it is not then your application will crash inside libpng16.dll as soon
|
||||
as libpng tries to read from a file handle you pass in.
|
||||
|
||||
If you do not want to use the DLL, for example for a very small application,
|
||||
the 'release library' configuration may be more appropriate. This is built
|
||||
with a non-standard runtime library - the "MultiThreaded" version. When you
|
||||
build your application it must be compiled with this option (/MT), otherwise
|
||||
it will not build (if you are lucky) or crash (if you are not.) See the
|
||||
WARNING file that is distributed along with this readme.txt.
|
||||
If you do not want to use the DLL, and prefer static linking instead,
|
||||
you may choose the 'release library' configuration. This is built with
|
||||
a non-standard runtime library - the "MultiThreaded" version. When you
|
||||
build your application, it must be compiled with this option (/MT),
|
||||
otherwise it will not build (if you are lucky) or it will crash (if you
|
||||
are not.) See the WARNING file that is distributed with this README.
|
||||
|
||||
Stop reading here
|
||||
=================
|
||||
-----------------
|
||||
You have enough information to build a working application.
|
||||
|
||||
Debug versions have limited support
|
||||
===================================
|
||||
This solution includes limited support for debug versions of libpng. You
|
||||
do not need these unless your own solution itself uses debug builds (it is
|
||||
far more effective to debug on the release builds, there is no point building
|
||||
a special debug build unless you have heap corruption problems that you can't
|
||||
track down.)
|
||||
-----------------------------------
|
||||
This solution includes limited support for debug versions of libpng.
|
||||
You do not need these unless your own solution itself uses debug builds
|
||||
(it is far more effective to debug on the release builds, there is no
|
||||
point building a special debug build unless you have heap corruption
|
||||
problems that you can't track down.)
|
||||
|
||||
The debug build of libpng is minimally supported. Support for debug builds of
|
||||
zlib is also minimal. You really don't want to do this.
|
||||
The debug build of libpng is minimally supported. Support for debug
|
||||
builds of zlib is also minimal. Please keep this in mind, if you want
|
||||
to use it.
|
||||
|
||||
WARNING
|
||||
=======
|
||||
Libpng 1.6.x does not use the default run-time library when building static
|
||||
library builds of libpng; instead of the shared DLL runtime it uses a static
|
||||
runtime. If you need to change this make sure to change the setting on all the
|
||||
relevant projects:
|
||||
-------
|
||||
Libpng 1.6.x does not use the default run-time library when building
|
||||
static library builds of libpng; instead of the shared DLL runtime, it
|
||||
uses a static runtime. If you need to change this, make sure to change
|
||||
the setting on all the relevant projects:
|
||||
|
||||
libpng
|
||||
zlib
|
||||
@ -82,16 +83,5 @@ The runtime library settings for each build are as follows:
|
||||
DLL /MD /MDd
|
||||
Library /MT /MTd
|
||||
|
||||
NOTICE that libpng 1.5.x erroneously used /MD for Debug DLL builds; if you used
|
||||
the debug builds in your app and you changed your app to use /MD you will need
|
||||
to change it back to /MDd for libpng 1.6.0 and later.
|
||||
|
||||
The Visual Studio 2010 defaults for a Win32 DLL or Static Library project are
|
||||
as follows:
|
||||
|
||||
Release Debug
|
||||
DLL /MD /MDd
|
||||
Static Library /MD /MDd
|
||||
|
||||
Also, be sure to build libpng, zlib, and your project all for the same
|
||||
Also, be sure to build libpng, zlib, and your project, all for the same
|
||||
platform (e.g., 32-bit or 64-bit).
|
||||
|
@ -2,16 +2,15 @@
|
||||
<!--
|
||||
* zlib.props - location of zlib source
|
||||
*
|
||||
* libpng version 1.6.35 - July 15, 2018
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
|
||||
* You must edit this file to record the location of the zlib
|
||||
* source code.
|
||||
* You may need to edit this file in order to update the location
|
||||
* of the zlib source code.
|
||||
-->
|
||||
|
||||
<Project ToolsVersion="4.0"
|
||||
@ -32,7 +31,7 @@
|
||||
versions do not match. The zlib version used in this build is recorded
|
||||
below:
|
||||
-->
|
||||
<ZLibSrcDir>..\..\..\..\zlib-1.2.8</ZLibSrcDir>
|
||||
<ZLibSrcDir>..\..\..\..\zlib</ZLibSrcDir>
|
||||
|
||||
<!-- The following line allows compilation for an ARM target with Visual
|
||||
Studio 2012. Notice that this is not supported by the Visual Studio
|
||||
|
@ -1,24 +1,20 @@
|
||||
|
||||
Makefiles for libpng version 1.6.35 - July 15, 2018
|
||||
Makefiles for libpng
|
||||
|
||||
pnglibconf.h.prebuilt => Stores configuration settings
|
||||
pnglibconf.h.prebuilt => Configuration settings
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng16.so.16.1.6.35)
|
||||
(gcc, creates shared libpng16.so.16.1.6.*)
|
||||
makefile.linux-opt=> Linux/ELF makefile with hardware optimizations on
|
||||
(gcc, creates libpng16.so.16.1.6.35)
|
||||
(gcc, creates shared libpng16.so.16.1.6.*)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
ftp://ftp.cs.wisc.edu/ghost)
|
||||
makefile.acorn => Acorn makefile
|
||||
makefile.aix => AIX/gcc makefile
|
||||
makefile.amiga => Amiga makefile
|
||||
makefile.atari => Atari makefile
|
||||
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
|
||||
makefile.beos => beos makefile
|
||||
makefile.bor => Borland makefile (uses bcc)
|
||||
makefile.beos => BeOS makefile
|
||||
makefile.cegcc => minge32ce for Windows CE makefile
|
||||
makefile.darwin => Darwin makefile, can use on MacosX
|
||||
makefile.darwin => Darwin makefile, for macOS (formerly Mac OS X)
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.freebsd => FreeBSD makefile
|
||||
@ -29,23 +25,20 @@ pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
|
||||
makefile.intel => Intel C/C++ version 4.0 and later
|
||||
makefile.mips => MIPS makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.netbsd => NetBSD/cc makefile, makes libpng.so.
|
||||
makefile.netbsd => NetBSD/cc makefile, makes shared libpng.so
|
||||
makefile.openbsd => OpenBSD makefile
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.sggcc => Silicon Graphics (gcc,
|
||||
creates libpng16.so.16.1.6.35)
|
||||
makefile.sco => SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.sggcc => Silicon Graphics makefile
|
||||
(gcc, creates shared libpng16.so.16.1.6.*)
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc,
|
||||
creates libpng16.so.16.1.6.35)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng16.so.16.1.6.35)
|
||||
makefile.solaris => Solaris 2.X makefile
|
||||
(gcc, creates shared libpng16.so.16.1.6.*)
|
||||
makefile.so9 => Solaris 9 makefile
|
||||
(gcc, creates shared libpng16.so.16.1.6.*)
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
makefile.64sunu => Sun Ultra 64-bit makefile
|
||||
makefile.tc3 => Turbo C 3.0 makefile
|
||||
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later
|
||||
makevms.com => VMS build script
|
||||
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
|
||||
@ -57,20 +50,20 @@ Other supporting scripts:
|
||||
libpng-config-body.in => used by several makefiles to create libpng-config
|
||||
libpng-config-head.in => used by several makefiles to create libpng-config
|
||||
libpng.pc.in => Used by several makefiles to create libpng.pc
|
||||
pngwin.rc => Used by the visualc71 project.
|
||||
pngwin.rc => Used by the visualc71 project
|
||||
pngwin.def => Used by makefile.os2
|
||||
pngwin.dfn => Used to maintain pngwin.def
|
||||
SCOPTIONS.ppc => Used with smakefile.ppc
|
||||
|
||||
checksym.awk => Used for maintaining pnglibconf.h
|
||||
def.dfn => Used for maintaining pnglibconf.h
|
||||
options.awk => Used for maintaining pnglibconf.h
|
||||
pnglibconf.dfa => Used for maintaining pnglibconf.h
|
||||
pnglibconf.mak => Used for maintaining pnglibconf.h
|
||||
sym.dfn => Used for symbol versioning
|
||||
symbols.def => Used for symbol versioning
|
||||
symbols.dfn => Used for symbol versioning
|
||||
vers.dfn => Used for symbol versioning
|
||||
checksym.awk => Used for maintaining pnglibconf.h
|
||||
def.dfn => Used for maintaining pnglibconf.h
|
||||
options.awk => Used for maintaining pnglibconf.h
|
||||
pnglibconf.dfa => Used for maintaining pnglibconf.h
|
||||
pnglibconf.mak => Used for maintaining pnglibconf.h
|
||||
sym.dfn => Used for symbol versioning
|
||||
symbols.def => Used for symbol versioning
|
||||
symbols.dfn => Used for symbol versioning
|
||||
vers.dfn => Used for symbol versioning
|
||||
|
||||
libtool.m4 => Used by autoconf tools
|
||||
ltoptions.m4 => Used by autoconf tools
|
||||
|
@ -1,29 +0,0 @@
|
||||
/* def.c - define format of libpng.def
|
||||
*
|
||||
* Last changed in libpng version 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 2011-2014 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* Write the export file header: */
|
||||
PNG_DFN ";--------------------------------------------------------------"
|
||||
PNG_DFN "; LIBPNG module definition file for OS/2"
|
||||
PNG_DFN ";--------------------------------------------------------------"
|
||||
PNG_DFN ""
|
||||
PNG_DFN "; If you give the library an explicit name one or other files"
|
||||
PNG_DFN "; may need modifying to support the new name on one or more"
|
||||
PNG_DFN "; systems."
|
||||
PNG_DFN "LIBRARY"
|
||||
PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
|
||||
PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
|
||||
PNG_DFN ""
|
||||
PNG_DFN "EXPORTS"
|
||||
PNG_DFN ";Version 1.6.35"
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
|
||||
|
||||
#include "../png.h"
|
@ -16,10 +16,10 @@ OBJS = png.obj, pngset.obj, pngget.obj, pngrutil.obj, pngtrans.obj,\
|
||||
CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF)
|
||||
|
||||
all : pngtest.exe libpng.olb
|
||||
@ write sys$output " pngtest available"
|
||||
@ write sys$output " pngtest available"
|
||||
|
||||
libpng.olb : libpng.olb($(OBJS))
|
||||
@ write sys$output " Libpng available"
|
||||
@ write sys$output " libpng available"
|
||||
|
||||
|
||||
pngtest.exe : pngtest.obj libpng.olb
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.6.35
|
||||
version=1.6.37
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.6.35
|
||||
Version: 1.6.37
|
||||
Libs: -L${libdir} -lpng16
|
||||
Cflags: -I${includedir}
|
||||
|
@ -219,7 +219,7 @@ clean:
|
||||
libpng-config $(LIBSO) $(LIBSOMAJ)* \
|
||||
libpng.pc
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -219,7 +219,7 @@ clean:
|
||||
libpng-config $(LIBSO) $(LIBSOMAJ)* \
|
||||
libpng.pc
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -1,170 +0,0 @@
|
||||
# Makefile for libpng
|
||||
# 16-bit Borland C++ (Note: All modules are compiled in C mode)
|
||||
# To build the library, do:
|
||||
# "make -fmakefile.bor -DMODEL=c"
|
||||
# or: "make -fmakefile.bor -DMODEL=l"
|
||||
#
|
||||
# ------------ Borland C++ ------------
|
||||
|
||||
### Absolutely necessary for this makefile to work
|
||||
.AUTODEPEND
|
||||
|
||||
## Where zlib.h, zconf.h and zlib_MODEL.lib are
|
||||
ZLIB_DIR=..\zlib
|
||||
|
||||
## Compiler, linker, librarian and other tools
|
||||
CC=bcc
|
||||
LD=bcc
|
||||
LIB=tlib
|
||||
CP=copy
|
||||
|
||||
!ifndef MODEL
|
||||
MODEL=l
|
||||
!endif
|
||||
|
||||
MODEL_ARG=-m$(MODEL)
|
||||
|
||||
#TARGET_CPU=3
|
||||
# 2 = 286, 3 = 386, etc.
|
||||
!ifndef TARGET_CPU
|
||||
TARGET_CPU=2
|
||||
!endif
|
||||
|
||||
# Use this if you don't want Borland's fancy exception handling
|
||||
# (for Borland C++ 4.0 or later)
|
||||
#NOEHLIB=noeh$(MODEL).lib
|
||||
|
||||
!ifdef DEBUG
|
||||
CDEBUG=-v
|
||||
LDEBUG=-v
|
||||
!else
|
||||
CDEBUG=
|
||||
LDEBUG=
|
||||
!endif
|
||||
|
||||
# STACKOFLOW=1
|
||||
!ifdef STACKOFLOW
|
||||
CDEBUG=$(CDEBUG) -N
|
||||
LDEBUG=$(LDEBUG) -N
|
||||
!endif
|
||||
|
||||
# -X- turn on dependency generation in the object file
|
||||
# -w set all warnings on
|
||||
# -O2 optimize for speed
|
||||
# -Z global optimization
|
||||
CPPFLAGS=-I$(ZLIB_DIR)
|
||||
CFLAGS=-O2 -Z -X- -w -$(TARGET_CPU) $(MODEL_ARG) $(CDEBUG)
|
||||
|
||||
# -M generate map file
|
||||
LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG)
|
||||
|
||||
# Pre-built configuration
|
||||
# See scripts\pnglibconf.mak for more options
|
||||
!ifndef PNGLIBCONF_H_PREBUILT
|
||||
PNGLIBCONF_H_PREBUILT = scripts\pnglibconf.h.prebuilt
|
||||
!endif
|
||||
|
||||
## Variables
|
||||
|
||||
OBJS = \
|
||||
png.obj \
|
||||
pngerror.obj \
|
||||
pngget.obj \
|
||||
pngmem.obj \
|
||||
pngpread.obj \
|
||||
pngread.obj \
|
||||
pngrio.obj \
|
||||
pngrtran.obj \
|
||||
pngrutil.obj \
|
||||
pngset.obj \
|
||||
pngtrans.obj \
|
||||
pngwio.obj \
|
||||
pngwrite.obj \
|
||||
pngwtran.obj \
|
||||
pngwutil.obj
|
||||
|
||||
LIBOBJS = \
|
||||
+png.obj \
|
||||
+pngerror.obj \
|
||||
+pngget.obj \
|
||||
+pngmem.obj \
|
||||
+pngpread.obj \
|
||||
+pngread.obj \
|
||||
+pngrio.obj \
|
||||
+pngrtran.obj \
|
||||
+pngrutil.obj \
|
||||
+pngset.obj \
|
||||
+pngtrans.obj \
|
||||
+pngwio.obj \
|
||||
+pngwrite.obj \
|
||||
+pngwtran.obj \
|
||||
+pngwutil.obj
|
||||
|
||||
LIBNAME=libpng$(MODEL).lib
|
||||
|
||||
## Implicit rules
|
||||
|
||||
# Braces let make "batch" calls to the compiler,
|
||||
# 2 calls instead of 12; space is important.
|
||||
.c.obj:
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c {$*.c }
|
||||
|
||||
.c.exe:
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $*.c \
|
||||
$(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB)
|
||||
|
||||
## Major targets
|
||||
|
||||
all: libpng pngtest
|
||||
|
||||
# try !include scripts\pnglibconf.mak for more options
|
||||
pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
|
||||
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
|
||||
|
||||
libpng: $(LIBNAME)
|
||||
|
||||
pngtest: pngtest$(MODEL).exe
|
||||
|
||||
test: pngtest$(MODEL).exe
|
||||
pngtest$(MODEL)
|
||||
|
||||
## Minor Targets
|
||||
|
||||
png.obj: png.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.obj: pngerror.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.obj: pngget.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.obj: pngmem.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.obj: pngpread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.obj: pngread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.obj: pngrio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.obj: pngrtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.obj: pngrutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.obj: pngset.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.obj: pngtrans.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.obj: pngwio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.obj: pngwrite.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.obj: pngwtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.obj: pngwutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
$(LIBNAME): $(OBJS)
|
||||
-del $(LIBNAME)
|
||||
$(LIB) $(LIBNAME) @&&|
|
||||
$(LIBOBJS), libpng$(MODEL)
|
||||
|
|
||||
|
||||
pngtest$(MODEL).obj: pngtest.c png.h pngconf.h pnglibconf.h
|
||||
$(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c
|
||||
|
||||
pngtest$(MODEL).exe: pngtest$(MODEL).obj
|
||||
$(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB)
|
||||
|
||||
# Clean up anything else you want
|
||||
clean:
|
||||
-del pnglibconf.h
|
||||
-del *.obj
|
||||
-del *.exe
|
||||
-del *.lib
|
||||
-del *.lst
|
||||
-del *.map
|
||||
|
||||
# End of makefile for libpng
|
@ -23,7 +23,7 @@
|
||||
|
||||
VERMAJ = 1
|
||||
VERMIN = 6
|
||||
VERMIC = 35
|
||||
VERMIC = 37
|
||||
VER = $(VERMAJ).$(VERMIN).$(VERMIC)
|
||||
NAME = libpng
|
||||
PACKAGE = $(NAME)-$(VER)
|
||||
|
87
scripts/makefile.clang
Normal file
87
scripts/makefile.clang
Normal file
@ -0,0 +1,87 @@
|
||||
# makefile for libpng using clang (generic, static library)
|
||||
# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2000, 2014, 2019 Cosmin Truta
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# Location of the zlib library and include files
|
||||
ZLIBINC = ../zlib
|
||||
ZLIBLIB = ../zlib
|
||||
|
||||
# Compiler, linker, lib and other tools
|
||||
CC = clang
|
||||
LD = $(CC)
|
||||
AR_RC = ar rcs
|
||||
RANLIB = ranlib
|
||||
CP = cp
|
||||
RM_F = rm -f
|
||||
|
||||
WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
|
||||
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
|
||||
CFLAGS = -W -Wall -O2 # $(WARNMORE) -g
|
||||
LDFLAGS = -L$(ZLIBLIB)
|
||||
LIBS = -lz -lm
|
||||
|
||||
# File extensions
|
||||
EXEEXT =
|
||||
|
||||
# Pre-built configuration
|
||||
# See scripts/pnglibconf.mak for more options
|
||||
PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
|
||||
|
||||
# Variables
|
||||
OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
|
||||
pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
|
||||
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
|
||||
|
||||
# Targets
|
||||
all: static
|
||||
|
||||
pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
|
||||
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
static: libpng.a pngtest$(EXEEXT)
|
||||
|
||||
shared:
|
||||
@echo This is a generic makefile that cannot create shared libraries.
|
||||
@echo Please use a configuration that is specific to your platform.
|
||||
@false
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
$(AR_RC) $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
test: pngtest$(EXEEXT)
|
||||
./pngtest$(EXEEXT)
|
||||
|
||||
pngtest$(EXEEXT): pngtest.o libpng.a
|
||||
$(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
|
||||
|
||||
clean:
|
||||
$(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h
|
||||
|
||||
png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
87
scripts/makefile.clang-asan
Normal file
87
scripts/makefile.clang-asan
Normal file
@ -0,0 +1,87 @@
|
||||
# makefile for libpng using clang + address sanitizer (generic, static library)
|
||||
# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2000, 2014, 2019 Cosmin Truta
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# Location of the zlib library and include files
|
||||
ZLIBINC = ../zlib
|
||||
ZLIBLIB = ../zlib
|
||||
|
||||
# Compiler, linker, lib and other tools
|
||||
CC = clang
|
||||
LD = $(CC)
|
||||
AR_RC = ar rcs
|
||||
RANLIB = ranlib
|
||||
CP = cp
|
||||
RM_F = rm -f
|
||||
|
||||
WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
|
||||
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
|
||||
CFLAGS = -W -Wall -O0 -g -fsanitize=address
|
||||
LDFLAGS = -L$(ZLIBLIB) -g -fsanitize=address
|
||||
LIBS = -lz -lm
|
||||
|
||||
# File extensions
|
||||
EXEEXT =
|
||||
|
||||
# Pre-built configuration
|
||||
# See scripts/pnglibconf.mak for more options
|
||||
PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
|
||||
|
||||
# Variables
|
||||
OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
|
||||
pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
|
||||
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
|
||||
|
||||
# Targets
|
||||
all: static
|
||||
|
||||
pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
|
||||
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
static: libpng.a pngtest$(EXEEXT)
|
||||
|
||||
shared:
|
||||
@echo This is a generic makefile that cannot create shared libraries.
|
||||
@echo Please use a configuration that is specific to your platform.
|
||||
@false
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
$(AR_RC) $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
test: pngtest$(EXEEXT)
|
||||
./pngtest$(EXEEXT)
|
||||
|
||||
pngtest$(EXEEXT): pngtest.o libpng.a
|
||||
$(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
|
||||
|
||||
clean:
|
||||
$(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h
|
||||
|
||||
png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
@ -200,7 +200,7 @@ clean:
|
||||
$(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
|
||||
libpng.pc $(LIBNAME).*dylib pngtesti pnglibconf.h
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -62,7 +62,7 @@ test: pngtest
|
||||
pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
|
||||
cp $(PNGLIBCONF_H_PREBUILT) $@
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# makefile for libpng using gcc (generic, static library)
|
||||
# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2000 Cosmin Truta
|
||||
# Copyright (C) 2000, 2014, 2019 Cosmin Truta
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
@ -24,7 +24,7 @@ WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
|
||||
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
|
||||
CFLAGS = -W -Wall -O2 # $(WARNMORE) -g
|
||||
LDFLAGS =
|
||||
LDFLAGS = -L$(ZLIBLIB)
|
||||
LIBS = -lz -lm
|
||||
|
||||
# File extensions
|
||||
@ -63,7 +63,7 @@ test: pngtest$(EXEEXT)
|
||||
./pngtest$(EXEEXT)
|
||||
|
||||
pngtest$(EXEEXT): pngtest.o libpng.a
|
||||
$(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest.o libpng.a $(LIBS)
|
||||
$(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
|
||||
|
||||
clean:
|
||||
$(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h
|
||||
|
87
scripts/makefile.gcc-asan
Normal file
87
scripts/makefile.gcc-asan
Normal file
@ -0,0 +1,87 @@
|
||||
# makefile for libpng using gcc + address sanitizer (generic, static library)
|
||||
# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2000, 2014, 2019 Cosmin Truta
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# Location of the zlib library and include files
|
||||
ZLIBINC = ../zlib
|
||||
ZLIBLIB = ../zlib
|
||||
|
||||
# Compiler, linker, lib and other tools
|
||||
CC = gcc
|
||||
LD = $(CC)
|
||||
AR_RC = ar rcs
|
||||
RANLIB = ranlib
|
||||
CP = cp
|
||||
RM_F = rm -f
|
||||
|
||||
WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
|
||||
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
|
||||
CFLAGS = -W -Wall -O0 -g -fsanitize=address
|
||||
LDFLAGS = -L$(ZLIBLIB) -g -fsanitize=address
|
||||
LIBS = -lz -lm
|
||||
|
||||
# File extensions
|
||||
EXEEXT =
|
||||
|
||||
# Pre-built configuration
|
||||
# See scripts/pnglibconf.mak for more options
|
||||
PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
|
||||
|
||||
# Variables
|
||||
OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
|
||||
pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
|
||||
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
|
||||
|
||||
# Targets
|
||||
all: static
|
||||
|
||||
pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
|
||||
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
static: libpng.a pngtest$(EXEEXT)
|
||||
|
||||
shared:
|
||||
@echo This is a generic makefile that cannot create shared libraries.
|
||||
@echo Please use a configuration that is specific to your platform.
|
||||
@false
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
$(AR_RC) $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
test: pngtest$(EXEEXT)
|
||||
./pngtest$(EXEEXT)
|
||||
|
||||
pngtest$(EXEEXT): pngtest.o libpng.a
|
||||
$(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
|
||||
|
||||
clean:
|
||||
$(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h
|
||||
|
||||
png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
@ -1,7 +1,7 @@
|
||||
# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
|
||||
# Copyright (C) 1999-2002, 2006, 2009, 2010-2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42
|
||||
# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
|
||||
# Contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@ -206,7 +206,7 @@ clean:
|
||||
libpng-config $(LIBSO) $(LIBSOMAJ)* \
|
||||
libpng.pc pnglibconf.h
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -209,7 +209,7 @@ clean:
|
||||
libpng-config $(LIBSO) $(LIBSOMAJ)* \
|
||||
libpng.pc pnglibconf.h
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
|
||||
# Copyright (C) 1999-2002, 2006, 2010-2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42
|
||||
# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
|
||||
# Contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@ -204,7 +204,7 @@ clean:
|
||||
libpng-config $(LIBSO) $(LIBSOMAJ)* \
|
||||
libpng.pc pnglibconf.h
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -1,116 +0,0 @@
|
||||
# makefile for libpng
|
||||
# Copyright (C) 2002, 2006, 2009, 2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
#
|
||||
# This makefile requires the file ansi2knr.c, which you can get
|
||||
# from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/
|
||||
# If you have libjpeg, you probably already have ansi2knr.c in the jpeg
|
||||
# source distribution.
|
||||
|
||||
# where make install puts libpng.a and png.h
|
||||
prefix=/usr/local
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(prefix)/lib
|
||||
|
||||
# override DESTDIR= on the make install command line to easily support
|
||||
# installing into a temporary location. Example:
|
||||
#
|
||||
# make install DESTDIR=/tmp/build/libpng
|
||||
#
|
||||
# If you're going to install into a temporary location
|
||||
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
|
||||
# you execute make install.
|
||||
DESTDIR=
|
||||
|
||||
CC = cc
|
||||
CPPFLAGS = -I../zlib
|
||||
CFLAGS = -O
|
||||
LDFLAGS = -L. -L../zlib/ -lpng -lz -lm
|
||||
# flags for ansi2knr
|
||||
ANSI2KNRFLAGS=
|
||||
|
||||
RANLIB = ranlib
|
||||
#RANLIB = echo
|
||||
|
||||
CP = cp
|
||||
RM_F = rm -f
|
||||
|
||||
# Pre-built configuration
|
||||
# See scripts/pnglibconf.mak for more options
|
||||
PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
|
||||
|
||||
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
|
||||
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
|
||||
pngwtran.o pngmem.o pngerror.o pngpread.o
|
||||
|
||||
all: ansi2knr libpng.a pngtest
|
||||
|
||||
pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
|
||||
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
|
||||
|
||||
# general rule to allow ansi2knr to work
|
||||
.c.o:
|
||||
./ansi2knr $*.c T$*.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c T$*.c
|
||||
rm -f T$*.c $*.o
|
||||
mv T$*.o $*.o
|
||||
|
||||
ansi2knr: ansi2knr.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c
|
||||
|
||||
libpng.a: ansi2knr $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
pngtest: pngtest.o libpng.a
|
||||
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||
|
||||
test: pngtest
|
||||
./pngtest
|
||||
|
||||
install: libpng.a png.h pngconf.h pnglibconf.h
|
||||
-@mkdir $(DESTDIR)$(INCPATH)
|
||||
-@mkdir $(DESTDIR)$(INCPATH)/libpng
|
||||
-@mkdir $(DESTDIR)$(LIBPATH)
|
||||
-@rm -f $(DESTDIR)$(INCPATH)/png.h
|
||||
-@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
|
||||
cp png.h $(DESTDIR)$(INCPATH)/libpng
|
||||
cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
|
||||
cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng
|
||||
chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
|
||||
chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
|
||||
chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h
|
||||
(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
|
||||
cp libpng.a $(DESTDIR)$(LIBPATH)
|
||||
chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
|
||||
|
||||
clean:
|
||||
$(RM_F) *.o libpng.a pngtest pngout.png ansi2knr pnglibconf.h
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
@ -10,7 +10,7 @@
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
RELEASE = 35
|
||||
RELEASE = 37
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@ -50,8 +50,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
# for pgcc version 2.95.1, -O3 is buggy; don't use it.
|
||||
|
||||
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
|
||||
CFLAGS= -W -Wall -O3 -funroll-loops \
|
||||
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
CFLAGS=-W -Wall -O3 -funroll-loops $(ALIGN) # $(WARNMORE) -g
|
||||
|
||||
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm
|
||||
LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
|
||||
@ -222,7 +221,7 @@ clean:
|
||||
$(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
|
||||
libpng.pc pnglibconf.h
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
RELEASE = 35
|
||||
RELEASE = 37
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@ -232,7 +232,7 @@ clean:
|
||||
$(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
|
||||
libpng.pc pnglibconf.h
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -78,7 +78,7 @@ install: libpng.a
|
||||
clean:
|
||||
rm -f *.o libpng.a pngtest pngout.png pnglibconf.h
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
|
||||
writelock:
|
||||
chmod a-w *.[ch35] $(DOCS) scripts/*
|
||||
|
||||
|
@ -1,100 +0,0 @@
|
||||
# makefile for libpng
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
# Copyright (C) 2006, 2009, 2014 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
#
|
||||
# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
|
||||
|
||||
# -------- Microsoft C 5.1 and later, does not use assembler code --------
|
||||
MODEL=L
|
||||
CPPFLAGS=-I..\zlib
|
||||
CFLAGS=-Oait -Gs -nologo -W3 -A$(MODEL)
|
||||
#-Ox generates bad code with MSC 5.1
|
||||
CC=cl
|
||||
LD=link
|
||||
LDFLAGS=/e/st:0x1500/noe
|
||||
CP=copy
|
||||
O=.obj
|
||||
|
||||
# Pre-built configuration
|
||||
# See scripts\pnglibconf.mak for more options
|
||||
PNGLIBCONF_H_PREBUILT = scripts\pnglibconf.h.prebuilt
|
||||
|
||||
#uncomment next to put error messages in a file
|
||||
ERRFILE= >> pngerrs
|
||||
|
||||
# variables
|
||||
OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
|
||||
OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
|
||||
OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O)
|
||||
|
||||
all: libpng.lib
|
||||
|
||||
pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
|
||||
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
|
||||
|
||||
png$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngset$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngget$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngpread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngrtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngrutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngerror$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngmem$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngrio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngtrans$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwrite$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||
del libpng.lib
|
||||
lib libpng $(OBJS1);
|
||||
lib libpng $(OBJS2);
|
||||
lib libpng $(OBJS3);
|
||||
|
||||
pngtest$(O): png.h pngconf.h pnglibconf.h
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngtest.exe: pngtest.obj libpng.lib
|
||||
$(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ;
|
||||
|
||||
test: pngtest.exe
|
||||
pngtest
|
||||
|
||||
# End of makefile for libpng
|
||||
|
@ -1,10 +1,11 @@
|
||||
# makefile for libpng using MSYS/gcc (shared, static library)
|
||||
# Copyright (C) 2019 Cosmin Truta
|
||||
# Copyright (C) 2012 Glenn Randers-Pehrson and Christopher M. Wheeler
|
||||
#
|
||||
# Portions taken from makefile.linux:
|
||||
# Portions taken from makefile.linux and makefile.gcc:
|
||||
# Copyright (C) 2000 Cosmin Truta
|
||||
# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2014 Greg Roelofs and
|
||||
# Glenn Randers-Pehrson
|
||||
# Copyright (C) 2000 Cosmin Truta
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
@ -18,7 +19,7 @@ exec_prefix=$(prefix)
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
RELEASE = 35
|
||||
RELEASE = 37
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).dll
|
||||
@ -176,7 +177,7 @@ test: pngtest$(EXEEXT)
|
||||
./pngtest$(EXEEXT)
|
||||
|
||||
pngtest$(EXEEXT): pngtest.o libpng.a
|
||||
$(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest.o libpng.a $(LIBS)
|
||||
$(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
|
||||
|
||||
clean:
|
||||
$(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h $(LIBSO) \
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user