[libpng16] Bump version to 1.6.1beta05
134
ANNOUNCE
@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.6.0beta05 - February 3, 2012
|
||||
Libpng 1.6.1beta05 - March 2, 2013
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
@ -9,105 +9,65 @@ Files available for download:
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
1.6.0beta05.tar.xz (LZMA-compressed, recommended)
|
||||
1.6.0beta05.tar.gz
|
||||
1.6.0beta05.tar.bz2
|
||||
1.6.1beta05.tar.xz (LZMA-compressed, recommended)
|
||||
1.6.1beta05.tar.gz
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
lp160b05.7z (LZMA-compressed, recommended)
|
||||
lp160b05.zip
|
||||
lp161b05.7z (LZMA-compressed, recommended)
|
||||
lp161b05.zip
|
||||
|
||||
Other information:
|
||||
|
||||
1.6.0beta05-README.txt
|
||||
1.6.0beta05-LICENSE.txt
|
||||
1.6.1beta05-README.txt
|
||||
1.6.1beta05-LICENSE.txt
|
||||
|
||||
Changes since the last public release (1.5.7):
|
||||
Changes since the last public release (1.6.0):
|
||||
|
||||
Version 1.6.0beta01 [December 15, 2011]
|
||||
Removed machine-generated configure files from the GIT repository (they will
|
||||
continue to appear in the tarball distributions).
|
||||
Restored the new 'simplified' API, which was started in libpng-1.5.7beta02
|
||||
but later deleted from libpng-1.5.7beta05.
|
||||
Added example programs for the new 'simplified' API.
|
||||
Added ANSI-C (C90) headers and require them, and take advantage of the
|
||||
change. Also fixed some of the projects/* and contrib/* files that needed
|
||||
updates for libpng16 and the move of pngvalid.c.
|
||||
With this change the required ANSI-C header files are assumed to exist: the
|
||||
implementation must provide float.h, limits.h, stdarg.h and stddef.h and
|
||||
libpng relies on limits.h and stddef.h existing and behaving as defined
|
||||
(the other two required headers aren't used). Non-ANSI systems that don't
|
||||
have stddef.h or limits.h will have to provide an appropriate fake
|
||||
containing the relevant types and #defines.
|
||||
The use of FAR/far has been eliminated and the definition of png_alloc_size_t
|
||||
is now controlled by a flag so that 'small size_t' systems can select it
|
||||
if necessary. Libpng 1.6 may not currently work on such systems -- it
|
||||
seems likely that it will ask 'malloc' for more than 65535 bytes with any
|
||||
image that has a sufficiently large row size (rather than simply failing
|
||||
to read such images).
|
||||
New tools directory containing tools used to generate libpng code.
|
||||
Fixed race conditions in parallel make builds. With higher degrees of
|
||||
parallelism during 'make' the use of the same temporary file names such
|
||||
as 'dfn*' can result in a race where a temporary file from one arm of the
|
||||
build is deleted or overwritten in another arm. This changes the
|
||||
temporary files for suffix rules to always use $* and ensures that the
|
||||
non-suffix rules use unique file names.
|
||||
Version 1.6.1beta01 [February 16, 2013]
|
||||
Made symbol prefixing work with the ARM neon optimizations. Also allow
|
||||
pngpriv.h to be included for preprocessor definitions only, so it can
|
||||
be used in non-C/C++ files. Back ported from libpng 1.7.
|
||||
Made sRGB check numbers consistent.
|
||||
Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug.
|
||||
Removed cc -E workround, corrected png_get_palette_max API Tested on
|
||||
SUN OS cc 5.9, which demonstrates the tokenization problem previously
|
||||
avoided by using /lib/cpp. Since all .dfn output is now protected in
|
||||
double quotes unless it is to be macro substituted the fix should
|
||||
work everywhere.
|
||||
Enabled parallel tests - back ported from libpng-1.7.
|
||||
scripts/pnglibconf.dfa formatting improvements back ported from libpng17.
|
||||
Fixed a race condition in the creation of the build 'scripts' directory
|
||||
while building with a parallel make.
|
||||
Use approved/supported Android method to check for NEON, use Linux/POSIX
|
||||
1003.1 API to check /proc/self/auxv avoiding buffer allocation and other
|
||||
library calls (ported from libpng15).
|
||||
|
||||
Version 1.6.0beta02 [December 21, 2011]
|
||||
Correct configure builds where build and source directories are separate.
|
||||
The include path of 'config.h' was erroneously made relative in pngvalid.c
|
||||
in libpng 1.5.7.
|
||||
Version 1.6.1beta02 [February 19, 2013]
|
||||
Use parentheses more consistently in "#if defined(MACRO)" tests.
|
||||
Folded long lines.
|
||||
Reenabled code to allow zero length PLTE chunks for MNG.
|
||||
|
||||
Version 1.6.0beta03 [December 22, 2011]
|
||||
Start-up code size improvements, error handler flexibility. These changes
|
||||
alter how the tricky allocation of the initial png_struct and png_info
|
||||
structures are handled. png_info is now handled in pretty much the same
|
||||
way as everything else, except that the allocations handle NULL return
|
||||
silently. png_struct is changed in a similar way on allocation and on
|
||||
deallocation a 'safety' error handler is put in place (which should never
|
||||
be required). The error handler itself is changed to permit mismatches
|
||||
in the application and libpng error buffer size; however, this means a
|
||||
silent change to the API to return the jmp_buf if the size doesn't match
|
||||
the size from the libpng compilation; libpng now allocates the memory and
|
||||
this may fail. Overall these changes result in slight code size
|
||||
reductions; however, this is a reduction in code that is always executed
|
||||
so is particularly valuable. Overall on a 64-bit system the libpng DLL
|
||||
decreases in code size by 1733 bytes. pngerror.o increases in size by
|
||||
about 465 bytes because of the new functionality.
|
||||
Version 1.6.1beta03 [February 22, 2013]
|
||||
Fixed ALIGNED_MEMORY support.
|
||||
Allow run-time ARM NEON checking to be disabled. A new configure option:
|
||||
--enable-arm-neon=always will stop the run-time checks. New checks
|
||||
within arm/arm_init.c will cause the code not to be compiled unless
|
||||
__ARM_NEON__ is set. This should make it fail safe (if someone asks
|
||||
for it on then the build will fail if it can't be done.)
|
||||
Updated the INSTALL document.
|
||||
|
||||
Version 1.6.0beta04 [December 30, 2011]
|
||||
Regenerated configure scripts with automake-1.11.2
|
||||
Eliminated png_info_destroy(). It is now used only in png.c and only calls
|
||||
one other internal function and memset().
|
||||
Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously
|
||||
it was disabled whenever internal fixed point arithmetic was selected,
|
||||
which meant it didn't exist even on systems where FP was available but not
|
||||
preferred.
|
||||
Added pngvalid.c compile time checks for const APIs.
|
||||
Implemented 'restrict' for png_info and png_struct. Because of the way
|
||||
libpng works both png_info and png_struct are always accessed via a
|
||||
single pointer. This means adding C99 'restrict' to the pointer gives
|
||||
the compiler some opportunity to optimize the code. This change allows
|
||||
that.
|
||||
Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper
|
||||
location in configure.ac (Gilles Espinasse).
|
||||
Changed png_memcpy to C assignment where appropriate. Changed all those
|
||||
uses of png_memcpy that were doing a simple assignment to assignments
|
||||
(all those cases where the thing being copied is a non-array C L-value).
|
||||
Added some error checking to png_set_*() routines.
|
||||
Removed the reference to the non-exported function png_memcpy() from
|
||||
example.c.
|
||||
Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but
|
||||
it had become misaligned.
|
||||
Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32
|
||||
and unsigned long are of different sizes.
|
||||
Version 1.6.1beta04 [February 27, 2013]
|
||||
Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
|
||||
Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC.
|
||||
Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
|
||||
with CRLF line endings.
|
||||
|
||||
Version 1.6.0beta05 [February 3, 2012]
|
||||
Updated manual with description of the simplified API (copied from png.h)
|
||||
Fix bug in pngerror.c: some long warnings were being improperly truncated
|
||||
(bug introduced in libpng-1.5.3beta05).
|
||||
Version 1.6.1beta05 [March 2, 2013]
|
||||
Avoid a possible memory leak in contrib/gregbook/readpng.c
|
||||
Fixed bug introduced in libpng-1.6.0beta28 that causes libpng to handle chunks
|
||||
even when they have been tagged PNG_HANDLE_CHUNK_NEVER.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
574
CHANGES
@ -3672,7 +3672,8 @@ Version 1.5.6 [November 3, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.7beta01 [November 4, 2011]
|
||||
Added support for ARM processor (Mans Rullgard)
|
||||
Added support for ARM processor, when decoding all PNG up-filtered rows
|
||||
and any other-filtered rows with 3 or 4 bytes per pixel (Mans Rullgard).
|
||||
Fixed bug in pngvalid on early allocation failure; fixed type cast in
|
||||
pngmem.c; pngvalid would attempt to call png_error() if the allocation
|
||||
of a png_struct or png_info failed. This would probably have led to a
|
||||
@ -3779,7 +3780,8 @@ Version 1.5.7 [December 15, 2011]
|
||||
|
||||
Version 1.6.0beta01 [December 15, 2011]
|
||||
Removed machine-generated configure files from the GIT repository (they will
|
||||
continue to appear in the tarball distributions).
|
||||
continue to appear in the tarball distributions and in the libpng15 and
|
||||
earlier GIT branches).
|
||||
Restored the new 'simplified' API, which was started in libpng-1.5.7beta02
|
||||
but later deleted from libpng-1.5.7beta05.
|
||||
Added example programs for the new 'simplified' API.
|
||||
@ -3827,6 +3829,8 @@ Version 1.6.0beta03 [December 22, 2011]
|
||||
so is particularly valuable. Overall on a 64-bit system the libpng DLL
|
||||
decreases in code size by 1733 bytes. pngerror.o increases in size by
|
||||
about 465 bytes because of the new functionality.
|
||||
Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123()
|
||||
to avoid including a spurious buffer in the png_struct.
|
||||
|
||||
Version 1.6.0beta04 [December 30, 2011]
|
||||
Regenerated configure scripts with automake-1.11.2
|
||||
@ -3855,10 +3859,572 @@ Version 1.6.0beta04 [December 30, 2011]
|
||||
Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32
|
||||
and unsigned long are of different sizes.
|
||||
|
||||
Version 1.6.0beta05 [February 3, 2012]
|
||||
Version 1.6.0beta05 [January 15, 2012]
|
||||
Updated manual with description of the simplified API (copied from png.h)
|
||||
Fix bug in pngerror.c: some long warnings were being improperly truncated
|
||||
(bug introduced in libpng-1.5.3beta05).
|
||||
(CVE-2011-3464, bug introduced in libpng-1.5.3beta05).
|
||||
|
||||
Version 1.6.0beta06 [January 24, 2012]
|
||||
Added palette support to the simplified APIs. This commit
|
||||
changes some of the macro definitions in png.h, app code
|
||||
may need corresponding changes.
|
||||
Increased the formatted warning buffer to 192 bytes.
|
||||
Added color-map support to simplified API. This is an initial version for
|
||||
review; the documentation has not yet been updated.
|
||||
Fixed Min/GW uninstall to remove libpng.dll.a
|
||||
|
||||
Version 1.6.0beta07 [January 28, 2012]
|
||||
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
|
||||
compiler issues slightly different warnings from those issued by the
|
||||
current vesions of GCC. This eliminates those warnings by
|
||||
adding/removing casts and small code rewrites.
|
||||
Updated configure.ac from autoupdate: added --enable-werror option.
|
||||
Also some layout regularization and removal of introduced tab characters
|
||||
(replaced with 3-character indentation). Obsolete macros identified by
|
||||
autoupdate have been removed; the replacements are all in 2.59 so
|
||||
the pre-req hasn't been changed. --enable-werror checks for support
|
||||
for -Werror (or the given argument) in the compiler. This mimics the
|
||||
gcc configure option by allowing -Werror to be turned on safely; without
|
||||
the option the tests written in configure itself fail compilation because
|
||||
they cause compiler warnings.
|
||||
Rewrote autogen.sh to run autoreconf instead of running tools one-by-one.
|
||||
Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and
|
||||
set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp).
|
||||
Freeze libtool files in the 'scripts' directory. This version of autogen.sh
|
||||
attempts to dissuade people from running it when it is not, or should not,
|
||||
be necessary. In fact, autogen.sh does not work when run in a libpng
|
||||
directory extracted from a tar distribution anymore. You must run it in
|
||||
a GIT clone instead.
|
||||
Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale),
|
||||
and renamed three whose names were inconsistent with those in
|
||||
pngsuite/README.txt.
|
||||
|
||||
Version 1.6.0beta08 [February 1, 2012]
|
||||
Fixed Image::colormap misalignment in pngstest.c
|
||||
Check libtool/libtoolize version number (2.4.2) in configure.ac
|
||||
Divide test-pngstest.sh into separate pngstest runs for basic and
|
||||
transparent images.
|
||||
Moved automake options to AM_INIT_AUTOMAKE in configure.ac
|
||||
Added color-tests, silent-rules (Not yet implemented in Makefile.am) and
|
||||
version checking to configure.ac
|
||||
Improved pngstest speed by not doing redundant tests and add const to
|
||||
the background parameter of png_image_finish_read. The --background
|
||||
option is now done automagically only when required, so that commandline
|
||||
option no longer exists.
|
||||
Cleaned up pngpriv.h to consistently declare all functions and data.
|
||||
Also eliminated PNG_CONST_DATA, which is apparently not needed but we
|
||||
can't be sure until it is gone.
|
||||
Added symbol prefixing that allows all the libpng external symbols
|
||||
to be prefixed (suggested by Reuben Hawkins).
|
||||
Updated "ftbb*.png" list in the owatcom and vstudio projects.
|
||||
Fixed 'prefix' builds on clean systems. The generation of pngprefix.h
|
||||
should not require itself.
|
||||
Updated INSTALL to explain that autogen.sh must be run in a GIT clone,
|
||||
not in a libpng directory extracted from a tar distribution.
|
||||
|
||||
Version 1.6.0beta09 [February 1, 2012]
|
||||
Reverted the prebuilt configure files to libpng-1.6.0beta05 condition.
|
||||
|
||||
Version 1.6.0beta10 [February 3, 2012]
|
||||
Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests
|
||||
Updated list of test images in CMakeLists.txt
|
||||
Updated the prebuilt configure files to current condition.
|
||||
Revised INSTALL information about autogen.sh; it works in tar distributions.
|
||||
|
||||
Version 1.6.0beta11 [February 16, 2012]
|
||||
Fix character count in pngstest command in projects/owatcom/pngstest.tgt
|
||||
Revised test-pngstest.sh to report PASS/FAIL for each image.
|
||||
Updated documentation about the simplified API.
|
||||
Corrected estimate of error in libpng png_set_rgb_to_gray API. The API is
|
||||
extremely inaccurate for sRGB conversions because it uses an 8-bit
|
||||
intermediate linear value and it does not use the sRGB transform, so it
|
||||
suffers from the known instability in gamma transforms for values close
|
||||
to 0 (see Poynton). The net result is that the calculation has a maximum
|
||||
error of 14.99/255; 0.5/255^(1/2.2). pngstest now uses 15 for the
|
||||
permitted 8-bit error. This may still not be enough because of arithmetic
|
||||
error.
|
||||
Removed some unused arrays (with #ifdef) from png_read_push_finish_row().
|
||||
Fixed a memory overwrite bug in simplified read of RGB PNG with
|
||||
non-linear gamma Also bugs in the error checking in pngread.c and changed
|
||||
quite a lot of the checks in pngstest.c to be correct; either correctly
|
||||
written or not over-optimistic. The pngstest changes are insufficient to
|
||||
allow all possible RGB transforms to be passed; pngstest cmppixel needs
|
||||
to be rewritten to make it clearer which errors it allows and then changed
|
||||
to permit known inaccuracies.
|
||||
Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h
|
||||
Fixed fixed/float API export conditionals. 1) If FIXED_POINT or
|
||||
FLOATING_POINT options were switched off, png.h ended up with lone ';'
|
||||
characters. This is not valid ANSI-C outside a function. The ';'
|
||||
characters have been moved inside the definition of PNG_FP_EXPORT and
|
||||
PNG_FIXED_EXPORT. 2) If either option was switched off, the declaration
|
||||
of the corresponding functions were completely omitted, even though some
|
||||
of them are still used internally. The result is still valid, but
|
||||
produces warnings from gcc with some warning options (including -Wall). The
|
||||
fix is to cause png.h to declare the functions with PNG_INTERNAL_FUNCTION
|
||||
when png.h is included from pngpriv.h.
|
||||
Check for invalid palette index while reading paletted PNG. When one is
|
||||
found, issue a warning and increase png_ptr->num_palette accordingly.
|
||||
Apps are responsible for checking to see if that happened.
|
||||
|
||||
Version 1.6.0beta12 [February 18, 2012]
|
||||
Do not increase num_palette on invalid_index.
|
||||
Relocated check for invalid palette index to pngrtran.c, after unpacking
|
||||
the sub-8-bit pixels.
|
||||
Fixed CVE-2011-3026 buffer overrun bug. This bug was introduced when
|
||||
iCCP chunk support was added at libpng-1.0.6. Deal more correctly with the
|
||||
test on iCCP chunk length. Also removed spurious casts that may hide
|
||||
problems on 16-bit systems.
|
||||
|
||||
Version 1.6.0beta13 [February 24, 2012]
|
||||
Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from
|
||||
pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c;
|
||||
now that png_ptr->buffer is inaccessible to applications, the special
|
||||
handling is no longer useful.
|
||||
Added PNG_SAFE_LIMITS feature to pnglibconf.dfa, pngpriv.h, and new
|
||||
pngusr.dfa to reset the user limits to safe ones if PNG_SAFE_LIMITS is
|
||||
defined. To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED=1" on the
|
||||
configure command or put #define PNG_SAFE_LIMITS_SUPPORTED in
|
||||
pnglibconf.h.prebuilt and pnglibconf.h.
|
||||
|
||||
Version 1.6.0beta14 [February 27, 2012]
|
||||
Added information about the new limits in the manual.
|
||||
Updated Makefile.in
|
||||
|
||||
Version 1.6.0beta15 [March 2, 2012]
|
||||
Removed unused "current_text" members of png_struct and the png_free()
|
||||
of png_ptr->current_text from pngread.c
|
||||
Rewrote pngstest.c for substantial speed improvement.
|
||||
Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a
|
||||
spurious check in pngwrite.c
|
||||
Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store
|
||||
intermediate files, or intermediate in-memory data, while processing
|
||||
image data with the simplified API. The option makes the files larger
|
||||
but faster to write and read. pngstest now uses this by default; this
|
||||
can be disabled with the --slow option.
|
||||
Improved pngstest fine tuning of error numbers, new test file generator.
|
||||
The generator generates images that test the full range of sample values,
|
||||
allow the error numbers in pngstest to be tuned and checked. makepng
|
||||
also allows generation of images with extra chunks, although this is
|
||||
still work-in-progress.
|
||||
Added check for invalid palette index while reading.
|
||||
Fixed some bugs in ICC profile writing. The code should now accept
|
||||
all potentially valid ICC profiles and reject obviously invalid ones.
|
||||
It now uses png_error() to do so rather than casually writing a PNG
|
||||
without the necessary color data.
|
||||
Removed whitespace from the end of lines in all source files and scripts.
|
||||
|
||||
Version 1.6.0beta16 [March 6, 2012]
|
||||
Relocated palette-index checking function from pngrutil.c to pngtrans.c
|
||||
Added palette-index checking while writing.
|
||||
Changed png_inflate() and calling routines to avoid overflow problems.
|
||||
This is an intermediate check-in that solves the immediate problems and
|
||||
introduces one performance improvement (avoiding a copy via png_ptr->zbuf.)
|
||||
Further changes will be made to make ICC profile handling more secure.
|
||||
Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options
|
||||
declares 'index' as a global, causing a warning if it is used as a local
|
||||
variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit)
|
||||
to an (int) (signed 32-bit). MSVC, however, warns about using the
|
||||
unary '-' operator on an unsigned value (even though it is well defined
|
||||
by ANSI-C to be ~x+1). The padding calculation was changed to use a
|
||||
different method. Removed the tests on png_ptr->pass.
|
||||
Added contrib/libtests/tarith.c to test internal arithmetic functions from
|
||||
png.c. This is a libpng maintainer program used to validate changes to the
|
||||
internal arithmetic functions.
|
||||
Made read 'inflate' handling like write 'deflate' handling. The read
|
||||
code now claims and releases png_ptr->zstream, like the write code.
|
||||
The bug whereby the progressive reader failed to release the zstream
|
||||
is now fixed, all initialization is delayed, and the code checks for
|
||||
changed parameters on deflate rather than always calling
|
||||
deflatedEnd/deflateInit.
|
||||
Validate the zTXt strings in pngvalid.
|
||||
Added code to validate the windowBits value passed to deflateInit2().
|
||||
If the call to deflateInit2() is wrong a png_warning will be issued
|
||||
(in fact this is harmless, but the PNG data produced may be sub-optimal).
|
||||
|
||||
Version 1.6.0beta17 [March 10, 2012]
|
||||
Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
|
||||
Reject all iCCP chunks after the first, even if the first one is invalid.
|
||||
Deflate/inflate was reworked to move common zlib calls into single
|
||||
functions [rw]util.c. A new shared keyword check routine was also added
|
||||
and the 'zbuf' is no longer allocated on progressive read. It is now
|
||||
possible to call png_inflate() incrementally.
|
||||
If benign errors are disabled use maximum window on ancilliary inflate.
|
||||
This works round a bug introduced in 1.5.4 where compressed ancillary
|
||||
chunks could end up with a too-small windowBits value in the deflate
|
||||
header.
|
||||
|
||||
Version 1.6.0beta18 [March 16, 2012]
|
||||
Issue a png_benign_error() instead of png_warning() about bad palette index.
|
||||
In pngtest, treat benign errors as errors if "-strict" is present.
|
||||
Fixed an off-by-one error in the palette index checking function.
|
||||
Fixed a compiler warning under Cygwin (Windows-7, 32-bit system)
|
||||
Revised example.c to put text strings in a temporary character array
|
||||
instead of directly assigning string constants to png_textp members.
|
||||
This avoids compiler warnings when -Wwrite-strings is enabled.
|
||||
Added output flushing to aid debugging under Visual Studio. Unfortunately
|
||||
this is necessary because the VS2010 output window otherwise simply loses
|
||||
the error messages on error (they weren't flushed to the window before
|
||||
the process exited, apparently!)
|
||||
Added configuration support for benign errors and changed the read
|
||||
default. Also changed some warnings in the iCCP and sRGB handling
|
||||
from to benign errors. Configuration now makes read benign
|
||||
errors warnings and write benign errors to errors by default (thus
|
||||
changing the behavior on read). The simplified API always forces
|
||||
read benign errors to warnings (regardless of the system default, unless
|
||||
this is disabled in which case the simplified API can't be built.)
|
||||
|
||||
Version 1.6.0beta19 [March 18, 2012]
|
||||
Work around for duplicate row start calls; added warning messages.
|
||||
This turns on PNG_FLAG_DETECT_UNINITIALIZED to detect app code that
|
||||
fails to call one of the 'start' routines (not enabled in libpng-1.5
|
||||
because it is technically an API change, since it did normally work
|
||||
before.) It also makes duplicate calls to png_read_start_row (an
|
||||
internal function called at the start of the image read) benign, as
|
||||
they were before changes to use png_inflate_claim. Somehow webkit is
|
||||
causing this to happen; this is probably a mis-feature in the zlib
|
||||
changes so this commit is only a work-round.
|
||||
Removed erroneous setting of DETECT_UNINITIALIZED and added more
|
||||
checks. The code now does a png_error if an attempt is made to do the
|
||||
row initialization twice; this is an application error and it has
|
||||
serious consequences because the transform data in png_struct is
|
||||
changed by each call.
|
||||
Added application error reporting and added chunk names to read
|
||||
benign errors; also added --strict to pngstest - not enabled
|
||||
yet because a warning is produced.
|
||||
Avoid the double gamma correction warning in the simplified API.
|
||||
This allows the --strict option to pass in the pngstest checks
|
||||
|
||||
Version 1.6.0beta20 [March 29, 2012]
|
||||
Changed chunk handler warnings into benign errors, incrementally load iCCP
|
||||
Added checksum-icc.c to contrib/tools
|
||||
Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice.
|
||||
Recognize known sRGB ICC profiles while reading; prefer writing the
|
||||
iCCP profile over writing the sRGB chunk, controlled by the
|
||||
PNG_sRGB_PROFILE_CHECKS option.
|
||||
Revised png_set_text_2() to avoid potential memory corruption (fixes
|
||||
CVE-2011-3048, also known as CVE-2012-3425).
|
||||
|
||||
Version 1.6.0beta21 [April 27, 2012]
|
||||
Revised scripts/makefile.darwin: use system zlib; remove quotes around
|
||||
architecture list; add missing ppc architecture; add architecture options
|
||||
to shared library link; don't try to create a shared lib based on missing
|
||||
RELEASE variable.
|
||||
Enable png_set_check_for_invalid_index() for both read and write.
|
||||
Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpriv.h around
|
||||
declaration of png_handle_unknown().
|
||||
Added -lssp_nonshared in a comment in scripts/makefile.freebsd
|
||||
and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE.
|
||||
|
||||
Version 1.6.0beta22 [May 23, 2012]
|
||||
Removed need for -Wno-cast-align with clang. clang correctly warns on
|
||||
alignment increasing pointer casts when -Wcast-align is passed. This
|
||||
fixes the cases that clang warns about either by eliminating the
|
||||
casts from png_bytep to png_uint_16p (pngread.c), or, for pngrutil.c
|
||||
where the cast is previously verified or pngstest.c where it is OK, by
|
||||
introducing new png_aligncast macros to do the cast in a way that clang
|
||||
accepts.
|
||||
|
||||
Version 1.6.0beta23 [June 6, 2012]
|
||||
Revised CMakeLists.txt to not attempt to make a symlink under mingw.
|
||||
Made fixes for new optimization warnings from gcc 4.7.0. The compiler
|
||||
performs an optimization which is safe; however it then warns about it.
|
||||
Changing the type of 'palette_number' in pngvalid.c removes the warning.
|
||||
Do not depend upon a GCC feature macro being available for use in generating
|
||||
the linker mapfile symbol prefix.
|
||||
Improved performance of new do_check_palette_indexes() function (only
|
||||
update the value when it actually increases, move test for whether
|
||||
the check is wanted out of the function.
|
||||
|
||||
Version 1.6.0beta24 [June 7, 2012]
|
||||
Don't check palette indexes if num_palette is 0 (as it can be in MNG files).
|
||||
|
||||
Version 1.6.0beta25 [June 16, 2012]
|
||||
Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all
|
||||
unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT,
|
||||
and IEND. Previously it only meant ignore all unknown chunks, the
|
||||
same as num_chunks == 0. Revised png_image_skip_unused_chunks() to
|
||||
provide a list of chunks to be processed instead of a list of chunks to
|
||||
ignore. Revised contrib/gregbook/readpng2.c accordingly.
|
||||
|
||||
Version 1.6.0beta26 [July 10, 2012]
|
||||
Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it
|
||||
depends on configure, which is not included in those archives.
|
||||
Moved scripts/chkfmt to contrib/tools.
|
||||
Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386.
|
||||
|
||||
Version 1.6.0beta27 [August 11, 2012]
|
||||
Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3.
|
||||
Do not use __restrict when GNUC is <= 3.1
|
||||
Removed references to png_zalloc() and png_zfree() from the manual.
|
||||
Fixed configurations where floating point is completely disabled. Because
|
||||
of the changes to support symbol prefixing PNG_INTERNAL_FUNCTION declares
|
||||
floating point APIs during libpng builds even if they are completely
|
||||
disabled. This requires the png floating point types (png_double*) to be
|
||||
declared even though the functions are never actually defined. This
|
||||
change provides a dummy definition so that the declarations work, yet any
|
||||
implementation will fail to compile because of an incomplete type.
|
||||
Re-eliminated the use of strcpy() in pngtest.c. An unncessary use of
|
||||
strcpy() was accidentally re-introduced in libpng16; this change replaces
|
||||
it with strncpy().
|
||||
Eliminated use of png_sizeof(); use sizeof() instead.
|
||||
Use a consistent style for (sizeof type) and (sizeof (array))
|
||||
Cleanup of png_set_filler(). This function does very different things on
|
||||
read and write. In libpng 1.6 the two cases can be distinguished and
|
||||
considerable code cleanup, and extra error checking, is possible. This
|
||||
makes calls on the write side that have no effect be ignored with a
|
||||
png_app_error(), which can be disabled in the app using
|
||||
png_set_benign_errors(), and removes the spurious use of usr_channels
|
||||
on the read side.
|
||||
Insist on autotools 1.12.1 for git builds because there are security issues
|
||||
with 1.12 and insisting on anything less would allow 1.12 to be used.
|
||||
Removed info_ptr->signature[8] from WRITE-only builds.
|
||||
Add some conditions for compiling png_fixed(). This is a small function
|
||||
but it requires "-lm" on some platforms.
|
||||
Cause pngtest --strict to fail on any warning from libpng (not just errors)
|
||||
and cause it not to fail at the comparison step if libpng lacks support
|
||||
for writing chunks that it reads from the input (currently only implemented
|
||||
for compressed text chunks).
|
||||
Make all three "make check" test programs work without READ or WRITE support.
|
||||
Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ
|
||||
or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading
|
||||
and writing of a PNG file is always tested by one or more of the tests.
|
||||
Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the
|
||||
png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros.
|
||||
Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and
|
||||
png_memcmp() macros.
|
||||
Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object
|
||||
to the split initialization of num_chunks.
|
||||
|
||||
Version 1.6.0beta28 [August 29, 2012]
|
||||
Unknown handling fixes and clean up. This adds more correct option
|
||||
control of the unknown handling, corrects the pre-existing bug where
|
||||
the per-chunk 'keep' setting is ignored and makes it possible to skip
|
||||
IDAT chunks in the sequential reader (broken in earlier 1.6 versions).
|
||||
There is a new test program, test-unknown.c, which is a work in progress
|
||||
(not currently part of the test suite). Comments in the header files now
|
||||
explain how the unknown handling works.
|
||||
Allow fine grain control of unknown chunk APIs. This change allows
|
||||
png_set_keep_unknown_chunks() to be turned off if not required and causes
|
||||
both read and write to behave appropriately (on read this is only possible
|
||||
if the user callback is used to handle unknown chunks). The change
|
||||
also removes the support for storing unknown chunks in the info_struct
|
||||
if the only unknown handling enabled is via the callback, allowing libpng
|
||||
to be configured with callback reading and none of the unnecessary code.
|
||||
Corrected fix for unknown handling in pngtest. This reinstates the
|
||||
libpng handling of unknown chunks other than vpAg and sTER (including
|
||||
unsafe-to-copy chunks which were dropped before) and eliminates the
|
||||
repositioning of vpAg and sTER in pngtest.png by changing pngtest.png
|
||||
(so the chunks are where libpng would put them).
|
||||
Added "tunknown" test and corrected a logic error in png_handle_unknown()
|
||||
when SAVE support is absent. Moved the shell test scripts for
|
||||
contrib/libtests from the libpng top directory to contrib/libtests.
|
||||
png_handle_unknown() must always read or skip the chunk, if
|
||||
SAVE_UNKNOWN_CHUNKS is turned off *and* the application does not set
|
||||
a user callback an unknown chunk will not be read, leading to a read
|
||||
error, which was revealed by the "tunknown" test.
|
||||
Cleaned up and corrected ICC profile handling.
|
||||
contrib/libtests/makepng: corrected 'rgb' and 'gray' cases. profile_error
|
||||
messages could be truncated; made a correct buffer size calculation and
|
||||
adjusted pngerror.c appropriately. png_icc_check_* checking improved;
|
||||
changed the functions to receive the correct color type of the PNG on read
|
||||
or write and check that it matches the color space of the profile (despite
|
||||
what the comments said before, there is danger in assuming the app will
|
||||
cope correctly with an RGB profile on a grayscale image and, since it
|
||||
violates the PNG spec, allowing it is certain to produce inconsistent
|
||||
app behavior and might even cause app crashes.) Check that profiles
|
||||
contain the tags needed to process the PNG (tags all required by the ICC
|
||||
spec). Removed unused PNG_STATIC from pngpriv.h.
|
||||
|
||||
Version 1.6.0beta29 [September 4, 2012]
|
||||
Fixed the simplified API example programs to add the *colormap parameter
|
||||
to several of he API and improved the error message if the version field
|
||||
is not set.
|
||||
Added contrib/examples/* to the *.zip and *.7z distributions.
|
||||
Updated simplified API synopses and description of the png_image structure
|
||||
in the manual.
|
||||
Made makepng and pngtest produce identical PNGs, add "--relaxed" option
|
||||
to pngtest. The "--relaxed" option turns off the benign errors that are
|
||||
enabled by default in pre-RC builds. makepng can now write ICC profiles
|
||||
where the length has not been extended to a multiple of 4, and pngtest
|
||||
now intercepts all libpng errors, allowing the previously-introduced
|
||||
"--strict test" on no warnings to actually work.
|
||||
Improved ICC profile handling including cHRM chunk generation and fixed
|
||||
Cygwin+MSVC build errors. The ICC profile handling now includes more
|
||||
checking. Several errors that caused rejection of the profile are now
|
||||
handled with a warning in such a way that the invalid profiles will be
|
||||
read by default in release (but not pre-RC) builds but will not be
|
||||
written by default. The easy part of handling the cHRM chunk is written,
|
||||
where the ICC profile contains the required data. The more difficult
|
||||
part plus guessing a gAMA value requires code to pass selected RGB values
|
||||
through the profile.
|
||||
|
||||
Version 1.6.0beta30 [October 24, 2012]
|
||||
Changed ICC profile matrix/vector types to not depend on array type rules.
|
||||
By the ANSI-C standard the new types should be identical to the previous
|
||||
versions, and all known versions of gcc tested with the previous versions
|
||||
except for GCC-4.2.1 work with this version. The change makes the ANSI-C
|
||||
rule that const applied to an array of elements applies instead to the
|
||||
elements in the array moot by explicitly applying const to the base
|
||||
elements of the png_icc_matrix and png_icc_vector types. The accidental
|
||||
(harmless) 'const' previously applied to the parameters of two of the
|
||||
functions have also been removed.
|
||||
Added a work around for GCC 4.2 optimization bug.
|
||||
Marked the broken (bad white point) original HP sRGB profiles correctly and
|
||||
correct comments.
|
||||
Added -DZ_SOLO to contrib/pngminim/*/makefile to work with zlib-1.2.7
|
||||
Use /MDd for vstudio debug builds. Also added pngunkown to the vstudio
|
||||
builds, fixed build errors and corrected a minor exit code error in
|
||||
pngvalid if the 'touch' file name is invalid.
|
||||
Add updated WARNING file to projects/vstudio from libpng 1.5/vstudio
|
||||
Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in
|
||||
pngrtran.c (Domani Hannes).
|
||||
|
||||
Version 1.6.0beta31 [November 1, 2012]
|
||||
Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30.
|
||||
Made pngvalid so that it will build outside the libpng source tree.
|
||||
Made builds -DPNG_NO_READ_GAMMA compile (the unit tests still fail).
|
||||
Made PNG_NO_READ_GAMMA switch off interfaces that depend on READ_GAMMA.
|
||||
Prior to 1.6.0 switching off READ_GAMMA did unpredictable things to the
|
||||
interfaces that use it (specifically, png_do_background in 1.4 would
|
||||
simply display composite for grayscale images but do composition
|
||||
with the incorrect arithmetic for color ones). In 1.6 the semantic
|
||||
of -DPNG_NO_READ_GAMMA is changed to simply disable any interface that
|
||||
depends on it; this obliges people who set it to consider whether they
|
||||
really want it off if they happen to use any of the interfaces in
|
||||
question (typically most users who disable it won't).
|
||||
Fixed GUIDs in projects/vstudio. Some were duplicated or missing,
|
||||
resulting in VS2010 having to update the files.
|
||||
Removed non-working ICC profile support code that was mostly added to
|
||||
libpng-1.6.0beta29 and beta30. There was too much code for too little
|
||||
gain; implementing full ICC color correction may be desireable but is left
|
||||
up to applications.
|
||||
|
||||
Version 1.6.0beta32 [November 25, 2012]
|
||||
Fixed an intermittent SEGV in pngstest due to an uninitialized array element.
|
||||
Added the ability for contrib/libtests/makepng.c to make a PNG with just one
|
||||
color. This is useful for debugging pngstest color inaccuracy reports.
|
||||
Fixed error checking in the simplified write API (Olaf van der Spek)
|
||||
Made png_user_version_check() ok to use with libpng version 1.10.x and later.
|
||||
|
||||
Version 1.6.0beta33 [December 15, 2012]
|
||||
Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX)
|
||||
that causes the MALLOC_MAX limit not to work (John Bowler)
|
||||
Change png_warning() to png_app_error() in pngwrite.c and comment the
|
||||
fall-through condition.
|
||||
Change png_warning() to png_app_warning() in png_write_tRNS().
|
||||
Rearranged the ARM-NEON optimizations: Isolated the machine specific code
|
||||
to the hardware subdirectory and added comments to pngrutil.c so that
|
||||
implementors of other optimizations know what to do.
|
||||
Fixed cases of unquoted DESTDIR in Makefile.am
|
||||
Rebuilt Makefile.in, etc., with autoconf-2.69 and automake-1.12.5.
|
||||
|
||||
Version 1.6.0beta34 [December 19, 2012]
|
||||
Cleaned up whitespace in the synopsis portion of the manpage "libpng.3"
|
||||
Disassembled the version number in scripts/options.awk (necessary for
|
||||
building on SunOs).
|
||||
|
||||
Version 1.6.0beta35 [December 23, 2012]
|
||||
Made default Zlib compression settings be configurable. This adds #defines to
|
||||
pnglibconf.h to control the defaults.
|
||||
Fixed Windows build issues, enabled ARM compilation. Various warnings issued
|
||||
by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old
|
||||
GCCs.) ARM support is enabled by default in zlib.props (unsupported by
|
||||
Microsoft) and ARM compilation is made possible by deleting the check for
|
||||
x86. The test programs cannot be run because they are not signed.
|
||||
|
||||
Version 1.6.0beta36 [January 2, 2013]
|
||||
Discontinued distributing libpng-1.x.x.tar.bz2.
|
||||
Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar.
|
||||
Rebuilt configure with autoconf-2.69 (inadvertently not done in beta33)
|
||||
Fixed 'make distcheck' on SUN OS - libpng.so was not being removed
|
||||
|
||||
Version 1.6.0beta37 [January 10, 2013]
|
||||
Fixed conceivable but difficult to repro overflow. Also added two test
|
||||
programs to generate and test a PNG which should have the problem.
|
||||
|
||||
Version 1.6.0beta39 [January 19, 2013]
|
||||
Again corrected attempt at overflow detection in png_set_unknown_chunks().
|
||||
Added overflow detection in png_set_sPLT() and png_set_text_2().
|
||||
|
||||
Version 1.6.0beta40 [January 20, 2013]
|
||||
Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs
|
||||
|
||||
Version 1.6.0rc01 [January 26, 2013]
|
||||
No changes.
|
||||
|
||||
Version 1.6.0rc02 [February 4, 2013]
|
||||
Added png_get_palette_max() function.
|
||||
|
||||
Version 1.6.0rc03 [February 5, 2013]
|
||||
Fixed the png_get_palette_max API.
|
||||
|
||||
Version 1.6.0rc04 [February 7, 2013]
|
||||
Turn serial tests back on (recently turned off by autotools upgrade).
|
||||
|
||||
Version 1.6.0rc05 [February 8, 2013]
|
||||
Update manual about png_get_palette_max().
|
||||
|
||||
Version 1.6.0rc06 [February 9, 2013]
|
||||
Fixed missing dependency in --prefix builds The intermediate
|
||||
internal 'prefix.h' file can only be generated correctly after
|
||||
pnglibconf.h, however the dependency was not in Makefile.am. The
|
||||
symptoms are unpredictable depending on the order make chooses to
|
||||
build pngprefix.h and pnglibconf.h, often the error goes unnoticed
|
||||
because there is a system pnglibconf.h to use instead.
|
||||
|
||||
Version 1.6.0rc07 [February 10, 2013]
|
||||
Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly.
|
||||
|
||||
Version 1.6.0rc08 [February 10, 2013]
|
||||
Fix typo in png.h #ifdef
|
||||
|
||||
Version 1.6.0 [February 14, 2013]
|
||||
No changes.
|
||||
|
||||
Version 1.6.1beta01 [February 16, 2013]
|
||||
Made symbol prefixing work with the ARM neon optimizations. Also allow
|
||||
pngpriv.h to be included for preprocessor definitions only, so it can
|
||||
be used in non-C/C++ files. Back ported from libpng 1.7.
|
||||
Made sRGB check numbers consistent.
|
||||
Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug.
|
||||
Removed cc -E workround, corrected png_get_palette_max API Tested on
|
||||
SUN OS cc 5.9, which demonstrates the tokenization problem previously
|
||||
avoided by using /lib/cpp. Since all .dfn output is now protected in
|
||||
double quotes unless it is to be macro substituted the fix should
|
||||
work everywhere.
|
||||
Enabled parallel tests - back ported from libpng-1.7.
|
||||
scripts/pnglibconf.dfa formatting improvements back ported from libpng17.
|
||||
Fixed a race condition in the creation of the build 'scripts' directory
|
||||
while building with a parallel make.
|
||||
Use approved/supported Android method to check for NEON, use Linux/POSIX
|
||||
1003.1 API to check /proc/self/auxv avoiding buffer allocation and other
|
||||
library calls (ported from libpng15).
|
||||
|
||||
Version 1.6.1beta02 [February 19, 2013]
|
||||
Use parentheses more consistently in "#if defined(MACRO)" tests.
|
||||
Folded long lines.
|
||||
Reenabled code to allow zero length PLTE chunks for MNG.
|
||||
|
||||
Version 1.6.1beta03 [February 22, 2013]
|
||||
Fixed ALIGNED_MEMORY support.
|
||||
Allow run-time ARM NEON checking to be disabled. A new configure option:
|
||||
--enable-arm-neon=always will stop the run-time checks. New checks
|
||||
within arm/arm_init.c will cause the code not to be compiled unless
|
||||
__ARM_NEON__ is set. This should make it fail safe (if someone asks
|
||||
for it on then the build will fail if it can't be done.)
|
||||
Updated the INSTALL document.
|
||||
|
||||
Version 1.6.1beta04 [February 27, 2013]
|
||||
Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
|
||||
Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC.
|
||||
Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
|
||||
with CRLF line endings.
|
||||
|
||||
Version 1.6.1beta05 [March 2, 2013]
|
||||
Avoid a possible memory leak in contrib/gregbook/readpng.c
|
||||
Fixed bug introduced in libpng-1.6.0beta28 that causes libpng to handle chunks
|
||||
even when they have been tagged PNG_HANDLE_CHUNK_NEVER.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
@ -35,7 +35,7 @@ enable_testing()
|
||||
|
||||
set(PNGLIB_MAJOR 1)
|
||||
set(PNGLIB_MINOR 6)
|
||||
set(PNGLIB_RELEASE 0)
|
||||
set(PNGLIB_RELEASE 1)
|
||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||
|
||||
@ -191,16 +191,18 @@ if(PNG_TESTS AND PNG_SHARED)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn1g04.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g01.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g02.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g04.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn2c16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn2c16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbrn2c08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn1g16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn0g16.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbyn3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n1g08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n0g08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n2c08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n3p08.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp1n3p08.png
|
||||
@ -209,11 +211,7 @@ endif()
|
||||
|
||||
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
|
||||
IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
IF(WIN32)
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "bin")
|
||||
ELSE(WIN32)
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
|
||||
ENDIF(WIN32)
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
|
||||
ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
|
||||
# Set a variable with CMake code which:
|
||||
@ -221,7 +219,7 @@ ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
# copies if different.
|
||||
macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||
FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
if(WIN32 AND NOT CYGWIN AND NOT MINGW)
|
||||
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||
@ -229,10 +227,10 @@ macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||
DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC}
|
||||
)
|
||||
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
else(WIN32 AND NOT CYGWIN AND NOT MINGW)
|
||||
else(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif(WIN32 AND NOT CYGWIN AND NOT MINGW)
|
||||
endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
endmacro()
|
||||
|
||||
# libpng is a library so default to 'lib'
|
||||
@ -244,25 +242,25 @@ endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
# 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
|
||||
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(LIBS "-lz -lm")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
||||
CREATE_SYMLINK(${PNGLIB_NAME}.pc libpng.pc)
|
||||
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(LIBS "-lz -lm")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
||||
CREATE_SYMLINK(${PNGLIB_NAME}.pc libpng.pc)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||
CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||
CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config)
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.0beta05
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.1beta05
|
||||
VERSION 16.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 16
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
@ -334,10 +332,13 @@ if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
DESTINATION bin)
|
||||
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)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
# Install man pages
|
||||
if(NOT PNG_MAN_DIR)
|
||||
@ -346,14 +347,16 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
|
||||
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
|
||||
# Install pkg-config files
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
|
||||
DESTINATION bin)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
DESTINATION bin)
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
|
||||
DESTINATION bin)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
DESTINATION bin)
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
endif()
|
||||
|
||||
# On versions of CMake that support it, create an export file CMake
|
||||
|
41
INSTALL
@ -9,16 +9,16 @@ On Unix/Linux and similar systems, you can simply type
|
||||
|
||||
and ignore the rest of this document.
|
||||
|
||||
If configure does not work on your system and you have a reasonably
|
||||
up-to-date set of tools, running ./autogen.sh before running ./configure
|
||||
may fix the problem. You can also run the individual commands in
|
||||
autogen.sh with the --force option, if supported by your version of
|
||||
the tools. To be really sure that you aren't using any of the included
|
||||
pre-built scripts, you can do this:
|
||||
If configure does not work on your system, or if you have a need to
|
||||
change configure.ac or Makefile.am, and you have a reasonably
|
||||
up-to-date set of tools, running ./autogen.sh in a git clone before
|
||||
running ./configure may fix the problem. To be really sure that you
|
||||
aren't using any of the included pre-built scripts, you can do this:
|
||||
|
||||
./configure --enable-maintainer-mode
|
||||
make maintainer-clean
|
||||
./autogen.sh
|
||||
./autogen.sh --maintainer --clean
|
||||
./autogen.sh --maintainer
|
||||
./configure [--prefix=/path] [other options]
|
||||
make
|
||||
make install
|
||||
@ -41,19 +41,33 @@ is not already on your system. zlib can usually be found
|
||||
wherever you got libpng. zlib can be placed in another directory,
|
||||
at the same level as libpng.
|
||||
|
||||
If your system already has a preinstalled zlib you will still need
|
||||
to have access to the zlib.h and zconf.h include files that
|
||||
correspond to the version of zlib that's installed.
|
||||
|
||||
If you wish to test with a particular zlib that is not first in the
|
||||
standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
|
||||
and LD_LIBRARY_PATH in your environment before running "make test"
|
||||
or "make distcheck":
|
||||
|
||||
ZLIBLIB=/path/to/lib export ZLIBLIB
|
||||
ZLIBINC=/path/to/include export ZLIBINC
|
||||
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
|
||||
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
|
||||
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
|
||||
|
||||
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
|
||||
in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
|
||||
|
||||
If you want to use "cmake" (see www.cmake.org), type
|
||||
|
||||
cmake . -DCMAKE_INSTALL_PREFIX=/path
|
||||
make
|
||||
make install
|
||||
|
||||
If your system already has a preinstalled zlib you will still need
|
||||
to have access to the zlib.h and zconf.h include files that
|
||||
correspond to the version of zlib that's installed.
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.5"
|
||||
or "zlib125") so that you have directories called "zlib" and "libpng".
|
||||
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.7"
|
||||
or "zlib127") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
|
||||
@ -71,6 +85,7 @@ Your directory structure should look like this:
|
||||
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
|
||||
contrib
|
||||
gregbook
|
||||
libtests
|
||||
pngminim
|
||||
pngminus
|
||||
pngsuite
|
||||
|
6
LICENSE
@ -10,8 +10,8 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.0beta05, February 3, 2012, are
|
||||
Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.1beta05, March 2, 2013, are
|
||||
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
|
||||
@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
February 3, 2012
|
||||
March 2, 2013
|
||||
|
106
Makefile.am
@ -7,19 +7,44 @@ PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||
ACLOCAL_AMFLAGS = -I scripts
|
||||
|
||||
# test programs - run on make check, make distcheck
|
||||
TESTS_ENVIRONMENT= srcdir=$(srcdir)
|
||||
check_PROGRAMS= pngtest
|
||||
check_PROGRAMS= pngtest pngunknown pngstest pngvalid
|
||||
|
||||
pngtest_SOURCES = pngtest.c
|
||||
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
TESTS = test-pngtest.sh
|
||||
|
||||
# Only do the following if the contrib directory is present.
|
||||
check_PROGRAMS+= pngvalid pngstest
|
||||
pngvalid_SOURCES = contrib/libtests/pngvalid.c
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
TESTS += test-pngvalid-simple.sh test-pngvalid-full.sh test-pngstest.sh
|
||||
|
||||
pngunknown_SOURCES = contrib/libtests/pngunknown.c
|
||||
pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
# Generally these are single line shell scripts to run a test with a particular
|
||||
# set of parameters:
|
||||
TESTS =\
|
||||
tests/pngtest\
|
||||
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
|
||||
tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\
|
||||
tests/pngvalid-gamma-expand16-background\
|
||||
tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\
|
||||
tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\
|
||||
tests/pngvalid-progressive-interlace-size\
|
||||
tests/pngvalid-progressive-interlace-standard\
|
||||
tests/pngvalid-progressive-interlace-transform\
|
||||
tests/pngvalid-progressive-standard tests/pngvalid-standard\
|
||||
tests/pngstest-0g01 tests/pngstest-0g02 tests/pngstest-0g04\
|
||||
tests/pngstest-0g08 tests/pngstest-0g16 tests/pngstest-2c08\
|
||||
tests/pngstest-2c16 tests/pngstest-3p01 tests/pngstest-3p02\
|
||||
tests/pngstest-3p04 tests/pngstest-3p08 tests/pngstest-4a08\
|
||||
tests/pngstest-4a16 tests/pngstest-6a08 tests/pngstest-6a16\
|
||||
tests/pngstest-error tests/pngunknown-IDAT\
|
||||
tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
|
||||
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg
|
||||
|
||||
# These tests are expected, and required, to fail:
|
||||
XFAIL_TESTS = tests/pngstest-error
|
||||
|
||||
# man pages
|
||||
dist_man_MANS= libpng.3 libpngpf.3 png.5
|
||||
@ -35,10 +60,11 @@ lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||
pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\
|
||||
pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\
|
||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa
|
||||
|
||||
if PNG_ARM_NEON
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/filter_neon.S
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
||||
arm/filter_neon.S
|
||||
endif
|
||||
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
@ -71,12 +97,14 @@ nodist_pkginclude_HEADERS= pnglibconf.h
|
||||
pkgconfigdir = @pkgconfigdir@
|
||||
pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
|
||||
|
||||
#extra source distribution files.
|
||||
# Extra source distribution files, '${srcdir}' is used below to stop build files
|
||||
# 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 \
|
||||
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
|
||||
${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
|
||||
$(TESTS) \
|
||||
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
|
||||
CMakeLists.txt example.c libpng-manual.txt
|
||||
|
||||
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.dfn
|
||||
@ -113,6 +141,7 @@ $(PNGLIB_BASENAME)-config: libpng-config
|
||||
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
|
||||
scripts/prefix.out: png.h pngconf.h pnglibconf.out
|
||||
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
|
||||
scripts/intprefix.out: pnglibconf.h
|
||||
|
||||
libpng.sym: scripts/sym.out
|
||||
rm -f $@
|
||||
@ -158,6 +187,7 @@ $(srcdir)/scripts/pnglibconf.h.prebuilt:
|
||||
# an installed one (this can happen immediately after on a clean system if
|
||||
# 'make test' is the first thing the user does.)
|
||||
contrib/libtests/pngstest.o contrib/libtests/pngvalid.o pngtest.o: pnglibconf.h
|
||||
contrib/libtests/pngunknown.o: pnglibconf.h
|
||||
|
||||
# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually
|
||||
# be built with PNG_USE_READ_MACROS; this prevents the read macros from
|
||||
@ -172,23 +202,21 @@ SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
||||
endif
|
||||
|
||||
.dfn.out:
|
||||
rm -f $@ $*.c $*.tf[123]
|
||||
test -d scripts || mkdir scripts
|
||||
rm -f $@ $*.c $*.tf[12]
|
||||
test -d scripts || mkdir scripts || test -d scripts
|
||||
echo '#include "$<"' >$*.c
|
||||
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) $*.c > $*.tf1
|
||||
$(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\
|
||||
$*.tf1 >$*.tf2
|
||||
$(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' $*.tf2 >$*.tf3
|
||||
rm -f $*.c $*.tf[12]
|
||||
mv $*.tf3 $@
|
||||
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
|
||||
rm -f $*.c $*.tf1
|
||||
mv $*.tf2 $@
|
||||
|
||||
# The .dfn file for pnglibconf.h is machine generated
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
||||
rm -f $@ $*.tf[45]
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\
|
||||
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||
$(DFA_XTRA) 1>&2
|
||||
${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2
|
||||
rm $*.tf4
|
||||
mv $*.tf5 $@
|
||||
@ -230,22 +258,24 @@ dist-hook:
|
||||
|
||||
# install the .../include headers as links to the new ones
|
||||
install-data-hook:
|
||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
|
||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h
|
||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \
|
||||
cd '$(DESTDIR)$(includedir)'; rm -f png.h pngconf.h pnglibconf.h
|
||||
cd '$(DESTDIR)$(includedir)'; $(LN_S) $(PNGLIB_BASENAME)/png.h png.h
|
||||
cd '$(DESTDIR)$(includedir)'; $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \
|
||||
pngconf.h
|
||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pnglibconf.h \
|
||||
cd '$(DESTDIR)$(includedir)'; $(LN_S) $(PNGLIB_BASENAME)/pnglibconf.h \
|
||||
pnglibconf.h
|
||||
cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc
|
||||
cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc
|
||||
cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc
|
||||
cd '$(DESTDIR)$(pkgconfigdir)'; $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc
|
||||
|
||||
# do evil things to libpng to cause libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ to be used
|
||||
install-exec-hook:
|
||||
cd $(DESTDIR)$(bindir); rm -f libpng-config
|
||||
cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config
|
||||
cd '$(DESTDIR)$(bindir)'; rm -f libpng-config
|
||||
cd '$(DESTDIR)$(bindir)';\
|
||||
$(LN_S) $(PNGLIB_BASENAME)-config libpng-config
|
||||
@set -x;\
|
||||
cd $(DESTDIR)$(libdir);\
|
||||
for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib dll.a; do\
|
||||
cd '$(DESTDIR)$(libdir)';\
|
||||
for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@\
|
||||
sl dylib dll.a; do\
|
||||
rm -f libpng.$$ext;\
|
||||
if test -f $(PNGLIB_BASENAME).$$ext; then\
|
||||
$(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\
|
||||
@ -253,9 +283,13 @@ install-exec-hook:
|
||||
done
|
||||
|
||||
uninstall-hook:
|
||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
|
||||
rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc
|
||||
rm -f $(DESTDIR)$(bindir)/libpng-config
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.a
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.la
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.dll.a
|
||||
cd '$(DESTDIR)$(includedir)'; rm -f png.h pngconf.h pnglibconf.h
|
||||
rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc'
|
||||
rm -f '$(DESTDIR)$(bindir)/libpng-config'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.a'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.la'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.so'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.sl'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.dylib'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.dll.a'
|
||||
|
4
README
@ -1,4 +1,4 @@
|
||||
README for libpng version 1.6.0beta05 - February 3, 2012 (shared library 16.0)
|
||||
README for libpng version 1.6.1beta05 - March 2, 2013 (shared library 16.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
@ -105,7 +105,7 @@ based in a large way on Guy's and Andreas' earlier work), and the PNG
|
||||
development group.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at
|
||||
lists.sourceforge.net (subscription required; visit
|
||||
lists.sourceforge.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe) or to glennrp at users.sourceforge.net
|
||||
|
||||
|
203
arm/arm_init.c
Normal file
@ -0,0 +1,203 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.5.15 [%RDATE%]
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#define _POSIX_SOURCE 1
|
||||
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \
|
||||
defined(__ARM_NEON__)
|
||||
/* __arm__ is defined by GCC, MSVC defines _M_ARM to the ARM version number,
|
||||
* Andoid intends to define __ANDROID__, however there are bugs in their
|
||||
* toolchain; use -D__ANDROID__ to work round this.
|
||||
*
|
||||
* __ARM_NEON__ is used to ensure that the compiler has the appropriate ARM
|
||||
* NEON support
|
||||
*/
|
||||
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
|
||||
#ifdef __ANDROID__
|
||||
/* Linux provides access to information about CPU capabilites via
|
||||
* /proc/self/auxv, however Android blocks this while still claiming to be
|
||||
* Linux. The Andoid NDK, however, provides appropriate support.
|
||||
*
|
||||
* Documentation: http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
|
||||
*/
|
||||
#include <cpu-features.h>
|
||||
|
||||
static int
|
||||
png_have_neon(png_structp png_ptr)
|
||||
{
|
||||
/* This is a whole lot easier than the mess below, however it is probably
|
||||
* implemented as below, therefore it is better to cache the result (these
|
||||
* function calls may be slow!)
|
||||
*/
|
||||
return andoid_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
|
||||
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
/* The generic __linux__ implementation requires reading /proc/self/auxv and
|
||||
* looking at each element for one that records NEON capabilities.
|
||||
*/
|
||||
#include <unistd.h> /* for POSIX 1003.1 */
|
||||
#include <errno.h> /* for EINTR */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <elf.h>
|
||||
#include <asm/hwcap.h>
|
||||
|
||||
/* A read call may be interrupted, in which case it returns -1 and sets errno to
|
||||
* EINTR if nothing was done, otherwise (if something was done) a partial read
|
||||
* may result.
|
||||
*/
|
||||
static size_t
|
||||
safe_read(png_structp png_ptr, int fd, void *buffer_in, size_t nbytes)
|
||||
{
|
||||
size_t ntotal = 0;
|
||||
char *buffer = png_voidcast(char*, buffer_in);
|
||||
|
||||
while (nbytes > 0)
|
||||
{
|
||||
unsigned int nread;
|
||||
int iread;
|
||||
|
||||
/* Passing nread > INT_MAX to read is implementation defined in POSIX
|
||||
* 1003.1, therefore despite the unsigned argument portable code must
|
||||
* limit the value to INT_MAX!
|
||||
*/
|
||||
if (nbytes > INT_MAX)
|
||||
nread = INT_MAX;
|
||||
|
||||
else
|
||||
nread = (unsigned int)/*SAFE*/nbytes;
|
||||
|
||||
iread = read(fd, buffer, nread);
|
||||
|
||||
if (iread == -1)
|
||||
{
|
||||
/* This is the devil in the details, a read can terminate early with 0
|
||||
* bytes read because of EINTR, yet it still returns -1 otherwise end
|
||||
* of file cannot be distinguished.
|
||||
*/
|
||||
if (errno != EINTR)
|
||||
{
|
||||
png_warning(png_ptr, "/proc read failed");
|
||||
return 0; /* I.e. a permanent failure */
|
||||
}
|
||||
}
|
||||
|
||||
else if (iread < 0)
|
||||
{
|
||||
/* Not a valid 'read' result: */
|
||||
png_warning(png_ptr, "OS /proc read bug");
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if (iread > 0)
|
||||
{
|
||||
/* Continue reading until a permanent failure, or EOF */
|
||||
buffer += iread;
|
||||
nbytes -= (unsigned int)/*SAFE*/iread;
|
||||
ntotal += (unsigned int)/*SAFE*/iread;
|
||||
}
|
||||
|
||||
else
|
||||
return ntotal;
|
||||
}
|
||||
|
||||
return ntotal; /* nbytes == 0 */
|
||||
}
|
||||
|
||||
static int
|
||||
png_have_neon(png_structp png_ptr)
|
||||
{
|
||||
int fd = open("/proc/self/auxv", O_RDONLY);
|
||||
Elf32_auxv_t aux;
|
||||
|
||||
/* Failsafe: failure to open means no NEON */
|
||||
if (fd == -1)
|
||||
{
|
||||
png_warning(png_ptr, "/proc/self/auxv open failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (safe_read(png_ptr, fd, &aux, sizeof aux) == sizeof aux)
|
||||
{
|
||||
if (aux.a_type == AT_HWCAP && (aux.a_un.a_val & HWCAP_NEON) != 0)
|
||||
{
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
/* We don't know how to do a run-time check on this system */
|
||||
# error "no support for run-time ARM NEON checks"
|
||||
#endif /* OS checks */
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
|
||||
#endif
|
||||
|
||||
void
|
||||
png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
|
||||
{
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
|
||||
static volatile sig_atomic_t no_neon = -1; /* not checked */
|
||||
|
||||
if (no_neon < 0)
|
||||
no_neon = !png_have_neon(pp);
|
||||
|
||||
if (no_neon)
|
||||
return;
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
/* IMPORTANT: any new external functions used here must be declared using
|
||||
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
|
||||
* 'prefix' option to configure works:
|
||||
*
|
||||
* ./configure --with-libpng-prefix=foobar_
|
||||
*
|
||||
* Verify you have got this right by running the above command, doing a build
|
||||
* and examining pngprefix.h; it must contain a #define for every external
|
||||
* function you add. (Notice that this happens automatically for the
|
||||
* initialization function.)
|
||||
*/
|
||||
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;
|
||||
|
||||
if (bpp == 3)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth3_neon;
|
||||
}
|
||||
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth4_neon;
|
||||
}
|
||||
}
|
||||
#endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */
|
@ -3,12 +3,21 @@
|
||||
*
|
||||
* Copyright (c) 2011 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.5.7 [December 15, 2011]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* This is required to get the symbol renames, which are #defines, and also
|
||||
* includes the value of PNG_FILTER_OPTIMIZATIONS.
|
||||
*/
|
||||
#define PNG_VERSION_INFO_ONLY
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \
|
||||
defined(__ARM_NEON__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||
#endif
|
||||
@ -223,3 +232,4 @@ func png_read_filter_row_paeth3_neon, export=1
|
||||
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
#endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */
|
||||
|
@ -74,7 +74,7 @@ done
|
||||
#
|
||||
# The autotools generated files:
|
||||
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in\
|
||||
config.sub configure depcomp install-sh ltmain.sh missing"
|
||||
config.sub configure depcomp install-sh ltmain.sh missing test-driver"
|
||||
#
|
||||
# These are separate because 'maintainer-clean' does not remove them.
|
||||
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
|
||||
@ -134,7 +134,7 @@ do
|
||||
libpng_autotools_file_missing=1
|
||||
fi
|
||||
done
|
||||
#
|
||||
#
|
||||
# The cache directory doesn't matter - it will be regenerated and does not exist
|
||||
# anyway in a tarball.
|
||||
#
|
||||
@ -213,7 +213,7 @@ case "$mode" in
|
||||
exec >&2
|
||||
echo "Your system has a partial set of autotools generated files."
|
||||
echo "autogen.sh is unable to proceed. The full set of files is"
|
||||
echo "contained in the distribution archive and you do not need to run"
|
||||
echo "autogen.sh if you use it."
|
||||
echo "contained in the libpng 'tar' distribution archive and you do"
|
||||
echo "not need to run autogen.sh if you use it."
|
||||
exit 1;;
|
||||
esac
|
||||
|
79
configure.ac
@ -18,17 +18,19 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.6.0beta05],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.6.1beta05],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
# color-tests requires automake 1.11 or later
|
||||
# silent-rules requires automake 1.11 or later
|
||||
# dist-xz requires automake 1.11 or later
|
||||
# 1.11.1 fixes a security issue in 1.11
|
||||
AM_INIT_AUTOMAKE([1.11.1 foreign dist-xz dist-bzip2 color-tests silent-rules])
|
||||
# was:
|
||||
# AM_INIT_AUTOMAKE
|
||||
# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
|
||||
# 1.13 is required for parallel tests
|
||||
AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules])
|
||||
# The following line causes --disable-maintainer-mode to be the default to
|
||||
# configure, this is necessary because libpng distributions cannot rely on the
|
||||
# time stamps of the autotools generated files being correct
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
|
||||
@ -37,10 +39,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
|
||||
dnl AM_PREREQ([1.11.2])
|
||||
dnl stop configure from automagically running automake
|
||||
|
||||
PNGLIB_VERSION=1.6.0beta05
|
||||
PNGLIB_VERSION=1.6.1beta05
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_RELEASE=0
|
||||
PNGLIB_RELEASE=1
|
||||
|
||||
dnl End of version number stuff
|
||||
|
||||
@ -53,8 +55,7 @@ AC_PROG_CC
|
||||
AM_PROG_AS
|
||||
LT_PATH_LD
|
||||
AC_PROG_CPP
|
||||
AC_CHECK_TOOL(SED, sed, :)
|
||||
AC_CHECK_TOOL(AWK, awk, :)
|
||||
AC_PROG_AWK
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
@ -64,30 +65,23 @@ dnl compatible later version may be used
|
||||
LT_INIT([win32-dll])
|
||||
LT_PREREQ([2.4.2])
|
||||
|
||||
# On Solaris 10 and 12 CPP gets set to cc -E, however this still
|
||||
# does some input parsing. We need strict ANSI-C style tokenization,
|
||||
# check this:
|
||||
AC_REQUIRE_CPP
|
||||
AC_MSG_CHECKING([for a C preprocessor that does not parse its input])
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
|
||||
[DFNCPP="$CPP"],
|
||||
[ DFNCPP=""
|
||||
sav_CPP="$CPP"
|
||||
for CPP in "${CC-cc} -E" "${CC-cc} -E -traditional-cpp" "/lib/cpp" "cpp"
|
||||
do
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
|
||||
[DFNCPP="$CPP"]
|
||||
[break],,)
|
||||
done
|
||||
CPP="$sav_CPP"
|
||||
])
|
||||
if test -n "$DFNCPP"; then
|
||||
AC_MSG_RESULT([$DFNCPP])
|
||||
AC_SUBST(DFNCPP)
|
||||
# Some awks crash when confronted with pnglibconf.dfa, do a test run now
|
||||
# to make sure this doesn't happen
|
||||
AC_MSG_CHECKING([that AWK works])
|
||||
if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
|
||||
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||
${srcdir}/pngusr.dfa 1>&2
|
||||
then
|
||||
AC_MSG_RESULT([ok])
|
||||
else
|
||||
AC_MSG_FAILURE([not found], 1)
|
||||
AC_MSG_FAILURE([failed], 1)
|
||||
fi
|
||||
|
||||
# This is a remnant of the old cc -E validation, where it may have been
|
||||
# necessary to use a different preprocessor for .dfn files
|
||||
DFNCPP="$CPP"
|
||||
AC_SUBST(DFNCPP)
|
||||
|
||||
# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
|
||||
# checks the compiler with a program that generates a warning), add the
|
||||
# following option to deal with this
|
||||
@ -115,7 +109,6 @@ AC_ARG_ENABLE(werror,
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
@ -185,9 +178,9 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
|
||||
if test "$have_ld_version_script" = "yes"; then
|
||||
AC_MSG_CHECKING([for symbol prefix])
|
||||
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
|
||||
| ${CPP-${CC-gcc} -E} - 2>&1 \
|
||||
| ${EGREP-grep} "^PREFIX=" \
|
||||
| ${SED-sed} "s:^PREFIX=::"`
|
||||
| ${CPP-${CC-gcc} -E} - 2>&1 \
|
||||
| ${EGREP-grep} "^PREFIX=" \
|
||||
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
|
||||
AC_SUBST(SYMBOL_PREFIX)
|
||||
AC_MSG_RESULT($SYMBOL_PREFIX)
|
||||
fi
|
||||
@ -239,12 +232,20 @@ AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
|
||||
AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
|
||||
|
||||
AC_ARG_ENABLE([arm-neon],
|
||||
AS_HELP_STRING([[[--enable-arm-neon]]], [Enable ARM NEON optimizations]),
|
||||
[if test "${enableval}" = "yes"; then
|
||||
AC_DEFINE([PNG_ARM_NEON], [1], [Enable ARM NEON optimizations])
|
||||
AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1], [Align row buffers])
|
||||
AS_HELP_STRING([[[--enable-arm-neon]]],
|
||||
[Enable ARM NEON optimizations: use 'always' to turn off run-time checks]),
|
||||
[if test "${enableval}" = "yes" -o "${enableval}" = "always"; then
|
||||
AC_DEFINE([PNG_FILTER_OPTIMIZATIONS],
|
||||
[png_init_filter_functions_neon],
|
||||
[ARM NEON filter initialization function])
|
||||
AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [],
|
||||
[Align row buffers])
|
||||
if test "${enableval}" = "always"; then
|
||||
AC_DEFINE([PNG_NO_ARM_NEON_CHECK], [],
|
||||
[Turn off run-time checking for ARM NEON support])
|
||||
fi
|
||||
fi])
|
||||
AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes])
|
||||
AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" != "no"])
|
||||
|
||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||
|
||||
|
@ -103,7 +103,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
index < num_trans ? trans_alpha[index] : 255);
|
||||
|
||||
else /* no transparency */
|
||||
printf("INDEXED %u = %d %d %d\n", index,
|
||||
printf("INDEXED %u = %d %d %d\n", index,
|
||||
palette[index].red, palette[index].green,
|
||||
palette[index].blue);
|
||||
}
|
||||
@ -273,7 +273,7 @@ int main(int argc, const char **argv)
|
||||
ystep = xstep = 1;
|
||||
}
|
||||
|
||||
/* To find the pixel loop over 'py' for each pass
|
||||
/* To find the pixel, loop over 'py' for each pass
|
||||
* reading a row and then checking to see if it
|
||||
* contains the pixel.
|
||||
*/
|
||||
@ -283,12 +283,13 @@ int main(int argc, const char **argv)
|
||||
|
||||
/* png_read_row takes two pointers. When libpng
|
||||
* handles the interlace the first is filled in
|
||||
* pixel-by-pixel, the second receives the same
|
||||
* pixel-by-pixel, and the second receives the same
|
||||
* pixels but they are replicated across the
|
||||
* unwritten pixels so far for each pass. When we
|
||||
* do the interlace, however, they just contain
|
||||
* the pixels from the interlace pass - giving
|
||||
* both is wasteful and pointless.
|
||||
* both is wasteful and pointless, so we pass a
|
||||
* NULL pointer.
|
||||
*/
|
||||
png_read_row(png_ptr, row_tmp, NULL);
|
||||
|
||||
@ -326,7 +327,7 @@ int main(int argc, const char **argv)
|
||||
else
|
||||
{
|
||||
/* Else libpng has raised an error. An error message has
|
||||
* already been output, it is only necessary to clean up
|
||||
* already been output, so it is only necessary to clean up
|
||||
* locally allocated data:
|
||||
*/
|
||||
if (row != NULL)
|
||||
|
@ -29,13 +29,17 @@ int main(int argc, const char **argv)
|
||||
{
|
||||
png_image image;
|
||||
|
||||
/* Only the image structure version number needs to be set. */
|
||||
memset(&image, 0, sizeof image);
|
||||
image.version = PNG_IMAGE_VERSION;
|
||||
|
||||
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||
{
|
||||
png_bytep buffer;
|
||||
|
||||
/* Change this to try different formats! */
|
||||
|
||||
/* Change this to try different formats! If you set a colormap format
|
||||
* then you must also supply a colormap below.
|
||||
*/
|
||||
image.format = PNG_FORMAT_RGBA;
|
||||
|
||||
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||
@ -43,10 +47,11 @@ int main(int argc, const char **argv)
|
||||
if (buffer != NULL)
|
||||
{
|
||||
if (png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/))
|
||||
0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */))
|
||||
{
|
||||
if (png_image_write_to_file(&image, argv[2],
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/))
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||
NULL/*colormap*/))
|
||||
result = 0;
|
||||
|
||||
else
|
||||
|
@ -215,6 +215,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
* libpng function */
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
free(image_data);
|
||||
image_data = NULL;
|
||||
free(row_pointers);
|
||||
row_pointers = NULL;
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -136,29 +136,23 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
|
||||
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
|
||||
{
|
||||
/* These byte strings were copied from png.h. If a future libpng
|
||||
* version recognizes more chunks, add them to this list. If a
|
||||
* future version of readpng2.c recognizes more chunks, delete them
|
||||
* from this list. */
|
||||
static /* const */ png_byte chunks_to_ignore[] = {
|
||||
99, 72, 82, 77, '\0', /* cHRM */
|
||||
104, 73, 83, 84, '\0', /* hIST */
|
||||
105, 67, 67, 80, '\0', /* iCCP */
|
||||
105, 84, 88, 116, '\0', /* iTXt */
|
||||
111, 70, 70, 115, '\0', /* oFFs */
|
||||
112, 67, 65, 76, '\0', /* pCAL */
|
||||
112, 72, 89, 115, '\0', /* pHYs */
|
||||
115, 66, 73, 84, '\0', /* sBIT */
|
||||
115, 67, 65, 76, '\0', /* sCAL */
|
||||
115, 80, 76, 84, '\0', /* sPLT */
|
||||
115, 84, 69, 82, '\0', /* sTER */
|
||||
116, 69, 88, 116, '\0', /* tEXt */
|
||||
116, 73, 77, 69, '\0', /* tIME */
|
||||
122, 84, 88, 116, '\0' /* zTXt */
|
||||
};
|
||||
/* 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[] = {
|
||||
98, 75, 71, 68, '\0', /* bKGD */
|
||||
103, 65, 77, 65, '\0', /* gAMA */
|
||||
115, 82, 71, 66, '\0', /* sRGB */
|
||||
};
|
||||
|
||||
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
|
||||
chunks_to_ignore, sizeof(chunks_to_ignore)/5);
|
||||
/* Ignore all chunks except for IHDR, PLTE, tRNS, IDAT, and IEND */
|
||||
png_set_keep_unknown_chunks(png_ptr, -1 /* PNG_HANDLE_CHUNK_NEVER */,
|
||||
NULL, -1);
|
||||
|
||||
/* But do not ignore chunks in the "chunks_to_process" list */
|
||||
png_set_keep_unknown_chunks(png_ptr,
|
||||
0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */, chunks_to_process,
|
||||
sizeof(chunks_to_process)/5);
|
||||
}
|
||||
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
|
||||
|
||||
|
57
contrib/libtests/fakepng.c
Normal file
@ -0,0 +1,57 @@
|
||||
/* Fake a PNG - just write it out directly. */
|
||||
#include <stdio.h>
|
||||
#include <zlib.h> /* for crc32 */
|
||||
|
||||
void
|
||||
put_uLong(uLong val)
|
||||
{
|
||||
putchar(val >> 24);
|
||||
putchar(val >> 16);
|
||||
putchar(val >> 8);
|
||||
putchar(val >> 0);
|
||||
}
|
||||
|
||||
void
|
||||
put_chunk(const unsigned char *chunk, uInt length)
|
||||
{
|
||||
uLong crc;
|
||||
|
||||
put_uLong(length-4); /* Exclude the tag */
|
||||
|
||||
fwrite(chunk, length, 1, stdout);
|
||||
|
||||
crc = crc32(0, Z_NULL, 0);
|
||||
put_uLong(crc32(crc, chunk, length));
|
||||
}
|
||||
|
||||
const unsigned char signature[] =
|
||||
{
|
||||
137, 80, 78, 71, 13, 10, 26, 10
|
||||
};
|
||||
|
||||
const unsigned char IHDR[] =
|
||||
{
|
||||
73, 72, 68, 82, /* IHDR */
|
||||
0, 0, 0, 1, /* width */
|
||||
0, 0, 0, 1, /* height */
|
||||
1, /* bit depth */
|
||||
0, /* color type: greyscale */
|
||||
0, /* compression method */
|
||||
0, /* filter method */
|
||||
0 /* interlace method: none */
|
||||
};
|
||||
|
||||
const unsigned char unknown[] =
|
||||
{
|
||||
'u', 'n', 'K', 'n' /* "unKn" - private safe to copy */
|
||||
};
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fwrite(signature, sizeof signature, 1, stdout);
|
||||
put_chunk(IHDR, sizeof IHDR);
|
||||
|
||||
for(;;)
|
||||
put_chunk(unknown, sizeof unknown);
|
||||
}
|
102
contrib/libtests/gentests.sh
Executable file
@ -0,0 +1,102 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2013 John Cunningham Bowler
|
||||
#
|
||||
# Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
#
|
||||
# Generate a set of PNG test images. The images are generated in a
|
||||
# sub-directory called 'tests' by default, however a command line argument will
|
||||
# change that name. The generation requires a built version of makepng in the
|
||||
# current directory.
|
||||
#
|
||||
usage(){
|
||||
exec >&2
|
||||
echo "$0 [<directory>]"
|
||||
echo ' Generate a set of PNG test files in "directory" ("tests" by default)'
|
||||
exit 1
|
||||
}
|
||||
|
||||
mp="$PWD/makepng"
|
||||
test -x "$mp" || {
|
||||
exec >&2
|
||||
echo "$0: the 'makepng' program must exist"
|
||||
echo " in the directory within which this program:"
|
||||
echo " $mp"
|
||||
echo " is executed"
|
||||
usage
|
||||
}
|
||||
|
||||
# Just one argument: the directory
|
||||
testdir="tests"
|
||||
test $# -gt 1 && {
|
||||
testdir="$1"
|
||||
shift
|
||||
}
|
||||
test $# -eq 0 || usage
|
||||
|
||||
# Take care not to clobber something
|
||||
if test -e "$testdir"
|
||||
then
|
||||
test -d "$testdir" || usage
|
||||
else
|
||||
# mkdir -p isn't portable, so do the following
|
||||
mkdir "$testdir" 2>/dev/null || mkdir -p "$testdir" || usage
|
||||
fi
|
||||
|
||||
# This fails in a very satisfactory way if it's not accessible
|
||||
cd "$testdir"
|
||||
:>"test$$.png" || {
|
||||
exec >&2
|
||||
echo "$testdir: directory not writable"
|
||||
usage
|
||||
}
|
||||
rm "test$$.png" || {
|
||||
exec >&2
|
||||
echo "$testdir: you have create but not write privileges here."
|
||||
echo " This is unexpected. You have a spurion; "'"'"test$$.png"'"'"."
|
||||
echo " You need to remove this yourself. Try a different directory."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Now call makepng ($mp) to create every file we can think of with a
|
||||
# reasonable name
|
||||
doit(){
|
||||
for gamma in "" --sRGB --linear --1.8
|
||||
do
|
||||
case "$gamma" in
|
||||
"")
|
||||
gname=;;
|
||||
--sRGB)
|
||||
gname="-srgb";;
|
||||
--linear)
|
||||
gname="-lin";;
|
||||
--1.8)
|
||||
gname="-18";;
|
||||
*)
|
||||
gname="-$gamma";;
|
||||
esac
|
||||
"$mp" $gamma "$1" "$2" "test-$1-$2$gname.png"
|
||||
done
|
||||
}
|
||||
#
|
||||
for ct in gray palette
|
||||
do
|
||||
for bd in 1 2 4 8
|
||||
do
|
||||
doit "$ct" "$bd"
|
||||
done
|
||||
done
|
||||
#
|
||||
doit "gray" "16"
|
||||
#
|
||||
for ct in gray-alpha rgb rgb-alpha
|
||||
do
|
||||
for bd in 8 16
|
||||
do
|
||||
doit "$ct" "$bd"
|
||||
done
|
||||
done
|
1486
contrib/libtests/makepng.c
Normal file
960
contrib/libtests/pngunknown.c
Normal file
@ -0,0 +1,960 @@
|
||||
|
||||
/* pngunknown.c - test the read side unknown chunk handling
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by John Cunningham Bowler
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* NOTES:
|
||||
* This is a C program that is intended to be linked against libpng. It
|
||||
* allows the libpng unknown handling code to be tested by interpreting
|
||||
* arguments to save or discard combinations of chunks. The program is
|
||||
* currently just a minimal validation for the built-in libpng facilities.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
/* Define the following to use this test against your installed libpng, rather
|
||||
* than the one being built here:
|
||||
*/
|
||||
#ifdef PNG_FREESTANDING_TESTS
|
||||
# include <png.h>
|
||||
#else
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
/* This deliberately lacks the PNG_CONST. */
|
||||
typedef png_byte *png_const_bytep;
|
||||
|
||||
/* This is copied from 1.5.1 png.h: */
|
||||
#define PNG_INTERLACE_ADAM7_PASSES 7
|
||||
#define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7)
|
||||
#define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7)
|
||||
#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)
|
||||
#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)
|
||||
#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\
|
||||
-1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))
|
||||
#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\
|
||||
-1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))
|
||||
#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \
|
||||
(((yIn)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
|
||||
#define PNG_COL_FROM_PASS_COL(xIn, pass) \
|
||||
(((xIn)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
|
||||
#define PNG_PASS_MASK(pass,off) ( \
|
||||
((0x110145AFU>>(((7-(off))-(pass))<<2)) & 0xFU) | \
|
||||
((0x01145AF0U>>(((7-(off))-(pass))<<2)) & 0xF0U))
|
||||
#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
|
||||
((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
|
||||
#define PNG_COL_IN_INTERLACE_PASS(x, pass) \
|
||||
((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
|
||||
|
||||
/* These are needed too for the default build: */
|
||||
#define PNG_WRITE_16BIT_SUPPORTED
|
||||
#define PNG_READ_16BIT_SUPPORTED
|
||||
|
||||
/* This comes from pnglibconf.h afer 1.5: */
|
||||
#define PNG_FP_1 100000
|
||||
#define PNG_GAMMA_THRESHOLD_FIXED\
|
||||
((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1))
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
/* 1.6.0 constifies many APIs. The following exists to allow pngvalid to be
|
||||
* compiled against earlier versions.
|
||||
*/
|
||||
# define png_const_structp png_structp
|
||||
#endif
|
||||
|
||||
|
||||
/* Copied from pngpriv.h */
|
||||
#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
|
||||
#define PNG_CHUNK(b1,b2,b3,b4) \
|
||||
(PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
|
||||
|
||||
#define png_IHDR PNG_CHUNK( 73, 72, 68, 82)
|
||||
#define png_IDAT PNG_CHUNK( 73, 68, 65, 84)
|
||||
#define png_IEND PNG_CHUNK( 73, 69, 78, 68)
|
||||
#define png_PLTE PNG_CHUNK( 80, 76, 84, 69)
|
||||
#define png_bKGD PNG_CHUNK( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_CHUNK( 99, 72, 82, 77)
|
||||
#define png_gAMA PNG_CHUNK(103, 65, 77, 65)
|
||||
#define png_hIST PNG_CHUNK(104, 73, 83, 84)
|
||||
#define png_iCCP PNG_CHUNK(105, 67, 67, 80)
|
||||
#define png_iTXt PNG_CHUNK(105, 84, 88, 116)
|
||||
#define png_oFFs PNG_CHUNK(111, 70, 70, 115)
|
||||
#define png_pCAL PNG_CHUNK(112, 67, 65, 76)
|
||||
#define png_sCAL PNG_CHUNK(115, 67, 65, 76)
|
||||
#define png_pHYs PNG_CHUNK(112, 72, 89, 115)
|
||||
#define png_sBIT PNG_CHUNK(115, 66, 73, 84)
|
||||
#define png_sPLT PNG_CHUNK(115, 80, 76, 84)
|
||||
#define png_sRGB PNG_CHUNK(115, 82, 71, 66)
|
||||
#define png_sTER PNG_CHUNK(115, 84, 69, 82)
|
||||
#define png_tEXt PNG_CHUNK(116, 69, 88, 116)
|
||||
#define png_tIME PNG_CHUNK(116, 73, 77, 69)
|
||||
#define png_tRNS PNG_CHUNK(116, 82, 78, 83)
|
||||
#define png_zTXt PNG_CHUNK(122, 84, 88, 116)
|
||||
#define png_vpAg PNG_CHUNK('v', 'p', 'A', 'g')
|
||||
|
||||
/* Test on flag values as defined in the spec (section 5.4): */
|
||||
#define PNG_CHUNK_ANCILLARY(c ) (1 & ((c) >> 29))
|
||||
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c))
|
||||
#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
|
||||
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
|
||||
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
|
||||
|
||||
/* Chunk information */
|
||||
#define PNG_INFO_tEXt 0x10000000U
|
||||
#define PNG_INFO_iTXt 0x20000000U
|
||||
#define PNG_INFO_zTXt 0x40000000U
|
||||
|
||||
#define PNG_INFO_sTER 0x01000000U
|
||||
#define PNG_INFO_vpAg 0x02000000U
|
||||
|
||||
#define ABSENT 0
|
||||
#define START 1
|
||||
#define END 2
|
||||
|
||||
static struct
|
||||
{
|
||||
char name[5];
|
||||
png_uint_32 flag;
|
||||
png_uint_32 tag;
|
||||
int unknown; /* Chunk not known to libpng */
|
||||
int all; /* Chunk set by the '-1' option */
|
||||
int position; /* position in pngtest.png */
|
||||
int keep; /* unknown handling setting */
|
||||
} chunk_info[] = {
|
||||
/* Critical chunks */
|
||||
{ "IDAT", PNG_INFO_IDAT, png_IDAT, 0, 0, START, 0 }, /* must be [0] */
|
||||
{ "PLTE", PNG_INFO_PLTE, png_PLTE, 0, 0, ABSENT, 0 },
|
||||
|
||||
/* Non-critical chunks that libpng handles */
|
||||
{ "bKGD", PNG_INFO_bKGD, png_bKGD, 0, 1, START, 0 },
|
||||
{ "cHRM", PNG_INFO_cHRM, png_cHRM, 0, 1, START, 0 },
|
||||
{ "gAMA", PNG_INFO_gAMA, png_gAMA, 0, 1, START, 0 },
|
||||
{ "hIST", PNG_INFO_hIST, png_hIST, 0, 1, ABSENT, 0 },
|
||||
{ "iCCP", PNG_INFO_iCCP, png_iCCP, 0, 1, ABSENT, 0 },
|
||||
{ "iTXt", PNG_INFO_iTXt, png_iTXt, 0, 1, ABSENT, 0 },
|
||||
{ "oFFs", PNG_INFO_oFFs, png_oFFs, 0, 1, START, 0 },
|
||||
{ "pCAL", PNG_INFO_pCAL, png_pCAL, 0, 1, START, 0 },
|
||||
{ "pHYs", PNG_INFO_pHYs, png_pHYs, 0, 1, START, 0 },
|
||||
{ "sBIT", PNG_INFO_sBIT, png_sBIT, 0, 1, START, 0 },
|
||||
{ "sCAL", PNG_INFO_sCAL, png_sCAL, 0, 1, START, 0 },
|
||||
{ "sPLT", PNG_INFO_sPLT, png_sPLT, 0, 1, ABSENT, 0 },
|
||||
{ "sRGB", PNG_INFO_sRGB, png_sRGB, 0, 1, START, 0 },
|
||||
{ "tEXt", PNG_INFO_tEXt, png_tEXt, 0, 1, START, 0 },
|
||||
{ "tIME", PNG_INFO_tIME, png_tIME, 0, 1, START, 0 },
|
||||
{ "tRNS", PNG_INFO_tRNS, png_tRNS, 0, 0, ABSENT, 0 },
|
||||
{ "zTXt", PNG_INFO_zTXt, png_zTXt, 0, 1, END, 0 },
|
||||
|
||||
/* No libpng handling */
|
||||
{ "sTER", PNG_INFO_sTER, png_sTER, 1, 1, START, 0 },
|
||||
{ "vpAg", PNG_INFO_vpAg, png_vpAg, 1, 0, START, 0 },
|
||||
};
|
||||
|
||||
#define NINFO ((int)((sizeof chunk_info)/(sizeof chunk_info[0])))
|
||||
|
||||
static void
|
||||
clear_keep(void)
|
||||
{
|
||||
int i = NINFO;
|
||||
while (--i >= 0)
|
||||
chunk_info[i].keep = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
find(const char *name)
|
||||
{
|
||||
int i = NINFO;
|
||||
while (--i >= 0)
|
||||
{
|
||||
if (memcmp(chunk_info[i].name, name, 4) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int
|
||||
findb(const png_byte *name)
|
||||
{
|
||||
int i = NINFO;
|
||||
while (--i >= 0)
|
||||
{
|
||||
if (memcmp(chunk_info[i].name, name, 4) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int
|
||||
find_by_flag(png_uint_32 flag)
|
||||
{
|
||||
int i = NINFO;
|
||||
|
||||
while (--i >= 0) if (chunk_info[i].flag == flag) return i;
|
||||
|
||||
fprintf(stderr, "pngunknown: internal error\n");
|
||||
exit(4);
|
||||
}
|
||||
|
||||
static int
|
||||
ancillary(const char *name)
|
||||
{
|
||||
return PNG_CHUNK_ANCILLARY(PNG_CHUNK(name[0], name[1], name[2], name[3]));
|
||||
}
|
||||
|
||||
static int
|
||||
ancillaryb(const png_byte *name)
|
||||
{
|
||||
return PNG_CHUNK_ANCILLARY(PNG_CHUNK(name[0], name[1], name[2], name[3]));
|
||||
}
|
||||
|
||||
/* Type of an error_ptr */
|
||||
typedef struct
|
||||
{
|
||||
jmp_buf error_return;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr, end_ptr;
|
||||
int error_count;
|
||||
int warning_count;
|
||||
const char *program;
|
||||
const char *file;
|
||||
const char *test;
|
||||
} display;
|
||||
|
||||
static const char init[] = "initialization";
|
||||
static const char cmd[] = "command line";
|
||||
|
||||
static void
|
||||
init_display(display *d, const char *program)
|
||||
{
|
||||
memset(d, 0, sizeof *d);
|
||||
d->png_ptr = NULL;
|
||||
d->info_ptr = d->end_ptr = NULL;
|
||||
d->error_count = d->warning_count = 0;
|
||||
d->program = program;
|
||||
d->file = program;
|
||||
d->test = init;
|
||||
}
|
||||
|
||||
static void
|
||||
clean_display(display *d)
|
||||
{
|
||||
png_destroy_read_struct(&d->png_ptr, &d->info_ptr, &d->end_ptr);
|
||||
|
||||
/* This must not happen - it might cause an app crash */
|
||||
if (d->png_ptr != NULL || d->info_ptr != NULL || d->end_ptr != NULL)
|
||||
{
|
||||
fprintf(stderr, "%s(%s): png_destroy_read_struct error\n", d->file,
|
||||
d->test);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Invalidate the test */
|
||||
d->test = init;
|
||||
}
|
||||
|
||||
PNG_FUNCTION(void, display_exit, (display *d), static PNG_NORETURN)
|
||||
{
|
||||
++(d->error_count);
|
||||
|
||||
if (d->png_ptr != NULL)
|
||||
clean_display(d);
|
||||
|
||||
/* During initialization and if this is a single command line argument set
|
||||
* exit now - there is only one test, otherwise longjmp to do the next test.
|
||||
*/
|
||||
if (d->test == init || d->test == cmd)
|
||||
exit(1);
|
||||
|
||||
longjmp(d->error_return, 1);
|
||||
}
|
||||
|
||||
static int
|
||||
display_rc(const display *d, int strict)
|
||||
{
|
||||
return d->error_count + (strict ? d->warning_count : 0);
|
||||
}
|
||||
|
||||
/* libpng error and warning callbacks */
|
||||
PNG_FUNCTION(void, error, (png_structp png_ptr, const char *message),
|
||||
static PNG_NORETURN)
|
||||
{
|
||||
display *d = (display*)png_get_error_ptr(png_ptr);
|
||||
|
||||
fprintf(stderr, "%s(%s): libpng error: %s\n", d->file, d->test, message);
|
||||
display_exit(d);
|
||||
}
|
||||
|
||||
static void
|
||||
warning(png_structp png_ptr, const char *message)
|
||||
{
|
||||
display *d = (display*)png_get_error_ptr(png_ptr);
|
||||
|
||||
fprintf(stderr, "%s(%s): libpng warning: %s\n", d->file, d->test, message);
|
||||
++(d->warning_count);
|
||||
}
|
||||
|
||||
static png_uint_32
|
||||
get_valid(display *d, png_infop info_ptr)
|
||||
{
|
||||
png_uint_32 flags = png_get_valid(d->png_ptr, info_ptr, (png_uint_32)~0);
|
||||
|
||||
/* Map the text chunks back into the flags */
|
||||
{
|
||||
png_textp text;
|
||||
png_uint_32 ntext = png_get_text(d->png_ptr, info_ptr, &text, NULL);
|
||||
|
||||
while (ntext-- > 0) switch (text[ntext].compression)
|
||||
{
|
||||
case -1:
|
||||
flags |= PNG_INFO_tEXt;
|
||||
break;
|
||||
case 0:
|
||||
flags |= PNG_INFO_zTXt;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
flags |= PNG_INFO_iTXt;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s(%s): unknown text compression %d\n", d->file,
|
||||
d->test, text[ntext].compression);
|
||||
display_exit(d);
|
||||
}
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static png_uint_32
|
||||
get_unknown(display *d, int def, png_infop info_ptr)
|
||||
{
|
||||
/* Create corresponding 'unknown' flags */
|
||||
png_uint_32 flags = 0;
|
||||
{
|
||||
png_unknown_chunkp unknown;
|
||||
int num_unknown = png_get_unknown_chunks(d->png_ptr, info_ptr, &unknown);
|
||||
|
||||
while (--num_unknown >= 0)
|
||||
{
|
||||
int chunk = findb(unknown[num_unknown].name);
|
||||
|
||||
/* Chunks not known to pngunknown must be validated here; since they
|
||||
* must also be unknown to libpng the 'def' behavior should have been
|
||||
* used.
|
||||
*/
|
||||
if (chunk < 0) switch (def)
|
||||
{
|
||||
default: /* impossible */
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
fprintf(stderr, "%s(%s): %s: %s: unknown chunk saved\n",
|
||||
d->file, d->test, def ? "discard" : "default",
|
||||
unknown[num_unknown].name);
|
||||
++(d->error_count);
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
if (!ancillaryb(unknown[num_unknown].name))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s(%s): if-safe: %s: unknown critical chunk saved\n",
|
||||
d->file, d->test, unknown[num_unknown].name);
|
||||
++(d->error_count);
|
||||
break;
|
||||
}
|
||||
/* FALL THROUGH (safe) */
|
||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
flags |= chunk_info[chunk].flag;
|
||||
}
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static int
|
||||
check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
display *d)
|
||||
{
|
||||
int i, def = PNG_HANDLE_CHUNK_AS_DEFAULT, npasses, ipass;
|
||||
png_uint_32 height;
|
||||
|
||||
/* Some of these errors are permanently fatal and cause an exit here, others
|
||||
* are per-test and cause an error return.
|
||||
*/
|
||||
d->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, d, error,
|
||||
warning);
|
||||
if (d->png_ptr == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s(%s): could not allocate png struct\n", d->file,
|
||||
d->test);
|
||||
/* Terminate here, this error is not test specific. */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
d->info_ptr = png_create_info_struct(d->png_ptr);
|
||||
d->end_ptr = png_create_info_struct(d->png_ptr);
|
||||
if (d->info_ptr == NULL || d->end_ptr == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s(%s): could not allocate png info\n", d->file,
|
||||
d->test);
|
||||
clean_display(d);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
png_init_io(d->png_ptr, fp);
|
||||
|
||||
/* Handle each argument in turn; multiple settings are possible for the same
|
||||
* chunk and multiple calls will occur (the last one should override all
|
||||
* preceding ones).
|
||||
*/
|
||||
for (i=0; i<argc; ++i)
|
||||
{
|
||||
const char *equals = strchr(argv[i], '=');
|
||||
|
||||
if (equals != NULL)
|
||||
{
|
||||
int chunk, option;
|
||||
|
||||
if (strcmp(equals+1, "default") == 0)
|
||||
option = PNG_HANDLE_CHUNK_AS_DEFAULT;
|
||||
else if (strcmp(equals+1, "discard") == 0)
|
||||
option = PNG_HANDLE_CHUNK_NEVER;
|
||||
else if (strcmp(equals+1, "if-safe") == 0)
|
||||
option = PNG_HANDLE_CHUNK_IF_SAFE;
|
||||
else if (strcmp(equals+1, "save") == 0)
|
||||
option = PNG_HANDLE_CHUNK_ALWAYS;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s(%s): %s: unrecognized chunk option\n", d->file,
|
||||
d->test, argv[i]);
|
||||
display_exit(d);
|
||||
}
|
||||
|
||||
switch (equals - argv[i])
|
||||
{
|
||||
case 4: /* chunk name */
|
||||
chunk = find(argv[i]);
|
||||
|
||||
if (chunk >= 0)
|
||||
{
|
||||
/* These #if tests have the effect of skipping the arguments
|
||||
* if SAVE support is unavailable - we can't do a useful test
|
||||
* in this case, so we just check the arguments! This could
|
||||
* be improved in the future by using the read callback.
|
||||
*/
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_byte name[5];
|
||||
|
||||
memcpy(name, chunk_info[chunk].name, 5);
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, name, 1);
|
||||
chunk_info[chunk].keep = option;
|
||||
# endif
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 7: /* default */
|
||||
if (memcmp(argv[i], "default", 7) == 0)
|
||||
{
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0);
|
||||
# endif
|
||||
def = option;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 3: /* all */
|
||||
if (memcmp(argv[i], "all", 3) == 0)
|
||||
{
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1);
|
||||
def = option;
|
||||
|
||||
for (chunk = 0; chunk < NINFO; ++chunk)
|
||||
if (chunk_info[chunk].all)
|
||||
chunk_info[chunk].keep = option;
|
||||
# endif
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default: /* some misplaced = */
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s(%s): %s: unrecognized chunk argument\n", d->file,
|
||||
d->test, argv[i]);
|
||||
display_exit(d);
|
||||
}
|
||||
|
||||
png_read_info(d->png_ptr, d->info_ptr);
|
||||
|
||||
switch (png_get_interlace_type(d->png_ptr, d->info_ptr))
|
||||
{
|
||||
case PNG_INTERLACE_NONE:
|
||||
npasses = 1;
|
||||
break;
|
||||
|
||||
case PNG_INTERLACE_ADAM7:
|
||||
npasses = PNG_INTERLACE_ADAM7_PASSES;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Hard error because it is not test specific */
|
||||
fprintf(stderr, "%s(%s): invalid interlace type\n", d->file, d->test);
|
||||
clean_display(d);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Skip the image data, if IDAT is not being handled then don't do this
|
||||
* because it will cause a CRC error.
|
||||
*/
|
||||
if (chunk_info[0/*IDAT*/].keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
{
|
||||
png_start_read_image(d->png_ptr);
|
||||
height = png_get_image_height(d->png_ptr, d->info_ptr);
|
||||
|
||||
if (npasses > 1)
|
||||
{
|
||||
png_uint_32 width = png_get_image_width(d->png_ptr, d->info_ptr);
|
||||
|
||||
for (ipass=0; ipass<npasses; ++ipass)
|
||||
{
|
||||
png_uint_32 wPass = PNG_PASS_COLS(width, ipass);
|
||||
|
||||
if (wPass > 0)
|
||||
{
|
||||
png_uint_32 y;
|
||||
|
||||
for (y=0; y<height; ++y) if (PNG_ROW_IN_INTERLACE_PASS(y, ipass))
|
||||
png_read_row(d->png_ptr, NULL, NULL);
|
||||
}
|
||||
}
|
||||
} /* interlaced */
|
||||
|
||||
else /* not interlaced */
|
||||
{
|
||||
png_uint_32 y;
|
||||
|
||||
for (y=0; y<height; ++y)
|
||||
png_read_row(d->png_ptr, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
png_read_end(d->png_ptr, d->end_ptr);
|
||||
|
||||
flags[0] = get_valid(d, d->info_ptr);
|
||||
flags[1] = get_unknown(d, def, d->info_ptr);
|
||||
|
||||
/* Only png_read_png sets PNG_INFO_IDAT! */
|
||||
flags[chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT] |=
|
||||
PNG_INFO_IDAT;
|
||||
|
||||
flags[2] = get_valid(d, d->end_ptr);
|
||||
flags[3] = get_unknown(d, def, d->end_ptr);
|
||||
|
||||
clean_display(d);
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
static void
|
||||
check_error(display *d, png_uint_32 flags, const char *message)
|
||||
{
|
||||
while (flags)
|
||||
{
|
||||
png_uint_32 flag = flags & -(png_int_32)flags;
|
||||
int i = find_by_flag(flag);
|
||||
|
||||
fprintf(stderr, "%s(%s): chunk %s: %s\n", d->file, d->test,
|
||||
chunk_info[i].name, message);
|
||||
++(d->error_count);
|
||||
|
||||
flags &= ~flag;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
|
||||
png_uint_32 unknown, const char *position)
|
||||
{
|
||||
while (chunks)
|
||||
{
|
||||
png_uint_32 flag = chunks & -(png_int_32)chunks;
|
||||
int i = find_by_flag(flag);
|
||||
int keep = chunk_info[i].keep;
|
||||
const char *type;
|
||||
const char *errorx = NULL;
|
||||
|
||||
if (chunk_info[i].unknown)
|
||||
{
|
||||
if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
{
|
||||
type = "UNKNOWN (default)";
|
||||
keep = def;
|
||||
}
|
||||
|
||||
else
|
||||
type = "UNKNOWN (specified)";
|
||||
|
||||
if (flag & known)
|
||||
errorx = "chunk processed";
|
||||
|
||||
else switch (keep)
|
||||
{
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
if (flag & unknown)
|
||||
errorx = "DEFAULT: unknown chunk saved";
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
if (flag & unknown)
|
||||
errorx = "DISCARD: unknown chunk saved";
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
if (ancillary(chunk_info[i].name))
|
||||
{
|
||||
if (!(flag & unknown))
|
||||
errorx = "IF-SAFE: unknown ancillary chunk lost";
|
||||
}
|
||||
|
||||
else if (flag & unknown)
|
||||
errorx = "IF-SAFE: unknown critical chunk saved";
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||
if (!(flag & unknown))
|
||||
errorx = "SAVE: unknown chunk lost";
|
||||
break;
|
||||
|
||||
default:
|
||||
errorx = "internal error: bad keep";
|
||||
break;
|
||||
}
|
||||
} /* unknown chunk */
|
||||
|
||||
else /* known chunk */
|
||||
{
|
||||
type = "KNOWN";
|
||||
|
||||
if (flag & known)
|
||||
{
|
||||
/* chunk was processed, it won't have been saved because that is
|
||||
* caught below when checking for inconsistent processing.
|
||||
*/
|
||||
if (keep != PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
errorx = "!DEFAULT: known chunk processed";
|
||||
}
|
||||
|
||||
else /* not processed */ switch (keep)
|
||||
{
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
errorx = "DEFAULT: known chunk not processed";
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
if (flag & unknown)
|
||||
errorx = "DISCARD: known chunk saved";
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
if (ancillary(chunk_info[i].name))
|
||||
{
|
||||
if (!(flag & unknown))
|
||||
errorx = "IF-SAFE: known ancillary chunk lost";
|
||||
}
|
||||
|
||||
else if (flag & unknown)
|
||||
errorx = "IF-SAFE: known critical chunk saved";
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||
if (!(flag & unknown))
|
||||
errorx = "SAVE: known chunk lost";
|
||||
break;
|
||||
|
||||
default:
|
||||
errorx = "internal error: bad keep (2)";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorx != NULL)
|
||||
{
|
||||
++(d->error_count);
|
||||
fprintf(stderr, "%s(%s): %s %s %s: %s\n",
|
||||
d->file, d->test, type, chunk_info[i].name, position, errorx);
|
||||
}
|
||||
|
||||
chunks &= ~flag;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
perform_one_test(FILE *fp, int argc, const char **argv,
|
||||
png_uint_32 *default_flags, display *d)
|
||||
{
|
||||
int def;
|
||||
png_uint_32 flags[2][4];
|
||||
|
||||
rewind(fp);
|
||||
clear_keep();
|
||||
memcpy(flags[0], default_flags, sizeof flags[0]);
|
||||
|
||||
def = check(fp, argc, argv, flags[1], d);
|
||||
|
||||
/* Chunks should either be known or unknown, never both and this should apply
|
||||
* whether the chunk is before or after the IDAT (actually, the app can
|
||||
* probably change this by swapping the handling after the image, but this
|
||||
* test does not do that.)
|
||||
*/
|
||||
check_error(d, (flags[0][0]|flags[0][2]) & (flags[0][1]|flags[0][3]),
|
||||
"chunk handled inconsistently in count tests");
|
||||
check_error(d, (flags[1][0]|flags[1][2]) & (flags[1][1]|flags[1][3]),
|
||||
"chunk handled inconsistently in option tests");
|
||||
|
||||
/* Now find out what happened to each chunk before and after the IDAT and
|
||||
* determine if the behavior was correct. First some basic sanity checks,
|
||||
* any known chunk should be known in the original count, any unknown chunk
|
||||
* should be either known or unknown in the original.
|
||||
*/
|
||||
{
|
||||
png_uint_32 test;
|
||||
|
||||
test = flags[1][0] & ~flags[0][0];
|
||||
check_error(d, test, "new known chunk before IDAT");
|
||||
test = flags[1][1] & ~(flags[0][0] | flags[0][1]);
|
||||
check_error(d, test, "new unknown chunk before IDAT");
|
||||
test = flags[1][2] & ~flags[0][2];
|
||||
check_error(d, test, "new known chunk after IDAT");
|
||||
test = flags[1][3] & ~(flags[0][2] | flags[0][3]);
|
||||
check_error(d, test, "new unknown chunk after IDAT");
|
||||
}
|
||||
|
||||
/* Now each chunk in the original list should have been handled according to
|
||||
* the options set for that chunk, regardless of whether libpng knows about
|
||||
* it or not.
|
||||
*/
|
||||
check_handling(d, def, flags[0][0] | flags[0][1], flags[1][0], flags[1][1],
|
||||
"before IDAT");
|
||||
check_handling(d, def, flags[0][2] | flags[0][3], flags[1][2], flags[1][3],
|
||||
"after IDAT");
|
||||
}
|
||||
|
||||
static void
|
||||
perform_one_test_safe(FILE *fp, int argc, const char **argv,
|
||||
png_uint_32 *default_flags, display *d, const char *test)
|
||||
{
|
||||
if (setjmp(d->error_return) == 0)
|
||||
{
|
||||
d->test = test; /* allow use of d->error_return */
|
||||
perform_one_test(fp, argc, argv, default_flags, d);
|
||||
d->test = init; /* prevent use of d->error_return */
|
||||
}
|
||||
}
|
||||
|
||||
static const char *standard_tests[] =
|
||||
{
|
||||
"discard", "default=discard", 0,
|
||||
"save", "default=save", 0,
|
||||
"if-safe", "default=if-safe", 0,
|
||||
"vpAg", "vpAg=if-safe", 0,
|
||||
"sTER", "sTER=if-safe", 0,
|
||||
"IDAT", "default=discard", "IDAT=save", 0,
|
||||
"sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save",
|
||||
"sBIT=save", "sRGB=save", 0,
|
||||
0/*end*/
|
||||
};
|
||||
|
||||
static PNG_NORETURN void
|
||||
usage(const char *program, const char *reason)
|
||||
{
|
||||
fprintf(stderr, "pngunknown: %s: usage:\n %s [--strict] "
|
||||
"--default|{(CHNK|default|all)=(default|discard|if-safe|save)} "
|
||||
"testfile.png\n", reason, program);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
FILE *fp;
|
||||
png_uint_32 default_flags[4/*valid,unknown{before,after}*/];
|
||||
int strict = 0, default_tests = 0;
|
||||
const char *count_argv = "default=save";
|
||||
const char *touch_file = NULL;
|
||||
display d;
|
||||
|
||||
init_display(&d, argv[0]);
|
||||
|
||||
while (++argv, --argc > 0)
|
||||
{
|
||||
if (strcmp(*argv, "--strict") == 0)
|
||||
strict = 1;
|
||||
|
||||
else if (strcmp(*argv, "--default") == 0)
|
||||
default_tests = 1;
|
||||
|
||||
else if (strcmp(*argv, "--touch") == 0)
|
||||
{
|
||||
if (argc > 1)
|
||||
touch_file = *++argv, --argc;
|
||||
|
||||
else
|
||||
usage(d.program, "--touch: missing file name");
|
||||
}
|
||||
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/* A file name is required, but there should be no other arguments if
|
||||
* --default was specified.
|
||||
*/
|
||||
if (argc <= 0)
|
||||
usage(d.program, "missing test file");
|
||||
|
||||
/* GCC BUG: if (default_tests && argc != 1) triggers some weird GCC argc
|
||||
* optimization which causes warnings with -Wstrict-overflow!
|
||||
*/
|
||||
else if (default_tests) if (argc != 1)
|
||||
usage(d.program, "extra arguments");
|
||||
|
||||
# ifndef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
fprintf(stderr, "%s: warning: no 'save' support so arguments ignored\n",
|
||||
d.program);
|
||||
# endif
|
||||
|
||||
/* The name of the test file is the last argument; remove it. */
|
||||
d.file = argv[--argc];
|
||||
|
||||
fp = fopen(d.file, "rb");
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror(d.file);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* First find all the chunks, known and unknown, in the test file, a failure
|
||||
* here aborts the whole test.
|
||||
*/
|
||||
if (check(fp, 1, &count_argv, default_flags, &d) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS)
|
||||
{
|
||||
fprintf(stderr, "%s: %s: internal error\n", d.program, d.file);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
/* Now find what the various supplied options cause to change: */
|
||||
if (!default_tests)
|
||||
{
|
||||
d.test = cmd; /* acts as a flag to say exit, do not longjmp */
|
||||
perform_one_test(fp, argc, argv, default_flags, &d);
|
||||
d.test = init;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
const char **test = standard_tests;
|
||||
|
||||
/* Set the exit_test pointer here so we can continue after a libpng error.
|
||||
* NOTE: this leaks memory because the png_struct data from the failing
|
||||
* test is never freed.
|
||||
*/
|
||||
while (*test)
|
||||
{
|
||||
const char *this_test = *test++;
|
||||
const char **next = test;
|
||||
int count = display_rc(&d, strict), new_count;
|
||||
const char *result;
|
||||
int arg_count = 0;
|
||||
|
||||
while (*next) ++next, ++arg_count;
|
||||
|
||||
perform_one_test_safe(fp, arg_count, test, default_flags, &d,
|
||||
this_test);
|
||||
|
||||
new_count = display_rc(&d, strict);
|
||||
|
||||
if (new_count == count)
|
||||
result = "PASS";
|
||||
|
||||
else
|
||||
result = "FAIL";
|
||||
|
||||
printf("%s: %s %s\n", result, d.program, this_test);
|
||||
|
||||
test = next+1;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if (display_rc(&d, strict) == 0)
|
||||
{
|
||||
/* Success, touch the success file if appropriate */
|
||||
if (touch_file != NULL)
|
||||
{
|
||||
FILE *fsuccess = fopen(touch_file, "wt");
|
||||
|
||||
if (fsuccess != NULL)
|
||||
{
|
||||
int err = 0;
|
||||
fprintf(fsuccess, "PNG unknown tests succeeded\n");
|
||||
fflush(fsuccess);
|
||||
err = ferror(fsuccess);
|
||||
|
||||
if (fclose(fsuccess) || err)
|
||||
{
|
||||
fprintf(stderr, "%s: write failed\n", touch_file);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: open failed\n", touch_file);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
" test ignored because libpng was not built with unknown chunk support\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngvalid.c - validate libpng by constructing then reading png files.
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by John Cunningham Bowler
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
@ -24,8 +24,9 @@
|
||||
#define _GNU_SOURCE 1 /* For the floating point exception extension */
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@ -42,6 +43,8 @@
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED /* else pngvalid can do nothing */
|
||||
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
/* This deliberately lacks the PNG_CONST. */
|
||||
typedef png_byte *png_const_bytep;
|
||||
@ -82,10 +85,10 @@ typedef png_byte *png_const_bytep;
|
||||
/* 1.6.0 constifies many APIs, the following exists to allow pngvalid to be
|
||||
* compiled against earlier versions.
|
||||
*/
|
||||
# define png_const_strutp png_structp
|
||||
# define png_const_structp png_structp
|
||||
#endif
|
||||
|
||||
#include "zlib.h" /* For crc32 */
|
||||
#include <zlib.h> /* For crc32 */
|
||||
|
||||
#include <float.h> /* For floating point constants */
|
||||
#include <stdlib.h> /* For malloc */
|
||||
@ -104,7 +107,11 @@ typedef png_byte *png_const_bytep;
|
||||
#endif
|
||||
|
||||
/***************************** EXCEPTION HANDLING *****************************/
|
||||
#include "../visupng/cexcept.h"
|
||||
#ifdef PNG_FREESTANDING_TESTS
|
||||
# include <cexcept.h>
|
||||
#else
|
||||
# include "../visupng/cexcept.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define this not_the_cpp_this
|
||||
@ -170,6 +177,7 @@ static PNG_CONST char *colour_types[8] =
|
||||
"grayscale with alpha", invalid, "truecolour with alpha", invalid
|
||||
};
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Convert a double precision value to fixed point. */
|
||||
static png_fixed_point
|
||||
fix(double d)
|
||||
@ -177,12 +185,14 @@ fix(double d)
|
||||
d = floor(d * PNG_FP_1 + .5);
|
||||
return (png_fixed_point)d;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Generate random bytes. This uses a boring repeatable algorithm and it
|
||||
* is implemented here so that it gives the same set of numbers on every
|
||||
* architecture. It's a linear congruential generator (Knuth or Sedgewick
|
||||
* "Algorithms") but it comes from the 'feedback taps' table in Horowitz and
|
||||
* Hill, "The Art of Electronics".
|
||||
* Hill, "The Art of Electronics" (Pseudo-Random Bit Sequences and Noise
|
||||
* Generation.)
|
||||
*/
|
||||
static void
|
||||
make_random_bytes(png_uint_32* seed, void* pv, size_t size)
|
||||
@ -215,6 +225,7 @@ make_four_random_bytes(png_uint_32* seed, png_bytep bytes)
|
||||
make_random_bytes(seed, bytes, 4);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static void
|
||||
randomize(void *pv, size_t size)
|
||||
{
|
||||
@ -234,6 +245,7 @@ random_mod(unsigned int max)
|
||||
return x % max; /* 0 .. max-1 */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
static int
|
||||
random_choice(void)
|
||||
{
|
||||
@ -243,6 +255,8 @@ random_choice(void)
|
||||
|
||||
return x & 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* A numeric ID based on PNG file characteristics. The 'do_interlace' field
|
||||
* simply records whether pngvalid did the interlace itself or whether it
|
||||
@ -255,7 +269,7 @@ random_choice(void)
|
||||
|
||||
#define COL_FROM_ID(id) ((png_byte)((id)& 0x7U))
|
||||
#define DEPTH_FROM_ID(id) ((png_byte)(((id) >> 3) & 0x1fU))
|
||||
#define PALETTE_FROM_ID(id) ((int)(((id) >> 8) & 0x1f))
|
||||
#define PALETTE_FROM_ID(id) (((id) >> 8) & 0x1f)
|
||||
#define INTERLACE_FROM_ID(id) ((int)(((id) >> 13) & 0x3))
|
||||
#define DO_INTERLACE_FROM_ID(id) ((int)(((id)>>15) & 1))
|
||||
#define WIDTH_FROM_ID(id) (((id)>>16) & 0xff)
|
||||
@ -264,7 +278,7 @@ random_choice(void)
|
||||
/* Utility to construct a standard name for a standard image. */
|
||||
static size_t
|
||||
standard_name(char *buffer, size_t bufsize, size_t pos, png_byte colour_type,
|
||||
int bit_depth, int npalette, int interlace_type,
|
||||
int bit_depth, unsigned int npalette, int interlace_type,
|
||||
png_uint_32 w, png_uint_32 h, int do_interlace)
|
||||
{
|
||||
pos = safecat(buffer, bufsize, pos, colour_types[colour_type]);
|
||||
@ -326,10 +340,11 @@ standard_name_from_id(char *buffer, size_t bufsize, size_t pos, png_uint_32 id)
|
||||
/* The following defines the number of different palettes to generate for
|
||||
* each log bit depth of a colour type 3 standard image.
|
||||
*/
|
||||
#define PALETTE_COUNT(bit_depth) ((bit_depth) > 4 ? 1 : 16)
|
||||
#define PALETTE_COUNT(bit_depth) ((bit_depth) > 4 ? 1U : 16U)
|
||||
|
||||
static int
|
||||
next_format(png_bytep colour_type, png_bytep bit_depth, int* palette_number)
|
||||
next_format(png_bytep colour_type, png_bytep bit_depth,
|
||||
unsigned int* palette_number)
|
||||
{
|
||||
if (*bit_depth == 0)
|
||||
{
|
||||
@ -460,6 +475,7 @@ pixel_copy(png_bytep toBuffer, png_uint_32 toIndex,
|
||||
memmove(toBuffer+(toIndex>>3), fromBuffer+(fromIndex>>3), pixelSize>>3);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Copy a complete row of pixels, taking into account potential partial
|
||||
* bytes at the end.
|
||||
*/
|
||||
@ -525,6 +541,7 @@ pixel_cmp(png_const_bytep pa, png_const_bytep pb, png_uint_32 bit_width)
|
||||
return 1+where;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/*************************** BASIC PNG FILE WRITING ***************************/
|
||||
/* A png_store takes data from the sequential writer or provides data
|
||||
@ -635,6 +652,7 @@ store_pool_mark(png_bytep mark)
|
||||
make_four_random_bytes(store_seed, mark);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Use this for random 32 bit values; this function makes sure the result is
|
||||
* non-zero.
|
||||
*/
|
||||
@ -654,6 +672,7 @@ random_32(void)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
static void
|
||||
store_pool_init(png_store *ps, store_pool *pool)
|
||||
@ -859,6 +878,7 @@ store_log(png_store* ps, png_const_structp pp, png_const_charp message,
|
||||
store_verbose(ps, pp, is_error ? "error: " : "warning: ", message);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Internal error function, called with a png_store but no libpng stuff. */
|
||||
static void
|
||||
internal_error(png_store *ps, png_const_charp message)
|
||||
@ -871,6 +891,7 @@ internal_error(png_store *ps, png_const_charp message)
|
||||
Throw ps;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Functions to use as PNG callbacks. */
|
||||
static void
|
||||
@ -1008,6 +1029,7 @@ store_ensure_image(png_store *ps, png_const_structp pp, int nImages,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static void
|
||||
store_image_check(PNG_CONST png_store* ps, png_const_structp pp, int iImage)
|
||||
{
|
||||
@ -1037,6 +1059,7 @@ store_image_check(PNG_CONST png_store* ps, png_const_structp pp, int iImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
static void
|
||||
store_write(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
@ -1072,6 +1095,7 @@ store_flush(png_structp ppIn)
|
||||
UNUSED(ppIn) /*DOES NOTHING*/
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static size_t
|
||||
store_read_buffer_size(png_store *ps)
|
||||
{
|
||||
@ -1189,6 +1213,7 @@ store_progressive_read(png_store *ps, png_structp pp, png_infop pi)
|
||||
}
|
||||
while (store_read_buffer_next(ps));
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* The caller must fill this in: */
|
||||
static store_palette_entry *
|
||||
@ -1215,6 +1240,7 @@ store_write_palette(png_store *ps, int npalette)
|
||||
return ps->palette;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static store_palette_entry *
|
||||
store_current_palette(png_store *ps, int *npalette)
|
||||
{
|
||||
@ -1228,6 +1254,7 @@ store_current_palette(png_store *ps, int *npalette)
|
||||
*npalette = ps->current->npalette;
|
||||
return ps->current->palette;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/***************************** MEMORY MANAGEMENT*** ***************************/
|
||||
/* A store_memory is simply the header for an allocated block of memory. The
|
||||
@ -1502,25 +1529,29 @@ set_store_for_write(png_store *ps, png_infopp ppi,
|
||||
}
|
||||
|
||||
/* Cleanup when finished reading (either due to error or in the success case).
|
||||
* This routine exists even when there is no read support to make the code
|
||||
* tidier (avoid a mass of ifdefs) and so easier to maintain.
|
||||
*/
|
||||
static void
|
||||
store_read_reset(png_store *ps)
|
||||
{
|
||||
if (ps->pread != NULL)
|
||||
{
|
||||
anon_context(ps);
|
||||
|
||||
Try
|
||||
png_destroy_read_struct(&ps->pread, &ps->piread, NULL);
|
||||
|
||||
Catch_anonymous
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if (ps->pread != NULL)
|
||||
{
|
||||
/* error already output: continue */
|
||||
}
|
||||
anon_context(ps);
|
||||
|
||||
ps->pread = NULL;
|
||||
ps->piread = NULL;
|
||||
}
|
||||
Try
|
||||
png_destroy_read_struct(&ps->pread, &ps->piread, NULL);
|
||||
|
||||
Catch_anonymous
|
||||
{
|
||||
/* error already output: continue */
|
||||
}
|
||||
|
||||
ps->pread = NULL;
|
||||
ps->piread = NULL;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Always do this to be safe. */
|
||||
store_pool_delete(ps, &ps->read_memory_pool);
|
||||
@ -1531,6 +1562,7 @@ store_read_reset(png_store *ps)
|
||||
ps->validated = 0;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static void
|
||||
store_read_set(png_store *ps, png_uint_32 id)
|
||||
{
|
||||
@ -1608,6 +1640,7 @@ set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id,
|
||||
|
||||
return ps->pread;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* The overall cleanup of a store simply calls the above then removes all the
|
||||
* saved files. This does not delete the store itself.
|
||||
@ -1647,18 +1680,6 @@ typedef struct CIE_color
|
||||
double X, Y, Z;
|
||||
} CIE_color;
|
||||
|
||||
static double
|
||||
chromaticity_x(CIE_color c)
|
||||
{
|
||||
return c.X / (c.X + c.Y + c.Z);
|
||||
}
|
||||
|
||||
static double
|
||||
chromaticity_y(CIE_color c)
|
||||
{
|
||||
return c.Y / (c.X + c.Y + c.Z);
|
||||
}
|
||||
|
||||
typedef struct color_encoding
|
||||
{
|
||||
/* A description of an (R,G,B) encoding of color (as defined above); this
|
||||
@ -1671,11 +1692,24 @@ typedef struct color_encoding
|
||||
CIE_color red, green, blue; /* End points */
|
||||
} color_encoding;
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static double
|
||||
chromaticity_x(CIE_color c)
|
||||
{
|
||||
return c.X / (c.X + c.Y + c.Z);
|
||||
}
|
||||
|
||||
static double
|
||||
chromaticity_y(CIE_color c)
|
||||
{
|
||||
return c.Y / (c.X + c.Y + c.Z);
|
||||
}
|
||||
|
||||
static CIE_color
|
||||
white_point(PNG_CONST color_encoding *encoding)
|
||||
{
|
||||
CIE_color white;
|
||||
|
||||
|
||||
white.X = encoding->red.X + encoding->green.X + encoding->blue.X;
|
||||
white.Y = encoding->red.Y + encoding->green.Y + encoding->blue.Y;
|
||||
white.Z = encoding->red.Z + encoding->green.Z + encoding->blue.Z;
|
||||
@ -1683,6 +1717,7 @@ white_point(PNG_CONST color_encoding *encoding)
|
||||
return white;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
static void
|
||||
normalize_color_encoding(color_encoding *encoding)
|
||||
{
|
||||
@ -1702,6 +1737,7 @@ normalize_color_encoding(color_encoding *encoding)
|
||||
encoding->blue.Z /= whiteY;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static size_t
|
||||
safecat_color_encoding(char *buffer, size_t bufsize, size_t pos,
|
||||
@ -1742,6 +1778,7 @@ safecat_color_encoding(char *buffer, size_t bufsize, size_t pos,
|
||||
|
||||
return pos;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
typedef struct png_modifier
|
||||
{
|
||||
@ -1935,6 +1972,7 @@ modifier_init(png_modifier *pm)
|
||||
* to a calculation - not a digitization operation - unless the following API is
|
||||
* called directly.
|
||||
*/
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
static double digitize(PNG_CONST png_modifier *pm, double value,
|
||||
int sample_depth, int do_round)
|
||||
{
|
||||
@ -1959,7 +1997,10 @@ static double digitize(PNG_CONST png_modifier *pm, double value,
|
||||
if (do_round) value += .5;
|
||||
return floor(value)/digitization_factor;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) ||\
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
{
|
||||
/* Absolute error permitted in linear values - affected by the bit depth of
|
||||
@ -1971,7 +2012,9 @@ static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
else
|
||||
return pm->maxabs8;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
static double calcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
{
|
||||
/* Error in the linear composition arithmetic - only relevant when
|
||||
@ -2088,6 +2131,7 @@ static int output_quantization_factor(PNG_CONST png_modifier *pm, int in_depth,
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
|
||||
/* One modification structure must be provided for each chunk to be modified (in
|
||||
* fact more than one can be provided if multiple separate changes are desired
|
||||
@ -2140,6 +2184,7 @@ modification_init(png_modification *pmm)
|
||||
modification_reset(pmm);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
static void
|
||||
modifier_current_encoding(PNG_CONST png_modifier *pm, color_encoding *ce)
|
||||
{
|
||||
@ -2151,6 +2196,7 @@ modifier_current_encoding(PNG_CONST png_modifier *pm, color_encoding *ce)
|
||||
|
||||
ce->gamma = pm->current_gamma;
|
||||
}
|
||||
#endif
|
||||
|
||||
static size_t
|
||||
safecat_current_encoding(char *buffer, size_t bufsize, size_t pos,
|
||||
@ -2776,6 +2822,7 @@ srgb_modification_init(srgb_modification *me, png_modifier *pm, png_byte intent)
|
||||
pm->modifications = &me->this;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
typedef struct sbit_modification
|
||||
{
|
||||
png_modification this;
|
||||
@ -2842,6 +2889,7 @@ sbit_modification_init(sbit_modification *me, png_modifier *pm, png_byte sbit)
|
||||
me->this.next = pm->modifications;
|
||||
pm->modifications = &me->this;
|
||||
}
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||
|
||||
/***************************** STANDARD PNG FILES *****************************/
|
||||
@ -2903,9 +2951,9 @@ make_standard_palette(png_store* ps, int npalette, int do_tRNS)
|
||||
*/
|
||||
for (; i<8; ++i)
|
||||
{
|
||||
values[i][1] = (i&1) ? 255 : 0;
|
||||
values[i][2] = (i&2) ? 255 : 0;
|
||||
values[i][3] = (i&4) ? 255 : 0;
|
||||
values[i][1] = (png_byte)((i&1) ? 255U : 0U);
|
||||
values[i][2] = (png_byte)((i&2) ? 255U : 0U);
|
||||
values[i][3] = (png_byte)((i&4) ? 255U : 0U);
|
||||
}
|
||||
|
||||
/* Then add 62 grays (one quarter of the remaining 256 slots). */
|
||||
@ -3120,6 +3168,7 @@ transform_height(png_const_structp pp, png_byte colour_type, png_byte bit_depth)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* The following can only be defined here, now we have the definitions
|
||||
* of the transform image sizes.
|
||||
*/
|
||||
@ -3155,6 +3204,7 @@ standard_rowsize(png_const_structp pp, png_uint_32 id)
|
||||
width *= bit_size(pp, COL_FROM_ID(id), DEPTH_FROM_ID(id));
|
||||
return (width + 7) / 8;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
static void
|
||||
transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
@ -3166,20 +3216,20 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
switch (bit_size(pp, colour_type, bit_depth))
|
||||
{
|
||||
case 1:
|
||||
while (i<128/8) buffer[i] = v & 0xff, v += 17, ++i;
|
||||
while (i<128/8) buffer[i] = (png_byte)(v & 0xff), v += 17, ++i;
|
||||
return;
|
||||
|
||||
case 2:
|
||||
while (i<128/4) buffer[i] = v & 0xff, v += 33, ++i;
|
||||
while (i<128/4) buffer[i] = (png_byte)(v & 0xff), v += 33, ++i;
|
||||
return;
|
||||
|
||||
case 4:
|
||||
while (i<128/2) buffer[i] = v & 0xff, v += 65, ++i;
|
||||
while (i<128/2) buffer[i] = (png_byte)(v & 0xff), v += 65, ++i;
|
||||
return;
|
||||
|
||||
case 8:
|
||||
/* 256 bytes total, 128 bytes in each row set as follows: */
|
||||
while (i<128) buffer[i] = v & 0xff, ++v, ++i;
|
||||
while (i<128) buffer[i] = (png_byte)(v & 0xff), ++v, ++i;
|
||||
return;
|
||||
|
||||
case 16:
|
||||
@ -3187,7 +3237,12 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
* GA case as well as the 16 bit G case.
|
||||
*/
|
||||
while (i<128)
|
||||
buffer[2*i] = (v>>8) & 0xff, buffer[2*i+1] = v & 0xff, ++v, ++i;
|
||||
{
|
||||
buffer[2*i] = (png_byte)((v>>8) & 0xff);
|
||||
buffer[2*i+1] = (png_byte)(v & 0xff);
|
||||
++v;
|
||||
++i;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@ -3196,9 +3251,9 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
while (i<128)
|
||||
{
|
||||
/* Three bytes per pixel, r, g, b, make b by r^g */
|
||||
buffer[3*i+0] = (v >> 8) & 0xff;
|
||||
buffer[3*i+1] = v & 0xff;
|
||||
buffer[3*i+2] = ((v >> 8) ^ v) & 0xff;
|
||||
buffer[3*i+0] = (png_byte)((v >> 8) & 0xff);
|
||||
buffer[3*i+1] = (png_byte)(v & 0xff);
|
||||
buffer[3*i+2] = (png_byte)(((v >> 8) ^ v) & 0xff);
|
||||
++v;
|
||||
++i;
|
||||
}
|
||||
@ -3209,10 +3264,10 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
/* 65535 pixels, r, g, b, a; just replicate */
|
||||
while (i<128)
|
||||
{
|
||||
buffer[4*i+0] = (v >> 8) & 0xff;
|
||||
buffer[4*i+1] = v & 0xff;
|
||||
buffer[4*i+2] = (v >> 8) & 0xff;
|
||||
buffer[4*i+3] = v & 0xff;
|
||||
buffer[4*i+0] = (png_byte)((v >> 8) & 0xff);
|
||||
buffer[4*i+1] = (png_byte)(v & 0xff);
|
||||
buffer[4*i+2] = (png_byte)((v >> 8) & 0xff);
|
||||
buffer[4*i+3] = (png_byte)(v & 0xff);
|
||||
++v;
|
||||
++i;
|
||||
}
|
||||
@ -3226,14 +3281,14 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
while (i<128)
|
||||
{
|
||||
png_uint_32 t = v++;
|
||||
buffer[6*i+0] = (t >> 8) & 0xff;
|
||||
buffer[6*i+1] = t & 0xff;
|
||||
buffer[6*i+0] = (png_byte)((t >> 8) & 0xff);
|
||||
buffer[6*i+1] = (png_byte)(t & 0xff);
|
||||
t *= 257;
|
||||
buffer[6*i+2] = (t >> 8) & 0xff;
|
||||
buffer[6*i+3] = t & 0xff;
|
||||
buffer[6*i+2] = (png_byte)((t >> 8) & 0xff);
|
||||
buffer[6*i+3] = (png_byte)(t & 0xff);
|
||||
t *= 17;
|
||||
buffer[6*i+4] = (t >> 8) & 0xff;
|
||||
buffer[6*i+5] = t & 0xff;
|
||||
buffer[6*i+4] = (png_byte)((t >> 8) & 0xff);
|
||||
buffer[6*i+5] = (png_byte)(t & 0xff);
|
||||
++i;
|
||||
}
|
||||
|
||||
@ -3244,15 +3299,15 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
while (i<128)
|
||||
{
|
||||
png_uint_32 t = v++;
|
||||
buffer[8*i+0] = (t >> 8) & 0xff;
|
||||
buffer[8*i+1] = t & 0xff;
|
||||
buffer[8*i+4] = (t >> 8) & 0xff;
|
||||
buffer[8*i+5] = t & 0xff;
|
||||
buffer[8*i+0] = (png_byte)((t >> 8) & 0xff);
|
||||
buffer[8*i+1] = (png_byte)(t & 0xff);
|
||||
buffer[8*i+4] = (png_byte)((t >> 8) & 0xff);
|
||||
buffer[8*i+5] = (png_byte)(t & 0xff);
|
||||
t *= 257;
|
||||
buffer[8*i+2] = (t >> 8) & 0xff;
|
||||
buffer[8*i+3] = t & 0xff;
|
||||
buffer[8*i+6] = (t >> 8) & 0xff;
|
||||
buffer[8*i+7] = t & 0xff;
|
||||
buffer[8*i+2] = (png_byte)((t >> 8) & 0xff);
|
||||
buffer[8*i+3] = (png_byte)(t & 0xff);
|
||||
buffer[8*i+6] = (png_byte)((t >> 8) & 0xff);
|
||||
buffer[8*i+7] = (png_byte)(t & 0xff);
|
||||
++i;
|
||||
}
|
||||
return;
|
||||
@ -3277,8 +3332,8 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
*/
|
||||
static void
|
||||
make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
png_byte PNG_CONST bit_depth, int palette_number, int interlace_type,
|
||||
png_const_charp name)
|
||||
png_byte PNG_CONST bit_depth, unsigned int palette_number,
|
||||
int interlace_type, png_const_charp name)
|
||||
{
|
||||
context(ps, fault);
|
||||
|
||||
@ -3302,6 +3357,11 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
# if defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
# define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_zTXt
|
||||
# else
|
||||
# define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_NONE
|
||||
# endif
|
||||
{
|
||||
static char key[] = "image name"; /* must be writeable */
|
||||
size_t pos;
|
||||
@ -3311,7 +3371,7 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
/* Use a compressed text string to test the correct interaction of text
|
||||
* compression and IDAT compression.
|
||||
*/
|
||||
text.compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text.compression = TEXT_COMPRESSION;
|
||||
text.key = key;
|
||||
/* Yuck: the text must be writable! */
|
||||
pos = safecat(copy, sizeof copy, 0, ps->wname);
|
||||
@ -3369,7 +3429,7 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
/* Use a compressed text string to test the correct interaction of text
|
||||
* compression and IDAT compression.
|
||||
*/
|
||||
text.compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text.compression = TEXT_COMPRESSION;
|
||||
text.key = key;
|
||||
text.text = comment;
|
||||
text.text_length = (sizeof comment)-1;
|
||||
@ -3405,7 +3465,7 @@ make_transform_images(png_store *ps)
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
/* This is in case of errors. */
|
||||
safecat(ps->test, sizeof ps->test, 0, "make standard images");
|
||||
@ -3453,6 +3513,7 @@ interlace_row(png_bytep buffer, png_const_bytep imageRow,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static void
|
||||
deinterlace_row(png_bytep buffer, png_const_bytep row,
|
||||
unsigned int pixel_size, png_uint_32 w, int pass)
|
||||
@ -3473,6 +3534,7 @@ deinterlace_row(png_bytep buffer, png_const_bytep row,
|
||||
++xin;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Build a single row for the 'size' test images; this fills in only the
|
||||
* first bit_width bits of the sample row.
|
||||
@ -3530,6 +3592,30 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
png_set_IHDR(pp, pi, w, h, bit_depth, colour_type, interlace_type,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
{
|
||||
static char key[] = "image name"; /* must be writeable */
|
||||
size_t pos;
|
||||
png_text text;
|
||||
char copy[FILE_NAME_SIZE];
|
||||
|
||||
/* Use a compressed text string to test the correct interaction of text
|
||||
* compression and IDAT compression.
|
||||
*/
|
||||
text.compression = TEXT_COMPRESSION;
|
||||
text.key = key;
|
||||
/* Yuck: the text must be writable! */
|
||||
pos = safecat(copy, sizeof copy, 0, ps->wname);
|
||||
text.text = copy;
|
||||
text.text_length = pos;
|
||||
text.itxt_length = 0;
|
||||
text.lang = 0;
|
||||
text.lang_key = 0;
|
||||
|
||||
png_set_text(pp, pi, &text, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (colour_type == 3) /* palette */
|
||||
init_standard_palette(ps, pp, pi, 1U << bit_depth, 0/*do tRNS*/);
|
||||
|
||||
@ -3607,6 +3693,27 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
{
|
||||
static char key[] = "end marker";
|
||||
static char comment[] = "end";
|
||||
png_text text;
|
||||
|
||||
/* Use a compressed text string to test the correct interaction of text
|
||||
* compression and IDAT compression.
|
||||
*/
|
||||
text.compression = TEXT_COMPRESSION;
|
||||
text.key = key;
|
||||
text.text = comment;
|
||||
text.text_length = (sizeof comment)-1;
|
||||
text.itxt_length = 0;
|
||||
text.lang = 0;
|
||||
text.lang_key = 0;
|
||||
|
||||
png_set_text(pp, pi, &text, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_write_end(pp, pi);
|
||||
|
||||
/* And store this under the appropriate id, then clean up. */
|
||||
@ -3671,6 +3778,7 @@ make_size_images(png_store *ps)
|
||||
make_size(ps, 6, 3, WRITE_BDHI);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Return a row based on image id and 'y' for checking: */
|
||||
static void
|
||||
standard_row(png_const_structp pp, png_byte std[STANDARD_ROWMAX],
|
||||
@ -3682,6 +3790,7 @@ standard_row(png_const_structp pp, png_byte std[STANDARD_ROWMAX],
|
||||
size_row(std, WIDTH_FROM_ID(id) * bit_size(pp, COL_FROM_ID(id),
|
||||
DEPTH_FROM_ID(id)), y);
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Tests - individual test cases */
|
||||
/* Like 'make_standard' but errors are deliberately introduced into the calls
|
||||
@ -3966,6 +4075,7 @@ perform_formatting_test(png_store *volatile ps)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Because we want to use the same code in both the progressive reader and the
|
||||
* sequential reader it is necessary to deal with the fact that the progressive
|
||||
* reader callbacks only have one parameter (png_get_progressive_ptr()), so this
|
||||
@ -4560,6 +4670,114 @@ sequential_row(standard_display *dp, png_structp pp, png_infop pi,
|
||||
png_read_end(pp, pi);
|
||||
}
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
static void
|
||||
standard_check_text(png_const_structp pp, png_const_textp tp,
|
||||
png_const_charp keyword, png_const_charp text)
|
||||
{
|
||||
char msg[1024];
|
||||
size_t pos = safecat(msg, sizeof msg, 0, "text: ");
|
||||
size_t ok;
|
||||
|
||||
pos = safecat(msg, sizeof msg, pos, keyword);
|
||||
pos = safecat(msg, sizeof msg, pos, ": ");
|
||||
ok = pos;
|
||||
|
||||
if (tp->compression != TEXT_COMPRESSION)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
sprintf(buf, "compression [%d->%d], ", TEXT_COMPRESSION,
|
||||
tp->compression);
|
||||
pos = safecat(msg, sizeof msg, pos, buf);
|
||||
}
|
||||
|
||||
if (tp->key == NULL || strcmp(tp->key, keyword) != 0)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, "keyword \"");
|
||||
if (tp->key != NULL)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, tp->key);
|
||||
pos = safecat(msg, sizeof msg, pos, "\", ");
|
||||
}
|
||||
|
||||
else
|
||||
pos = safecat(msg, sizeof msg, pos, "null, ");
|
||||
}
|
||||
|
||||
if (tp->text == NULL)
|
||||
pos = safecat(msg, sizeof msg, pos, "text lost, ");
|
||||
|
||||
else
|
||||
{
|
||||
if (tp->text_length != strlen(text))
|
||||
{
|
||||
char buf[64];
|
||||
sprintf(buf, "text length changed[%lu->%lu], ",
|
||||
(unsigned long)strlen(text), (unsigned long)tp->text_length);
|
||||
pos = safecat(msg, sizeof msg, pos, buf);
|
||||
}
|
||||
|
||||
if (strcmp(tp->text, text) != 0)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, "text becomes \"");
|
||||
pos = safecat(msg, sizeof msg, pos, tp->text);
|
||||
pos = safecat(msg, sizeof msg, pos, "\" (was \"");
|
||||
pos = safecat(msg, sizeof msg, pos, text);
|
||||
pos = safecat(msg, sizeof msg, pos, "\"), ");
|
||||
}
|
||||
}
|
||||
|
||||
if (tp->itxt_length != 0)
|
||||
pos = safecat(msg, sizeof msg, pos, "iTXt length set, ");
|
||||
|
||||
if (tp->lang != NULL)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, "iTXt language \"");
|
||||
pos = safecat(msg, sizeof msg, pos, tp->lang);
|
||||
pos = safecat(msg, sizeof msg, pos, "\", ");
|
||||
}
|
||||
|
||||
if (tp->lang_key != NULL)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, "iTXt keyword \"");
|
||||
pos = safecat(msg, sizeof msg, pos, tp->lang_key);
|
||||
pos = safecat(msg, sizeof msg, pos, "\", ");
|
||||
}
|
||||
|
||||
if (pos > ok)
|
||||
{
|
||||
msg[pos-2] = '\0'; /* Remove the ", " at the end */
|
||||
png_error(pp, msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
standard_text_validate(standard_display *dp, png_const_structp pp,
|
||||
png_infop pi)
|
||||
{
|
||||
png_textp tp = NULL;
|
||||
png_uint_32 num_text = png_get_text(pp, pi, &tp, NULL);
|
||||
|
||||
if (num_text == 2 && tp != NULL)
|
||||
{
|
||||
standard_check_text(pp, tp, "image name", dp->ps->current->name);
|
||||
standard_check_text(pp, tp+1, "end marker", "end");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
char msg[64];
|
||||
|
||||
sprintf(msg, "expected two text items, got %lu",
|
||||
(unsigned long)num_text);
|
||||
png_error(pp, msg);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define standard_text_validate(dp,pp,pi) ((void)0)
|
||||
#endif
|
||||
|
||||
static void
|
||||
standard_row_validate(standard_display *dp, png_const_structp pp,
|
||||
int iImage, int iDisplay, png_uint_32 y)
|
||||
@ -4591,8 +4809,8 @@ standard_row_validate(standard_display *dp, png_const_structp pp,
|
||||
dp->bit_width)) != 0)
|
||||
{
|
||||
char msg[64];
|
||||
sprintf(msg, "PNG image row[%d][%d] changed from %.2x to %.2x", y,
|
||||
where-1, std[where-1],
|
||||
sprintf(msg, "PNG image row[%lu][%d] changed from %.2x to %.2x",
|
||||
(unsigned long)y, where-1, std[where-1],
|
||||
store_image_row(dp->ps, pp, iImage, y)[where-1]);
|
||||
png_error(pp, msg);
|
||||
}
|
||||
@ -4609,8 +4827,8 @@ standard_row_validate(standard_display *dp, png_const_structp pp,
|
||||
dp->bit_width)) != 0)
|
||||
{
|
||||
char msg[64];
|
||||
sprintf(msg, "display row[%d][%d] changed from %.2x to %.2x", y,
|
||||
where-1, std[where-1],
|
||||
sprintf(msg, "display row[%lu][%d] changed from %.2x to %.2x",
|
||||
(unsigned long)y, where-1, std[where-1],
|
||||
store_image_row(dp->ps, pp, iDisplay, y)[where-1]);
|
||||
png_error(pp, msg);
|
||||
}
|
||||
@ -4647,6 +4865,7 @@ standard_end(png_structp ppIn, png_infop pi)
|
||||
/* Validate the image - progressive reading only produces one variant for
|
||||
* interlaced images.
|
||||
*/
|
||||
standard_text_validate(dp, pp, pi);
|
||||
standard_image_validate(dp, pp, 0, -1);
|
||||
}
|
||||
|
||||
@ -4716,7 +4935,10 @@ standard_test(png_store* PNG_CONST psIn, png_uint_32 PNG_CONST id,
|
||||
* image is correct.
|
||||
*/
|
||||
if (!d.speed)
|
||||
{
|
||||
standard_text_validate(&d, pp, pi);
|
||||
standard_image_validate(&d, pp, 0, 1);
|
||||
}
|
||||
else
|
||||
d.ps->validated = 1;
|
||||
}
|
||||
@ -5794,6 +6016,7 @@ image_transform_default_ini(PNG_CONST image_transform *this,
|
||||
this->next->ini(this->next, that);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
static int
|
||||
image_transform_default_add(image_transform *this,
|
||||
PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
|
||||
@ -5806,6 +6029,7 @@ image_transform_default_add(image_transform *this,
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
/* png_set_palette_to_rgb */
|
||||
@ -7121,7 +7345,7 @@ perform_transform_test(png_modifier *pm)
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number))
|
||||
{
|
||||
@ -7484,6 +7708,7 @@ gamma_component_compose(int do_background, double input_sample, double alpha,
|
||||
{
|
||||
switch (do_background)
|
||||
{
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
case PNG_BACKGROUND_GAMMA_SCREEN:
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
case PNG_BACKGROUND_GAMMA_UNIQUE:
|
||||
@ -7501,6 +7726,7 @@ gamma_component_compose(int do_background, double input_sample, double alpha,
|
||||
input_sample = background;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD:
|
||||
@ -7533,6 +7759,9 @@ gamma_component_compose(int do_background, double input_sample, double alpha,
|
||||
/* Standard cases where no compositing is done (so the component
|
||||
* value is already correct.)
|
||||
*/
|
||||
UNUSED(alpha)
|
||||
UNUSED(background)
|
||||
UNUSED(compose)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -7932,11 +8161,13 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi,
|
||||
*/
|
||||
switch (do_background)
|
||||
{
|
||||
case PNG_BACKGROUND_GAMMA_SCREEN:
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
case PNG_BACKGROUND_GAMMA_UNIQUE:
|
||||
use_background = (alpha >= 0 && alpha < 1);
|
||||
/*FALL THROUGH*/
|
||||
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
case PNG_BACKGROUND_GAMMA_SCREEN:
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
case PNG_BACKGROUND_GAMMA_UNIQUE:
|
||||
use_background = (alpha >= 0 && alpha < 1);
|
||||
/*FALL THROUGH*/
|
||||
# endif
|
||||
# ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD:
|
||||
case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN:
|
||||
@ -8277,7 +8508,8 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
char msg[64];
|
||||
|
||||
/* No transform is expected on the threshold tests. */
|
||||
sprintf(msg, "gamma: below threshold row %d changed", y);
|
||||
sprintf(msg, "gamma: below threshold row %lu changed",
|
||||
(unsigned long)y);
|
||||
|
||||
png_error(pp, msg);
|
||||
}
|
||||
@ -8482,7 +8714,7 @@ perform_gamma_threshold_tests(png_modifier *pm)
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
/* Don't test more than one instance of each palette - it's pointless, in
|
||||
* fact this test is somewhat excessive since libpng doesn't make this
|
||||
@ -8547,7 +8779,7 @@ static void perform_gamma_transform_tests(png_modifier *pm)
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number))
|
||||
{
|
||||
@ -8576,11 +8808,8 @@ static void perform_gamma_sbit_tests(png_modifier *pm)
|
||||
*/
|
||||
for (sbit=pm->sbitlow; sbit<(1<<READ_BDHI); ++sbit)
|
||||
{
|
||||
png_byte colour_type, bit_depth;
|
||||
int npalette;
|
||||
|
||||
colour_type = bit_depth = 0;
|
||||
npalette = 0;
|
||||
png_byte colour_type = 0, bit_depth = 0;
|
||||
unsigned int npalette = 0;
|
||||
|
||||
while (next_format(&colour_type, &bit_depth, &npalette))
|
||||
if ((colour_type & PNG_COLOR_MASK_ALPHA) == 0 &&
|
||||
@ -8666,8 +8895,8 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
|
||||
}
|
||||
#endif /* 16 to 8 bit conversion */
|
||||
|
||||
#if defined PNG_READ_BACKGROUND_SUPPORTED ||\
|
||||
defined PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
static void gamma_composition_test(png_modifier *pm,
|
||||
PNG_CONST png_byte colour_type, PNG_CONST png_byte bit_depth,
|
||||
PNG_CONST int palette_number,
|
||||
@ -8796,7 +9025,7 @@ perform_gamma_composition_tests(png_modifier *pm, int do_background,
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
/* Skip the non-alpha cases - there is no setting of a transparency colour at
|
||||
* present.
|
||||
@ -8857,7 +9086,9 @@ perform_gamma_test(png_modifier *pm, int summary)
|
||||
/* Save certain values for the temporary overrides below. */
|
||||
unsigned int calculations_use_input_precision =
|
||||
pm->calculations_use_input_precision;
|
||||
double maxout8 = pm->maxout8;
|
||||
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
double maxout8 = pm->maxout8;
|
||||
# endif
|
||||
|
||||
/* First some arbitrary no-transform tests: */
|
||||
if (!pm->this.speed && pm->test_gamma_threshold)
|
||||
@ -8976,6 +9207,7 @@ perform_gamma_test(png_modifier *pm, int summary)
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* INTERLACE MACRO VALIDATION */
|
||||
/* This is copied verbatim from the specification, it is simply the pass
|
||||
@ -9425,7 +9657,7 @@ static void signal_handler(int signum)
|
||||
}
|
||||
|
||||
/* main program */
|
||||
int main(int argc, PNG_CONST char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
volatile int summary = 1; /* Print the error summary at the end */
|
||||
volatile int memstats = 0; /* Print memory statistics at the end */
|
||||
@ -9784,7 +10016,9 @@ int main(int argc, PNG_CONST char **argv)
|
||||
{
|
||||
perform_interlace_macro_validation();
|
||||
perform_formatting_test(&pm.this);
|
||||
perform_standard_test(&pm);
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
perform_standard_test(&pm);
|
||||
# endif
|
||||
perform_error_test(&pm);
|
||||
}
|
||||
|
||||
@ -9792,7 +10026,9 @@ int main(int argc, PNG_CONST char **argv)
|
||||
if (pm.test_size)
|
||||
{
|
||||
make_size_images(&pm.this);
|
||||
perform_size_test(&pm);
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
perform_size_test(&pm);
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
@ -9885,7 +10121,20 @@ int main(int argc, PNG_CONST char **argv)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: open failed\n", touch);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else /* write not supported */
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "pngvalid: no write support in libpng, all tests skipped\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
104
contrib/libtests/readpng.c
Normal file
@ -0,0 +1,104 @@
|
||||
/* readpng.c
|
||||
*
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Load an arbitrary number of PNG files (from the command line, or, if there
|
||||
* are no arguments on the command line, from stdin) then run a time test by
|
||||
* reading each file by row. The test does nothing with the read result and
|
||||
* does no transforms. The only output is a time as a floating point number of
|
||||
* seconds with 9 decimal digits.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Define the following to use this test against your installed libpng, rather
|
||||
* than the one being built here:
|
||||
*/
|
||||
#ifdef PNG_FREESTANDING_TESTS
|
||||
# include <png.h>
|
||||
#else
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
static int
|
||||
read_png(FILE *fp)
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytep row = NULL, display = NULL;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
if (row != NULL) free(row);
|
||||
if (display != NULL) free(display);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, NULL, 0);
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
{
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
row = malloc(rowbytes);
|
||||
display = malloc(rowbytes);
|
||||
|
||||
if (row == NULL || display == NULL)
|
||||
png_error(png_ptr, "OOM allocating row buffers");
|
||||
|
||||
{
|
||||
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
||||
int passes = png_set_interlace_handling(png_ptr);
|
||||
int pass;
|
||||
|
||||
png_start_read_image(png_ptr);
|
||||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_uint_32 y = height;
|
||||
|
||||
/* NOTE: this trashes the row each time; interlace handling won't
|
||||
* work, but this avoids memory thrashing for speed testing.
|
||||
*/
|
||||
while (y-- > 0)
|
||||
png_read_row(png_ptr, row, display);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure to read to the end of the file: */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
free(row);
|
||||
free(display);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
/* Exit code 0 on success. */
|
||||
return !read_png(stdin);
|
||||
}
|
999
contrib/libtests/tarith.c
Normal file
@ -0,0 +1,999 @@
|
||||
|
||||
/* tarith.c
|
||||
*
|
||||
* Copyright (c) 2011-2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Test internal arithmetic functions of libpng.
|
||||
*
|
||||
* This code must be linked against a math library (-lm), but does not require
|
||||
* libpng or zlib to work. Because it includes the complete source of 'png.c'
|
||||
* it tests the code with whatever compiler options are used to build it.
|
||||
* Changing these options can substantially change the errors in the
|
||||
* calculations that the compiler chooses!
|
||||
*/
|
||||
#define _POSIX_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
|
||||
/* Obtain a copy of the code to be tested (plus other things), disabling
|
||||
* stuff that is not required.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../../pngpriv.h"
|
||||
|
||||
#define png_error png_warning
|
||||
|
||||
void png_warning(png_const_structrp png_ptr, png_const_charp msg)
|
||||
{
|
||||
fprintf(stderr, "validation: %s\n", msg);
|
||||
}
|
||||
|
||||
#define png_fixed_error png_fixed_warning
|
||||
|
||||
void png_fixed_warning(png_const_structrp png_ptr, png_const_charp msg)
|
||||
{
|
||||
fprintf(stderr, "overflow in: %s\n", msg);
|
||||
}
|
||||
|
||||
#define png_set_error_fn(pp, ep, efp, wfp) ((void)0)
|
||||
#define png_malloc(pp, s) malloc(s)
|
||||
#define png_malloc_warn(pp, s) malloc(s)
|
||||
#define png_malloc_base(pp, s) malloc(s)
|
||||
#define png_calloc(pp, s) calloc(1, (s))
|
||||
#define png_free(pp, s) free(s)
|
||||
|
||||
#define png_safecat(b, sb, pos, str) (pos)
|
||||
#define png_format_number(start, end, format, number) (start)
|
||||
|
||||
#define crc32(crc, pp, s) (crc)
|
||||
#define inflateReset(zs) Z_OK
|
||||
|
||||
#define png_create_struct(type) (0)
|
||||
#define png_destroy_struct(pp) ((void)0)
|
||||
#define png_create_struct_2(type, m, mm) (0)
|
||||
#define png_destroy_struct_2(pp, f, mm) ((void)0)
|
||||
|
||||
#undef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
#undef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#undef PNG_USER_MEM_SUPPORTED
|
||||
|
||||
#include "../../png.c"
|
||||
|
||||
/* Validate ASCII to fp routines. */
|
||||
static int verbose = 0;
|
||||
|
||||
int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
{
|
||||
int showall = 0;
|
||||
double max_error=2; /* As a percentage error-in-last-digit/.5 */
|
||||
double max_error_abs=17; /* Used when precision is DBL_DIG */
|
||||
double max = 0;
|
||||
double max_abs = 0;
|
||||
double test = 0; /* Important to test this. */
|
||||
int precision = 5;
|
||||
int nonfinite = 0;
|
||||
int finite = 0;
|
||||
int ok = 0;
|
||||
int failcount = 0;
|
||||
int minorarith = 0;
|
||||
|
||||
while (--argc > 0)
|
||||
if (strcmp(*++argv, "-a") == 0)
|
||||
showall = 1;
|
||||
else if (strcmp(*argv, "-e") == 0 && argc > 0)
|
||||
{
|
||||
--argc;
|
||||
max_error = atof(*++argv);
|
||||
}
|
||||
else if (strcmp(*argv, "-E") == 0 && argc > 0)
|
||||
{
|
||||
--argc;
|
||||
max_error_abs = atof(*++argv);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
png_size_t index;
|
||||
int state, failed = 0;
|
||||
char buffer[64];
|
||||
|
||||
if (isfinite(test))
|
||||
++finite;
|
||||
else
|
||||
++nonfinite;
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "%.*g %d\n", DBL_DIG, test, precision);
|
||||
|
||||
/* Check for overflow in the buffer by setting a marker. */
|
||||
memset(buffer, 71, sizeof buffer);
|
||||
|
||||
png_ascii_from_fp(0, buffer, precision+10, test, precision);
|
||||
|
||||
/* Allow for a three digit exponent, this stuff will fail if
|
||||
* the exponent is bigger than this!
|
||||
*/
|
||||
if (buffer[precision+7] != 71)
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s'[%lu] buffer overflow\n", test,
|
||||
precision, buffer, (unsigned long)strlen(buffer));
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
/* Following are used for the number parser below and must be
|
||||
* initialized to zero.
|
||||
*/
|
||||
state = 0;
|
||||
index = 0;
|
||||
if (!isfinite(test))
|
||||
{
|
||||
/* Expect 'inf' */
|
||||
if (test >= 0 && strcmp(buffer, "inf") ||
|
||||
test < 0 && strcmp(buffer, "-inf"))
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but expected 'inf'\n", test,
|
||||
precision, buffer);
|
||||
failed = 1;
|
||||
}
|
||||
}
|
||||
else if (!png_check_fp_number(buffer, precision+10, &state, &index) ||
|
||||
buffer[index] != 0)
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but has bad format ('%c')\n", test,
|
||||
precision, buffer, buffer[index]);
|
||||
failed = 1;
|
||||
}
|
||||
else if (PNG_FP_IS_NEGATIVE(state) && !(test < 0))
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but negative value not so reported\n",
|
||||
test, precision, buffer);
|
||||
failed = 1;
|
||||
assert(!PNG_FP_IS_ZERO(state));
|
||||
assert(!PNG_FP_IS_POSITIVE(state));
|
||||
}
|
||||
else if (PNG_FP_IS_ZERO(state) && !(test == 0))
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but zero value not so reported\n",
|
||||
test, precision, buffer);
|
||||
failed = 1;
|
||||
assert(!PNG_FP_IS_NEGATIVE(state));
|
||||
assert(!PNG_FP_IS_POSITIVE(state));
|
||||
}
|
||||
else if (PNG_FP_IS_POSITIVE(state) && !(test > 0))
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but postive value not so reported\n",
|
||||
test, precision, buffer);
|
||||
failed = 1;
|
||||
assert(!PNG_FP_IS_NEGATIVE(state));
|
||||
assert(!PNG_FP_IS_ZERO(state));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check the result against the original. */
|
||||
double out = atof(buffer);
|
||||
double change = fabs((out - test)/test);
|
||||
double allow = .5/pow(10,
|
||||
(precision >= DBL_DIG) ? DBL_DIG-1 : precision-1);
|
||||
|
||||
/* NOTE: if you hit this error case are you compiling with gcc
|
||||
* and -O0? Try -O2 - the errors can accumulate if the FP
|
||||
* code above is not optimized and may drift outside the .5 in
|
||||
* DBL_DIG allowed. In any case a small number of errors may
|
||||
* occur (very small ones - 1 or 2%) because of rounding in the
|
||||
* calculations, either in the conversion API or in atof.
|
||||
*/
|
||||
if (change >= allow && (isfinite(out) ||
|
||||
fabs(test/DBL_MAX) <= 1-allow))
|
||||
{
|
||||
double percent = (precision >= DBL_DIG) ? max_error_abs : max_error;
|
||||
double allowp = (change-allow)*100/allow;
|
||||
|
||||
if (precision >= DBL_DIG)
|
||||
{
|
||||
if (max_abs < allowp) max_abs = allowp;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (max < allowp) max = allowp;
|
||||
}
|
||||
|
||||
if (showall || allowp >= percent)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%.*g[%d] -> '%s' -> %.*g number changed (%g > %g (%d%%))\n",
|
||||
DBL_DIG, test, precision, buffer, DBL_DIG, out, change, allow,
|
||||
(int)round(allowp));
|
||||
failed = 1;
|
||||
}
|
||||
else
|
||||
++minorarith;
|
||||
}
|
||||
}
|
||||
|
||||
if (failed)
|
||||
++failcount;
|
||||
else
|
||||
++ok;
|
||||
|
||||
skip:
|
||||
/* Generate a new number and precision. */
|
||||
precision = rand();
|
||||
if (precision & 1) test = -test;
|
||||
precision >>= 1;
|
||||
|
||||
/* Generate random numbers. */
|
||||
if (test == 0 || !isfinite(test))
|
||||
test = precision+1;
|
||||
else
|
||||
{
|
||||
/* Derive the exponent from the previous rand() value. */
|
||||
int exponent = precision % (DBL_MAX_EXP - DBL_MIN_EXP) + DBL_MIN_EXP;
|
||||
int tmp;
|
||||
test = frexp(test * rand(), &tmp);
|
||||
test = ldexp(test, exponent);
|
||||
precision >>= 8; /* arbitrary */
|
||||
}
|
||||
|
||||
/* This limits the precision to 32 digits, enough for standard
|
||||
* IEEE implementations which have at most 15 digits.
|
||||
*/
|
||||
precision = (precision & 0x1f) + 1;
|
||||
}
|
||||
while (--count);
|
||||
|
||||
printf("Tested %d finite values, %d non-finite, %d OK (%d failed) %d minor "
|
||||
"arithmetic errors\n", finite, nonfinite, ok, failcount, minorarith);
|
||||
printf(" Error with >=%d digit precision %.2f%%\n", DBL_DIG, max_abs);
|
||||
printf(" Error with < %d digit precision %.2f%%\n", DBL_DIG, max);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Observe that valid FP numbers have the forms listed in the PNG extensions
|
||||
* specification:
|
||||
*
|
||||
* [+,-]{integer,integer.fraction,.fraction}[{e,E}[+,-]integer]
|
||||
*
|
||||
* Test each of these in turn, including invalid cases.
|
||||
*/
|
||||
typedef enum checkfp_state
|
||||
{
|
||||
start, fraction, exponent, states
|
||||
} checkfp_state;
|
||||
|
||||
/* The characters (other than digits) that characterize the states: */
|
||||
static const char none[] = "";
|
||||
static const char hexdigits[16] = "0123456789ABCDEF";
|
||||
|
||||
static const struct
|
||||
{
|
||||
const char *start; /* Characters valid at the start */
|
||||
const char *end; /* Valid characters that end the state */
|
||||
const char *tests; /* Characters to test after 2 digits seen */
|
||||
}
|
||||
state_characters[states] =
|
||||
{
|
||||
/* start: */ { "+-.", ".eE", "+-.e*0369" },
|
||||
/* fraction: */ { none, "eE", "+-.E#0147" },
|
||||
/* exponent: */ { "+-", none, "+-.eE^0258" }
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char number[1024]; /* Buffer for number being tested */
|
||||
int limit; /* Command line limit */
|
||||
int verbose; /* Shadows global variable */
|
||||
int ctimes; /* Number of numbers tested */
|
||||
int cmillions; /* Count of millions of numbers */
|
||||
int cinvalid; /* Invalid strings checked */
|
||||
int cnoaccept; /* Characters not accepted */
|
||||
}
|
||||
checkfp_command;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int cnumber; /* Index into number string */
|
||||
checkfp_state check_state; /* Current number state */
|
||||
int at_start; /* At start (first character) of state */
|
||||
int cdigits_in_state; /* Digits seen in that state */
|
||||
int limit; /* Limit on same for checking all chars */
|
||||
int state; /* Current parser state */
|
||||
int is_negative; /* Number is negative */
|
||||
int is_zero; /* Number is (still) zero */
|
||||
int number_was_valid; /* Previous character validity */
|
||||
}
|
||||
checkfp_control;
|
||||
|
||||
static int check_all_characters(checkfp_command *co, checkfp_control c);
|
||||
|
||||
static int check_some_characters(checkfp_command *co, checkfp_control c,
|
||||
const char *tests);
|
||||
|
||||
static int check_one_character(checkfp_command *co, checkfp_control c, int ch)
|
||||
{
|
||||
/* Test this character (ch) to ensure the parser does the correct thing.
|
||||
*/
|
||||
png_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);
|
||||
|
||||
if (c.check_state != exponent && isdigit(ch) && ch != '0')
|
||||
c.is_zero = 0;
|
||||
|
||||
if (c.check_state == start && c.at_start && ch == '-')
|
||||
c.is_negative = 1;
|
||||
|
||||
if (isprint(ch))
|
||||
co->number[c.cnumber++] = (char)ch;
|
||||
else
|
||||
{
|
||||
co->number[c.cnumber++] = '<';
|
||||
co->number[c.cnumber++] = hexdigits[(ch >> 4) & 0xf];
|
||||
co->number[c.cnumber++] = hexdigits[ch & 0xf];
|
||||
co->number[c.cnumber++] = '>';
|
||||
}
|
||||
co->number[c.cnumber] = 0;
|
||||
|
||||
if (co->verbose > 1)
|
||||
fprintf(stderr, "%s\n", co->number);
|
||||
|
||||
if (++(co->ctimes) == 1000000)
|
||||
{
|
||||
if (co->verbose == 1)
|
||||
fputc('.', stderr);
|
||||
co->ctimes = 0;
|
||||
++(co->cmillions);
|
||||
}
|
||||
|
||||
if (!number_is_valid)
|
||||
++(co->cinvalid);
|
||||
|
||||
if (!character_accepted)
|
||||
++(co->cnoaccept);
|
||||
|
||||
/* This should never fail (it's a serious bug if it does): */
|
||||
if (index != 0 && index != 1)
|
||||
{
|
||||
fprintf(stderr, "%s: read beyond end of string (%lu)\n", co->number,
|
||||
(unsigned long)index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Validate the new state, note that the PNG_FP_IS_ macros all return
|
||||
* false unless the number is valid.
|
||||
*/
|
||||
if (PNG_FP_IS_NEGATIVE(c.state) !=
|
||||
(number_is_valid && !c.is_zero && c.is_negative))
|
||||
{
|
||||
fprintf(stderr, "%s: negative when it is not\n", co->number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PNG_FP_IS_ZERO(c.state) != (number_is_valid && c.is_zero))
|
||||
{
|
||||
fprintf(stderr, "%s: zero when it is not\n", co->number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PNG_FP_IS_POSITIVE(c.state) !=
|
||||
(number_is_valid && !c.is_zero && !c.is_negative))
|
||||
{
|
||||
fprintf(stderr, "%s: positive when it is not\n", co->number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Testing a digit */
|
||||
if (isdigit(ch))
|
||||
{
|
||||
if (!character_accepted)
|
||||
{
|
||||
fprintf(stderr, "%s: digit '%c' not accepted\n", co->number, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!number_is_valid)
|
||||
{
|
||||
fprintf(stderr, "%s: saw a digit (%c) but number not valid\n",
|
||||
co->number, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
++c.cdigits_in_state;
|
||||
c.at_start = 0;
|
||||
c.number_was_valid = 1;
|
||||
|
||||
/* Continue testing characters in this state. Either test all of
|
||||
* them or, if we have already seen one digit in this state, just test a
|
||||
* limited set.
|
||||
*/
|
||||
if (c.cdigits_in_state < 1)
|
||||
return check_all_characters(co, c);
|
||||
|
||||
else
|
||||
return check_some_characters(co, c,
|
||||
state_characters[c.check_state].tests);
|
||||
}
|
||||
|
||||
/* A non-digit; is it allowed here? */
|
||||
else if (((ch == '+' || ch == '-') && c.check_state != fraction &&
|
||||
c.at_start) ||
|
||||
(ch == '.' && c.check_state == start) ||
|
||||
((ch == 'e' || ch == 'E') && c.number_was_valid &&
|
||||
c.check_state != exponent))
|
||||
{
|
||||
if (!character_accepted)
|
||||
{
|
||||
fprintf(stderr, "%s: character '%c' not accepted\n", co->number, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The number remains valid after start of fraction but nowhere else. */
|
||||
if (number_is_valid && (c.check_state != start || ch != '.'))
|
||||
{
|
||||
fprintf(stderr, "%s: saw a non-digit (%c) but number valid\n",
|
||||
co->number, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
c.number_was_valid = number_is_valid;
|
||||
|
||||
/* Check for a state change. When changing to 'fraction' if the number
|
||||
* is valid at this point set the at_start to false to allow an exponent
|
||||
* 'e' to come next.
|
||||
*/
|
||||
if (c.check_state == start && ch == '.')
|
||||
{
|
||||
c.check_state = fraction;
|
||||
c.at_start = !number_is_valid;
|
||||
c.cdigits_in_state = 0;
|
||||
c.limit = co->limit;
|
||||
return check_all_characters(co, c);
|
||||
}
|
||||
|
||||
else if (c.check_state < exponent && (ch == 'e' || ch == 'E'))
|
||||
{
|
||||
c.check_state = exponent;
|
||||
c.at_start = 1;
|
||||
c.cdigits_in_state = 0;
|
||||
c.limit = co->limit;
|
||||
return check_all_characters(co, c);
|
||||
}
|
||||
|
||||
/* Else it was a sign, and the state doesn't change. */
|
||||
else
|
||||
{
|
||||
if (ch != '-' && ch != '+')
|
||||
{
|
||||
fprintf(stderr, "checkfp: internal error (1)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
c.at_start = 0;
|
||||
return check_all_characters(co, c);
|
||||
}
|
||||
}
|
||||
|
||||
/* Testing an invalid character */
|
||||
else
|
||||
{
|
||||
if (character_accepted)
|
||||
{
|
||||
fprintf(stderr, "%s: character '%c' [0x%.2x] accepted\n", co->number,
|
||||
ch, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (number_is_valid != c.number_was_valid)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: character '%c' [0x%.2x] changed number validity\n", co->number,
|
||||
ch, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Do nothing - the parser has stuck; return success and keep going with
|
||||
* the next character.
|
||||
*/
|
||||
}
|
||||
|
||||
/* Successful return (the caller will try the next character.) */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int check_all_characters(checkfp_command *co, checkfp_control c)
|
||||
{
|
||||
int ch;
|
||||
|
||||
if (c.cnumber+4 < sizeof co->number) for (ch=0; ch<256; ++ch)
|
||||
{
|
||||
if (!check_one_character(co, c, ch))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int check_some_characters(checkfp_command *co, checkfp_control c,
|
||||
const char *tests)
|
||||
{
|
||||
int i;
|
||||
|
||||
--(c.limit);
|
||||
|
||||
if (c.cnumber+4 < sizeof co->number && c.limit >= 0)
|
||||
{
|
||||
if (c.limit > 0) for (i=0; tests[i]; ++i)
|
||||
{
|
||||
if (!check_one_character(co, c, tests[i]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* At the end check all the characters. */
|
||||
else
|
||||
return check_all_characters(co, c);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int validation_checkfp(int count, int argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
checkfp_command command;
|
||||
checkfp_control control;
|
||||
|
||||
command.number[0] = 0;
|
||||
command.limit = 3;
|
||||
command.verbose = verbose;
|
||||
command.ctimes = 0;
|
||||
command.cmillions = 0;
|
||||
command.cinvalid = 0;
|
||||
command.cnoaccept = 0;
|
||||
|
||||
while (--argc > 0)
|
||||
{
|
||||
++argv;
|
||||
if (argc > 1 && strcmp(*argv, "-l") == 0)
|
||||
{
|
||||
--argc;
|
||||
command.limit = atoi(*++argv);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
control.cnumber = 0;
|
||||
control.check_state = start;
|
||||
control.at_start = 1;
|
||||
control.cdigits_in_state = 0;
|
||||
control.limit = command.limit;
|
||||
control.state = 0;
|
||||
control.is_negative = 0;
|
||||
control.is_zero = 1;
|
||||
control.number_was_valid = 0;
|
||||
|
||||
result = check_all_characters(&command, control);
|
||||
|
||||
printf("checkfp: %s: checked %d,%.3d,%.3d,%.3d strings (%d invalid)\n",
|
||||
result ? "pass" : "FAIL", command.cmillions / 1000,
|
||||
command.cmillions % 1000, command.ctimes / 1000, command.ctimes % 1000,
|
||||
command.cinvalid);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int validation_muldiv(int count, int argc, char **argv)
|
||||
{
|
||||
int tested = 0;
|
||||
int overflow = 0;
|
||||
int error = 0;
|
||||
int error64 = 0;
|
||||
int passed = 0;
|
||||
int randbits = 0;
|
||||
png_uint_32 randbuffer;
|
||||
png_fixed_point a;
|
||||
png_int_32 times, div;
|
||||
|
||||
while (--argc > 0)
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *++argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Find out about the random number generator. */
|
||||
randbuffer = RAND_MAX;
|
||||
while (randbuffer != 0) ++randbits, randbuffer >>= 1;
|
||||
printf("Using random number generator that makes %d bits\n", randbits);
|
||||
for (div=0; div<32; div += randbits)
|
||||
randbuffer = (randbuffer << randbits) ^ rand();
|
||||
|
||||
a = 0;
|
||||
times = div = 0;
|
||||
do
|
||||
{
|
||||
png_fixed_point result;
|
||||
/* NOTE: your mileage may vary, a type is required below that can
|
||||
* hold 64 bits or more, if floating point is used a 64 bit or
|
||||
* better mantissa is required.
|
||||
*/
|
||||
long long int fp, fpround;
|
||||
unsigned long hi, lo;
|
||||
int ok;
|
||||
|
||||
/* Check the values, png_64bit_product can only handle positive
|
||||
* numbers, so correct for that here.
|
||||
*/
|
||||
{
|
||||
long u1, u2;
|
||||
int n = 0;
|
||||
if (a < 0) u1 = -a, n = 1; else u1 = a;
|
||||
if (times < 0) u2 = -times, n = !n; else u2 = times;
|
||||
png_64bit_product(u1, u2, &hi, &lo);
|
||||
if (n)
|
||||
{
|
||||
/* -x = ~x+1 */
|
||||
lo = ((~lo) + 1) & 0xffffffff;
|
||||
hi = ~hi;
|
||||
if (lo == 0) ++hi;
|
||||
}
|
||||
}
|
||||
|
||||
fp = a;
|
||||
fp *= times;
|
||||
if ((fp & 0xffffffff) != lo || ((fp >> 32) & 0xffffffff) != hi)
|
||||
{
|
||||
fprintf(stderr, "png_64bit_product %d * %d -> %lx|%.8lx not %llx\n",
|
||||
a, times, hi, lo, fp);
|
||||
++error64;
|
||||
}
|
||||
|
||||
if (div != 0)
|
||||
{
|
||||
/* Round - this is C round to zero. */
|
||||
if ((fp < 0) != (div < 0))
|
||||
fp -= div/2;
|
||||
else
|
||||
fp += div/2;
|
||||
|
||||
fp /= div;
|
||||
fpround = fp;
|
||||
/* Assume 2's complement here: */
|
||||
ok = fpround <= PNG_UINT_31_MAX &&
|
||||
fpround >= -1-(long long int)PNG_UINT_31_MAX;
|
||||
if (!ok) ++overflow;
|
||||
}
|
||||
else
|
||||
ok = 0, ++overflow, fpround = fp/*misleading*/;
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "TEST %d * %d / %d -> %lld (%s)\n", a, times, div,
|
||||
fp, ok ? "ok" : "overflow");
|
||||
|
||||
++tested;
|
||||
if (png_muldiv(&result, a, times, div) != ok)
|
||||
{
|
||||
++error;
|
||||
if (ok)
|
||||
fprintf(stderr, "%d * %d / %d -> overflow (expected %lld)\n", a,
|
||||
times, div, fp);
|
||||
else
|
||||
fprintf(stderr, "%d * %d / %d -> %d (expected overflow %lld)\n", a,
|
||||
times, div, result, fp);
|
||||
}
|
||||
else if (ok && result != fpround)
|
||||
{
|
||||
++error;
|
||||
fprintf(stderr, "%d * %d / %d -> %d not %lld\n", a, times, div, result,
|
||||
fp);
|
||||
}
|
||||
else
|
||||
++passed;
|
||||
|
||||
/* Generate three new values, this uses rand() and rand() only returns
|
||||
* up to RAND_MAX.
|
||||
*/
|
||||
/* CRUDE */
|
||||
a += times;
|
||||
times += div;
|
||||
div = randbuffer;
|
||||
randbuffer = (randbuffer << randbits) ^ rand();
|
||||
}
|
||||
while (--count > 0);
|
||||
|
||||
printf("%d tests including %d overflows, %d passed, %d failed (%d 64 bit "
|
||||
"errors)\n", tested, overflow, passed, error, error64);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* When FP is on this just becomes a speed test - compile without FP to get real
|
||||
* validation.
|
||||
*/
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
#define LN2 .000010576586617430806112933839 /* log(2)/65536 */
|
||||
#define L2INV 94548.46219969910586572651 /* 65536/log(2) */
|
||||
|
||||
/* For speed testing, need the internal functions too: */
|
||||
static png_uint_32 png_log8bit(unsigned x)
|
||||
{
|
||||
if (x > 0)
|
||||
return (png_uint_32)floor(.5-log(x/255.)*L2INV);
|
||||
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
static png_uint_32 png_log16bit(png_uint_32 x)
|
||||
{
|
||||
if (x > 0)
|
||||
return (png_uint_32)floor(.5-log(x/65535.)*L2INV);
|
||||
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
static png_uint_32 png_exp(png_uint_32 x)
|
||||
{
|
||||
return (png_uint_32)floor(.5 + exp(x * -LN2) * 0xffffffffU);
|
||||
}
|
||||
|
||||
static png_byte png_exp8bit(png_uint_32 log)
|
||||
{
|
||||
return (png_byte)floor(.5 + exp(log * -LN2) * 255);
|
||||
}
|
||||
|
||||
static png_uint_16 png_exp16bit(png_uint_32 log)
|
||||
{
|
||||
return (png_uint_16)floor(.5 + exp(log * -LN2) * 65535);
|
||||
}
|
||||
#endif /* FLOATING_ARITHMETIC */
|
||||
|
||||
int validation_gamma(int argc, char **argv)
|
||||
{
|
||||
double gamma[9] = { 2.2, 1.8, 1.52, 1.45, 1., 1/1.45, 1/1.52, 1/1.8, 1/2.2 };
|
||||
double maxerr;
|
||||
int i, silent=0, onlygamma=0;
|
||||
|
||||
/* Silence the output with -s, just test the gamma functions with -g: */
|
||||
while (--argc > 0)
|
||||
if (strcmp(*++argv, "-s") == 0)
|
||||
silent = 1;
|
||||
else if (strcmp(*argv, "-g") == 0)
|
||||
onlygamma = 1;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!onlygamma)
|
||||
{
|
||||
/* First validate the log functions: */
|
||||
maxerr = 0;
|
||||
for (i=0; i<256; ++i)
|
||||
{
|
||||
double correct = -log(i/255.)/log(2.)*65536;
|
||||
double error = png_log8bit(i) - correct;
|
||||
|
||||
if (i != 0 && fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
|
||||
if (i == 0 && png_log8bit(i) != 0xffffffff ||
|
||||
i != 0 && png_log8bit(i) != floor(correct+.5))
|
||||
{
|
||||
fprintf(stderr, "8 bit log error: %d: got %u, expected %f\n",
|
||||
i, png_log8bit(i), correct);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 8 bit log error = %f\n", maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (i=0; i<65536; ++i)
|
||||
{
|
||||
double correct = -log(i/65535.)/log(2.)*65536;
|
||||
double error = png_log16bit(i) - correct;
|
||||
|
||||
if (i != 0 && fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
|
||||
if (i == 0 && png_log16bit(i) != 0xffffffff ||
|
||||
i != 0 && png_log16bit(i) != floor(correct+.5))
|
||||
{
|
||||
if (error > .68) /* By experiment error is less than .68 */
|
||||
{
|
||||
fprintf(stderr, "16 bit log error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_log16bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 16 bit log error = %f\n", maxerr);
|
||||
|
||||
/* Now exponentiations. */
|
||||
maxerr = 0;
|
||||
for (i=0; i<=0xfffff; ++i)
|
||||
{
|
||||
double correct = exp(-i/65536. * log(2.)) * (65536. * 65536);
|
||||
double error = png_exp(i) - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > 1883) /* By experiment. */
|
||||
{
|
||||
fprintf(stderr, "32 bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 32 bit exp error = %f\n", maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (i=0; i<=0xfffff; ++i)
|
||||
{
|
||||
double correct = exp(-i/65536. * log(2.)) * 255;
|
||||
double error = png_exp8bit(i) - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > .50002) /* By experiment */
|
||||
{
|
||||
fprintf(stderr, "8 bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp8bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 8 bit exp error = %f\n", maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (i=0; i<=0xfffff; ++i)
|
||||
{
|
||||
double correct = exp(-i/65536. * log(2.)) * 65535;
|
||||
double error = png_exp16bit(i) - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > .524) /* By experiment */
|
||||
{
|
||||
fprintf(stderr, "16 bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp16bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 16 bit exp error = %f\n", maxerr);
|
||||
} /* !onlygamma */
|
||||
|
||||
/* Test the overall gamma correction. */
|
||||
for (i=0; i<9; ++i)
|
||||
{
|
||||
unsigned j;
|
||||
double g = gamma[i];
|
||||
png_fixed_point gfp = floor(g * PNG_FP_1 + .5);
|
||||
|
||||
if (!silent)
|
||||
printf("Test gamma %f\n", g);
|
||||
|
||||
maxerr = 0;
|
||||
for (j=0; j<256; ++j)
|
||||
{
|
||||
double correct = pow(j/255., g) * 255;
|
||||
png_byte out = png_gamma_8bit_correct(j, gfp);
|
||||
double error = out - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (out != floor(correct+.5))
|
||||
{
|
||||
fprintf(stderr, "8bit %d ^ %f: got %d expected %f error %f\n",
|
||||
j, g, out, correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("gamma %f: maximum 8 bit error %f\n", g, maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (j=0; j<65536; ++j)
|
||||
{
|
||||
double correct = pow(j/65535., g) * 65535;
|
||||
png_uint_16 out = png_gamma_16bit_correct(j, gfp);
|
||||
double error = out - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > 1.62)
|
||||
{
|
||||
fprintf(stderr, "16bit %d ^ %f: got %d expected %f error %f\n",
|
||||
j, g, out, correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("gamma %f: maximum 16 bit error %f\n", g, maxerr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************** VALIDATION TESTS ********************************/
|
||||
/* Various validation routines are included herein, they require some
|
||||
* definition for png_warning and png_error, seetings of VALIDATION:
|
||||
*
|
||||
* 1: validates the ASCII to floating point conversions
|
||||
* 2: validates png_muldiv
|
||||
* 3: accuracy test of fixed point gamma tables
|
||||
*/
|
||||
|
||||
/* The following COUNT (10^8) takes about 1 hour on a 1GHz Pentium IV
|
||||
* processor.
|
||||
*/
|
||||
#define COUNT 1000000000
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int count = COUNT;
|
||||
|
||||
while (argc > 1)
|
||||
{
|
||||
if (argc > 2 && strcmp(argv[1], "-c") == 0)
|
||||
{
|
||||
count = atoi(argv[2]);
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[1], "-v") == 0)
|
||||
{
|
||||
++verbose;
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (count > 0 && argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1], "ascii") == 0)
|
||||
return validation_ascii_to_fp(count, argc-1, argv+1);
|
||||
else if (strcmp(argv[1], "checkfp") == 0)
|
||||
return validation_checkfp(count, argc-1, argv+1);
|
||||
else if (strcmp(argv[1], "muldiv") == 0)
|
||||
return validation_muldiv(count, argc-1, argv+1);
|
||||
else if (strcmp(argv[1], "gamma") == 0)
|
||||
return validation_gamma(argc-1, argv+1);
|
||||
}
|
||||
|
||||
/* Bad argument: */
|
||||
fprintf(stderr,
|
||||
"usage: tarith [-v] [-c count] {ascii,muldiv,gamma} [args]\n");
|
||||
fprintf(stderr, " arguments: ascii [-a (all results)] [-e error%%]\n");
|
||||
fprintf(stderr, " checkfp [-l max-number-chars]\n");
|
||||
fprintf(stderr, " muldiv\n");
|
||||
fprintf(stderr, " gamma -s (silent) -g (only gamma; no log)\n");
|
||||
return 1;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
/* timepng.c
|
||||
*
|
||||
* Copyright (c) 2012 John Cunningham Bowler
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
|
@ -14,7 +14,7 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. -O1
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. -O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
|
@ -1,6 +1,6 @@
|
||||
# pngminim/decoder/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@ -37,3 +37,4 @@ option SETJMP on
|
||||
option STDIO on
|
||||
option READ_EXPAND on
|
||||
option READ_STRIP_16_TO_8 on
|
||||
option USER_LIMITS on
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
||||
*
|
||||
* Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
@ -1,6 +1,6 @@
|
||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
||||
|
||||
The makefile builds a minimal write-only decoder with embedded libpng
|
||||
The makefile builds a minimal write-only encoder with embedded libpng
|
||||
and zlib.
|
||||
|
||||
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||
|
@ -14,7 +14,7 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZIP -I. -O1
|
||||
CFLAGS=-DPNG_USER_CONFIG -DZ_SOLO -DNO_GZIP -I. -O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
|
@ -1,6 +1,6 @@
|
||||
# pngminim/encoder/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* minwrpngconf.h: headers to make a minimal png-write-only library
|
||||
*
|
||||
* Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
@ -30,7 +30,7 @@ XLIB = -L/usr/X11R6/lib -lX11
|
||||
#LIBS = $(XLIB)
|
||||
LIBS = $(XLIB) -lm #platforms that need libm
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. $(XINC) -O1
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. $(XINC) -O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
|
@ -1,6 +1,6 @@
|
||||
# pngminim/preader/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
||||
*
|
||||
* Copyright (c) 2009, 2010-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2009, 2010-2013 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
@ -239,7 +239,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
get_token(pnm_file, maxval_token);
|
||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||
maxval = (png_uint_32) ul_maxval;
|
||||
|
||||
|
||||
if (maxval <= 1)
|
||||
bit_depth = 1;
|
||||
else if (maxval <= 3)
|
||||
|
@ -1,7 +1,8 @@
|
||||
|
||||
pngsuite
|
||||
--------
|
||||
(c) Willem van Schaik, 1999, 2011
|
||||
(c) Willem van Schaik, 1999, 2011, 2012
|
||||
Two images are by Glenn Randers-Pehrson, 2012
|
||||
|
||||
Permission to use, copy, modify, and distribute these images for any
|
||||
purpose and without fee is hereby granted.
|
||||
@ -38,6 +39,8 @@ can use them to test the proper functioning of PNG software.
|
||||
basn6a08.png 8-bit RGBA
|
||||
basn6a16.png 16-bit RGBA
|
||||
|
||||
ftbbn0g01.png 1-bit grayscale, black bKGD
|
||||
ftbbn0g02.png 2-bit grayscale, black bKGD
|
||||
ftbbn0g04.png 4-bit grayscale, black bKGD
|
||||
ftbbn2c16.png 16-bit truecolor, black bKGD
|
||||
ftbbn3p08.png 8-bit paletted, black bKGD
|
||||
|
BIN
contrib/pngsuite/ftbbn0g01.png
Normal file
After Width: | Height: | Size: 176 B |
BIN
contrib/pngsuite/ftbbn0g02.png
Normal file
After Width: | Height: | Size: 197 B |
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 429 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 719 B |
102
contrib/tools/checksum-icc.c
Normal file
@ -0,0 +1,102 @@
|
||||
/* checksum-icc.c
|
||||
*
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Generate crc32 and adler32 checksums of the given input files, used to
|
||||
* generate check-codes for use when matching ICC profiles within libpng.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
static int
|
||||
read_one_file(FILE *ip, const char *name)
|
||||
{
|
||||
uLong length = 0;
|
||||
uLong a32 = adler32(0, NULL, 0);
|
||||
uLong c32 = crc32(0, NULL, 0);
|
||||
Byte header[132];
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int ch = getc(ip);
|
||||
Byte b;
|
||||
|
||||
if (ch == EOF) break;
|
||||
|
||||
b = (Byte)ch;
|
||||
|
||||
if (length < sizeof header)
|
||||
header[length] = b;
|
||||
|
||||
++length;
|
||||
a32 = adler32(a32, &b, 1);
|
||||
c32 = crc32(c32, &b, 1);
|
||||
}
|
||||
|
||||
if (ferror(ip))
|
||||
return 0;
|
||||
|
||||
/* Success */
|
||||
printf("PNG_ICC_CHECKSUM(0x%8.8lx, 0x%8.8lx,\n PNG_MD5("
|
||||
"0x%2.2x%2.2x%2.2x%2.2x, 0x%2.2x%2.2x%2.2x%2.2x, 0x%2.2x%2.2x%2.2x%2.2x,"
|
||||
" 0x%2.2x%2.2x%2.2x%2.2x), %d,\n"
|
||||
" \"%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d\", %lu, \"%s\")\n",
|
||||
(unsigned long)a32, (unsigned long)c32,
|
||||
header[84], header[85], header[86], header[87],
|
||||
header[88], header[89], header[90], header[91],
|
||||
header[92], header[93], header[94], header[95],
|
||||
header[96], header[97], header[98], header[99],
|
||||
# define u16(x) (header[x] * 256 + header[x+1])
|
||||
# define u32(x) (u16(x) * 65536 + u16(x+2))
|
||||
u32(64), u16(24), u16(26), u16(28), u16(30), u16(32), u16(34),
|
||||
(unsigned long)length, name);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
printf("/* adler32, crc32, MD5[16], intent, date, length, file-name */\n");
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=1; i<argc; ++i)
|
||||
{
|
||||
FILE *ip = fopen(argv[i], "rb");
|
||||
|
||||
if (ip == NULL || !read_one_file(ip, argv[i]))
|
||||
{
|
||||
err = 1;
|
||||
perror(argv[i]);
|
||||
fprintf(stderr, "%s: read error\n", argv[i]);
|
||||
printf("/* ERROR: %s */\n", argv[i]);
|
||||
}
|
||||
|
||||
(void)fclose(ip);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (!read_one_file(stdin, "-"))
|
||||
{
|
||||
err = 1;
|
||||
perror("stdin");
|
||||
fprintf(stderr, "stdin: read error\n");
|
||||
printf("/* ERROR: stdin */\n");
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
/*-
|
||||
* convert.c
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2013.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
|
@ -2,9 +2,9 @@
|
||||
#
|
||||
# intgamma.sh
|
||||
#
|
||||
# Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
# Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
#
|
||||
# COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
# COPYRIGHT: Written by John Cunningham Bowler, 2013.
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* makesRGB.c -- build sRGB-to-linear and linear-to-sRGB conversion tables
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2013.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*-
|
||||
* sRGB.h
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2013.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
|
@ -17,7 +17,7 @@ void PngFileInitialize (HWND hwnd) ;
|
||||
BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
|
||||
BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
|
||||
|
||||
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor);
|
||||
BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
int iWidth, int iHeight, png_color BkgColor);
|
||||
|
86
example.c
@ -2,8 +2,8 @@
|
||||
#if 0 /* in case someone actually tries to compile this */
|
||||
|
||||
/* example.c - an example of using libpng
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Maintained 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Maintained 1998-2013 Glenn Randers-Pehrson
|
||||
* Maintained 1996, 1997 Andreas Dilger)
|
||||
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
* To the extent possible under law, the authors have waived
|
||||
@ -48,7 +48,8 @@ int main(int argc, const char **argv)
|
||||
png_image image; /* The control structure used by libpng */
|
||||
|
||||
/* Initialize the 'png_image' structure. */
|
||||
memset(&image, 0, sizeof image);
|
||||
memset(&image, 0, (sizeof image));
|
||||
image.version = PNG_IMAGE_VERSION;
|
||||
|
||||
/* The first argument is the file to read: */
|
||||
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||
@ -75,16 +76,28 @@ int main(int argc, const char **argv)
|
||||
* be supplied or the output buffer would have to be initialized to the
|
||||
* actual background of the image.
|
||||
*
|
||||
* The final argument to png_image_finish_read is the 'row_stride' -
|
||||
* 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
|
||||
* 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
|
||||
* 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:
|
||||
*
|
||||
* PNG_IMAGE_COLORMAP_SIZE(image)
|
||||
*
|
||||
* to find the maximum size of the colormap in bytes.
|
||||
*/
|
||||
if (buffer != NULL &&
|
||||
png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/))
|
||||
0/*row_stride*/, NULL/*colormap*/))
|
||||
{
|
||||
/* Now write the image out to the second argument. In the write
|
||||
* call 'convert_to_8bit' allows 16-bit data to be squashed down to
|
||||
@ -92,7 +105,7 @@ int main(int argc, const char **argv)
|
||||
* to the 8-bit format.
|
||||
*/
|
||||
if (png_image_write_to_file(&image, argv[2], 0/*convert_to_8bit*/,
|
||||
buffer, 0/*row_stride*/))
|
||||
buffer, 0/*row_stride*/, NULL/*colormap*/))
|
||||
{
|
||||
/* The image has been written successfully. */
|
||||
exit(0);
|
||||
@ -833,7 +846,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
|
||||
/* Set the palette if there is one. REQUIRED for indexed-color images */
|
||||
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
|
||||
* png_sizeof(png_color));
|
||||
* (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
|
||||
@ -864,25 +877,38 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
png_set_gAMA(png_ptr, info_ptr, gamma);
|
||||
|
||||
/* Optionally write comments into the image */
|
||||
text_ptr[0].key = "Title";
|
||||
text_ptr[0].text = "Mona Lisa";
|
||||
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[0].itxt_length = 0;
|
||||
text_ptr[0].lang = NULL;
|
||||
text_ptr[0].lang_key = NULL;
|
||||
text_ptr[1].key = "Author";
|
||||
text_ptr[1].text = "Leonardo DaVinci";
|
||||
text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[1].itxt_length = 0;
|
||||
text_ptr[1].lang = NULL;
|
||||
text_ptr[1].lang_key = NULL;
|
||||
text_ptr[2].key = "Description";
|
||||
text_ptr[2].text = "<long text>";
|
||||
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text_ptr[2].itxt_length = 0;
|
||||
text_ptr[2].lang = NULL;
|
||||
text_ptr[2].lang_key = NULL;
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 3);
|
||||
{
|
||||
png_text text_ptr[3];
|
||||
|
||||
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;
|
||||
text_ptr[0].itxt_length = 0;
|
||||
text_ptr[0].lang = NULL;
|
||||
text_ptr[0].lang_key = NULL;
|
||||
|
||||
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;
|
||||
text_ptr[1].itxt_length = 0;
|
||||
text_ptr[1].lang = NULL;
|
||||
text_ptr[1].lang_key = NULL;
|
||||
|
||||
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;
|
||||
text_ptr[2].itxt_length = 0;
|
||||
text_ptr[2].lang = NULL;
|
||||
text_ptr[2].lang_key = NULL;
|
||||
|
||||
png_set_text(write_ptr, write_info_ptr, text_ptr, 3);
|
||||
}
|
||||
|
||||
/* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */
|
||||
|
||||
@ -955,12 +981,16 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* use the first method if you aren't handling interlacing yourself.
|
||||
*/
|
||||
png_uint_32 k, height, width;
|
||||
png_byte image[height][width*bytes_per_pixel];
|
||||
|
||||
/* In this example, "image" is a one-dimensional array of bytes */
|
||||
png_byte image[height*width*bytes_per_pixel];
|
||||
|
||||
png_bytep row_pointers[height];
|
||||
|
||||
if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
|
||||
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 */
|
||||
for (k = 0; k < height; k++)
|
||||
row_pointers[k] = image + k*width*bytes_per_pixel;
|
||||
|
||||
|
0
libpng-config.in
Executable file → Normal file
@ -1,9 +1,9 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.6.0beta05 - February 3, 2012
|
||||
libpng version 1.6.1beta05 - March 2, 2013
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
|
||||
This document is released under the libpng license.
|
||||
For conditions of distribution and use, see the disclaimer
|
||||
@ -11,9 +11,9 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.6.0beta05 - February 3, 2012
|
||||
libpng versions 0.97, January 1998, through 1.6.1beta05 - March 2, 2013
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
|
||||
libpng 1.0 beta 6 version 0.96 May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
@ -67,7 +67,7 @@ of reducing the amount of time and effort it takes to support the PNG
|
||||
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:2003 (E)) at
|
||||
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
|
||||
<http://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
The W3C and ISO documents have identical technical content.
|
||||
|
||||
@ -160,8 +160,8 @@ APIs. Most of these are fairly obvious; for example types corresponding
|
||||
to integers of particular sizes and types for passing color values.
|
||||
|
||||
One exception is how non-integral numbers are handled. For application
|
||||
convenience most APIs that take such numbers have C (double) arguments,
|
||||
however internally PNG, and libpng, use 32 bit signed integers and encode
|
||||
convenience most APIs that take such numbers have C (double) arguments;
|
||||
however, internally PNG, and libpng, use 32 bit signed integers and encode
|
||||
the value by multiplying by 100,000. As of libpng 1.5.0 a convenience
|
||||
macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point)
|
||||
which is simply (png_int_32).
|
||||
@ -572,6 +572,7 @@ chunk types. To change this, you can call:
|
||||
|
||||
png_set_keep_unknown_chunks(png_ptr, keep,
|
||||
chunk_list, num_chunks);
|
||||
|
||||
keep - 0: default unknown chunk handling
|
||||
1: ignore; do not keep
|
||||
2: keep only if safe-to-copy
|
||||
@ -585,11 +586,16 @@ chunk types. To change this, you can call:
|
||||
|
||||
chunk_list - list of chunks affected (a byte string,
|
||||
five bytes per chunk, NULL or '\0' if
|
||||
num_chunks is 0)
|
||||
num_chunks is positive; ignored if
|
||||
numchunks <= 0).
|
||||
|
||||
num_chunks - number of chunks affected; if 0, all
|
||||
unknown chunks are affected. If nonzero,
|
||||
only the chunks in the list are affected
|
||||
unknown chunks are affected. If positive,
|
||||
only the chunks in the list are affected,
|
||||
and if negative all unknown chunks and
|
||||
all known chunks except for the IHDR,
|
||||
PLTE, tRNS, IDAT, and IEND chunks are
|
||||
affected.
|
||||
|
||||
Unknown chunks declared in this way will be saved as raw data onto a
|
||||
list of png_unknown_chunk structures. If a chunk that is normally
|
||||
@ -630,7 +636,7 @@ callback function:
|
||||
|
||||
/* also ignore unused known chunks: */
|
||||
png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
|
||||
(int)sizeof(unused_chunks)/5);
|
||||
(int)(sizeof unused_chunks)/5);
|
||||
#endif
|
||||
|
||||
User limits
|
||||
@ -669,9 +675,6 @@ where 0x7fffffffL means unlimited. You can retrieve this limit with
|
||||
|
||||
chunk_cache_max = png_get_chunk_cache_max(png_ptr);
|
||||
|
||||
This limit also applies to the number of buffers that can be allocated
|
||||
by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks.
|
||||
|
||||
You can also set a limit on the amount of memory that a compressed chunk
|
||||
other than IDAT can occupy, with
|
||||
|
||||
@ -822,7 +825,7 @@ the screen_gamma value. Pixels with alpha less than 1.0
|
||||
will still have linear components.
|
||||
|
||||
Use this format if you have control over your
|
||||
compositing software and do don't do other arithmetic
|
||||
compositing software and so don't do other arithmetic
|
||||
(such as scaling) on the data you get from libpng. Your
|
||||
compositing software can simply copy opaque pixels to
|
||||
the output but still has linear values for the
|
||||
@ -985,7 +988,7 @@ where row_pointers is an array of pointers to the pixel data for each row:
|
||||
If you know your image size and pixel size ahead of time, you can allocate
|
||||
row_pointers prior to calling png_read_png() with
|
||||
|
||||
if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
|
||||
if (height > PNG_UINT_32_MAX/(sizeof (png_byte)))
|
||||
png_error (png_ptr,
|
||||
"Image is too tall to process in memory");
|
||||
|
||||
@ -994,7 +997,7 @@ row_pointers prior to calling png_read_png() with
|
||||
"Image is too wide to process in memory");
|
||||
|
||||
row_pointers = png_malloc(png_ptr,
|
||||
height*png_sizeof(png_bytep));
|
||||
height*(sizeof (png_bytep)));
|
||||
|
||||
for (int i=0; i<height, i++)
|
||||
row_pointers[i]=NULL; /* security precaution */
|
||||
@ -1153,6 +1156,15 @@ data has been read, or zero if it is missing. The parameters to the
|
||||
png_get_<chunk> are set directly if they are simple data types, or a
|
||||
pointer into the info_ptr is returned for any complex types.
|
||||
|
||||
The colorspace data from gAMA, cHRM, sRGB, iCCP, and sBIT chunks
|
||||
is simply returned to give the application information about how the
|
||||
image was encoded. Libpng itself only does transformations using the file
|
||||
gamma when combining semitransparent pixels with the background color, and,
|
||||
since libpng-1.6.0, when converting between 8-bit sRGB and 16-bit linear pixels
|
||||
within the simplified API. Libpng also uses the file gamma when converting
|
||||
RGB to gray, beginning with libpng-1.0.5, if the application calls
|
||||
png_set_rgb_to_gray()).
|
||||
|
||||
png_get_PLTE(png_ptr, info_ptr, &palette,
|
||||
&num_palette);
|
||||
|
||||
@ -1764,7 +1776,7 @@ the current display (e.g., the background color from a web page). You
|
||||
need to tell libpng how the color is represented, both the format of the
|
||||
component values in the color (the number of bits) and the gamma encoding of the
|
||||
color. The function takes two arguments, background_gamma_mode and need_expand
|
||||
to convey this information, however only two combinations are likely to be
|
||||
to convey this information; however, only two combinations are likely to be
|
||||
useful:
|
||||
|
||||
png_color_16 my_background;
|
||||
@ -2058,7 +2070,7 @@ the second parameter NULL.
|
||||
|
||||
If you don't want libpng to handle the interlacing details, just call
|
||||
png_read_rows() PNG_INTERLACE_ADAM7_PASSES times to read in all the images.
|
||||
Each of the images is a valid image by itself, however you will almost
|
||||
Each of the images is a valid image by itself; however, you will almost
|
||||
certainly need to distribute the pixels from each sub-image to the
|
||||
correct place. This is where everything gets very tricky.
|
||||
|
||||
@ -2215,7 +2227,7 @@ sPLT, only the n'th item in the structure is freed, where n is "seq".
|
||||
The default behavior is only to free data that was allocated internally
|
||||
by libpng. This can be changed, so that libpng will not free the data,
|
||||
or so that it will free data that was allocated by the user with png_malloc()
|
||||
or png_zalloc() and passed in via a png_set_*() function, with
|
||||
or png_calloc() and passed in via a png_set_*() function, with
|
||||
|
||||
png_data_freer(png_ptr, info_ptr, freer, mask)
|
||||
|
||||
@ -2236,7 +2248,7 @@ or png_destroy_*() is supposed to free the data. When the user assumes
|
||||
responsibility for libpng-allocated data, the application must use
|
||||
png_free() to free it, and when the user transfers responsibility to libpng
|
||||
for data that the user has allocated, the user must have used png_malloc()
|
||||
or png_zalloc() to allocate it.
|
||||
or png_calloc() to allocate it.
|
||||
|
||||
If you allocated your row_pointers in a single block, as suggested above in
|
||||
the description of the high level read interface, you must not transfer
|
||||
@ -2552,6 +2564,20 @@ You can #define PNG_ABORT() to a function that does something
|
||||
more useful than abort(), as long as your function does not
|
||||
return.
|
||||
|
||||
Checking for invalid palette index on write was added at libpng
|
||||
1.5.10. If a pixel contains an invalid (out-of-range) index libpng issues
|
||||
a benign error. This is enabled by default because this condition is an
|
||||
error according to the PNG specification, Clause 11.3.2, but the error can
|
||||
be ignored in each png_ptr with
|
||||
|
||||
png_set_check_for_invalid_index(png_ptr, 0);
|
||||
|
||||
If the error is ignored, or if png_benign_error() treats it as a warning,
|
||||
any invalid pixels are written as-is by the encoder, resulting in an
|
||||
invalid PNG datastream as output. In this case the application is
|
||||
responsible for ensuring that the pixel indexes are in range when it writes
|
||||
a PLTE chunk with fewer entries than the bit depth would allow.
|
||||
|
||||
Now you need to set up the output code. The default for libpng is to
|
||||
use the C function fwrite(). If you use this, you will need to pass a
|
||||
valid FILE * in the function png_init_io(). Be sure that the file is
|
||||
@ -3054,8 +3080,9 @@ tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
|
||||
although this isn't a requirement. Unlike the tIME chunk, the
|
||||
"Creation Time" tEXt chunk is not expected to be automatically changed
|
||||
by the software. To facilitate the use of RFC 1123 dates, a function
|
||||
png_convert_to_rfc1123(png_timep) is provided to convert from PNG
|
||||
time to an RFC 1123 format string.
|
||||
png_convert_to_rfc1123_buffer(png_ptr, buffer, png_timep) is provided to
|
||||
convert from PNG time to an RFC 1123 format string. The caller must provide
|
||||
a writeable buffer of at least 29 bytes.
|
||||
|
||||
Writing unknown chunks
|
||||
|
||||
@ -3417,7 +3444,7 @@ png_destroy_write_struct().
|
||||
The default behavior is only to free data that was allocated internally
|
||||
by libpng. This can be changed, so that libpng will not free the data,
|
||||
or so that it will free data that was allocated by the user with png_malloc()
|
||||
or png_zalloc() and passed in via a png_set_*() function, with
|
||||
or png_calloc() and passed in via a png_set_*() function, with
|
||||
|
||||
png_data_freer(png_ptr, info_ptr, freer, mask)
|
||||
|
||||
@ -3453,7 +3480,7 @@ When the user assumes responsibility for libpng-allocated data, the
|
||||
application must use
|
||||
png_free() to free it, and when the user transfers responsibility to libpng
|
||||
for data that the user has allocated, the user must have used png_malloc()
|
||||
or png_zalloc() to allocate it.
|
||||
or png_calloc() to allocate it.
|
||||
|
||||
If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
|
||||
separately, do not transfer responsibility for freeing text_ptr to libpng,
|
||||
@ -3508,29 +3535,34 @@ png_image is a structure that describes the in-memory format of an image
|
||||
when it is being read or define the in-memory format of an image that you
|
||||
need to write. The "png_image" structure contains the following members:
|
||||
|
||||
png_uint_32 version Set to PNG_IMAGE_VERSION
|
||||
png_uint_32 width Image width in pixels (columns)
|
||||
png_uint_32 height Image height in pixels (rows)
|
||||
png_uint_32 format Image format as defined below
|
||||
png_uint_32 flags A bit mask containing informational flags
|
||||
png_controlp opaque Initialize to NULL, free with png_image_free
|
||||
|
||||
In the event of an error or warning the following field will be set to a
|
||||
non-zero value and the 'message' field will contain a '\0' terminated
|
||||
string with the libpng error or warning message. If both warnings and
|
||||
an error were encountered, only the error is recorded. If there
|
||||
are multiple warnings, only the first one is recorded.
|
||||
|
||||
As of libpng-1.6.0 the values are
|
||||
0 - no warning or error
|
||||
1 - error
|
||||
2 - warning
|
||||
|
||||
png_uint_32 colormap_entries; Number of entries in the color-map
|
||||
png_uint_32 warning_or_error;
|
||||
char message[64];
|
||||
|
||||
In the event of an error or warning the following field warning_or_error
|
||||
field will be set to a non-zero value and the 'message' field will contain
|
||||
a '\0' terminated string with the libpng error or warning message. If both
|
||||
warnings and an error were encountered, only the error is recorded. If there
|
||||
are multiple warnings, only the first one is recorded.
|
||||
|
||||
The upper 30 bits of this value are reserved; the low two bits contain
|
||||
a two bit code such that a value more than 1 indicates a failure in the API
|
||||
just called:
|
||||
|
||||
0 - no warning or error
|
||||
1 - warning
|
||||
2 - error
|
||||
3 - error preceded by warning
|
||||
|
||||
The pixels (samples) of the image have one to four channels whose components
|
||||
have original values in the range 0 to 1.0:
|
||||
|
||||
|
||||
1: A single gray or luminance channel (G).
|
||||
2: A gray/luminance channel and an alpha channel (GA).
|
||||
3: Three red, green, blue color channels (RGB).
|
||||
@ -3538,7 +3570,7 @@ have original values in the range 0 to 1.0:
|
||||
|
||||
The channels are encoded in one of two ways:
|
||||
|
||||
a) As a small integer, value 0..255, contained in a (png_byte). For the
|
||||
a) As a small integer, value 0..255, contained in a single byte. For the
|
||||
alpha channel the original value is simply value/255. For the color or
|
||||
luminance channels the value is encoded according to the sRGB specification
|
||||
and matches the 8-bit format expected by typical display devices.
|
||||
@ -3546,7 +3578,7 @@ and matches the 8-bit format expected by typical display devices.
|
||||
The color/gray channels are not scaled (pre-multiplied) by the alpha
|
||||
channel and are suitable for passing to color management software.
|
||||
|
||||
b) As a value in the range 0..65535, contained in a (png_uint_16). All
|
||||
b) As a value in the range 0..65535, contained in a 2-byte integer. All
|
||||
channels can be converted to the original value by dividing by 65535; all
|
||||
channels are linear. Color channels use the RGB encoding (RGB end-points) of
|
||||
the sRGB specification. This encoding is identified by the
|
||||
@ -3557,6 +3589,12 @@ of the color or luminance channels and is returned as an associated alpha
|
||||
channel: the color/gray channels are scaled (pre-multiplied) by the alpha
|
||||
value.
|
||||
|
||||
When a color-mapped image is used as a result of calling
|
||||
png_image_read_colormap or png_image_write_colormap the channels are encoded
|
||||
in the color-map and the descriptions above apply to the color-map entries.
|
||||
The image data is encoded as small integers, value 0..255, that index the
|
||||
entries in the color-map. One integer (one byte) is stored for each pixel.
|
||||
|
||||
PNG_FORMAT_*
|
||||
|
||||
The #defines to be used in png_image::format. Each #define identifies a
|
||||
@ -3567,6 +3605,11 @@ A format is built up using single bit flag values. Not all combinations are
|
||||
valid: use the bit flag values below for testing a format returned by the
|
||||
read APIs, but set formats from the derived values.
|
||||
|
||||
When reading or writing color-mapped images the format should be set to the
|
||||
format of the entries in the color-map then png_image_{read,write}_colormap
|
||||
called to read or write the color-map and set the format correctly for the
|
||||
image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!
|
||||
|
||||
NOTE: libpng can be built with particular features disabled, if you see
|
||||
compiler errors because the definition of one of the following flags has been
|
||||
compiled out it is because libpng does not have the required support. It is
|
||||
@ -3579,8 +3622,9 @@ guard against this by checking for the definition of:
|
||||
PNG_FORMAT_FLAG_ALPHA 0x01 format with an alpha channel
|
||||
PNG_FORMAT_FLAG_COLOR 0x02 color format: otherwise grayscale
|
||||
PNG_FORMAT_FLAG_LINEAR 0x04 png_uint_16 channels else png_byte
|
||||
PNG_FORMAT_FLAG_BGR 0x08 BGR colors, else order is RGB
|
||||
PNG_FORMAT_FLAG_AFIRST 0x10 alpha channel comes first
|
||||
PNG_FORMAT_FLAG_COLORMAP 0x08 libpng use only
|
||||
PNG_FORMAT_FLAG_BGR 0x10 BGR colors, else order is RGB
|
||||
PNG_FORMAT_FLAG_AFIRST 0x20 alpha channel comes first
|
||||
|
||||
Supported formats are as follows. Future versions of libpng may support more
|
||||
formats; for compatibility with older versions simply check if the format
|
||||
@ -3599,7 +3643,7 @@ First the single byte formats:
|
||||
PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)
|
||||
PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)
|
||||
|
||||
Then the linear (png_uint_16) formats. When naming these "Y" is used to
|
||||
Then the linear 2-byte formats. When naming these "Y" is used to
|
||||
indicate a luminance (gray) channel. The component order within the pixel
|
||||
is always the same - there is no provision for swapping the order of the
|
||||
components in the linear format.
|
||||
@ -3613,44 +3657,101 @@ components in the linear format.
|
||||
(PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|
|
||||
PNG_FORMAT_FLAG_ALPHA)
|
||||
|
||||
Color-mapped formats are obtained by calling png_image_{read,write}_colormap,
|
||||
as appropriate after setting png_image::format to the format of the color-map
|
||||
to be read or written. Applications may check the value of
|
||||
PNG_FORMAT_FLAG_COLORMAP to see if they have called the colormap API. The
|
||||
format of the color-map may be extracted using the following macro.
|
||||
|
||||
PNG_FORMAT_OF_COLORMAP(fmt) ((fmt) & ~PNG_FORMAT_FLAG_COLORMAP)
|
||||
|
||||
PNG_IMAGE macros
|
||||
|
||||
These are convenience macros to derive information from a png_image structure:
|
||||
These are convenience macros to derive information from a png_image
|
||||
structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the
|
||||
actual image sample values - either the entries in the color-map or the
|
||||
pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values
|
||||
for the pixels and will always return 1 after a call to
|
||||
png_image_{read,write}_colormap. The remaining macros return information
|
||||
about the rows in the image and the complete image.
|
||||
|
||||
PNG_IMAGE_CHANNELS(fmt)
|
||||
NOTE: All the macros that take a png_image::format parameter are compile time
|
||||
constants if the format parameter is, itself, a constant. Therefore these
|
||||
macros can be used in array declarations and case labels where required.
|
||||
Similarly the macros are also pre-processor constants (sizeof is not used) so
|
||||
they can be used in #if tests.
|
||||
|
||||
First the information about the samples.
|
||||
|
||||
PNG_IMAGE_SAMPLE_CHANNELS(fmt)
|
||||
Returns the total number of channels in a given format: 1..4
|
||||
|
||||
PNG_IMAGE_COMPONENT_SIZE(fmt)
|
||||
Returns the size in bytes of a single component of a pixel
|
||||
in the image.
|
||||
PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)
|
||||
Returns the size in bytes of a single component of a pixel or color-map
|
||||
entry (as appropriate) in the image.
|
||||
|
||||
PNG_IMAGE_SAMPLE_SIZE(fmt)
|
||||
This is the size of the sample data for one sample. If the image is
|
||||
color-mapped it is the size of one color-map entry (and image pixels are
|
||||
one byte in size), otherwise it is the size of one image pixel.
|
||||
|
||||
PNG_IMAGE_COLORMAP_SIZE(fmt)
|
||||
The size of the color-map required by the format; this is the size of the
|
||||
color-map buffer passed to the png_image_{read,write}_colormap APIs, it is
|
||||
a fixed number determined by the format so can easily be allocated on the
|
||||
stack if necessary.
|
||||
|
||||
#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\
|
||||
(PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)
|
||||
/* The maximum size of the color-map required by the format expressed in a
|
||||
* count of components. This can be used to compile-time allocate a
|
||||
* color-map:
|
||||
*
|
||||
* png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)];
|
||||
*
|
||||
* png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];
|
||||
*
|
||||
* Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
|
||||
* information from one of the png_image_begin_read_ APIs and dynamically
|
||||
* allocate the required memory.
|
||||
*/
|
||||
|
||||
|
||||
Corresponding information about the pixels
|
||||
|
||||
PNG_IMAGE_PIXEL_(test,fmt)
|
||||
|
||||
PNG_IMAGE_PIXEL_CHANNELS(fmt)
|
||||
The number of separate channels (components) in a pixel; 1 for a
|
||||
color-mapped image.
|
||||
|
||||
PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\
|
||||
The size, in bytes, of each component in a pixel; 1 for a color-mapped
|
||||
image.
|
||||
|
||||
PNG_IMAGE_PIXEL_SIZE(fmt)
|
||||
Returns the size in bytes of a single pixel in the image.
|
||||
|
||||
The size, in bytes, of a complete pixel; 1 for a color-mapped image.
|
||||
|
||||
Information about the whole row, or whole image
|
||||
|
||||
PNG_IMAGE_ROW_STRIDE(image)
|
||||
Returns the total number of components in a single row
|
||||
of the image; this is the minimum 'row stride', the minimum
|
||||
count of components between each row.
|
||||
Returns the total number of components in a single row of the image; this
|
||||
is the minimum 'row stride', the minimum count of components between each
|
||||
row. For a color-mapped image this is the minimum number of bytes in a
|
||||
row.
|
||||
|
||||
PNG_IMAGE_BUFFER_SIZE(image, row_stride)
|
||||
Returns the size, in bytes, of an image buffer given
|
||||
a png_image and a row stride - the number of components to
|
||||
leave space for in each row.
|
||||
Returns the size, in bytes, of an image buffer given a png_image and a row
|
||||
stride - the number of components to leave space for in each row.
|
||||
|
||||
PNG_IMAGE_SIZE(image)
|
||||
Returns the size, in bytes, of the image in memory given
|
||||
just a png_image; the row stride is the minimum stride
|
||||
required for the image.
|
||||
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
|
||||
This indicates the 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_
|
||||
|
||||
Flags containing additional information about the image are held
|
||||
in the 'flags' field of png_image.
|
||||
|
||||
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB
|
||||
This indicates the 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_COLORMAP == 0x02
|
||||
The PNG is color-mapped. If this flag is set png_image_read_colormap
|
||||
can be used without further loss of image information. If it is not set
|
||||
png_image_read_colormap will cause significant loss if the image has any
|
||||
|
||||
READ APIs
|
||||
|
||||
@ -3662,7 +3763,6 @@ READ APIs
|
||||
|
||||
The named file is opened for read and the image header
|
||||
is filled in from the PNG header in the file.
|
||||
|
||||
|
||||
int png_image_begin_read_from_stdio (png_imagep image,
|
||||
FILE* file)
|
||||
@ -3675,24 +3775,25 @@ READ APIs
|
||||
The PNG header is read from the given memory buffer.
|
||||
|
||||
int png_image_finish_read(png_imagep image,
|
||||
png_colorp background, void *buffer, png_int_32 row_stride));
|
||||
png_colorp background, void *buffer,
|
||||
png_int_32 row_stride, void *colormap));
|
||||
|
||||
Finish reading the image into the supplied buffer and
|
||||
clean up the png_image structure.
|
||||
|
||||
|
||||
row_stride is the step, in png_byte or png_uint_16 units
|
||||
as appropriate, between adjacent rows. A positive stride
|
||||
indicates that the top-most row is first in the buffer -
|
||||
the normal top-down arrangement. A negative stride
|
||||
indicates that the bottom-most row is first in the buffer.
|
||||
|
||||
|
||||
background need only be supplied if an alpha channel must
|
||||
be removed from a png_byte format and the removal is to be
|
||||
done by compositing on a solid color; otherwise it may be
|
||||
NULL and any composition will be done directly onto the
|
||||
buffer. The value is an sRGB color to use for the
|
||||
background, for grayscale output the green channel is used.
|
||||
|
||||
|
||||
For linear output removing the alpha channel is always done
|
||||
by compositing on black.
|
||||
|
||||
@ -3702,12 +3803,17 @@ READ APIs
|
||||
setting the pointer to NULL. May be called at any time
|
||||
after the structure is initialized.
|
||||
|
||||
When the simplified API needs to convert between sRGB and linear colorspaces,
|
||||
the actual sRGB transfer curve defined in the sRGB specification (see the
|
||||
article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
|
||||
approximation used elsewhere in libpng.
|
||||
|
||||
WRITE APIS
|
||||
|
||||
For write you must initialize a png_image structure to describe the image to
|
||||
be written:
|
||||
|
||||
version: must be set to PNG_IMAGE_VERSION
|
||||
opaque: must be initialized to NULL
|
||||
width: image width in pixels
|
||||
height: image height in rows
|
||||
@ -3715,15 +3821,17 @@ be written:
|
||||
flags: set to 0 unless one of the defined flags applies; set
|
||||
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images
|
||||
where the RGB values do not correspond to the colors in sRGB.
|
||||
colormap_entries: set to the number of entries in the color-map (0 to 256)
|
||||
|
||||
int png_image_write_to_file, (png_imagep image,
|
||||
const char *file, int convert_to_8bit, const void *buffer,
|
||||
png_int_32 row_stride));
|
||||
png_int_32 row_stride, const void *colormap));
|
||||
|
||||
Write the image to the named file.
|
||||
|
||||
int png_image_write_to_stdio(png_imagep image, FILE *file,
|
||||
int convert_to_8_bit, const void *buffer, png_int_32 row_stride)
|
||||
int convert_to_8_bit, const void *buffer,
|
||||
png_int_32 row_stride, const void *colormap)
|
||||
|
||||
Write the image to the given (FILE*).
|
||||
|
||||
@ -3757,12 +3865,13 @@ in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change
|
||||
these functions, call the appropriate png_set_*_fn() function.
|
||||
|
||||
Memory allocation is done through the functions png_malloc(), png_calloc(),
|
||||
and png_free(). These currently just call the standard C functions.
|
||||
png_calloc() calls png_malloc() and then clears the newly
|
||||
allocated memory to zero. There is limited support for certain systems
|
||||
with segmented memory architectures and the types of pointers declared by
|
||||
png.h match this; you will have to use appropriate pointers in your
|
||||
application. Since it is
|
||||
and png_free(). The png_malloc() and png_free() functions currently just
|
||||
call the standard C functions and png_calloc() calls png_malloc() and then
|
||||
clears the newly allocated memory to zero; note that png_calloc(png_ptr, size)
|
||||
is not the same as the calloc(number, size) function provided by stdlib.h.
|
||||
There is limited support for certain systems with segmented memory
|
||||
architectures and the types of pointers declared by png.h match this; you
|
||||
will have to use appropriate pointers in your application. Since it is
|
||||
unlikely that the method of handling memory allocation on a platform
|
||||
will change between applications, these functions must be modified in
|
||||
the library at compile time. If you prefer to use a different method
|
||||
@ -3872,6 +3981,15 @@ compiler documentation for more details. For an alternative approach, you
|
||||
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net),
|
||||
which is illustrated in pngvalid.c and in contrib/visupng.
|
||||
|
||||
Beginning in libpng-1.4.0, the png_set_benign_errors() API became available.
|
||||
You can use this to handle certain errors (normally handled as errors)
|
||||
as warnings.
|
||||
|
||||
png_set_benign_errors (png_ptr, int allowed);
|
||||
|
||||
allowed: 0: (default) treat png_benign_error() an error.
|
||||
1: treat png_benign_error() as a warning.
|
||||
|
||||
Custom chunks
|
||||
|
||||
If you need to read or write custom chunks, you may need to get deeper
|
||||
@ -3992,7 +4110,7 @@ available to set these separately for non-IDAT
|
||||
compressed chunks such as zTXt, iTXt, and iCCP:
|
||||
|
||||
#include zlib.h
|
||||
#if PNG_LIBPNG_VER <= 10504
|
||||
#if PNG_LIBPNG_VER >= 10504
|
||||
png_set_text_compression_level(png_ptr, level);
|
||||
|
||||
png_set_text_compression_mem_level(png_ptr, level);
|
||||
@ -4160,6 +4278,17 @@ 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.
|
||||
|
||||
Prepending a prefix to exported symbols
|
||||
|
||||
Starting with libpng-1.6.0, you can configure libpng (when using the
|
||||
"configure" script) to prefix all exported symbols by means of the
|
||||
configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
|
||||
string beginning with a letter and containing only uppercase
|
||||
and lowercase letters, digits, and the underscore (i.e., a C language
|
||||
identifier). This creates a set of macros in pnglibconf.h, so this is
|
||||
transparent to applications; their function calls get transformed by
|
||||
the macros to use the modified names.
|
||||
|
||||
VII. MNG support
|
||||
|
||||
The MNG specification (available at http://www.libpng.org/pub/mng) allows
|
||||
@ -4429,7 +4558,9 @@ png_set_strip_error_numbers() was removed from the library by default.
|
||||
|
||||
The png_zalloc() and png_zfree() functions are no longer exported.
|
||||
The png_zalloc() function no longer zeroes out the memory that it
|
||||
allocates.
|
||||
allocates. Applications that called png_zalloc(png_ptr, number, size)
|
||||
can call png_calloc(png_ptr, number*size) instead, and can call
|
||||
png_free() instead of png_zfree().
|
||||
|
||||
Support for dithering was disabled by default in libpng-1.4.0, because
|
||||
it has not been well tested and doesn't actually "dither".
|
||||
@ -4449,10 +4580,41 @@ 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.
|
||||
|
||||
Checking for invalid palette index on read or write was added at libpng
|
||||
1.5.10. When an invalid index is found, libpng issues a benign error.
|
||||
This is enabled by default because this condition is an error according
|
||||
to the PNG specification, Clause 11.3.2, but the error can be ignored in
|
||||
each png_ptr with
|
||||
|
||||
png_set_check_for_invalid_index(png_ptr, allowed);
|
||||
|
||||
allowed - one of
|
||||
0: disable benign error (accept the
|
||||
invalid data without warning).
|
||||
1: enable benign error (treat the
|
||||
invalid data as an error or a
|
||||
warning).
|
||||
|
||||
If the error is ignored, or if png_benign_error() treats it as a warning,
|
||||
any invalid pixels are decoded as opaque black by the decoder and written
|
||||
as-is by the encoder.
|
||||
|
||||
Retrieving the maximum palette index found was added at libpng-1.5.15.
|
||||
This statement must appear after png_read_png() or png_read_image() while
|
||||
reading, and after png_write_png() or png_write_image() while writing.
|
||||
|
||||
int max_palette = png_get_palette_max(png_ptr, info_ptr);
|
||||
|
||||
This will return the maximum palette index found in the image, or "-1" if
|
||||
the palette was not checked, or "0" if no palette was found. Note that this
|
||||
does not account for any palette index used by ancillary chunks such as the
|
||||
bKGD chunk; you must check those separately to determine the maximum
|
||||
palette index actually used.
|
||||
|
||||
A. Changes that affect users of libpng
|
||||
|
||||
There are no substantial API changes between the non-deprecated parts of
|
||||
the 1.4.5 API and the 1.5.0 API; however the ability to directly access
|
||||
the 1.4.5 API and the 1.5.0 API; however, the ability to directly access
|
||||
members of the main libpng control structures, png_struct and png_info,
|
||||
deprecated in earlier versions of libpng, has been completely removed from
|
||||
libpng 1.5.
|
||||
@ -4463,9 +4625,12 @@ need access to information in zlib.h will need to add the '#include "zlib.h"'
|
||||
directive. It does not matter whether this is placed prior to or after
|
||||
the '"#include png.h"' directive.
|
||||
|
||||
We moved the png_strcpy(), png_strncpy(), png_strlen(), png_memcpy(),
|
||||
png_memcmp(), png_sprintf, and png_memcpy() macros into a private
|
||||
header file (pngpriv.h) that is not accessible by applications.
|
||||
The png_sprintf(), png_strcpy(), and png_strncpy() macros are no longer used
|
||||
and were removed.
|
||||
|
||||
We moved the png_strlen(), png_memcpy(), png_memset(), and png_memcmp()
|
||||
macros into a private header file (pngpriv.h) that is not accessible to
|
||||
applications.
|
||||
|
||||
In png_get_iCCP, the type of "profile" was changed from png_charpp
|
||||
to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep.
|
||||
@ -4568,16 +4733,30 @@ PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said
|
||||
that it could be used to override them. Now this function will reduce or
|
||||
increase the limits.
|
||||
|
||||
Starting in libpng-1.5.10, the user limits can be set en masse with the
|
||||
configuration option PNG_SAFE_LIMITS_SUPPORTED. If this option is enabled,
|
||||
a set of "safe" limits is applied in pngpriv.h. These can be overridden by
|
||||
application calls to png_set_user_limits(), png_set_user_chunk_cache_max(),
|
||||
and/or png_set_user_malloc_max() that increase or decrease the limits. Also,
|
||||
in libpng-1.5.10 the default width and height limits were increased
|
||||
from 1,000,000 to 0x7ffffff (i.e., made unlimited). Therefore, the
|
||||
limits are now
|
||||
default safe
|
||||
png_user_width_max 0x7fffffff 1,000,000
|
||||
png_user_height_max 0x7fffffff 1,000,000
|
||||
png_user_chunk_cache_max 0 (unlimited) 128
|
||||
png_user_chunk_malloc_max 0 (unlimited) 8,000,000
|
||||
|
||||
B. Changes to the build and configuration of libpng
|
||||
|
||||
Details of internal changes to the library code can be found in the CHANGES
|
||||
file and in the GIT repository logs. These will be of no concern to the vast
|
||||
majority of library users or builders, however the few who configure libpng
|
||||
majority of library users or builders; however, the few who configure libpng
|
||||
to a non-default feature set may need to change how this is done.
|
||||
|
||||
There should be no need for library builders to alter build scripts if
|
||||
these use the distributed build support - configure or the makefiles -
|
||||
however users of the makefiles may care to update their build scripts
|
||||
however, users of the makefiles may care to update their build scripts
|
||||
to build pnglibconf.h where the corresponding makefile does not do so.
|
||||
|
||||
Building libpng with a non-default configuration has changed completely.
|
||||
@ -4683,7 +4862,7 @@ merely stops the function from being exported.
|
||||
PNG_FLOATING_ARITHMETIC_SUPPORTED chooses between the internal floating
|
||||
point implementation or the fixed point one. Typically the fixed point
|
||||
implementation is larger and slower than the floating point implementation
|
||||
on a system that supports floating point, however it may be faster on a
|
||||
on a system that supports floating point; however, it may be faster on a
|
||||
system which lacks floating point hardware and therefore uses a software
|
||||
emulation.
|
||||
|
||||
@ -4712,7 +4891,7 @@ pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the
|
||||
build of pnglibconf.h and it is never included in an application build.
|
||||
|
||||
The rarely used alternative of adding a list of feature macros to the
|
||||
CFLAGS setting in the build also still works, however the macros will be
|
||||
CFLAGS setting in the build also still works; however, the macros will be
|
||||
copied to pnglibconf.h and this may produce macro redefinition warnings
|
||||
when the individual C files are compiled.
|
||||
|
||||
@ -4737,7 +4916,27 @@ how to do this, and a case where pngusr.h is still required.
|
||||
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)
|
||||
example in contrib/examples/pngtopng.c). The new publicly visible API
|
||||
includes the following:
|
||||
|
||||
macros:
|
||||
PNG_FORMAT_*
|
||||
PNG_IMAGE_*
|
||||
structures:
|
||||
png_control
|
||||
png_image
|
||||
read functions
|
||||
png_image_begin_read_from_file()
|
||||
png_image_begin_read_from_stdio()
|
||||
png_image_begin_read_from_memory()
|
||||
png_image_finish_read()
|
||||
png_image_free()
|
||||
write functions
|
||||
png_image_write_to_file()
|
||||
png_image_write_to_stdio()
|
||||
|
||||
Starting with libpng-1.6.0, you can configure libpng to prefix all exported
|
||||
symbols, using the PNG_PREFIX macro.
|
||||
|
||||
We no longer include string.h in png.h. The include statement has been moved
|
||||
to pngpriv.h, where it is not accessible by applications. Applications that
|
||||
@ -4749,14 +4948,49 @@ The following API are now DEPRECATED:
|
||||
png_info_init_3()
|
||||
png_convert_to_rfc1123() which has been replaced
|
||||
with png_convert_to_rfc1123_buffer()
|
||||
png_data_freer()
|
||||
png_malloc_default()
|
||||
png_free_default()
|
||||
png_reset_zstream()
|
||||
|
||||
The following has been removed:
|
||||
The following have been removed:
|
||||
png_get_io_chunk_name(), which has been replaced
|
||||
with png_get_io_chunk_type(). The new
|
||||
function returns a 32-bit integer instead of
|
||||
a string.
|
||||
The png_sizeof(), png_strlen(), png_memcpy(), png_memcmp(), and
|
||||
png_memset() macros are no longer used in the libpng sources and
|
||||
have been removed. These had already been made invisible to applications
|
||||
(i.e., defined in the private pngpriv.h header file) since libpng-1.5.0.
|
||||
|
||||
The signatures of many exported functions were changed, such that
|
||||
png_structp became png_structrp or png_const_structrp
|
||||
png_infop became png_inforp or png_const_inforp
|
||||
where "rp" indicates a "restricted pointer".
|
||||
|
||||
Error detection in some chunks has improved; in particular the iCCP chunk
|
||||
reader now does pretty complete validation of the basic format. Some bad
|
||||
profiles that were previously accepted are now rejected, in particular the
|
||||
very old broken Microsoft/HP sRGB profile.
|
||||
|
||||
The library now issues an error if the application attempts to set a
|
||||
transform after it calls png_read_update_info().
|
||||
|
||||
The library now issues a warning if both background processing and RGB to
|
||||
gray are used when gamma correction happens. As with previous versions of
|
||||
the library the results are numerically very incorrect in this case.
|
||||
|
||||
There are some minor arithmetic changes in some transforms such as
|
||||
png_set_background(), that might be detected by certain regression tests.
|
||||
|
||||
Unknown chunk handling has been improved internally, without any API change.
|
||||
This adds more correct option control of the unknown handling, corrects
|
||||
a pre-existing bug where the per-chunk 'keep' setting is ignored, and makes
|
||||
it possible to skip IDAT chunks in the sequential reader.
|
||||
|
||||
The machine-generated configure files are no longer included in branches
|
||||
libpng16 and later of the GIT repository. They continue to be included
|
||||
in the tarball releases, however.
|
||||
|
||||
XIII. Detecting libpng
|
||||
|
||||
@ -4874,11 +5108,22 @@ pngtest) appear in
|
||||
pngpriv.h
|
||||
above the comment that says
|
||||
|
||||
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
|
||||
/* Maintainer: Put new private prototypes here ^ */
|
||||
|
||||
We put a space after the "sizeof" operator and we omit the
|
||||
optional parentheses around its argument when the argument
|
||||
is an expression, not a type name, and we always enclose the
|
||||
sizeof operator, with its argument, in parentheses:
|
||||
|
||||
(sizeof (png_uint_32))
|
||||
(sizeof array)
|
||||
|
||||
Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as
|
||||
though it were a function.
|
||||
|
||||
To avoid polluting the global namespace, the names of all exported
|
||||
functions and variables begin with "png_", and all publicly visible C
|
||||
preprocessor macros begin with "PNG_". We request that applications that
|
||||
functions and variables begin with "png_", and all publicly visible C
|
||||
preprocessor macros begin with "PNG". We request that applications that
|
||||
use libpng *not* begin any of their own symbols with either of these strings.
|
||||
|
||||
We put a space after each comma and after each semicolon
|
||||
@ -4891,12 +5136,16 @@ left parenthesis that follows it:
|
||||
for (i = 2; i > 0; --i)
|
||||
y[i] = a(x) + (int)b;
|
||||
|
||||
We prefer #ifdef and #ifndef to #if defined() and if !defined()
|
||||
when there is only one macro being tested.
|
||||
We prefer #ifdef and #ifndef to #if defined() and #if !defined()
|
||||
when there is only one macro being tested. We always use parentheses
|
||||
with "defined".
|
||||
|
||||
We prefer to express integers that are used as bit masks in hex format,
|
||||
with an even number of lower-case hex digits (e.g., 0x00, 0xff, 0x0100).
|
||||
|
||||
We prefer to use underscores in variable names rather than camelCase, except
|
||||
for a few type names that we inherit from zlib.h.
|
||||
|
||||
We do not use the TAB character for indentation in the C sources.
|
||||
|
||||
Lines do not exceed 80 characters.
|
||||
@ -4905,25 +5154,25 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
XVI. Y2K Compliance in libpng
|
||||
|
||||
February 3, 2012
|
||||
March 2, 2013
|
||||
|
||||
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.0beta05 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.6.1beta05 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has three year fields. One is a 2-byte unsigned integer that
|
||||
will hold years up to 65535. The other two hold the date in text
|
||||
format, and will hold years up to 9999.
|
||||
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 strings are
|
||||
"png_charp time_buffer" in png_struct and
|
||||
"near_time_buffer", which is a local character string in png.c.
|
||||
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:
|
||||
|
||||
|
16
libpngpf.3
@ -1,21 +1,11 @@
|
||||
.TH LIBPNGPF 3 "February 3, 2012"
|
||||
.TH LIBPNGPF 3 "March 2, 2013"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.0beta05
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.1beta05
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer \fP\fImaintained\fP\fB, now \fIthat
|
||||
|
||||
\fBthe private function prototypes are hidden in pngpriv.h and not \fIaccessible
|
||||
|
||||
\fBto applications. Look in pngpriv.h for the prototypes and a short \fIdescription
|
||||
|
||||
\fBof each \fIfunction.
|
||||
|
||||
\fI\fB
|
||||
\fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer \fP\fImaintained\fP\fB, now that the private function prototypes are hidden in pngpriv.h and not accessible to applications. Look in pngpriv.h for the prototypes and a short description of each \fIfunction.
|
||||
|
||||
.SH DESCRIPTION
|
||||
The functions previously listed here are used privately by libpng and are not
|
||||
|
2
png.5
@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "February 3, 2012"
|
||||
.TH PNG 5 "March 2, 2013"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
108
pngconf.h
@ -1,9 +1,9 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.0beta05 - February 3, 2012
|
||||
* libpng version 1.6.1beta05 - March 2, 2013
|
||||
*
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -22,6 +22,26 @@
|
||||
#ifndef PNGCONF_H
|
||||
#define PNGCONF_H
|
||||
|
||||
/* To do: Do all of this in scripts/pnglibconf.dfa */
|
||||
#ifdef PNG_SAFE_LIMITS_SUPPORTED
|
||||
# ifdef PNG_USER_WIDTH_MAX
|
||||
# undef PNG_USER_WIDTH_MAX
|
||||
# define PNG_USER_WIDTH_MAX 1000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_HEIGHT_MAX
|
||||
# undef PNG_USER_HEIGHT_MAX
|
||||
# define PNG_USER_HEIGHT_MAX 1000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# undef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_CHUNK_CACHE_MAX
|
||||
# undef PNG_USER_CHUNK_CACHE_MAX
|
||||
# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||
|
||||
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
|
||||
@ -67,8 +87,8 @@
|
||||
|
||||
/* This controls optimization of the reading of 16 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 to the function is called.
|
||||
* The library builder sets the default, if read functions are not
|
||||
* 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.
|
||||
*/
|
||||
#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
@ -178,18 +198,16 @@
|
||||
* ==========================
|
||||
* This code is used at build time to find PNG_IMPEXP, the API settings
|
||||
* and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
|
||||
* import processing is possible. On Windows/x86 systems it also sets
|
||||
* import processing is possible. On Windows systems it also sets
|
||||
* compiler-specific macros to the values required to change the calling
|
||||
* conventions of the various functions.
|
||||
*/
|
||||
#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
|
||||
( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
|
||||
defined(_M_X64) || defined(_M_IA64) )
|
||||
/* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
|
||||
* builds under Cygwin or MinGW. Also includes Watcom builds but these need
|
||||
* special treatment because they are not compatible with GCC or Visual C
|
||||
* because of different calling conventions.
|
||||
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
|
||||
* MinGW on any architecture currently supported by Windows. Also includes
|
||||
* Watcom builds but these need special treatment because they are not
|
||||
* compatible with GCC or Visual C because of different calling conventions.
|
||||
*/
|
||||
# if PNG_API_RULE == 2
|
||||
/* If this line results in an error, either because __watcall is not
|
||||
@ -200,9 +218,12 @@
|
||||
# define PNGCAPI __watcall
|
||||
# endif
|
||||
|
||||
# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
|
||||
# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
|
||||
# define PNGCAPI __cdecl
|
||||
# if PNG_API_RULE == 1
|
||||
/* If this line results in an error __stdcall is not understood and
|
||||
* PNG_API_RULE should not have been set to '1'.
|
||||
*/
|
||||
# define PNGAPI __stdcall
|
||||
# endif
|
||||
# else
|
||||
@ -240,7 +261,7 @@
|
||||
# endif
|
||||
# endif /* compiler */
|
||||
|
||||
#else /* !Windows/x86 */
|
||||
#else /* !Windows */
|
||||
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
||||
# define PNGAPI _System
|
||||
# else /* !Windows/x86 && !OS/2 */
|
||||
@ -346,24 +367,28 @@
|
||||
# ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((warning("This function is not exported by libpng.")))
|
||||
# else
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# if __GNUC__ >= 3
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# endif
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((warning("This function is not exported by libpng.")))
|
||||
# else
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# endif
|
||||
# endif
|
||||
# if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif /* __GNUC__ == 3.0 */
|
||||
# endif /* __GNUC__ >= 3 */
|
||||
|
||||
# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# ifndef PNG_USE_RESULT
|
||||
@ -411,10 +436,13 @@
|
||||
#ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE /* This is a private libpng function */
|
||||
#endif
|
||||
#ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT /* The C99 "restrict" feature */
|
||||
#endif
|
||||
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||
PNG_EXPORT(ordinal, type, name, args)
|
||||
PNG_EXPORT(ordinal, type, name, args);
|
||||
# else /* No floating point APIs */
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)
|
||||
# endif
|
||||
@ -422,7 +450,7 @@
|
||||
#ifndef PNG_FIXED_EXPORT /* A fixed point API. */
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
# define PNG_FIXED_EXPORT(ordinal, type, name, args)\
|
||||
PNG_EXPORT(ordinal, type, name, args)
|
||||
PNG_EXPORT(ordinal, type, name, args);
|
||||
# else /* No fixed point APIs */
|
||||
# define PNG_FIXED_EXPORT(ordinal, type, name, args)
|
||||
# endif
|
||||
@ -465,9 +493,9 @@
|
||||
# error "libpng requires an unsigned 16 bit type"
|
||||
#endif
|
||||
|
||||
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||
typedef int png_int_32;
|
||||
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||
typedef long int png_int_32;
|
||||
#else
|
||||
# error "libpng requires a signed 32 bit (or more) type"
|
||||
@ -513,7 +541,7 @@ typedef ptrdiff_t png_ptrdiff_t;
|
||||
* png_uint_32) should be explicitly applied; however, we do not expect to
|
||||
* encounter practical situations that require such conversions.
|
||||
*
|
||||
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||
* 4294967295 - i.e. less than the maximum value of png_uint_32.
|
||||
*/
|
||||
#ifdef PNG_SMALL_SIZE_T
|
||||
@ -522,12 +550,6 @@ typedef ptrdiff_t png_ptrdiff_t;
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
#endif
|
||||
|
||||
/* This macro makes the sizeof operator look and behave like a function, except
|
||||
* that it can take a type without the enclosing () as an argument so long as
|
||||
* the type contains no "," characters.
|
||||
*/
|
||||
#define png_sizeof(x) (sizeof (x))
|
||||
|
||||
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
|
||||
* implementations of Intel CPU specific support of user-mode segmented address
|
||||
* spaces, where 16-bit pointers address more than 65536 bytes of memory using
|
||||
|
125
pngerror.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.1 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -80,7 +80,8 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
}
|
||||
#endif
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), error_message);
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
|
||||
error_message);
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
@ -162,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02u:
|
||||
/* Expects at least 2 digits. */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_u:
|
||||
*--end = digits[number % 10];
|
||||
@ -172,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02x:
|
||||
/* This format expects at least two digits */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_x:
|
||||
*--end = digits[number & 0xf];
|
||||
@ -283,11 +284,13 @@ void
|
||||
png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||
png_const_charp message)
|
||||
{
|
||||
/* The internal buffer is just 128 bytes - enough for all our messages,
|
||||
* overflow doesn't happen because this code checks!
|
||||
/* The internal buffer is just 192 bytes - enough for all our messages,
|
||||
* overflow doesn't happen because this code checks! If someone figures
|
||||
* out how to send us a message longer than 192 bytes, all that will
|
||||
* happen is that the message will be truncated appropriately.
|
||||
*/
|
||||
size_t i = 0; /* Index in the msg[] buffer: */
|
||||
char msg[128];
|
||||
char msg[192];
|
||||
|
||||
/* Each iteration through the following loop writes at most one character
|
||||
* to msg[i++] then returns here to validate that there is still space for
|
||||
@ -358,12 +361,47 @@ png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||
void PNGAPI
|
||||
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
png_ptr->chunk_name != 0)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
else
|
||||
# endif
|
||||
png_warning(png_ptr, error_message);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
png_ptr->chunk_name != 0)
|
||||
png_chunk_error(png_ptr, error_message);
|
||||
else
|
||||
# endif
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
#endif
|
||||
|
||||
void /* PRIVATE */
|
||||
png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
#endif /* BENIGN_ERRORS */
|
||||
|
||||
/* These utilities are used internally to build an error message that relates
|
||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||
@ -377,7 +415,7 @@ static PNG_CONST char png_digit[16] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
#define PNG_MAX_ERROR_TEXT 64
|
||||
#define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
@ -460,7 +498,8 @@ png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
@ -471,6 +510,41 @@ png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp error_message
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
{
|
||||
/* This is always supported, but for just read or just write it
|
||||
* unconditionally does the right thing.
|
||||
*/
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
{
|
||||
if (error < PNG_CHUNK_ERROR)
|
||||
png_chunk_warning(png_ptr, message);
|
||||
|
||||
else
|
||||
png_chunk_benign_error(png_ptr, message);
|
||||
}
|
||||
# endif
|
||||
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
else if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
{
|
||||
if (error < PNG_CHUNK_WRITE_ERROR)
|
||||
png_app_warning(png_ptr, message);
|
||||
|
||||
else
|
||||
png_app_error(png_ptr, message);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
PNG_FUNCTION(void,
|
||||
@ -480,7 +554,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||
int iin;
|
||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
png_memcpy(msg, fixed_message, fixed_message_ln);
|
||||
memcpy(msg, fixed_message, fixed_message_ln);
|
||||
iin = 0;
|
||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
@ -518,7 +592,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
{
|
||||
png_ptr->jmp_buf_size = 0; /* not allocated */
|
||||
|
||||
if (jmp_buf_size <= sizeof png_ptr->jmp_buf_local)
|
||||
if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))
|
||||
png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
|
||||
|
||||
else
|
||||
@ -539,7 +613,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
size = sizeof png_ptr->jmp_buf_local;
|
||||
size = (sizeof png_ptr->jmp_buf_local);
|
||||
if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
|
||||
{
|
||||
/* This is an internal error in libpng: somehow we have been left
|
||||
@ -770,8 +844,8 @@ png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\
|
||||
defined PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
/* Currently the above both depend on SETJMP_SUPPORTED, however it would be
|
||||
* possible to implement without setjmp support just so long as there is some
|
||||
* way to handle the error return here:
|
||||
@ -788,8 +862,8 @@ png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
*/
|
||||
if (image != NULL)
|
||||
{
|
||||
png_safecat(image->message, sizeof image->message, 0, error_message);
|
||||
image->warning_or_error = 1;
|
||||
png_safecat(image->message, (sizeof image->message), 0, error_message);
|
||||
image->warning_or_error |= PNG_IMAGE_ERROR;
|
||||
|
||||
/* Retrieve the jmp_buf from within the png_control, making this work for
|
||||
* C++ compilation too is pretty tricky: C++ wants a pointer to the first
|
||||
@ -800,9 +874,10 @@ png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
|
||||
/* Missing longjmp buffer, the following is to help debugging: */
|
||||
{
|
||||
size_t pos = png_safecat(image->message, sizeof image->message, 0,
|
||||
size_t pos = png_safecat(image->message, (sizeof image->message), 0,
|
||||
"bad longjmp: ");
|
||||
png_safecat(image->message, sizeof image->message, pos, error_message);
|
||||
png_safecat(image->message, (sizeof image->message), pos,
|
||||
error_message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -820,16 +895,16 @@ png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
/* A warning is only logged if there is no prior warning or error. */
|
||||
if (image->warning_or_error == 0)
|
||||
{
|
||||
png_safecat(image->message, sizeof image->message, 0, warning_message);
|
||||
image->warning_or_error = 2;
|
||||
png_safecat(image->message, (sizeof image->message), 0, warning_message);
|
||||
image->warning_or_error |= PNG_IMAGE_WARNING;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int /* PRIVATE */
|
||||
png_safe_execute(png_imagep imageIn, int (*function)(png_voidp), png_voidp arg)
|
||||
png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||
{
|
||||
volatile png_imagep image = imageIn;
|
||||
volatile png_imagep image = image_in;
|
||||
volatile int result;
|
||||
volatile png_voidp saved_error_buf;
|
||||
jmp_buf safe_jmpbuf;
|
||||
|
309
pngget.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.1 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -112,7 +112,8 @@ png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@ -129,7 +130,8 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@ -164,7 +166,8 @@ png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float PNGAPI
|
||||
png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
|
||||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@ -175,6 +178,9 @@ png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp info_ptr
|
||||
return ((float)((float)info_ptr->y_pixels_per_unit
|
||||
/(float)info_ptr->x_pixels_per_unit));
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return ((float)0.0);
|
||||
@ -203,6 +209,9 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
|
||||
(png_int_32)info_ptr->x_pixels_per_unit))
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@ -422,6 +431,7 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
@ -431,6 +441,7 @@ png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
png_const_bytep PNGAPI
|
||||
png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
@ -439,6 +450,7 @@ png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
@ -463,87 +475,47 @@ png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
* same time to correct the rgb grayscale coefficient defaults obtained from the
|
||||
* cHRM chunk in 1.5.4
|
||||
*/
|
||||
png_uint_32 PNGFAPI
|
||||
png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
||||
png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
|
||||
png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
|
||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
{
|
||||
png_xy xy;
|
||||
png_XYZ XYZ;
|
||||
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
xy.whitex = info_ptr->x_white;
|
||||
xy.whitey = info_ptr->y_white;
|
||||
xy.redx = info_ptr->x_red;
|
||||
xy.redy = info_ptr->y_red;
|
||||
xy.greenx = info_ptr->x_green;
|
||||
xy.greeny = info_ptr->y_green;
|
||||
xy.bluex = info_ptr->x_blue;
|
||||
xy.bluey = info_ptr->y_blue;
|
||||
|
||||
/* The *_checked function handles error reporting, so just return 0 if
|
||||
* there is a failure here.
|
||||
*/
|
||||
if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
|
||||
{
|
||||
if (int_red_X != NULL)
|
||||
*int_red_X = XYZ.redX;
|
||||
if (int_red_Y != NULL)
|
||||
*int_red_Y = XYZ.redY;
|
||||
if (int_red_Z != NULL)
|
||||
*int_red_Z = XYZ.redZ;
|
||||
if (int_green_X != NULL)
|
||||
*int_green_X = XYZ.greenX;
|
||||
if (int_green_Y != NULL)
|
||||
*int_green_Y = XYZ.greenY;
|
||||
if (int_green_Z != NULL)
|
||||
*int_green_Z = XYZ.greenZ;
|
||||
if (int_blue_X != NULL)
|
||||
*int_blue_X = XYZ.blueX;
|
||||
if (int_blue_Y != NULL)
|
||||
*int_blue_Y = XYZ.blueY;
|
||||
if (int_blue_Z != NULL)
|
||||
*int_blue_Z = XYZ.blueZ;
|
||||
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
/* Quiet API change: this code used to only return the end points if a cHRM
|
||||
* chunk was present, but the end points can also come from iCCP or sRGB
|
||||
* chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
|
||||
* the png_set_ APIs merely check that set end points are mutually
|
||||
* consistent.
|
||||
*/
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
if (white_x != NULL)
|
||||
*white_x = png_float(png_ptr, info_ptr->x_white, "cHRM white X");
|
||||
*white_x = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
|
||||
if (white_y != NULL)
|
||||
*white_y = png_float(png_ptr, info_ptr->y_white, "cHRM white Y");
|
||||
*white_y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
|
||||
if (red_x != NULL)
|
||||
*red_x = png_float(png_ptr, info_ptr->x_red, "cHRM red X");
|
||||
*red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
|
||||
"cHRM red X");
|
||||
if (red_y != NULL)
|
||||
*red_y = png_float(png_ptr, info_ptr->y_red, "cHRM red Y");
|
||||
*red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
|
||||
"cHRM red Y");
|
||||
if (green_x != NULL)
|
||||
*green_x = png_float(png_ptr, info_ptr->x_green, "cHRM green X");
|
||||
*green_x = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
|
||||
if (green_y != NULL)
|
||||
*green_y = png_float(png_ptr, info_ptr->y_green, "cHRM green Y");
|
||||
*green_y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
|
||||
if (blue_x != NULL)
|
||||
*blue_x = png_float(png_ptr, info_ptr->x_blue, "cHRM blue X");
|
||||
*blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
|
||||
"cHRM blue X");
|
||||
if (blue_y != NULL)
|
||||
*blue_y = png_float(png_ptr, info_ptr->y_blue, "cHRM blue Y");
|
||||
*blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
|
||||
"cHRM blue Y");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@ -556,30 +528,38 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
||||
double *blue_Z)
|
||||
{
|
||||
png_XYZ XYZ;
|
||||
|
||||
if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,
|
||||
&XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,
|
||||
&XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
|
||||
|
||||
if (red_X != NULL)
|
||||
*red_X = png_float(png_ptr, XYZ.redX, "cHRM red X");
|
||||
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
|
||||
"cHRM red X");
|
||||
if (red_Y != NULL)
|
||||
*red_Y = png_float(png_ptr, XYZ.redY, "cHRM red Y");
|
||||
*red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
|
||||
"cHRM red Y");
|
||||
if (red_Z != NULL)
|
||||
*red_Z = png_float(png_ptr, XYZ.redZ, "cHRM red Z");
|
||||
*red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
|
||||
"cHRM red Z");
|
||||
if (green_X != NULL)
|
||||
*green_X = png_float(png_ptr, XYZ.greenX, "cHRM green X");
|
||||
*green_X = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
|
||||
if (green_Y != NULL)
|
||||
*green_Y = png_float(png_ptr, XYZ.greenY, "cHRM green Y");
|
||||
*green_Y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
|
||||
if (green_Z != NULL)
|
||||
*green_Z = png_float(png_ptr, XYZ.greenZ, "cHRM green Z");
|
||||
*green_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
|
||||
if (blue_X != NULL)
|
||||
*blue_X = png_float(png_ptr, XYZ.blueX, "cHRM blue X");
|
||||
*blue_X = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
|
||||
if (blue_Y != NULL)
|
||||
*blue_Y = png_float(png_ptr, XYZ.blueY, "cHRM blue Y");
|
||||
*blue_Y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
|
||||
if (blue_Z != NULL)
|
||||
*blue_Z = png_float(png_ptr, XYZ.blueZ, "cHRM blue Z");
|
||||
*blue_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@ -588,6 +568,43 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
||||
png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
|
||||
png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
|
||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
if (int_red_X != NULL)
|
||||
*int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
|
||||
if (int_red_Y != NULL)
|
||||
*int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
|
||||
if (int_red_Z != NULL)
|
||||
*int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
|
||||
if (int_green_X != NULL)
|
||||
*int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
|
||||
if (int_green_Y != NULL)
|
||||
*int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
|
||||
if (int_green_Z != NULL)
|
||||
*int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
|
||||
if (int_blue_X != NULL)
|
||||
*int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
|
||||
if (int_blue_Y != NULL)
|
||||
*int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
|
||||
if (int_blue_Z != NULL)
|
||||
*int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
|
||||
@ -596,24 +613,25 @@ png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
if (white_x != NULL)
|
||||
*white_x = info_ptr->x_white;
|
||||
*white_x = info_ptr->colorspace.end_points_xy.whitex;
|
||||
if (white_y != NULL)
|
||||
*white_y = info_ptr->y_white;
|
||||
*white_y = info_ptr->colorspace.end_points_xy.whitey;
|
||||
if (red_x != NULL)
|
||||
*red_x = info_ptr->x_red;
|
||||
*red_x = info_ptr->colorspace.end_points_xy.redx;
|
||||
if (red_y != NULL)
|
||||
*red_y = info_ptr->y_red;
|
||||
*red_y = info_ptr->colorspace.end_points_xy.redy;
|
||||
if (green_x != NULL)
|
||||
*green_x = info_ptr->x_green;
|
||||
*green_x = info_ptr->colorspace.end_points_xy.greenx;
|
||||
if (green_y != NULL)
|
||||
*green_y = info_ptr->y_green;
|
||||
*green_y = info_ptr->colorspace.end_points_xy.greeny;
|
||||
if (blue_x != NULL)
|
||||
*blue_x = info_ptr->x_blue;
|
||||
*blue_x = info_ptr->colorspace.end_points_xy.bluex;
|
||||
if (blue_y != NULL)
|
||||
*blue_y = info_ptr->y_blue;
|
||||
*blue_y = info_ptr->colorspace.end_points_xy.bluey;
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@ -623,35 +641,43 @@ png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
png_uint_32 PNGFAPI
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *file_gamma)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "gAMA");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||
&& file_gamma != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = info_ptr->gamma;
|
||||
*file_gamma = info_ptr->colorspace.gamma;
|
||||
return (PNG_INFO_gAMA);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *file_gamma)
|
||||
{
|
||||
png_fixed_point igamma;
|
||||
png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);
|
||||
png_debug1(1, "in %s retrieval function", "gAMA(float)");
|
||||
|
||||
if (ok)
|
||||
*file_gamma = png_float(png_ptr, igamma, "png_get_gAMA");
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
|
||||
"png_get_gAMA");
|
||||
return (PNG_INFO_gAMA);
|
||||
}
|
||||
|
||||
return ok;
|
||||
return (0);
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -665,7 +691,7 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||
&& file_srgb_intent != NULL)
|
||||
{
|
||||
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
||||
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
|
||||
return (PNG_INFO_sRGB);
|
||||
}
|
||||
|
||||
@ -675,7 +701,7 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_charpp name, int *compression_type,
|
||||
png_bytepp profile, png_uint_32 *proflen)
|
||||
{
|
||||
@ -687,11 +713,11 @@ png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
*name = info_ptr->iccp_name;
|
||||
*profile = info_ptr->iccp_profile;
|
||||
/* Compression_type is a dummy so the API won't have to change
|
||||
* if we introduce multiple compression types later.
|
||||
*proflen = png_get_uint_32(info_ptr->iccp_profile);
|
||||
/* This is somewhat irrelevant since the profile data returned has
|
||||
* actually been uncompressed.
|
||||
*/
|
||||
*proflen = info_ptr->iccp_proflen;
|
||||
*compression_type = info_ptr->iccp_compression;
|
||||
*compression_type = PNG_COMPRESSION_TYPE_BASE;
|
||||
return (PNG_INFO_iCCP);
|
||||
}
|
||||
|
||||
@ -700,14 +726,14 @@ png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sPLT(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int PNGAPI
|
||||
png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_sPLT_tpp spalettes)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||
{
|
||||
*spalettes = info_ptr->splt_palettes;
|
||||
return ((png_uint_32)info_ptr->splt_palettes_num);
|
||||
return info_ptr->splt_palettes_num;
|
||||
}
|
||||
|
||||
return (0);
|
||||
@ -716,7 +742,7 @@ png_get_sPLT(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_hIST(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_uint_16p *hist)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "hIST");
|
||||
@ -792,7 +818,7 @@ png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||
png_charp *units, png_charpp *params)
|
||||
{
|
||||
@ -818,8 +844,8 @@ png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
# if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||
(defined PNG_FLOATING_POINT_SUPPORTED)
|
||||
# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_fixed_point *width, png_fixed_point *height)
|
||||
@ -912,7 +938,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
#endif /* pHYs */
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_PLTE(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_colorp *palette, int *num_palette)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "PLTE");
|
||||
@ -948,8 +974,8 @@ png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int PNGAPI
|
||||
png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_textp *text_ptr, int *num_text)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
||||
@ -963,7 +989,7 @@ png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
if (num_text != NULL)
|
||||
*num_text = info_ptr->num_text;
|
||||
|
||||
return ((png_uint_32)info_ptr->num_text);
|
||||
return info_ptr->num_text;
|
||||
}
|
||||
|
||||
if (num_text != NULL)
|
||||
@ -1036,9 +1062,9 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int PNGAPI
|
||||
png_get_unknown_chunks(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_unknown_chunkpp unknowns)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
||||
@ -1070,7 +1096,24 @@ png_get_user_chunk_ptr(png_const_structrp png_ptr)
|
||||
png_size_t PNGAPI
|
||||
png_get_compression_buffer_size(png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->zbuf_size : 0);
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
# endif
|
||||
{
|
||||
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
return png_ptr->IDAT_read_size;
|
||||
# else
|
||||
return PNG_IDAT_READ_SIZE;
|
||||
# endif
|
||||
}
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
else
|
||||
return png_ptr->zbuffer_size;
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
@ -1116,15 +1159,19 @@ png_get_io_chunk_type (png_const_structrp png_ptr)
|
||||
{
|
||||
return png_ptr->chunk_name;
|
||||
}
|
||||
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
png_const_bytep PNGAPI
|
||||
png_get_io_chunk_name (png_structrp png_ptr)
|
||||
{
|
||||
PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);
|
||||
return png_ptr->io_chunk_string;
|
||||
}
|
||||
#endif
|
||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
int PNGAPI
|
||||
png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return png_ptr->num_palette_max;
|
||||
|
||||
return (-1);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
73
pnginfo.h
@ -1,11 +1,11 @@
|
||||
|
||||
/* pnginfo.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Last changed in libpng 1.6.1 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -55,7 +55,7 @@
|
||||
|
||||
struct png_info_def
|
||||
{
|
||||
/* the following are necessary for every PNG file */
|
||||
/* The following are necessary for every PNG file */
|
||||
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
||||
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
||||
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
||||
@ -70,11 +70,17 @@ struct png_info_def
|
||||
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
||||
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
|
||||
/* The following is informational only on read, and not used on writes. */
|
||||
/* The following are set by png_set_IHDR, called from the application on
|
||||
* write, but the are never actually used by the write code.
|
||||
*/
|
||||
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte spare_byte; /* to align the data, and for future use */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* This is never set during write */
|
||||
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
||||
#endif
|
||||
|
||||
/* The rest of the data is optional. If you are reading, check the
|
||||
* valid field to see if the information in these are valid. If you
|
||||
@ -82,18 +88,25 @@ struct png_info_def
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
/* The gAMA chunk describes the gamma characteristics of the system
|
||||
* on which the image was created, normally in the range [1.0, 2.5].
|
||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||
* defined. When COLORSPACE is switched on all the colorspace-defining
|
||||
* chunks should be enabled, when GAMMA is switched on all the gamma-defining
|
||||
* chunks should be enabled. If this is not done it becomes possible to read
|
||||
* inconsistent PNG files and assign a probably incorrect interpretation to
|
||||
* the information. (In other words, by carefully choosing which chunks to
|
||||
* recognize the system configuration can select an interpretation for PNG
|
||||
* files containing ambiguous data and this will result in inconsistent
|
||||
* behavior between different libpng builds!)
|
||||
*/
|
||||
png_fixed_point gamma;
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
/* GR-P, 0.96a */
|
||||
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
|
||||
png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
@ -183,23 +196,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_uint_16p hist;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* The cHRM chunk describes the CIE color characteristics of the monitor
|
||||
* on which the PNG was created. This data allows the viewer to do gamut
|
||||
* mapping of the input image to ensure that the viewer sees the same
|
||||
* colors in the image as the creator. Values are in the range
|
||||
* [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
|
||||
*/
|
||||
png_fixed_point x_white;
|
||||
png_fixed_point y_white;
|
||||
png_fixed_point x_red;
|
||||
png_fixed_point y_red;
|
||||
png_fixed_point x_green;
|
||||
png_fixed_point y_green;
|
||||
png_fixed_point x_blue;
|
||||
png_fixed_point y_blue;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
/* The pCAL chunk describes a transformation between the stored pixel
|
||||
* values and original physical data values used to create the image.
|
||||
@ -224,25 +220,20 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* New members added in libpng-1.0.6 */
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||
png_byte iccp_compression; /* Always zero */
|
||||
/* The type of this field is limited by the type of
|
||||
* png_struct::user_chunk_cache_max, else overflow can occur.
|
||||
*/
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
/* Data on sPLT chunks (there may be more than one). */
|
||||
png_sPLT_tp splt_palettes;
|
||||
png_uint_32 splt_palettes_num;
|
||||
int splt_palettes_num; /* Match type returned by png_get API */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
|
72
pngmem.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -30,7 +30,7 @@ png_destroy_png_struct(png_structrp png_ptr)
|
||||
* png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||
*/
|
||||
png_struct dummy_struct = *png_ptr;
|
||||
memset(png_ptr, 0, sizeof *png_ptr);
|
||||
memset(png_ptr, 0, (sizeof *png_ptr));
|
||||
png_free(&dummy_struct, png_ptr);
|
||||
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
@ -54,7 +54,7 @@ png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
ret = png_malloc(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret, 0, size);
|
||||
memset(ret, 0, size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -76,7 +76,7 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
if (size > 0 && size <= ~(size_t)0
|
||||
if (size > 0 && size <= PNG_SIZE_MAX
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
&& size <= 65536U
|
||||
# endif
|
||||
@ -95,6 +95,68 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
|
||||
* that arises because of the checks in png_realloc_array that are repeated in
|
||||
* png_malloc_array.
|
||||
*/
|
||||
static png_voidp
|
||||
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size)
|
||||
{
|
||||
png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||
|
||||
if (req <= PNG_SIZE_MAX/element_size)
|
||||
return png_malloc_base(png_ptr, req * element_size);
|
||||
|
||||
/* The failure case when the request is too large */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
if (nelements <= 0 || element_size == 0)
|
||||
png_error(png_ptr, "internal error: array alloc");
|
||||
|
||||
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
|
||||
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
/* These are internal errors: */
|
||||
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||
(old_array == NULL && old_elements > 0))
|
||||
png_error(png_ptr, "internal error: array realloc");
|
||||
|
||||
/* Check for overflow on the elements count (so the caller does not have to
|
||||
* check.)
|
||||
*/
|
||||
if (add_elements <= INT_MAX - old_elements)
|
||||
{
|
||||
png_voidp new_array = png_malloc_array_checked(png_ptr,
|
||||
old_elements+add_elements, element_size);
|
||||
|
||||
if (new_array != NULL)
|
||||
{
|
||||
/* Because png_malloc_array worked the size calculations below cannot
|
||||
* overflow.
|
||||
*/
|
||||
if (old_elements > 0)
|
||||
memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||
|
||||
memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||
element_size*(unsigned)add_elements);
|
||||
|
||||
return new_array;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL; /* error */
|
||||
}
|
||||
|
||||
/* Various functions that have different error handling are derived from this.
|
||||
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
|
||||
* function png_malloc_default is also provided.
|
||||
|
659
pngpread.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -128,30 +128,6 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
case PNG_READ_tEXt_MODE:
|
||||
{
|
||||
png_push_read_tEXt(png_ptr, info_ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
case PNG_READ_zTXt_MODE:
|
||||
{
|
||||
png_push_read_zTXt(png_ptr, info_ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
case PNG_READ_iTXt_MODE:
|
||||
{
|
||||
png_push_read_iTXt(png_ptr, info_ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
case PNG_SKIP_MODE:
|
||||
{
|
||||
png_push_crc_finish(png_ptr);
|
||||
@ -209,6 +185,9 @@ void /* PRIVATE */
|
||||
png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
png_uint_32 chunk_name;
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int keep; /* unknown handling method */
|
||||
#endif
|
||||
|
||||
/* First we make sure we have enough data for the 4 byte chunk name
|
||||
* and the 4 byte chunk length before proceeding with decoding the
|
||||
@ -240,14 +219,28 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
/* This is here above the if/else case statement below because if the
|
||||
* unknown handling marks 'IDAT' as unknown then the IDAT handling case is
|
||||
* completely skipped.
|
||||
*
|
||||
* TODO: there must be a better way of doing this.
|
||||
*/
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||
|
||||
/* If we reach an IDAT chunk, this means we have read all of the
|
||||
* header chunks, and we can start reading the image (or if this
|
||||
* is called after the image has been read - we have an error).
|
||||
*/
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
if (png_ptr->push_length == 0)
|
||||
return;
|
||||
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
}
|
||||
|
||||
if (chunk_name == png_IHDR)
|
||||
@ -279,7 +272,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if (png_chunk_unknown_handling(png_ptr, chunk_name))
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@ -287,23 +280,10 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (chunk_name == png_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);
|
||||
|
||||
if (chunk_name == png_PLTE)
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -319,30 +299,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
/* If we reach an IDAT chunk, this means we have read all of the
|
||||
* header chunks, and we can start reading the image (or if this
|
||||
* is called after the image has been read - we have an error).
|
||||
*/
|
||||
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
if (png_ptr->mode & PNG_HAVE_IDAT)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
if (png_ptr->push_length == 0)
|
||||
return;
|
||||
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
}
|
||||
|
||||
png_ptr->idat_size = png_ptr->push_length;
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
||||
png_push_have_info(png_ptr, info_ptr);
|
||||
png_ptr->zstream.avail_out =
|
||||
@ -543,7 +500,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -556,7 +513,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -569,7 +526,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -580,7 +537,8 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
}
|
||||
|
||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
@ -673,7 +631,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
else
|
||||
save_size = png_ptr->save_buffer_size;
|
||||
|
||||
png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
|
||||
memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
|
||||
length -= save_size;
|
||||
ptr += save_size;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
@ -690,7 +648,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
else
|
||||
save_size = png_ptr->current_buffer_size;
|
||||
|
||||
png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
|
||||
memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
@ -739,13 +697,13 @@ png_push_save_buffer(png_structrp png_ptr)
|
||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||
}
|
||||
|
||||
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
png_free(png_ptr, old_buffer);
|
||||
png_ptr->save_buffer_max = new_max;
|
||||
}
|
||||
if (png_ptr->current_buffer_size)
|
||||
{
|
||||
png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
|
||||
memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
|
||||
png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);
|
||||
png_ptr->save_buffer_size += png_ptr->current_buffer_size;
|
||||
png_ptr->current_buffer_size = 0;
|
||||
@ -790,7 +748,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
{
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
|
||||
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
||||
if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
png_error(png_ptr, "Not enough compressed data");
|
||||
|
||||
return;
|
||||
@ -862,6 +820,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_ptr->zowner = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -878,13 +837,14 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
* handle the uncompressed results.
|
||||
*/
|
||||
png_ptr->zstream.next_in = buffer;
|
||||
/* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */
|
||||
png_ptr->zstream.avail_in = (uInt)buffer_length;
|
||||
|
||||
/* Keep going until the decompressed data is all processed
|
||||
* or the stream marked as finished.
|
||||
*/
|
||||
while (png_ptr->zstream.avail_in > 0 &&
|
||||
!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
||||
!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -895,9 +855,9 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
*/
|
||||
if (!(png_ptr->zstream.avail_out > 0))
|
||||
{
|
||||
png_ptr->zstream.avail_out =
|
||||
(uInt) PNG_ROWBYTES(png_ptr->pixel_depth,
|
||||
png_ptr->iwidth) + 1;
|
||||
/* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */
|
||||
png_ptr->zstream.avail_out = (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth,
|
||||
png_ptr->iwidth) + 1);
|
||||
|
||||
png_ptr->zstream.next_out = png_ptr->row_buf;
|
||||
}
|
||||
@ -915,7 +875,8 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
if (ret != Z_OK && ret != Z_STREAM_END)
|
||||
{
|
||||
/* Terminate the decompression. */
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
png_ptr->zowner = 0;
|
||||
|
||||
/* This may be a truncated stream (missing or
|
||||
* damaged end code). Treat that as a warning.
|
||||
@ -943,7 +904,8 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
{
|
||||
/* Extra data. */
|
||||
png_warning(png_ptr, "Extra compressed data in IDAT");
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
png_ptr->zowner = 0;
|
||||
|
||||
/* Do no more processing; skip the unprocessed
|
||||
* input check below.
|
||||
@ -958,7 +920,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
|
||||
/* And check for the end of the stream. */
|
||||
if (ret == Z_STREAM_END)
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
}
|
||||
|
||||
/* All the data should have been processed, if anything
|
||||
@ -996,7 +958,7 @@ png_push_process_row(png_structrp png_ptr)
|
||||
* it may not be in the future, so this was changed just to copy the
|
||||
* interlaced row count:
|
||||
*/
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
if (png_ptr->transformations)
|
||||
@ -1201,6 +1163,7 @@ png_push_process_row(png_structrp png_ptr)
|
||||
void /* PRIVATE */
|
||||
png_read_push_finish_row(png_structrp png_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
@ -1219,6 +1182,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
* it, uncomment it here and in png.h
|
||||
static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||
*/
|
||||
#endif
|
||||
|
||||
png_ptr->row_number++;
|
||||
if (png_ptr->row_number < png_ptr->num_rows)
|
||||
@ -1228,7 +1192,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
|
||||
do
|
||||
{
|
||||
@ -1262,525 +1226,6 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_push_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||
{
|
||||
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
|
||||
png_error(png_ptr, "Out of place tEXt");
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
png_ptr->skip_length = 0; /* This may not be necessary */
|
||||
|
||||
if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
|
||||
{
|
||||
png_warning(png_ptr, "tEXt chunk too large to fit in memory");
|
||||
png_ptr->skip_length = length - (png_uint_32)65535L;
|
||||
length = (png_uint_32)65535L;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||
(png_size_t)(length + 1));
|
||||
png_ptr->current_text[length] = '\0';
|
||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||
png_ptr->current_text_size = (png_size_t)length;
|
||||
png_ptr->current_text_left = (png_size_t)length;
|
||||
png_ptr->process_mode = PNG_READ_tEXt_MODE;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_read_tEXt(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
{
|
||||
png_size_t text_size;
|
||||
|
||||
if (png_ptr->buffer_size < png_ptr->current_text_left)
|
||||
text_size = png_ptr->buffer_size;
|
||||
|
||||
else
|
||||
text_size = png_ptr->current_text_left;
|
||||
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
|
||||
png_ptr->current_text_left -= text_size;
|
||||
png_ptr->current_text_ptr += text_size;
|
||||
}
|
||||
if (!(png_ptr->current_text_left))
|
||||
{
|
||||
png_textp text_ptr;
|
||||
png_charp text;
|
||||
png_charp key;
|
||||
int ret;
|
||||
|
||||
if (png_ptr->buffer_size < 4)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
png_push_crc_finish(png_ptr);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (png_ptr->skip_length)
|
||||
return;
|
||||
#endif
|
||||
|
||||
key = png_ptr->current_text;
|
||||
|
||||
for (text = key; *text; text++)
|
||||
/* Empty loop */ ;
|
||||
|
||||
if (text < key + png_ptr->current_text_size)
|
||||
text++;
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, png_sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr->key = key;
|
||||
text_ptr->itxt_length = 0;
|
||||
text_ptr->lang = NULL;
|
||||
text_ptr->lang_key = NULL;
|
||||
text_ptr->text = text;
|
||||
|
||||
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, text_ptr);
|
||||
png_ptr->current_text = NULL;
|
||||
|
||||
if (ret)
|
||||
png_warning(png_ptr, "Insufficient memory to store text chunk");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_push_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||
{
|
||||
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
|
||||
png_error(png_ptr, "Out of place zTXt");
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
/* We can't handle zTXt chunks > 64K, since we don't have enough space
|
||||
* to be able to store the uncompressed data. Actually, the threshold
|
||||
* is probably around 32K, but it isn't as definite as 64K is.
|
||||
*/
|
||||
if (length > (png_uint_32)65535L)
|
||||
{
|
||||
png_warning(png_ptr, "zTXt chunk too large to fit in memory");
|
||||
png_push_crc_skip(png_ptr, length);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||
(png_size_t)(length + 1));
|
||||
png_ptr->current_text[length] = '\0';
|
||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||
png_ptr->current_text_size = (png_size_t)length;
|
||||
png_ptr->current_text_left = (png_size_t)length;
|
||||
png_ptr->process_mode = PNG_READ_zTXt_MODE;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_read_zTXt(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
{
|
||||
png_size_t text_size;
|
||||
|
||||
if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left)
|
||||
text_size = png_ptr->buffer_size;
|
||||
|
||||
else
|
||||
text_size = png_ptr->current_text_left;
|
||||
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
|
||||
png_ptr->current_text_left -= text_size;
|
||||
png_ptr->current_text_ptr += text_size;
|
||||
}
|
||||
if (!(png_ptr->current_text_left))
|
||||
{
|
||||
png_textp text_ptr;
|
||||
png_charp text;
|
||||
png_charp key;
|
||||
int ret;
|
||||
png_size_t text_size, key_size;
|
||||
|
||||
if (png_ptr->buffer_size < 4)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
png_push_crc_finish(png_ptr);
|
||||
|
||||
key = png_ptr->current_text;
|
||||
|
||||
for (text = key; *text; text++)
|
||||
/* Empty loop */ ;
|
||||
|
||||
/* zTXt can't have zero text */
|
||||
if (text >= key + png_ptr->current_text_size)
|
||||
{
|
||||
png_ptr->current_text = NULL;
|
||||
png_free(png_ptr, key);
|
||||
return;
|
||||
}
|
||||
|
||||
text++;
|
||||
|
||||
if (*text != PNG_TEXT_COMPRESSION_zTXt) /* Check compression byte */
|
||||
{
|
||||
png_ptr->current_text = NULL;
|
||||
png_free(png_ptr, key);
|
||||
return;
|
||||
}
|
||||
|
||||
text++;
|
||||
|
||||
png_ptr->zstream.next_in = (png_bytep)text;
|
||||
png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -
|
||||
(text - key));
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
|
||||
key_size = text - key;
|
||||
text_size = 0;
|
||||
text = NULL;
|
||||
ret = Z_STREAM_END;
|
||||
|
||||
while (png_ptr->zstream.avail_in)
|
||||
{
|
||||
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
||||
if (ret != Z_OK && ret != Z_STREAM_END)
|
||||
{
|
||||
inflateReset(&png_ptr->zstream);
|
||||
png_ptr->zstream.avail_in = 0;
|
||||
png_ptr->current_text = NULL;
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, text);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END)
|
||||
{
|
||||
if (text == NULL)
|
||||
{
|
||||
text = (png_charp)png_malloc(png_ptr,
|
||||
(png_ptr->zbuf_size
|
||||
- png_ptr->zstream.avail_out + key_size + 1));
|
||||
|
||||
png_memcpy(text + key_size, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
||||
|
||||
png_memcpy(text, key, key_size);
|
||||
|
||||
text_size = key_size + png_ptr->zbuf_size -
|
||||
png_ptr->zstream.avail_out;
|
||||
|
||||
*(text + text_size) = '\0';
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_charp tmp;
|
||||
|
||||
tmp = text;
|
||||
text = (png_charp)png_malloc(png_ptr, text_size +
|
||||
(png_ptr->zbuf_size
|
||||
- png_ptr->zstream.avail_out + 1));
|
||||
|
||||
png_memcpy(text, tmp, text_size);
|
||||
png_free(png_ptr, tmp);
|
||||
|
||||
png_memcpy(text + text_size, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
||||
|
||||
text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
|
||||
*(text + text_size) = '\0';
|
||||
}
|
||||
|
||||
if (ret != Z_STREAM_END)
|
||||
{
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret == Z_STREAM_END)
|
||||
break;
|
||||
}
|
||||
|
||||
inflateReset(&png_ptr->zstream);
|
||||
png_ptr->zstream.avail_in = 0;
|
||||
|
||||
if (ret != Z_STREAM_END)
|
||||
{
|
||||
png_ptr->current_text = NULL;
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, text);
|
||||
return;
|
||||
}
|
||||
|
||||
png_ptr->current_text = NULL;
|
||||
png_free(png_ptr, key);
|
||||
key = text;
|
||||
text += key_size;
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr,
|
||||
png_sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text_ptr->key = key;
|
||||
text_ptr->itxt_length = 0;
|
||||
text_ptr->lang = NULL;
|
||||
text_ptr->lang_key = NULL;
|
||||
text_ptr->text = text;
|
||||
|
||||
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
png_free(png_ptr, key);
|
||||
png_free(png_ptr, text_ptr);
|
||||
|
||||
if (ret)
|
||||
png_warning(png_ptr, "Insufficient memory to store text chunk");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_push_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||
{
|
||||
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
|
||||
png_error(png_ptr, "Out of place iTXt");
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
png_ptr->skip_length = 0; /* This may not be necessary */
|
||||
|
||||
if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
|
||||
{
|
||||
png_warning(png_ptr, "iTXt chunk too large to fit in memory");
|
||||
png_ptr->skip_length = length - (png_uint_32)65535L;
|
||||
length = (png_uint_32)65535L;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||
(png_size_t)(length + 1));
|
||||
png_ptr->current_text[length] = '\0';
|
||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||
png_ptr->current_text_size = (png_size_t)length;
|
||||
png_ptr->current_text_left = (png_size_t)length;
|
||||
png_ptr->process_mode = PNG_READ_iTXt_MODE;
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_read_iTXt(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
|
||||
if (png_ptr->buffer_size && png_ptr->current_text_left)
|
||||
{
|
||||
png_size_t text_size;
|
||||
|
||||
if (png_ptr->buffer_size < png_ptr->current_text_left)
|
||||
text_size = png_ptr->buffer_size;
|
||||
|
||||
else
|
||||
text_size = png_ptr->current_text_left;
|
||||
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
|
||||
png_ptr->current_text_left -= text_size;
|
||||
png_ptr->current_text_ptr += text_size;
|
||||
}
|
||||
|
||||
if (!(png_ptr->current_text_left))
|
||||
{
|
||||
png_textp text_ptr;
|
||||
png_charp key;
|
||||
int comp_flag;
|
||||
png_charp lang;
|
||||
png_charp lang_key;
|
||||
png_charp text;
|
||||
int ret;
|
||||
|
||||
if (png_ptr->buffer_size < 4)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
png_push_crc_finish(png_ptr);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (png_ptr->skip_length)
|
||||
return;
|
||||
#endif
|
||||
|
||||
key = png_ptr->current_text;
|
||||
|
||||
for (lang = key; *lang; lang++)
|
||||
/* Empty loop */ ;
|
||||
|
||||
if (lang < key + png_ptr->current_text_size - 3)
|
||||
lang++;
|
||||
|
||||
comp_flag = *lang++;
|
||||
lang++; /* Skip comp_type, always zero */
|
||||
|
||||
for (lang_key = lang; *lang_key; lang_key++)
|
||||
/* Empty loop */ ;
|
||||
|
||||
lang_key++; /* Skip NUL separator */
|
||||
|
||||
text=lang_key;
|
||||
|
||||
if (lang_key < key + png_ptr->current_text_size - 1)
|
||||
{
|
||||
for (; *text; text++)
|
||||
/* Empty loop */ ;
|
||||
}
|
||||
|
||||
if (text < key + png_ptr->current_text_size)
|
||||
text++;
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr,
|
||||
png_sizeof(png_text));
|
||||
|
||||
text_ptr->compression = comp_flag + 2;
|
||||
text_ptr->key = key;
|
||||
text_ptr->lang = lang;
|
||||
text_ptr->lang_key = lang_key;
|
||||
text_ptr->text = text;
|
||||
text_ptr->text_length = 0;
|
||||
text_ptr->itxt_length = png_strlen(text);
|
||||
|
||||
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
|
||||
|
||||
png_ptr->current_text = NULL;
|
||||
|
||||
png_free(png_ptr, text_ptr);
|
||||
if (ret)
|
||||
png_warning(png_ptr, "Insufficient memory to store iTXt chunk");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function is called when we haven't found a handler for this
|
||||
* chunk. If there isn't a problem with the chunk itself (ie a bad chunk
|
||||
* name or a critical chunk), the chunk is (currently) silently ignored.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_push_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
png_uint_32 skip = 0;
|
||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||
|
||||
if (PNG_CHUNK_CRITICAL(chunk_name))
|
||||
{
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
&& png_ptr->read_user_chunk_fn == NULL
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
|
||||
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* TODO: the code below is apparently just using the
|
||||
* png_struct::unknown_chunk member as a temporarily variable, it should be
|
||||
* possible to eliminate both it and the temporary buffer.
|
||||
*/
|
||||
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
|
||||
{
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (length > 65535)
|
||||
{
|
||||
png_warning(png_ptr, "unknown chunk too large to fit in memory");
|
||||
skip = length - 65535;
|
||||
length = 65535;
|
||||
}
|
||||
#endif
|
||||
/* This is just a record for the user; libpng doesn't use the character
|
||||
* form of the name.
|
||||
*/
|
||||
PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);
|
||||
|
||||
/* The following cast should be safe because of the check above. */
|
||||
png_ptr->unknown_chunk.size = (png_size_t)length;
|
||||
|
||||
if (length == 0)
|
||||
png_ptr->unknown_chunk.data = NULL;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->unknown_chunk.size);
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data,
|
||||
png_ptr->unknown_chunk.size);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
if (png_ptr->read_user_chunk_fn != NULL)
|
||||
{
|
||||
/* Callback to user unknown chunk handler */
|
||||
int ret;
|
||||
ret = (*(png_ptr->read_user_chunk_fn))
|
||||
(png_ptr, &png_ptr->unknown_chunk);
|
||||
|
||||
if (ret < 0)
|
||||
png_chunk_error(png_ptr, "error in user chunk");
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
|
||||
if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS)
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
png_set_unknown_chunks(png_ptr, info_ptr,
|
||||
&png_ptr->unknown_chunk, 1);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
#endif
|
||||
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
|
||||
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||
png_ptr->unknown_chunk.data = NULL;
|
||||
}
|
||||
|
||||
else
|
||||
#endif
|
||||
skip=length;
|
||||
png_push_crc_skip(png_ptr, skip);
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_push_have_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
|
4
pngrio.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
357
pngrtran.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.1 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -88,6 +88,36 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
/* Is it OK to set a transformation now? Only if png_start_read_image or
|
||||
* png_read_update_info have not been called. It is not necessary for the IHDR
|
||||
* to have been read in all cases, the parameter allows for this check too.
|
||||
*/
|
||||
static int
|
||||
png_rtran_ok(png_structrp png_ptr, int need_IHDR)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_ROW_INIT)
|
||||
png_app_error(png_ptr,
|
||||
"invalid after png_start_read_image or png_read_update_info");
|
||||
|
||||
else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||
png_app_error(png_ptr, "invalid before the PNG header has been read");
|
||||
|
||||
else
|
||||
{
|
||||
/* Turn on failure to initialize correctly for all transforms. */
|
||||
png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
|
||||
|
||||
return 1; /* Ok */
|
||||
}
|
||||
}
|
||||
|
||||
return 0; /* no png_error possible! */
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
/* Handle alpha and tRNS via a background color */
|
||||
void PNGFAPI
|
||||
@ -97,7 +127,7 @@ png_set_background_fixed(png_structrp png_ptr,
|
||||
{
|
||||
png_debug(1, "in png_set_background_fixed");
|
||||
|
||||
if (png_ptr == NULL || background_color == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0) || background_color == NULL)
|
||||
return;
|
||||
|
||||
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
||||
@ -141,7 +171,7 @@ png_set_scale_16(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_scale_16");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_SCALE_16_TO_8;
|
||||
@ -155,7 +185,7 @@ png_set_strip_16(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_16");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_16_TO_8;
|
||||
@ -168,7 +198,7 @@ png_set_strip_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_alpha");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||
@ -247,7 +277,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
|
||||
png_debug(1, "in png_set_alpha_mode");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
|
||||
@ -319,8 +349,11 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
* the side effect that the gamma in a second call to png_set_alpha_mode will
|
||||
* be ignored.)
|
||||
*/
|
||||
if (png_ptr->gamma == 0)
|
||||
png_ptr->gamma = file_gamma;
|
||||
if (png_ptr->colorspace.gamma == 0)
|
||||
{
|
||||
png_ptr->colorspace.gamma = file_gamma;
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
}
|
||||
|
||||
/* But always set the output gamma: */
|
||||
png_ptr->screen_gamma = output_gamma;
|
||||
@ -331,8 +364,8 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
if (compose)
|
||||
{
|
||||
/* And obtain alpha pre-multiplication by composing on black: */
|
||||
png_memset(&png_ptr->background, 0, sizeof png_ptr->background);
|
||||
png_ptr->background_gamma = png_ptr->gamma; /* just in case */
|
||||
memset(&png_ptr->background, 0, (sizeof png_ptr->background));
|
||||
png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */
|
||||
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
|
||||
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
|
||||
|
||||
@ -342,9 +375,6 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
|
||||
png_ptr->transformations |= PNG_COMPOSE;
|
||||
}
|
||||
|
||||
/* New API, make sure apps call the correct initializers: */
|
||||
png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@ -383,7 +413,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
{
|
||||
png_debug(1, "in png_set_quantize");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_QUANTIZE;
|
||||
@ -393,7 +423,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
int i;
|
||||
|
||||
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->quantize_index[i] = (png_byte)i;
|
||||
}
|
||||
@ -410,7 +440,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
|
||||
/* Initialize an array to sort colors */
|
||||
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
|
||||
/* Initialize the quantize_sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@ -544,9 +574,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
|
||||
/* Initialize palette index arrays */
|
||||
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
|
||||
/* Initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@ -556,7 +586,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
}
|
||||
|
||||
hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
|
||||
png_sizeof(png_dsortp)));
|
||||
(sizeof (png_dsortp))));
|
||||
|
||||
num_new_palette = num_palette;
|
||||
|
||||
@ -586,7 +616,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
{
|
||||
|
||||
t = (png_dsortp)png_malloc_warn(png_ptr,
|
||||
(png_uint_32)(png_sizeof(png_dsort)));
|
||||
(png_uint_32)(sizeof (png_dsort)));
|
||||
|
||||
if (t == NULL)
|
||||
break;
|
||||
@ -711,12 +741,12 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
||||
|
||||
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
|
||||
(png_uint_32)(num_entries * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_entries * (sizeof (png_byte))));
|
||||
|
||||
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
||||
png_sizeof(png_byte)));
|
||||
(sizeof (png_byte))));
|
||||
|
||||
png_memset(distance, 0xff, num_entries * png_sizeof(png_byte));
|
||||
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
||||
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
@ -770,7 +800,7 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
||||
{
|
||||
png_debug(1, "in png_set_gamma_fixed");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
|
||||
@ -798,7 +828,8 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
||||
* file if a gAMA chunk was present. png_set_alpha_mode provides a
|
||||
* different, easier, way to default the file gamma.
|
||||
*/
|
||||
png_ptr->gamma = file_gamma;
|
||||
png_ptr->colorspace.gamma = file_gamma;
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
png_ptr->screen_gamma = scrn_gamma;
|
||||
}
|
||||
|
||||
@ -822,11 +853,10 @@ png_set_expand(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
|
||||
/* GRR 19990627: the following three functions currently are identical
|
||||
@ -853,11 +883,10 @@ png_set_palette_to_rgb(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_palette_to_rgb");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
|
||||
/* Expand grayscale images of less than 8-bit depth to 8 bits. */
|
||||
@ -866,23 +895,22 @@ png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_EXPAND;
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Expand tRNS chunks to alpha channels. */
|
||||
void PNGAPI
|
||||
png_set_tRNS_to_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_tRNS_to_alpha");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||
|
||||
@ -895,14 +923,10 @@ png_set_expand_16(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand_16");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
|
||||
/* New API, make sure apps call the correct initializers: */
|
||||
png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -912,13 +936,12 @@ png_set_gray_to_rgb(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_gray_to_rgb");
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* Because rgb must be 8 bits or more: */
|
||||
png_set_expand_gray_1_2_4_to_8(png_ptr);
|
||||
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
/* Because rgb must be 8 bits or more: */
|
||||
png_set_expand_gray_1_2_4_to_8(png_ptr);
|
||||
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -929,7 +952,9 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
{
|
||||
png_debug(1, "in png_set_rgb_to_gray");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
/* Need the IHDR here because of the check on color_type below. */
|
||||
/* TODO: fix this */
|
||||
if (!png_rtran_ok(png_ptr, 1))
|
||||
return;
|
||||
|
||||
switch(error_action)
|
||||
@ -950,15 +975,19 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
png_error(png_ptr, "invalid error action to rgb_to_gray");
|
||||
break;
|
||||
}
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
png_ptr->transformations |= PNG_EXPAND;
|
||||
#else
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
/* Make this an error in 1.6 because otherwise the application may assume
|
||||
* that it just worked and get a memory overwrite.
|
||||
*/
|
||||
png_error(png_ptr,
|
||||
"Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED");
|
||||
|
||||
png_ptr->transformations &= ~PNG_RGB_TO_GRAY;
|
||||
/* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */
|
||||
}
|
||||
#endif
|
||||
{
|
||||
@ -982,7 +1011,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
else
|
||||
{
|
||||
if (red >= 0 && green >= 0)
|
||||
png_warning(png_ptr,
|
||||
png_app_warning(png_ptr,
|
||||
"ignoring out of range rgb_to_gray coefficients");
|
||||
|
||||
/* Use the defaults, from the cHRM chunk if set, else the historical
|
||||
@ -1011,16 +1040,13 @@ void PNGAPI
|
||||
png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red,
|
||||
double green)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_set_rgb_to_gray_fixed(png_ptr, error_action,
|
||||
png_fixed(png_ptr, red, "rgb to gray red coefficient"),
|
||||
png_fixed(png_ptr, green, "rgb to gray green coefficient"));
|
||||
}
|
||||
#endif /* FLOATING POINT */
|
||||
|
||||
#endif
|
||||
#endif /* RGB_TO_GRAY */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
@ -1030,7 +1056,7 @@ png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_transform_fn");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
@ -1219,7 +1245,7 @@ png_init_rgb_transformations(png_structrp png_ptr)
|
||||
default:
|
||||
|
||||
case 8:
|
||||
/* Already 8 bits, fall through */
|
||||
/* FALL THROUGH (Already 8 bits) */
|
||||
|
||||
case 16:
|
||||
/* Already a full 16 bits */
|
||||
@ -1265,17 +1291,17 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
*/
|
||||
int gamma_correction = 0;
|
||||
|
||||
if (png_ptr->gamma != 0) /* has been set */
|
||||
if (png_ptr->colorspace.gamma != 0) /* has been set */
|
||||
{
|
||||
if (png_ptr->screen_gamma != 0) /* screen set too */
|
||||
gamma_correction = png_gamma_threshold(png_ptr->gamma,
|
||||
gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma,
|
||||
png_ptr->screen_gamma);
|
||||
|
||||
else
|
||||
/* Assume the output matches the input; a long time default behavior
|
||||
* of libpng, although the standard has nothing to say about this.
|
||||
*/
|
||||
png_ptr->screen_gamma = png_reciprocal(png_ptr->gamma);
|
||||
png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma);
|
||||
}
|
||||
|
||||
else if (png_ptr->screen_gamma != 0)
|
||||
@ -1284,7 +1310,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* png_set_alpha_mode (even if the alpha handling mode isn't required
|
||||
* or isn't changed from the default.)
|
||||
*/
|
||||
png_ptr->gamma = png_reciprocal(png_ptr->screen_gamma);
|
||||
png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma);
|
||||
|
||||
else /* neither are set */
|
||||
/* Just in case the following prevents any processing - file and screen
|
||||
@ -1292,7 +1318,10 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* third gamma value other than png_set_background with 'UNIQUE', and,
|
||||
* prior to 1.5.4
|
||||
*/
|
||||
png_ptr->screen_gamma = png_ptr->gamma = PNG_FP_1;
|
||||
png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1;
|
||||
|
||||
/* We have a gamma value now. */
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
|
||||
/* Now turn the gamma transformation on or off as appropriate. Notice
|
||||
* that PNG_GAMMA just refers to the file->screen correction. Alpha
|
||||
@ -1374,9 +1403,16 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
|
||||
defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* Make sure the coefficients for the rgb to gray conversion are set
|
||||
* appropriately.
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
png_colorspace_set_rgb_coefficients(png_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* Detect gray background and attempt to enable optimization for
|
||||
* gray --> RGB case.
|
||||
*
|
||||
@ -1418,7 +1454,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED (etc) */
|
||||
#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
|
||||
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
|
||||
|
||||
/* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations
|
||||
* can be performed directly on the palette, and some (such as rgb to gray)
|
||||
@ -1454,7 +1491,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* NOTE: this discards the low 16 bits of the user supplied background
|
||||
* color, but until expand_16 works properly there is no choice!
|
||||
*/
|
||||
# define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16))
|
||||
# define CHOP(x) (x)=((png_uint_16)PNG_DIV257(x))
|
||||
CHOP(png_ptr->background.red);
|
||||
CHOP(png_ptr->background.green);
|
||||
CHOP(png_ptr->background.blue);
|
||||
@ -1514,10 +1551,10 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_GAMMA)
|
||||
|| ((png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
&& (png_gamma_significant(png_ptr->gamma) ||
|
||||
&& (png_gamma_significant(png_ptr->colorspace.gamma) ||
|
||||
png_gamma_significant(png_ptr->screen_gamma)))
|
||||
|| ((png_ptr->transformations & PNG_COMPOSE)
|
||||
&& (png_gamma_significant(png_ptr->gamma)
|
||||
&& (png_gamma_significant(png_ptr->colorspace.gamma)
|
||||
|| png_gamma_significant(png_ptr->screen_gamma)
|
||||
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
|
||||
@ -1574,8 +1611,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
break;
|
||||
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
g = png_reciprocal(png_ptr->gamma);
|
||||
gs = png_reciprocal2(png_ptr->gamma,
|
||||
g = png_reciprocal(png_ptr->colorspace.gamma);
|
||||
gs = png_reciprocal2(png_ptr->colorspace.gamma,
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
|
||||
@ -1683,8 +1720,9 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
break;
|
||||
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
g = png_reciprocal(png_ptr->gamma);
|
||||
gs = png_reciprocal2(png_ptr->gamma, png_ptr->screen_gamma);
|
||||
g = png_reciprocal(png_ptr->colorspace.gamma);
|
||||
gs = png_reciprocal2(png_ptr->colorspace.gamma,
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
|
||||
case PNG_BACKGROUND_GAMMA_UNIQUE:
|
||||
@ -1768,8 +1806,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
int num_palette = png_ptr->num_palette;
|
||||
int i;
|
||||
|
||||
/*NOTE: there are other transformations that should probably be in here
|
||||
* too.
|
||||
/* NOTE: there are other transformations that should probably be in
|
||||
* here too.
|
||||
*/
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
@ -1828,12 +1866,15 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
|
||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SHIFT) &&
|
||||
!(png_ptr->transformations & PNG_EXPAND) &&
|
||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
int i;
|
||||
int istop = png_ptr->num_palette;
|
||||
int shift = 8 - png_ptr->sig_bit.red;
|
||||
|
||||
png_ptr->transformations &= ~PNG_SHIFT;
|
||||
|
||||
/* significant bits can be in the range 1 to 7 for a meaninful result, if
|
||||
* the number of significant bits is 0 then no shift is done (this is an
|
||||
* error condition which is silently ignored.)
|
||||
@ -1923,8 +1964,12 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
* however it seems that the code in png_init_read_transformations, which has
|
||||
* been called before this from png_read_update_info->png_read_start_row
|
||||
* sometimes does the gamma transform and cancels the flag.
|
||||
*
|
||||
* TODO: this looks wrong; the info_ptr should end up with a gamma equal to
|
||||
* the screen_gamma value. The following probably results in weirdness if
|
||||
* the info_ptr is used by the app after the rows have been read.
|
||||
*/
|
||||
info_ptr->gamma = png_ptr->gamma;
|
||||
info_ptr->colorspace.gamma = png_ptr->colorspace.gamma;
|
||||
#endif
|
||||
|
||||
if (info_ptr->bit_depth == 16)
|
||||
@ -2087,8 +2132,9 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
|
||||
/* The following is debugging; prior to 1.5.4 the code was never compiled in;
|
||||
* in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
|
||||
* PNG_WARN_UNINITIALIZED_ROW removed. In 1.5 the new flag is set only for
|
||||
* selected new APIs to ensure that there is no API change.
|
||||
* PNG_WARN_UNINITIALIZED_ROW removed. In 1.6 the new flag is set only for
|
||||
* all transformations, however in practice the ROW_INIT always gets done on
|
||||
* demand, if necessary.
|
||||
*/
|
||||
if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&
|
||||
!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
@ -2193,8 +2239,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
(defined PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_COMPOSE)
|
||||
png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);
|
||||
#endif
|
||||
@ -2205,8 +2251,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
/* Because RGB_TO_GRAY does the gamma transform. */
|
||||
!(png_ptr->transformations & PNG_RGB_TO_GRAY) &&
|
||||
#endif
|
||||
#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
(defined PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
/* Because PNG_COMPOSE does the gamma transform if there is something to
|
||||
* do (if there is an alpha channel or transparency.)
|
||||
*/
|
||||
@ -2272,7 +2318,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
/*NOTE: moved here in 1.5.4 (from much later in this list.) */
|
||||
/* NOTE: moved here in 1.5.4 (from much later in this list.) */
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
|
||||
@ -2294,6 +2340,13 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
png_do_unpack(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Added at libpng-1.5.10 */
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
png_ptr->num_palette_max >= 0)
|
||||
png_do_check_palette_indexes(png_ptr, row_info);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_BGR_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
@ -3231,7 +3284,7 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
/* Notice that gamma to/from 1 are not necessarily inverses (if
|
||||
* there is an overall gamma correction). Prior to 1.5.5 this code
|
||||
* checked the linearized values for equality; this doesn't match
|
||||
@ -3291,7 +3344,7 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
if (red != green || red != blue)
|
||||
{
|
||||
rgb_error |= 1;
|
||||
/*NOTE: this is the historical approach which simply
|
||||
/* NOTE: this is the historical approach which simply
|
||||
* truncates the results.
|
||||
*/
|
||||
*(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
|
||||
@ -3308,7 +3361,7 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
else /* RGB bit_depth == 16 */
|
||||
{
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL)
|
||||
{
|
||||
png_bytep sp = row;
|
||||
@ -3465,8 +3518,8 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
(defined PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
/* Replace any alpha or transparency with the supplied background color.
|
||||
* "background" is already in the screen gamma, while "background_1" is
|
||||
* at a gamma of 1.0. Paletted files have already been taken care of.
|
||||
@ -3482,12 +3535,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1;
|
||||
png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1;
|
||||
int gamma_shift = png_ptr->gamma_shift;
|
||||
int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0;
|
||||
#endif
|
||||
|
||||
png_bytep sp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0;
|
||||
int shift;
|
||||
|
||||
png_debug(1, "in png_do_compose");
|
||||
@ -3508,8 +3561,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x01)
|
||||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
||||
unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
if (!shift)
|
||||
@ -3536,17 +3590,19 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x03)
|
||||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
||||
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0x03);
|
||||
png_byte g = (png_byte)((gamma_table [p | (p << 2) |
|
||||
(p << 4) | (p << 6)] >> 6) & 0x03);
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(g << shift);
|
||||
unsigned int p = (*sp >> shift) & 0x03;
|
||||
unsigned int g = (gamma_table [p | (p << 2) |
|
||||
(p << 4) | (p << 6)] >> 6) & 0x03;
|
||||
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||
tmp |= g << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
if (!shift)
|
||||
@ -3570,8 +3626,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x03)
|
||||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
||||
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
if (!shift)
|
||||
@ -3599,17 +3656,19 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
||||
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte p = (png_byte)((*sp >> shift) & 0x0f);
|
||||
png_byte g = (png_byte)((gamma_table[p |
|
||||
(p << 4)] >> 4) & 0x0f);
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(g << shift);
|
||||
unsigned int p = (*sp >> shift) & 0x0f;
|
||||
unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
|
||||
0x0f;
|
||||
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
|
||||
tmp |= g << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
if (!shift)
|
||||
@ -3633,8 +3692,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
||||
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
if (!shift)
|
||||
@ -3693,8 +3753,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
if (v == png_ptr->trans_color.gray)
|
||||
{
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray
|
||||
& 0xff);
|
||||
}
|
||||
|
||||
else
|
||||
@ -3717,8 +3779,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
if (v == png_ptr->trans_color.gray)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray
|
||||
& 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3798,9 +3862,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
}
|
||||
|
||||
@ -3841,9 +3908,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
}
|
||||
}
|
||||
@ -3898,7 +3968,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
*sp = (png_byte)png_ptr->background.gray;
|
||||
|
||||
else if (a < 0xff)
|
||||
png_composite(*sp, *sp, a, png_ptr->background_1.gray);
|
||||
png_composite(*sp, *sp, a, png_ptr->background.gray);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3926,7 +3996,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
else if (a == 0)
|
||||
{
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
}
|
||||
|
||||
@ -3956,7 +4027,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
if (a == 0)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
}
|
||||
|
||||
@ -3965,7 +4037,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
png_uint_16 g, v;
|
||||
|
||||
g = (png_uint_16)(((*sp) << 8) + *(sp + 1));
|
||||
png_composite_16(v, g, a, png_ptr->background_1.gray);
|
||||
png_composite_16(v, g, a, png_ptr->background.gray);
|
||||
*sp = (png_byte)((v >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(v & 0xff);
|
||||
}
|
||||
@ -4086,9 +4158,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
}
|
||||
|
||||
@ -4099,14 +4174,16 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.red);
|
||||
if (!optimize)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
*sp = (png_byte)((w >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(w & 0xff);
|
||||
|
||||
v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.green);
|
||||
if (!optimize)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
|
||||
*(sp + 2) = (png_byte)((w >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(w & 0xff);
|
||||
@ -4114,7 +4191,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.blue);
|
||||
if (!optimize)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
|
||||
*(sp + 4) = (png_byte)((w >> 8) & 0xff);
|
||||
*(sp + 5) = (png_byte)(w & 0xff);
|
||||
@ -4135,9 +4213,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
}
|
||||
|
||||
@ -4617,7 +4698,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
png_uint_16 gray = (png_uint_16)(trans_color ? trans_color->gray : 0);
|
||||
unsigned int gray = trans_color ? trans_color->gray : 0;
|
||||
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
@ -4625,7 +4706,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
gray = (png_uint_16)((gray & 0x01) * 0xff);
|
||||
gray = (gray & 0x01) * 0xff;
|
||||
sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = 7 - (int)((row_width + 7) & 0x07);
|
||||
@ -4653,7 +4734,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
|
||||
case 2:
|
||||
{
|
||||
gray = (png_uint_16)((gray & 0x03) * 0x55);
|
||||
gray = (gray & 0x03) * 0x55;
|
||||
sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||
@ -4678,7 +4759,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
|
||||
case 4:
|
||||
{
|
||||
gray = (png_uint_16)((gray & 0x0f) * 0x11);
|
||||
gray = (gray & 0x0f) * 0x11;
|
||||
sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
||||
@ -4731,8 +4812,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_byte gray_high = (png_byte)((gray >> 8) & 0xff);
|
||||
png_byte gray_low = (png_byte)(gray & 0xff);
|
||||
unsigned int gray_high = (gray >> 8) & 0xff;
|
||||
unsigned int gray_low = gray & 0xff;
|
||||
sp = row + row_info->rowbytes - 1;
|
||||
dp = row + (row_info->rowbytes << 1) - 1;
|
||||
for (i = 0; i < row_width; i++)
|
||||
|
2975
pngrutil.c
210
pngstruct.h
@ -1,11 +1,11 @@
|
||||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.1 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -24,7 +24,122 @@
|
||||
* in this structure and is required for decompressing the LZ compressed
|
||||
* data in PNG files.
|
||||
*/
|
||||
#ifndef ZLIB_CONST
|
||||
/* We must ensure that zlib uses 'const' in declarations. */
|
||||
# define ZLIB_CONST
|
||||
#endif
|
||||
#include "zlib.h"
|
||||
#ifdef const
|
||||
/* zlib.h sometimes #defines const to nothing, undo this. */
|
||||
# undef const
|
||||
#endif
|
||||
|
||||
/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
|
||||
* with older builds.
|
||||
*/
|
||||
#if ZLIB_VERNUM < 0x1260
|
||||
# define PNGZ_MSG_CAST(s) png_constcast(char*,s)
|
||||
# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
|
||||
#else
|
||||
# define PNGZ_MSG_CAST(s) (s)
|
||||
# define PNGZ_INPUT_CAST(b) (b)
|
||||
#endif
|
||||
|
||||
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
|
||||
* can handle at once. This type need be no larger than 16 bits (so maximum of
|
||||
* 65535), this define allows us to discover how big it is, but limited by the
|
||||
* maximuum for png_size_t. The value can be overriden in a library build
|
||||
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
|
||||
* lower value (e.g. 255 works). A lower value may help memory usage (slightly)
|
||||
* and may even improve performance on some systems (and degrade it on others.)
|
||||
*/
|
||||
#ifndef ZLIB_IO_MAX
|
||||
# define ZLIB_IO_MAX ((uInt)-1)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* The type of a compression buffer list used by the write code. */
|
||||
typedef struct png_compression_buffer
|
||||
{
|
||||
struct png_compression_buffer *next;
|
||||
png_byte output[1]; /* actually zbuf_size */
|
||||
} png_compression_buffer, *png_compression_bufferp;
|
||||
|
||||
#define PNG_COMPRESSION_BUFFER_SIZE(pp)\
|
||||
(offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)
|
||||
#endif
|
||||
|
||||
/* Colorspace support; structures used in png_struct, png_info and in internal
|
||||
* functions to hold and communicate information about the color space.
|
||||
*
|
||||
* PNG_COLORSPACE_SUPPORTED is only required if the application will perform
|
||||
* colorspace corrections, otherwise all the colorspace information can be
|
||||
* skipped and the size of libpng can be reduced (significantly) by compiling
|
||||
* out the colorspace support.
|
||||
*/
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* The chromaticities of the red, green and blue colorants and the chromaticity
|
||||
* of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
|
||||
*/
|
||||
typedef struct png_xy
|
||||
{
|
||||
png_fixed_point redx, redy;
|
||||
png_fixed_point greenx, greeny;
|
||||
png_fixed_point bluex, bluey;
|
||||
png_fixed_point whitex, whitey;
|
||||
} png_xy;
|
||||
|
||||
/* The same data as above but encoded as CIE XYZ values. When this data comes
|
||||
* from chromaticities the sum of the Y values is assumed to be 1.0
|
||||
*/
|
||||
typedef struct png_XYZ
|
||||
{
|
||||
png_fixed_point red_X, red_Y, red_Z;
|
||||
png_fixed_point green_X, green_Y, green_Z;
|
||||
png_fixed_point blue_X, blue_Y, blue_Z;
|
||||
} png_XYZ;
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* A colorspace is all the above plus, potentially, profile information,
|
||||
* however at present libpng does not use the profile internally so it is only
|
||||
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||
* is retained here and is checked.
|
||||
*
|
||||
* The file gamma encoding information is also stored here and gamma correction
|
||||
* is done by libpng, whereas color correction must currently be done by the
|
||||
* application.
|
||||
*/
|
||||
typedef struct png_colorspace
|
||||
{
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
png_fixed_point gamma; /* File gamma */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
png_xy end_points_xy; /* End points as chromaticities */
|
||||
png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
|
||||
png_uint_16 rendering_intent; /* Rendering intent of a profile */
|
||||
#endif
|
||||
|
||||
/* Flags are always defined to simplify the code. */
|
||||
png_uint_16 flags; /* As defined below */
|
||||
} png_colorspace, * PNG_RESTRICT png_colorspacerp;
|
||||
|
||||
typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
|
||||
|
||||
/* General flags for the 'flags' field */
|
||||
#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
|
||||
#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
|
||||
#define PNG_COLORSPACE_HAVE_INTENT 0x0004
|
||||
#define PNG_COLORSPACE_FROM_gAMA 0x0008
|
||||
#define PNG_COLORSPACE_FROM_cHRM 0x0010
|
||||
#define PNG_COLORSPACE_FROM_sRGB 0x0020
|
||||
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
|
||||
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
|
||||
#define PNG_COLORSPACE_INVALID 0x8000
|
||||
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
|
||||
#endif /* COLORSPACE || GAMMA */
|
||||
|
||||
struct png_struct_def
|
||||
{
|
||||
@ -65,22 +180,12 @@ struct png_struct_def
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations; /* which transformations to perform */
|
||||
|
||||
z_stream zstream; /* pointer to decompression structure (below) */
|
||||
png_bytep zbuf; /* buffer for zlib */
|
||||
uInt zbuf_size; /* size of zbuf (typically 65536) */
|
||||
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||
z_stream zstream; /* decompression structure */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Added in 1.5.4: state to keep track of whether the zstream has been
|
||||
* initialized and if so whether it is for IDAT or some other chunk.
|
||||
*/
|
||||
#define PNG_ZLIB_UNINITIALIZED 0
|
||||
#define PNG_ZLIB_FOR_IDAT 1
|
||||
#define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */
|
||||
#define PNG_ZLIB_USE_MASK 3 /* bottom two bits */
|
||||
#define PNG_ZLIB_IN_USE 4 /* a flag value */
|
||||
|
||||
png_uint_32 zlib_state; /* State of zlib initialization */
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
||||
uInt zbuffer_size; /* size of the actual buffer */
|
||||
|
||||
int zlib_level; /* holds zlib compression level */
|
||||
int zlib_method; /* holds zlib compression method */
|
||||
@ -89,8 +194,7 @@ struct png_struct_def
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* Added at libpng 1.5.4 */
|
||||
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
int zlib_text_level; /* holds zlib compression level */
|
||||
int zlib_text_method; /* holds zlib compression method */
|
||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||
@ -98,6 +202,14 @@ struct png_struct_def
|
||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
/* Added at libpng 1.6.0 */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
int zlib_set_level; /* Actual values set into the zstream on write */
|
||||
int zlib_set_method;
|
||||
int zlib_set_window_bits;
|
||||
int zlib_set_mem_level;
|
||||
int zlib_set_strategy;
|
||||
#endif
|
||||
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
@ -113,16 +225,24 @@ struct png_struct_def
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||
* This is a pointer into big_row_buf
|
||||
*/
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
#endif
|
||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||
|
||||
png_uint_32 idat_size; /* current IDAT size for read */
|
||||
png_uint_32 crc; /* current chunk CRC value */
|
||||
png_colorp palette; /* palette from the input file */
|
||||
png_uint_16 num_palette; /* number of color entries in palette */
|
||||
|
||||
/* Added at libpng-1.5.10 */
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
int num_palette_max; /* maximum palette index found in IDAT */
|
||||
#endif
|
||||
|
||||
png_uint_16 num_trans; /* number of transparency values */
|
||||
png_byte compression; /* file compression type (always 0) */
|
||||
png_byte filter; /* file filter type (always 0) */
|
||||
@ -134,17 +254,14 @@ struct png_struct_def
|
||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte channels; /* number of channels in file */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_byte usr_channels; /* channels at start of write: write only */
|
||||
#endif
|
||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||
png_byte maximum_pixel_depth;
|
||||
/* pixel depth used for the row buffers */
|
||||
png_byte transformed_pixel_depth;
|
||||
/* pixel depth after read/write transforms */
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
png_byte io_chunk_string[5];
|
||||
/* string name of chunk */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
@ -167,7 +284,6 @@ struct png_struct_def
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
png_fixed_point gamma; /* file gamma value */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
@ -215,13 +331,6 @@ struct png_struct_def
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
# ifdef PNG_TEXT_SUPPORTED
|
||||
png_size_t current_text_size; /* current size of text input data */
|
||||
png_size_t current_text_left; /* how much text left to read in input */
|
||||
png_charp current_text; /* current text chunk buffer */
|
||||
png_charp current_text_ptr; /* current location in current_text */
|
||||
# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
@ -249,6 +358,7 @@ struct png_struct_def
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* To do: remove this from libpng-1.7 */
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||
#endif
|
||||
@ -260,17 +370,16 @@ struct png_struct_def
|
||||
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
png_voidp user_chunk_ptr;
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
unsigned int num_chunk_list;
|
||||
png_bytep chunk_list;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
/* Added in 1.5.5 to record an sRGB chunk in the png. */
|
||||
png_byte is_sRGB;
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int unknown_default; /* As PNG_HANDLE_* */
|
||||
unsigned int num_chunk_list; /* Number of entries in the list */
|
||||
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
|
||||
* followed by a PNG_HANDLE_* byte */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.3 */
|
||||
@ -285,9 +394,7 @@ struct png_struct_def
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED) || \
|
||||
defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
|
||||
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
/* Changed from png_byte to png_uint_32 at version 1.2.0 */
|
||||
png_uint_32 mng_features_permitted;
|
||||
#endif
|
||||
@ -337,20 +444,24 @@ struct png_struct_def
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Temporary storage for unknown chunk that the library doesn't recognize,
|
||||
* used while reading the chunk.
|
||||
*/
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
png_unknown_chunk unknown_chunk;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.2.26 */
|
||||
png_size_t old_big_row_buf_size;
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* New member added in libpng-1.2.30 */
|
||||
png_charp chunkdata; /* buffer for reading chunk data */
|
||||
png_bytep read_buffer; /* buffer for reading chunk data */
|
||||
png_alloc_size_t read_buffer_size; /* current size of the buffer */
|
||||
#endif
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* New member added in libpng-1.4.0 */
|
||||
@ -360,7 +471,14 @@ struct png_struct_def
|
||||
/* New member added in libpng-1.5.6 */
|
||||
png_bytep big_prev_row;
|
||||
|
||||
/* New member added in libpng-1.5.7 */
|
||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row);
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif /* PNGSTRUCT_H */
|
||||
|
673
pngtest.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.1 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -33,16 +33,23 @@
|
||||
|
||||
#define _POSIX_SOURCE 1
|
||||
|
||||
#include "zlib.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Defined so I can write to a file on gui/windowing platforms */
|
||||
/* #define STDERR stderr */
|
||||
#define STDERR stdout /* For DOS */
|
||||
|
||||
#include "png.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED /* else nothing can be done */
|
||||
#include "zlib.h"
|
||||
/* Copied from pngpriv.h but only used in error messages below. */
|
||||
#ifndef PNG_ZBUF_SIZE
|
||||
# define PNG_ZBUF_SIZE 8192
|
||||
#endif
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# define FCLOSE(file) fclose(file)
|
||||
#define FCLOSE(file) fclose(file)
|
||||
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
typedef FILE * png_FILE_p;
|
||||
@ -88,30 +95,37 @@ static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
|
||||
|
||||
static int verbose = 0;
|
||||
static int strict = 0;
|
||||
|
||||
int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname));
|
||||
static int relaxed = 0;
|
||||
static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */
|
||||
static int error_count = 0; /* count calls to png_error */
|
||||
static int warning_count = 0; /* count calls to png_warning */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#endif
|
||||
|
||||
/* Defined so I can write to a file on gui/windowing platforms */
|
||||
/* #define STDERR stderr */
|
||||
#define STDERR stdout /* For DOS */
|
||||
|
||||
/* 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
|
||||
|
||||
/* Defines for unknown chunk handling if required. */
|
||||
#ifndef PNG_HANDLE_CHUNK_ALWAYS
|
||||
# define PNG_HANDLE_CHUNK_ALWAYS 3
|
||||
#endif
|
||||
#ifndef PNG_HANDLE_CHUNK_IF_SAFE
|
||||
# define PNG_HANDLE_CHUNK_IF_SAFE 2
|
||||
#endif
|
||||
|
||||
/* Utility to save typing/errors, the argument must be a name */
|
||||
#define MEMZERO(var) ((void)memset(&var, 0, sizeof var))
|
||||
|
||||
/* Example of using row callbacks to make a simple progress meter */
|
||||
static int status_pass = 1;
|
||||
static int status_dots_requested = 0;
|
||||
static int status_dots = 1;
|
||||
|
||||
void PNGCBAPI
|
||||
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
|
||||
void PNGCBAPI
|
||||
static void PNGCBAPI
|
||||
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
{
|
||||
if (png_ptr == NULL || row_number > PNG_UINT_31_MAX)
|
||||
@ -135,9 +149,8 @@ read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
fprintf(stdout, "r");
|
||||
}
|
||||
|
||||
void PNGCBAPI
|
||||
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
|
||||
void PNGCBAPI
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
static void PNGCBAPI
|
||||
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
{
|
||||
if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7)
|
||||
@ -145,6 +158,7 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
|
||||
fprintf(stdout, "w");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
@ -153,9 +167,7 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
* 5 in case illegal filter values are present.)
|
||||
*/
|
||||
static png_uint_32 filters_used[256];
|
||||
void PNGCBAPI
|
||||
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data);
|
||||
void PNGCBAPI
|
||||
static void PNGCBAPI
|
||||
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
{
|
||||
if (png_ptr != NULL && row_info != NULL)
|
||||
@ -170,9 +182,7 @@ count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
|
||||
static png_uint_32 zero_samples;
|
||||
|
||||
void PNGCBAPI
|
||||
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data);
|
||||
void PNGCBAPI
|
||||
static void PNGCBAPI
|
||||
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
{
|
||||
png_bytep dp = data;
|
||||
@ -279,8 +289,6 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
}
|
||||
#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
|
||||
static int wrote_question = 0;
|
||||
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
/* START of code to validate stdio-free compilation */
|
||||
/* These copies of the default read/write functions come from pngrio.c and
|
||||
@ -388,24 +396,31 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||
#endif
|
||||
}
|
||||
#endif /* !PNG_STDIO_SUPPORTED */
|
||||
|
||||
/* This function is called when there is a warning, but the library thinks
|
||||
* it can continue anyway. Replacement functions don't have to do anything
|
||||
* here if you don't want to. In the default configuration, png_ptr is
|
||||
* not used, but it is passed in case it may be useful.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
PNG_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!)";
|
||||
char *test;
|
||||
test = png_get_error_ptr(png_ptr);
|
||||
pngtest_error_parameters *test =
|
||||
(pngtest_error_parameters*)png_get_error_ptr(png_ptr);
|
||||
|
||||
if (test == NULL)
|
||||
fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
|
||||
++warning_count;
|
||||
|
||||
else
|
||||
fprintf(STDERR, "%s: libpng warning: %s\n", test, message);
|
||||
if (test != NULL && test->file_name != NULL)
|
||||
name = test->file_name;
|
||||
|
||||
fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
|
||||
}
|
||||
|
||||
/* This is the default error handling function. Note that replacements for
|
||||
@ -416,12 +431,14 @@ pngtest_warning(png_structp png_ptr, png_const_charp message)
|
||||
static void PNGCBAPI
|
||||
pngtest_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
++error_count;
|
||||
|
||||
pngtest_warning(png_ptr, message);
|
||||
/* We can return because png_error calls the default handler, which is
|
||||
* actually OK in this case.
|
||||
*/
|
||||
}
|
||||
#endif /* !PNG_STDIO_SUPPORTED */
|
||||
|
||||
/* END of code to validate stdio-free compilation */
|
||||
|
||||
/* START of code to validate memory allocation and deallocation */
|
||||
@ -472,7 +489,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
memory_infop pinfo;
|
||||
png_set_mem_fn(png_ptr, NULL, NULL, NULL);
|
||||
pinfo = (memory_infop)png_malloc(png_ptr,
|
||||
png_sizeof(*pinfo));
|
||||
(sizeof *pinfo));
|
||||
pinfo->size = size;
|
||||
current_allocation += size;
|
||||
total_allocation += size;
|
||||
@ -566,25 +583,73 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
/* END of code to test memory allocation/deallocation */
|
||||
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* Demonstration of user chunk support of the sTER and vpAg chunks */
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
|
||||
/* (sTER is a public chunk not yet known by libpng. vpAg is a private
|
||||
chunk used in ImageMagick to store "virtual page" size). */
|
||||
|
||||
static png_uint_32 user_chunk_data[4];
|
||||
static struct user_chunk_data
|
||||
{
|
||||
png_const_infop info_ptr;
|
||||
png_uint_32 vpAg_width, vpAg_height;
|
||||
png_byte vpAg_units;
|
||||
png_byte sTER_mode;
|
||||
int location[2];
|
||||
}
|
||||
user_chunk_data;
|
||||
|
||||
/* 0: sTER mode + 1
|
||||
* 1: vpAg width
|
||||
* 2: vpAg height
|
||||
* 3: vpAg units
|
||||
*/
|
||||
/* Used for location and order; zero means nothing. */
|
||||
#define have_sTER 0x01
|
||||
#define have_vpAg 0x02
|
||||
#define before_PLTE 0x10
|
||||
#define before_IDAT 0x20
|
||||
#define after_IDAT 0x40
|
||||
|
||||
static void
|
||||
init_callback_info(png_const_infop info_ptr)
|
||||
{
|
||||
MEMZERO(user_chunk_data);
|
||||
user_chunk_data.info_ptr = info_ptr;
|
||||
}
|
||||
|
||||
static int
|
||||
set_location(png_structp png_ptr, struct user_chunk_data *data, int what)
|
||||
{
|
||||
int location;
|
||||
|
||||
if ((data->location[0] & what) || (data->location[1] & what))
|
||||
return 0; /* already have one of these */
|
||||
|
||||
/* Find where we are (the code below zeros info_ptr to indicate that the
|
||||
* chunks before the first IDAT have been read.)
|
||||
*/
|
||||
if (data->info_ptr == NULL) /* after IDAT */
|
||||
location = what | after_IDAT;
|
||||
|
||||
else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE))
|
||||
location = what | before_IDAT;
|
||||
|
||||
else
|
||||
location = what | before_PLTE;
|
||||
|
||||
if (data->location[0] == 0)
|
||||
data->location[0] = location;
|
||||
|
||||
else
|
||||
data->location[1] = location;
|
||||
|
||||
return 1; /* handled */
|
||||
}
|
||||
|
||||
static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
png_unknown_chunkp chunk)
|
||||
{
|
||||
png_uint_32
|
||||
*my_user_chunk_data;
|
||||
struct user_chunk_data *my_user_chunk_data =
|
||||
(struct user_chunk_data*)png_get_user_chunk_ptr(png_ptr);
|
||||
|
||||
if (my_user_chunk_data == NULL)
|
||||
png_error(png_ptr, "lost user chunk pointer");
|
||||
|
||||
/* Return one of the following:
|
||||
* return (-n); chunk had an error
|
||||
@ -609,9 +674,14 @@ static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
if (chunk->data[0] != 0 && chunk->data[0] != 1)
|
||||
return (-1); /* Invalid mode */
|
||||
|
||||
my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
|
||||
my_user_chunk_data[0]=chunk->data[0]+1;
|
||||
return (1);
|
||||
if (set_location(png_ptr, my_user_chunk_data, have_sTER))
|
||||
{
|
||||
my_user_chunk_data->sTER_mode=chunk->data[0];
|
||||
return (1);
|
||||
}
|
||||
|
||||
else
|
||||
return (0); /* duplicate sTER - give it to libpng */
|
||||
}
|
||||
|
||||
if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */
|
||||
@ -623,24 +693,119 @@ static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
if (chunk->size != 9)
|
||||
return (-1); /* Error return */
|
||||
|
||||
my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
|
||||
if (!set_location(png_ptr, my_user_chunk_data, have_vpAg))
|
||||
return (0); /* duplicate vpAg */
|
||||
|
||||
my_user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data);
|
||||
my_user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4);
|
||||
my_user_chunk_data[3]=(png_uint_32)chunk->data[8];
|
||||
my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data);
|
||||
my_user_chunk_data->vpAg_height = png_get_uint_31(png_ptr, chunk->data + 4);
|
||||
my_user_chunk_data->vpAg_units = chunk->data[8];
|
||||
|
||||
return (1);
|
||||
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
static void
|
||||
write_sTER_chunk(png_structp write_ptr)
|
||||
{
|
||||
png_byte png_sTER[5] = {115, 84, 69, 82, '\0'};
|
||||
|
||||
if (verbose)
|
||||
fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode);
|
||||
|
||||
png_write_chunk(write_ptr, png_sTER, &user_chunk_data.sTER_mode, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
write_vpAg_chunk(png_structp write_ptr)
|
||||
{
|
||||
png_byte png_vpAg[5] = {118, 112, 65, 103, '\0'};
|
||||
|
||||
png_byte vpag_chunk_data[9];
|
||||
|
||||
if (verbose)
|
||||
fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
|
||||
(unsigned long)user_chunk_data.vpAg_width,
|
||||
(unsigned long)user_chunk_data.vpAg_height,
|
||||
user_chunk_data.vpAg_units);
|
||||
|
||||
png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);
|
||||
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);
|
||||
vpag_chunk_data[8] = user_chunk_data.vpAg_units;
|
||||
png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9);
|
||||
}
|
||||
|
||||
static void
|
||||
write_chunks(png_structp write_ptr, int location)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Notice that this preserves the original chunk order, however chunks
|
||||
* intercepted by the callback will be written *after* chunks passed to
|
||||
* libpng. This will actually reverse a pair of sTER chunks or a pair of
|
||||
* vpAg chunks, resulting in an error later. This is not worth worrying
|
||||
* about - the chunks should not be duplicated!
|
||||
*/
|
||||
for (i=0; i<2; ++i)
|
||||
{
|
||||
if (user_chunk_data.location[i] == (location | have_sTER))
|
||||
write_sTER_chunk(write_ptr);
|
||||
|
||||
else if (user_chunk_data.location[i] == (location | have_vpAg))
|
||||
write_vpAg_chunk(write_ptr);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#else /* !PNG_READ_USER_CHUNKS_SUPPORTED */
|
||||
# define write_chunks(pp,loc) ((void)0)
|
||||
#endif
|
||||
/* END of code to demonstrate user chunk support */
|
||||
|
||||
/* START of code to check that libpng has the required text support; this only
|
||||
* checks for the write support because if read support is missing the chunk
|
||||
* will simply not be reported back to pngtest.
|
||||
*/
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
static void
|
||||
pngtest_check_text_support(png_const_structp png_ptr, png_textp text_ptr,
|
||||
int num_text)
|
||||
{
|
||||
while (num_text > 0)
|
||||
{
|
||||
switch (text_ptr[--num_text].compression)
|
||||
{
|
||||
case PNG_TEXT_COMPRESSION_NONE:
|
||||
break;
|
||||
|
||||
case PNG_TEXT_COMPRESSION_zTXt:
|
||||
# ifndef PNG_WRITE_zTXt_SUPPORTED
|
||||
++unsupported_chunks;
|
||||
# endif
|
||||
break;
|
||||
|
||||
case PNG_ITXT_COMPRESSION_NONE:
|
||||
case PNG_ITXT_COMPRESSION_zTXt:
|
||||
# ifndef PNG_WRITE_iTXt_SUPPORTED
|
||||
++unsupported_chunks;
|
||||
# endif
|
||||
break;
|
||||
|
||||
default:
|
||||
/* This is an error */
|
||||
png_error(png_ptr, "invalid text chunk compression field");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* END of code to check that libpng has the required text support */
|
||||
|
||||
/* Test one file */
|
||||
int
|
||||
static int
|
||||
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
static png_FILE_p fpin;
|
||||
static png_FILE_p fpout; /* "static" prevents setjmp corruption */
|
||||
pngtest_error_parameters error_parameters;
|
||||
png_structp read_ptr;
|
||||
png_infop read_info_ptr, end_info_ptr;
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
@ -658,9 +823,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int num_pass, pass;
|
||||
int bit_depth, color_type;
|
||||
|
||||
char inbuf[256], outbuf[256];
|
||||
|
||||
row_buf = NULL;
|
||||
error_parameters.file_name = inname;
|
||||
|
||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||
{
|
||||
@ -684,20 +848,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
read_ptr =
|
||||
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
#endif
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
|
||||
pngtest_warning);
|
||||
#endif
|
||||
png_set_error_fn(read_ptr, &error_parameters, pngtest_error,
|
||||
pngtest_warning);
|
||||
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
user_chunk_data[0] = 0;
|
||||
user_chunk_data[1] = 0;
|
||||
user_chunk_data[2] = 0;
|
||||
user_chunk_data[3] = 0;
|
||||
png_set_read_user_chunk_fn(read_ptr, user_chunk_data,
|
||||
read_user_chunk_callback);
|
||||
|
||||
#endif
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
write_ptr =
|
||||
@ -707,10 +860,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
write_ptr =
|
||||
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
#endif
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error,
|
||||
pngtest_warning);
|
||||
#endif
|
||||
png_set_error_fn(write_ptr, &error_parameters, pngtest_error,
|
||||
pngtest_warning);
|
||||
#endif
|
||||
pngtest_debug("Allocating read_info, write_info and end_info structures");
|
||||
read_info_ptr = png_create_info_struct(read_ptr);
|
||||
@ -720,6 +871,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
write_end_info_ptr = png_create_info_struct(write_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
init_callback_info(read_info_ptr);
|
||||
png_set_read_user_chunk_fn(read_ptr, &user_chunk_data,
|
||||
read_user_chunk_callback);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
pngtest_debug("Setting jmpbuf for read struct");
|
||||
if (setjmp(png_jmpbuf(read_ptr)))
|
||||
@ -755,6 +912,32 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (strict)
|
||||
{
|
||||
/* Treat png_benign_error() as errors on read */
|
||||
png_set_benign_errors(read_ptr, 0);
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* Treat them as errors on write */
|
||||
png_set_benign_errors(write_ptr, 0);
|
||||
#endif
|
||||
|
||||
/* if strict is not set, then app warnings and errors are treated as
|
||||
* warnings in release builds, but not in unstable builds; this can be
|
||||
* changed with '--relaxed'.
|
||||
*/
|
||||
}
|
||||
|
||||
else if (relaxed)
|
||||
{
|
||||
/* Allow application (pngtest) errors and warnings to pass */
|
||||
png_set_benign_errors(read_ptr, 1);
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_set_benign_errors(write_ptr, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
pngtest_debug("Initializing input and output streams");
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
png_init_io(read_ptr, fpin);
|
||||
@ -773,14 +956,6 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
/* Normally one would use Z_DEFAULT_STRATEGY for text compression.
|
||||
* This is here just to make pngtest replicate the results from libpng
|
||||
* versions prior to 1.5.4, and to test this new API.
|
||||
*/
|
||||
png_set_text_compression_strategy(write_ptr, Z_FILTERED);
|
||||
#endif
|
||||
|
||||
if (status_dots_requested == 1)
|
||||
{
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
@ -812,24 +987,37 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_set_write_user_transform_fn(write_ptr, count_zero_samples);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifndef PNG_HANDLE_CHUNK_ALWAYS
|
||||
# define PNG_HANDLE_CHUNK_ALWAYS 3
|
||||
# endif
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Preserve all the unknown chunks, if possible. If this is disabled then,
|
||||
* even if the png_{get,set}_unknown_chunks stuff is enabled, we can't use
|
||||
* libpng to *save* the unknown chunks on read (because we can't switch the
|
||||
* save option on!)
|
||||
*
|
||||
* Notice that if SET_UNKNOWN_CHUNKS is *not* supported read will discard all
|
||||
* unknown chunks and write will write them all.
|
||||
*/
|
||||
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,
|
||||
NULL, 0);
|
||||
#endif
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifndef PNG_HANDLE_CHUNK_IF_SAFE
|
||||
# define PNG_HANDLE_CHUNK_IF_SAFE 2
|
||||
# endif
|
||||
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE,
|
||||
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,
|
||||
NULL, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
pngtest_debug("Reading info struct");
|
||||
png_read_info(read_ptr, read_info_ptr);
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* This is a bit of a hack; there is no obvious way in the callback function
|
||||
* to determine that the chunks before the first IDAT have been read, so
|
||||
* remove the info_ptr (which is only used to determine position relative to
|
||||
* PLTE) here to indicate that we are after the IDAT.
|
||||
*/
|
||||
user_chunk_data.info_ptr = NULL;
|
||||
#endif
|
||||
|
||||
pngtest_debug("Transferring info struct");
|
||||
{
|
||||
int interlace_type, compression_type, filter_type;
|
||||
@ -1021,8 +1209,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text);
|
||||
|
||||
pngtest_check_text_support(read_ptr, text_ptr, num_text);
|
||||
|
||||
if (verbose)
|
||||
printf("\nText compression=%d\n", text_ptr->compression);
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("\n");
|
||||
for (i=0; i<num_text; i++)
|
||||
{
|
||||
printf(" Text compression[%d]=%d\n",
|
||||
i, text_ptr[i].compression);
|
||||
}
|
||||
}
|
||||
|
||||
png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
|
||||
}
|
||||
@ -1037,10 +1236,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_set_tIME(write_ptr, write_info_ptr, mod_time);
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
|
||||
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
|
||||
tIME_string[(sizeof tIME_string) - 1] = '\0';
|
||||
|
||||
else
|
||||
strcpy(tIME_string, "*** invalid time ***");
|
||||
{
|
||||
strncpy(tIME_string, "*** invalid time ***", (sizeof tIME_string));
|
||||
tIME_string[(sizeof tIME_string) - 1] = '\0';
|
||||
}
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
@ -1077,16 +1279,20 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
if (num_unknowns)
|
||||
{
|
||||
int i;
|
||||
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
/* Copy the locations from the read_info_ptr. The automatically
|
||||
* generated locations in write_info_ptr are wrong because we
|
||||
* haven't written anything yet.
|
||||
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
|
||||
* because they are reset from the write pointer (removed in 1.6.0).
|
||||
*/
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1094,47 +1300,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
pngtest_debug("Writing info struct");
|
||||
|
||||
/* If we wanted, we could write info in two steps:
|
||||
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
||||
*/
|
||||
/* Write the info in two steps so that if we write the 'unknown' chunks here
|
||||
* they go to the correct place.
|
||||
*/
|
||||
png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
||||
|
||||
write_chunks(write_ptr, before_PLTE); /* before PLTE */
|
||||
|
||||
png_write_info(write_ptr, write_info_ptr);
|
||||
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (user_chunk_data[0] != 0)
|
||||
{
|
||||
png_byte png_sTER[5] = {115, 84, 69, 82, '\0'};
|
||||
|
||||
unsigned char
|
||||
ster_chunk_data[1];
|
||||
|
||||
if (verbose)
|
||||
fprintf(STDERR, "\n stereo mode = %lu\n",
|
||||
(unsigned long)(user_chunk_data[0] - 1));
|
||||
|
||||
ster_chunk_data[0]=(unsigned char)(user_chunk_data[0] - 1);
|
||||
png_write_chunk(write_ptr, png_sTER, ster_chunk_data, 1);
|
||||
}
|
||||
|
||||
if (user_chunk_data[1] != 0 || user_chunk_data[2] != 0)
|
||||
{
|
||||
png_byte png_vpAg[5] = {118, 112, 65, 103, '\0'};
|
||||
|
||||
unsigned char
|
||||
vpag_chunk_data[9];
|
||||
|
||||
if (verbose)
|
||||
fprintf(STDERR, " vpAg = %lu x %lu, units = %lu\n",
|
||||
(unsigned long)user_chunk_data[1],
|
||||
(unsigned long)user_chunk_data[2],
|
||||
(unsigned long)user_chunk_data[3]);
|
||||
|
||||
png_save_uint_32(vpag_chunk_data, user_chunk_data[1]);
|
||||
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data[2]);
|
||||
vpag_chunk_data[8] = (unsigned char)(user_chunk_data[3] & 0xff);
|
||||
png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9);
|
||||
}
|
||||
|
||||
#endif
|
||||
write_chunks(write_ptr, before_IDAT); /* after PLTE */
|
||||
#endif
|
||||
|
||||
#ifdef SINGLE_ROWBUF_ALLOC
|
||||
@ -1217,6 +1392,21 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
|
||||
{
|
||||
pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text);
|
||||
|
||||
pngtest_check_text_support(read_ptr, text_ptr, num_text);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("\n");
|
||||
for (i=0; i<num_text; i++)
|
||||
{
|
||||
printf(" Text compression[%d]=%d\n",
|
||||
i, text_ptr[i].compression);
|
||||
}
|
||||
}
|
||||
|
||||
png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
|
||||
}
|
||||
}
|
||||
@ -1230,10 +1420,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
|
||||
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
|
||||
tIME_string[(sizeof tIME_string) - 1] = '\0';
|
||||
|
||||
else
|
||||
strcpy(tIME_string, "*** invalid time ***");
|
||||
{
|
||||
strncpy(tIME_string, "*** invalid time ***", sizeof tIME_string);
|
||||
tIME_string[(sizeof tIME_string)-1] = '\0';
|
||||
}
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
@ -1248,20 +1441,41 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
if (num_unknowns)
|
||||
{
|
||||
int i;
|
||||
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
/* Copy the locations from the read_info_ptr. The automatically
|
||||
* generated locations in write_end_info_ptr are wrong because we
|
||||
* haven't written the end_info yet.
|
||||
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
|
||||
* because they are reset from the write pointer (removed in 1.6.0).
|
||||
*/
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
/* Normally one would use Z_DEFAULT_STRATEGY for text compression.
|
||||
* This is here just to make pngtest replicate the results from libpng
|
||||
* versions prior to 1.5.4, and to test this new API.
|
||||
*/
|
||||
png_set_text_compression_strategy(write_ptr, Z_FILTERED);
|
||||
#endif
|
||||
|
||||
/* When the unknown vpAg/sTER chunks are written by pngtest the only way to
|
||||
* do it is to write them *before* calling png_write_end. When unknown
|
||||
* chunks are written by libpng, however, they are written just before IEND.
|
||||
* There seems to be no way round this, however vpAg/sTER are not expected
|
||||
* after IDAT.
|
||||
*/
|
||||
write_chunks(write_ptr, after_IDAT);
|
||||
|
||||
png_write_end(write_ptr, write_end_info_ptr);
|
||||
#endif
|
||||
|
||||
@ -1295,6 +1509,40 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
/* Summarize any warnings or errors and in 'strict' mode fail the test.
|
||||
* Unsupported chunks can result in warnings, in that case ignore the strict
|
||||
* setting, otherwise fail the test on warnings as well as errors.
|
||||
*/
|
||||
if (error_count > 0)
|
||||
{
|
||||
/* We don't really expect to get here because of the setjmp handling
|
||||
* above, but this is safe.
|
||||
*/
|
||||
fprintf(STDERR, "\n %s: %d libpng errors found (%d warnings)",
|
||||
inname, error_count, warning_count);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
}
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
/* If there we no write support nothing was written! */
|
||||
else if (unsupported_chunks > 0)
|
||||
{
|
||||
fprintf(STDERR, "\n %s: unsupported chunks (%d)%s",
|
||||
inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
|
||||
}
|
||||
# endif
|
||||
|
||||
else if (warning_count > 0)
|
||||
{
|
||||
fprintf(STDERR, "\n %s: %d libpng warnings found",
|
||||
inname, warning_count);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
}
|
||||
|
||||
pngtest_debug("Opening files for comparison");
|
||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||
{
|
||||
@ -1309,71 +1557,85 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
return (1);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
#ifdef PNG_WRITE_SUPPORTED /* else nothing was written */
|
||||
{
|
||||
png_size_t num_in, num_out;
|
||||
int wrote_question = 0;
|
||||
|
||||
num_in = fread(inbuf, 1, 1, fpin);
|
||||
num_out = fread(outbuf, 1, 1, fpout);
|
||||
|
||||
if (num_in != num_out)
|
||||
for (;;)
|
||||
{
|
||||
fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
|
||||
inname, outname);
|
||||
png_size_t num_in, num_out;
|
||||
char inbuf[256], outbuf[256];
|
||||
|
||||
if (wrote_question == 0)
|
||||
|
||||
num_in = fread(inbuf, 1, sizeof inbuf, fpin);
|
||||
num_out = fread(outbuf, 1, sizeof outbuf, fpout);
|
||||
|
||||
if (num_in != num_out)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
inname, PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
}
|
||||
fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
|
||||
inname, outname);
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (!num_in)
|
||||
break;
|
||||
|
||||
if (memcmp(inbuf, outbuf, num_in))
|
||||
{
|
||||
fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname);
|
||||
|
||||
if (wrote_question == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
if (wrote_question == 0 && unsupported_chunks == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
inname, PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
}
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
if (strict != 0 && unsupported_chunks == 0)
|
||||
return (1);
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
if (!num_in)
|
||||
break;
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
if (memcmp(inbuf, outbuf, num_in))
|
||||
{
|
||||
fprintf(STDERR, "\nFiles %s and %s are different\n", inname,
|
||||
outname);
|
||||
|
||||
else
|
||||
return (0);
|
||||
if (wrote_question == 0 && unsupported_chunks == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
inname, PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
}
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
/* NOTE: the unsupported_chunks escape is permitted here because
|
||||
* unsupported text chunk compression will result in the compression
|
||||
* mode being changed (to NONE) yet, in the test case, the result
|
||||
* can be exactly the same size!
|
||||
*/
|
||||
if (strict != 0 && unsupported_chunks == 0)
|
||||
return (1);
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
@ -1459,6 +1721,16 @@ main(int argc, char *argv[])
|
||||
verbose = 1;
|
||||
inname = argv[2];
|
||||
strict++;
|
||||
relaxed = 0;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[1], "--relaxed") == 0)
|
||||
{
|
||||
status_dots_requested = 0;
|
||||
verbose = 1;
|
||||
inname = argv[2];
|
||||
strict = 0;
|
||||
relaxed++;
|
||||
}
|
||||
|
||||
else
|
||||
@ -1667,6 +1939,15 @@ main(int argc, char *argv[])
|
||||
|
||||
return (int)(ierror != 0);
|
||||
}
|
||||
#else
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" test ignored because libpng was not built with read support\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_0beta05 Your_png_h_is_not_version_1_6_0beta05;
|
||||
typedef png_libpng_version_1_6_1beta05 Your_png_h_is_not_version_1_6_1beta05;
|
||||
|
BIN
pngtest.png
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
198
pngtrans.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -122,32 +122,79 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* In libpng 1.6 it is possible to determine whether this is a read or write
|
||||
* operation and therefore to do more checking here for a valid call.
|
||||
*/
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
{
|
||||
# ifdef PNG_READ_FILLER_SUPPORTED
|
||||
/* On read png_set_filler is always valid, regardless of the base PNG
|
||||
* format, because other transformations can give a format where the
|
||||
* filler code can execute (basically an 8 or 16-bit component RGB or G
|
||||
* format.)
|
||||
*
|
||||
* NOTE: usr_channels is not used by the read code! (This has led to
|
||||
* confusion in the past.) The filler is only used in the read code.
|
||||
*/
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
# else
|
||||
png_app_error(png_ptr, "png_set_filler not supported on read");
|
||||
PNG_UNUSED(filler) /* not used in the write case */
|
||||
return;
|
||||
# endif
|
||||
}
|
||||
|
||||
else /* write */
|
||||
{
|
||||
# ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
/* On write the usr_channels parameter must be set correctly at the
|
||||
* start to record the number of channels in the app-supplied data.
|
||||
*/
|
||||
switch (png_ptr->color_type)
|
||||
{
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
png_ptr->usr_channels = 4;
|
||||
break;
|
||||
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
if (png_ptr->bit_depth >= 8)
|
||||
{
|
||||
png_ptr->usr_channels = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* There simply isn't any code in libpng to strip out bits
|
||||
* from bytes when the components are less than a byte in
|
||||
* size!
|
||||
*/
|
||||
png_app_error(png_ptr,
|
||||
"png_set_filler is invalid for low bit depth gray output");
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
png_app_error(png_ptr,
|
||||
"png_set_filler: inappropriate color type");
|
||||
return;
|
||||
}
|
||||
# else
|
||||
png_app_error(png_ptr, "png_set_filler not supported on write");
|
||||
return;
|
||||
# endif
|
||||
}
|
||||
|
||||
/* Here on success - libpng supports the operation, set the transformation
|
||||
* and the flag to say where the filler channel is.
|
||||
*/
|
||||
png_ptr->transformations |= PNG_FILLER;
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
|
||||
if (filler_loc == PNG_FILLER_AFTER)
|
||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
/* This should probably go in the "do_read_filler" routine.
|
||||
* I attempted to do that in libpng-1.0.1a but that caused problems
|
||||
* so I restored it in libpng-1.0.2a
|
||||
*/
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
png_ptr->usr_channels = 4;
|
||||
}
|
||||
|
||||
/* Also I added this in libpng-1.0.2a (what happens when we expand
|
||||
* a less-than-8-bit grayscale to GA?) */
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
|
||||
{
|
||||
png_ptr->usr_channels = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Added to libpng-1.2.7 */
|
||||
@ -160,7 +207,9 @@ png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
return;
|
||||
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
/* The above may fail to do anything. */
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -619,6 +668,109 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||
/* Added at libpng-1.5.10 */
|
||||
void /* PRIVATE */
|
||||
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
||||
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
|
||||
{
|
||||
/* Calculations moved outside switch in an attempt to stop different
|
||||
* compiler warnings. 'padding' is in *bits* within the last byte, it is
|
||||
* an 'int' because pixel_depth becomes an 'int' in the expression below,
|
||||
* and this calculation is used because it avoids warnings that other
|
||||
* forms produced on either GCC or MSVC.
|
||||
*/
|
||||
int padding = (-row_info->pixel_depth * row_info->width) & 7;
|
||||
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
|
||||
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
/* in this case, all bytes must be 0 so we don't need
|
||||
* to unpack the pixels except for the rightmost one.
|
||||
*/
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if (*rp >> padding != 0)
|
||||
png_ptr->num_palette_max = 1;
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
int i = ((*rp >> padding) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 2) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 4) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 6) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
int i = ((*rp >> padding) & 0x0f);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 4) & 0x0f);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 8:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if (*rp > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = (int) *rp;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
@ -648,7 +800,7 @@ png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||
return png_ptr->user_transform_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
14
pngusr.dfa
Normal file
@ -0,0 +1,14 @@
|
||||
# pngusr.dfa
|
||||
#
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Enter build configuration options in this file
|
||||
#
|
||||
# Security settings: by default these limits are unset, you can change them
|
||||
# here by entering the appropriate values as #defines preceded by '@' (to cause,
|
||||
# them to be passed through to the build of pnglibconf.h), for example:
|
||||
#
|
||||
# @# define PNG_USER_WIDTH_MAX 1000000
|
||||
# @# define PNG_USER_HEIGHT_MAX 1000000
|
||||
# @# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||
# @# define PNG_USER_CHUNK_MALLOC_MAX 8000000
|
4
pngwio.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
744
pngwrite.c
40
pngwtran.c
@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@ -287,7 +287,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_bytep bp = row;
|
||||
png_size_t i;
|
||||
png_byte mask;
|
||||
unsigned int mask;
|
||||
png_size_t row_bytes = row_info->rowbytes;
|
||||
|
||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||
@ -301,20 +301,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (i = 0; i < row_bytes; i++, bp++)
|
||||
{
|
||||
png_uint_16 v;
|
||||
int j;
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & mask);
|
||||
out |= (v >> (-j)) & mask;
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,21 +329,23 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
|
||||
png_uint_16 v;
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
int c = (int)(i%channels);
|
||||
unsigned int v, out;
|
||||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
out = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
out |= v << j;
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & 0xff);
|
||||
out |= v >> (-j);
|
||||
}
|
||||
|
||||
*bp = (png_byte)(out & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,22 +357,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (bp = row, i = 0; i < istop; i++)
|
||||
{
|
||||
int c = (int)(i%channels);
|
||||
png_uint_16 value, v;
|
||||
const unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int value, v;
|
||||
|
||||
v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));
|
||||
v = png_get_uint_16(bp);
|
||||
value = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
|
||||
value |= v << j;
|
||||
|
||||
else
|
||||
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
||||
value |= v >> (-j);
|
||||
}
|
||||
*bp++ = (png_byte)(value >> 8);
|
||||
*bp++ = (png_byte)((value >> 8) & 0xff);
|
||||
*bp++ = (png_byte)(value & 0xff);
|
||||
}
|
||||
}
|
||||
|
1746
pngwutil.c
@ -21,8 +21,8 @@ MCommand
|
||||
0
|
||||
5
|
||||
MCommand
|
||||
1035
|
||||
pngstest --log ../../contrib/pngsuite/basn0g01.png ../../contrib/pngsuite/basn0g02.png ../../contrib/pngsuite/basn0g04.png ../../contrib/pngsuite/basn0g08.png ../../contrib/pngsuite/basn0g16.png ../../contrib/pngsuite/basn2c08.png ../../contrib/pngsuite/basn2c16.png ../../contrib/pngsuite/basn3p01.png ../../contrib/pngsuite/basn3p02.png ../../contrib/pngsuite/basn3p04.png ../../contrib/pngsuite/basn3p08.png ../../contrib/pngsuite/basn4a08.png ../../contrib/pngsuite/basn4a16.png ../../contrib/pngsuite/basn6a08.png ../../contrib/pngsuite/basn6a16.png ../../contrib/pngsuite/ftbbn1g04.png ../../contrib/pngsuite/ftbbn2c16.png ../../contrib/pngsuite/ftbbn3p08.png ../../contrib/pngsuite/ftbgn2c16.png ../../contrib/pngsuite/ftbgn3p08.png ../../contrib/pngsuite/ftbrn2c08.png ../../contrib/pngsuite/ftbwn1g16.png ../../contrib/pngsuite/ftbwn3p08.png ../../contrib/pngsuite/ftbyn3p08.png ../../contrib/pngsuite/ftp0n1g08.png ../../contrib/pngsuite/ftp0n2c08.png ../../contrib/pngsuite/ftp0n3p08.png ../../contrib/pngsuite/ftp1n3p08.png
|
||||
1118
|
||||
pngstest --strict --log ../../contrib/pngsuite/basn0g01.png ../../contrib/pngsuite/basn0g02.png ../../contrib/pngsuite/basn0g04.png ../../contrib/pngsuite/basn0g08.png ../../contrib/pngsuite/basn0g16.png ../../contrib/pngsuite/basn2c08.png ../../contrib/pngsuite/basn2c16.png ../../contrib/pngsuite/basn3p01.png ../../contrib/pngsuite/basn3p02.png ../../contrib/pngsuite/basn3p04.png ../../contrib/pngsuite/basn3p08.png ../../contrib/pngsuite/basn4a08.png ../../contrib/pngsuite/basn4a16.png ../../contrib/pngsuite/basn6a08.png ../../contrib/pngsuite/basn6a16.png ../../contrib/pngsuite/ftbbn0g04.png ../../contrib/pngsuite/ftbbn0g01.png ../../contrib/pngsuite/ftbbn0g02.png ../../contrib/pngsuite/ftbbn2c16.png ../../contrib/pngsuite/ftbbn3p08.png ../../contrib/pngsuite/ftbgn2c16.png ../../contrib/pngsuite/ftbgn3p08.png ../../contrib/pngsuite/ftbrn2c08.png ../../contrib/pngsuite/ftbwn0g16.png ../../contrib/pngsuite/ftbwn3p08.png ../../contrib/pngsuite/ftbyn3p08.png ../../contrib/pngsuite/ftp0n0g08.png ../../contrib/pngsuite/ftp0n2c08.png ../../contrib/pngsuite/ftp0n3p08.png ../../contrib/pngsuite/ftp1n3p08.png
|
||||
6
|
||||
MItem
|
||||
12
|
||||
|
27
projects/vstudio/WARNING
Normal file
@ -0,0 +1,27 @@
|
||||
WARNING
|
||||
=======
|
||||
Libpng 1.6 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
|
||||
all the test programs
|
||||
|
||||
The runtime library settings for each build are as follows:
|
||||
|
||||
Release Debug
|
||||
DLL /MD /MDd
|
||||
Library /MT /MTd
|
||||
|
||||
NOTICE that libpng 1.5 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 to /MDd for libpng 1.6.
|
||||
|
||||
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
|
@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>libpng</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
@ -101,6 +101,7 @@
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -17,6 +17,7 @@
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
|
@ -19,12 +19,12 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}</ProjectGuid>
|
||||
<ProjectGuid>{277AC57F-313B-4D06-B119-A3CDB672D2FF}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngstest</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
@ -91,16 +91,17 @@
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn1g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn1g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n1g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Command>"$(OutDir)pngstest.exe" --strict --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
@ -133,7 +134,7 @@
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn1g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn1g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n1g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Command>"$(OutDir)pngstest.exe" --strict --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
@ -162,13 +163,13 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn1g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn1g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n1g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Command>"$(OutDir)pngstest.exe" --strict --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
@ -204,7 +205,7 @@
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn1g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn1g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n1g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Command>"$(OutDir)pngstest.exe" --strict --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
|
@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngtest</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
@ -91,6 +91,7 @@
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
219
projects/vstudio/pngunknown/pngunknown.vcxproj
Normal file
@ -0,0 +1,219 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug Library|Win32">
|
||||
<Configuration>Debug Library</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release Library|Win32">
|
||||
<Configuration>Release Library</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngunknown</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildAfterTargets />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildAfterTargets />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildAfterTargets />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildAfterTargets />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing PNG validation program</Message>
|
||||
<Command>"$(OutDir)pngunknown.exe" --strict --default --touch "$(IntDir)pngunknown.out" ../../../pngtest.png</Command>
|
||||
<Outputs>$(IntDir)pngunknown.out</Outputs>
|
||||
<Inputs>$(OutDir)pngunknown.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing PNG validation program</Message>
|
||||
<Command>"$(OutDir)pngunknown.exe" --strict --default --touch "$(IntDir)pngunknown.out" ../../../pngtest.png</Command>
|
||||
<Outputs>$(IntDir)pngunknown.out</Outputs>
|
||||
<Inputs>$(OutDir)pngunknown.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing PNG validation program</Message>
|
||||
<Command>"$(OutDir)pngunknown.exe" --strict --default --touch "$(IntDir)pngunknown.out" ../../../pngtest.png</Command>
|
||||
<Outputs>$(IntDir)pngunknown.out</Outputs>
|
||||
<Inputs>$(OutDir)pngunknown.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Full</Optimization>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing PNG validation program</Message>
|
||||
<Command>"$(OutDir)pngunknown.exe" --strict --default --touch "$(IntDir)pngunknown.out" ../../../pngtest.png</Command>
|
||||
<Outputs>$(IntDir)pngunknown.out</Outputs>
|
||||
<Inputs>$(OutDir)pngunknown.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\contrib\libtests\pngunknown.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngvalid</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
@ -91,6 +91,7 @@
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
VisualStudio instructions
|
||||
|
||||
libpng version 1.6.0beta05 - February 3, 2012
|
||||
libpng version 1.6.1beta05 - March 2, 2013
|
||||
|
||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
|
||||
@ -33,8 +33,8 @@ optimization level (e.g. /Od.)
|
||||
Linking your application
|
||||
========================
|
||||
Normally you should link against the 'release' configuration. This builds a
|
||||
DLL for libpng 1.5 with the default runtime options used by Visual Studio
|
||||
2010. In particular the runtime library is the "MultiThreaded DLL" version.
|
||||
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.
|
||||
|
||||
@ -58,7 +58,8 @@ 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.)
|
||||
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.
|
||||
|
@ -1,5 +1,9 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcxproj", "{60F89955-91C6-3A36-8000-13C592FEC2DF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pnglibconf", "pnglibconf\pnglibconf.vcxproj", "{EB33566E-DA7F-4D28-9077-88C0B7C77E35}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "libpng\libpng.vcxproj", "{D6973076-9317-4EF2-A0B8-B7A18AC0713E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{60F89955-91C6-3A36-8000-13C592FEC2DF} = {60F89955-91C6-3A36-8000-13C592FEC2DF}
|
||||
@ -13,8 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngtest", "pngtest\pngtest.
|
||||
{D6973076-9317-4EF2-A0B8-B7A18AC0713E} = {D6973076-9317-4EF2-A0B8-B7A18AC0713E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcxproj", "{60F89955-91C6-3A36-8000-13C592FEC2DF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngvalid", "pngvalid\pngvalid.vcxproj", "{9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{60F89955-91C6-3A36-8000-13C592FEC2DF} = {60F89955-91C6-3A36-8000-13C592FEC2DF}
|
||||
@ -22,8 +24,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngvalid", "pngvalid\pngval
|
||||
{D6973076-9317-4EF2-A0B8-B7A18AC0713E} = {D6973076-9317-4EF2-A0B8-B7A18AC0713E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pnglibconf", "pnglibconf\pnglibconf.vcxproj", "{EB33566E-DA7F-4D28-9077-88C0B7C77E35}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngstest", "pngstest\pngstest.vcxproj", "{277AC57F-313B-4D06-B119-A3CDB672D2FF}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{60F89955-91C6-3A36-8000-13C592FEC2DF} = {60F89955-91C6-3A36-8000-13C592FEC2DF}
|
||||
@ -31,6 +31,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngstest", "pngstest\pngste
|
||||
{D6973076-9317-4EF2-A0B8-B7A18AC0713E} = {D6973076-9317-4EF2-A0B8-B7A18AC0713E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngunknown", "pngunknown\pngunknown.vcxproj", "{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{60F89955-91C6-3A36-8000-13C592FEC2DF} = {60F89955-91C6-3A36-8000-13C592FEC2DF}
|
||||
{EB33566E-DA7F-4D28-9077-88C0B7C77E35} = {EB33566E-DA7F-4D28-9077-88C0B7C77E35}
|
||||
{D6973076-9317-4EF2-A0B8-B7A18AC0713E} = {D6973076-9317-4EF2-A0B8-B7A18AC0713E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug Library|Win32 = Debug Library|Win32
|
||||
@ -87,6 +94,14 @@ Global
|
||||
{277AC57F-313B-4D06-B119-A3CDB672D2FF}.Release Library|Win32.Build.0 = Release Library|Win32
|
||||
{277AC57F-313B-4D06-B119-A3CDB672D2FF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{277AC57F-313B-4D06-B119-A3CDB672D2FF}.Release|Win32.Build.0 = Release|Win32
|
||||
{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}.Debug Library|Win32.ActiveCfg = Debug Library|Win32
|
||||
{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}.Debug Library|Win32.Build.0 = Debug Library|Win32
|
||||
{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}.Release Library|Win32.ActiveCfg = Release Library|Win32
|
||||
{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}.Release Library|Win32.Build.0 = Release Library|Win32
|
||||
{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C5D3156C-8C8C-4936-B35F-2B829BA36FEC}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -2,7 +2,7 @@
|
||||
<!--
|
||||
* zlib.props - location of zlib source
|
||||
*
|
||||
* libpng version 1.6.0beta05 - February 3, 2012
|
||||
* libpng version 1.6.1beta05 - March 2, 2013
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
*
|
||||
@ -33,5 +33,13 @@
|
||||
below:
|
||||
-->
|
||||
<ZLibSrcDir>..\..\..\..\zlib-1.2.5</ZLibSrcDir>
|
||||
|
||||
<!-- The following line allows compilation for an ARM target with Visual
|
||||
Studio 2012. Notice that this is not supported by the Visual Studio
|
||||
2012 IDE and that the programs that result cannot be run unless they
|
||||
signed by Microsoft. This is therefore untested; only Microsoft can
|
||||
test it:
|
||||
-->
|
||||
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
@ -32,10 +32,12 @@
|
||||
<ClCompile Include="$(ZLibSrcDir)\zutil.c" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{60F89955-91C6-3A36-8000-13C592FEC2DF}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>zlib</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
@ -84,12 +86,13 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
@ -99,11 +102,13 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
@ -123,6 +128,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
@ -144,21 +150,7 @@
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
<Lib>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;Z_SOLO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
@ -167,6 +159,9 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Lib>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
Makefiles for libpng version 1.6.0beta05 - February 3, 2012
|
||||
Makefiles for libpng version 1.6.1beta05 - March 2, 2013
|
||||
|
||||
pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng16.so.16.1.6.0beta05)
|
||||
(gcc, creates libpng16.so.16.1.6.1beta05)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
@ -20,7 +20,7 @@ pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.elf => Linux/ELF makefile symbol versioning,
|
||||
(gcc, creates libpng16.so.16.1.6.0beta05)
|
||||
(gcc, creates libpng16.so.16.1.6.1beta05)
|
||||
makefile.freebsd => FreeBSD makefile
|
||||
makefile.gcc => Generic gcc makefile
|
||||
makefile.hpgcc => HPUX makefile using gcc
|
||||
@ -35,12 +35,12 @@ pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.sggcc => Silicon Graphics (gcc,
|
||||
creates libpng16.so.16.1.6.0beta05)
|
||||
creates libpng16.so.16.1.6.1beta05)
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc,
|
||||
creates libpng16.so.16.1.6.0beta05)
|
||||
creates libpng16.so.16.1.6.1beta05)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng16.so.16.1.6.0beta05)
|
||||
creates libpng16.so.16.1.6.1beta05)
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
@ -62,15 +62,25 @@ Other supporting scripts:
|
||||
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
|
||||
ltsugar.m4 => Used by autoconf tools
|
||||
ltversion.m4 => Used by autoconf tools
|
||||
lt~obsolete.m4 => Used by autoconf tools
|
||||
|
||||
intprefix.dfn => Used by autoconf tools
|
||||
macro.lst => Used by autoconf tools
|
||||
prefix.dfn => Used by autoconf tools
|
||||
|
||||
|
||||
Further information can be found in comments in the individual makefiles.
|
||||
|
@ -8,31 +8,22 @@
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* These macros exist to make the header and trailer shorter below: */
|
||||
#define S PNG_DEFN_MAGIC
|
||||
#define E PNG_DEFN_END
|
||||
|
||||
/* Write the export file header: */
|
||||
S-;---------------------------------------------------------------E
|
||||
S-; LIBPNG module definition file for OS/2-E
|
||||
S-;---------------------------------------------------------------E
|
||||
S--E
|
||||
S-; If you give the library an explicit name one or other files-E
|
||||
S-; may need modifying to support the new name on one or more-E
|
||||
S-; systems.-E
|
||||
S-LIBRARY-E
|
||||
S-OS2 DESCRIPTION "PNG image compression library"-E
|
||||
S-OS2 CODE PRELOAD MOVEABLE DISCARDABLE-E
|
||||
S--E
|
||||
S-EXPORTS-E
|
||||
S-;Version 1.5.0beta58-E
|
||||
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.1beta05"
|
||||
|
||||
/* NOTE: PNG_JOIN is interpreted by the calling script as a signal to
|
||||
* join the two things on either side, so we can do symbol
|
||||
* substitution within the name, regular C ## joins the pp-tokens,
|
||||
* not their final values.
|
||||
*/
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DEFN_MAGIC- SYMBOL_PREFIX PNG_JOIN name-PNG_DEFN_END
|
||||
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
|
||||
|
||||
#include "../png.h"
|
||||
|
@ -33,20 +33,20 @@ clean :
|
||||
|
||||
|
||||
# Other dependencies.
|
||||
png.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngpread.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngset.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngget.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngread.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrtran.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrutil.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngerror.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngmem.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrio.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwio.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngtrans.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwrite.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwtran.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwutil.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
png.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngpread.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngset.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngget.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngread.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrtran.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrutil.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngerror.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngmem.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrio.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwio.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngtrans.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwrite.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwtran.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwutil.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
|
||||
pngtest.obj : png.h, pngconf.h
|
||||
|
135
scripts/dfn.awk
Normal file
@ -0,0 +1,135 @@
|
||||
#!/bin/awk -f
|
||||
# scripts/dfn.awk - process a .dfn file
|
||||
#
|
||||
# last changed in libpng version 1.5.14 - February 4, 2013
|
||||
#
|
||||
# Copyright (c) 2013-2013 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
|
||||
|
||||
# The output of this script is written to the file given by
|
||||
# the variable 'out', which should be set on the command line.
|
||||
# Error messages are printed to stdout and if any are printed
|
||||
# the script will exit with error code 1.
|
||||
|
||||
BEGIN{
|
||||
out="/dev/null" # as a flag
|
||||
out_count=0 # count of output lines
|
||||
err=0 # set if an error occured
|
||||
sort=0 # sort the output
|
||||
array[""]=""
|
||||
}
|
||||
|
||||
# The output file must be specified before any input:
|
||||
NR==1 && out == "/dev/null" {
|
||||
print "out=output.file must be given on the command line"
|
||||
# but continue without setting the error code, this allows the
|
||||
# script to be checked easily
|
||||
}
|
||||
|
||||
# Output can be sorted; two lines are recognized
|
||||
$1 == "PNG_DFN_START_SORT"{
|
||||
sort=0+$2
|
||||
next
|
||||
}
|
||||
|
||||
$1 ~ /^PNG_DFN_END_SORT/{
|
||||
# Do a very simple, slow, sort; notice that blank lines won't be
|
||||
# output by this
|
||||
for (entry in array) {
|
||||
while (array[entry] != "") {
|
||||
key = entry
|
||||
value = array[key]
|
||||
array[key] = ""
|
||||
|
||||
for (alt in array) {
|
||||
if (array[alt] != "" && alt < key) {
|
||||
array[key] = value
|
||||
value = array[alt]
|
||||
key = alt
|
||||
array[alt] = ""
|
||||
}
|
||||
}
|
||||
|
||||
print value >out
|
||||
}
|
||||
}
|
||||
sort=0
|
||||
next
|
||||
}
|
||||
|
||||
/^[^"]*PNG_DFN *".*"[^"]*$/{
|
||||
# A definition line, apparently correctly formated, extract the
|
||||
# definition then replace any doubled "" that remain with a single
|
||||
# double quote. Notice that the original doubled double quotes
|
||||
# may have been split by tokenization
|
||||
orig=$0
|
||||
|
||||
if (gsub(/^[^"]*PNG_DFN *"/,"") != 1 || gsub(/"[^"]*$/, "") != 1) {
|
||||
print "line", NR, "processing failed:"
|
||||
print orig
|
||||
print $0
|
||||
err=1
|
||||
} else {
|
||||
++out_count
|
||||
}
|
||||
|
||||
# Now examine quotes within the value:
|
||||
#
|
||||
# @" - delete this and any following spaces
|
||||
# "@ - delete this and any original spaces
|
||||
# @' - replace this by a double quote
|
||||
#
|
||||
# This allows macro substitution by the C compiler thus:
|
||||
#
|
||||
# #define first_name John
|
||||
# #define last_name Smith
|
||||
#
|
||||
# PNG_DFN"#define name @'@" first_name "@ @" last_name "@@'"
|
||||
#
|
||||
# Might get C preprocessed to:
|
||||
#
|
||||
# PNG_DFN "#define foo @'@" John "@ @" Smith "@@'"
|
||||
#
|
||||
# Which this script reduces to:
|
||||
#
|
||||
# #define name "John Smith"
|
||||
#
|
||||
while (sub(/@" */, "")) {
|
||||
if (!sub(/ *"@/, "")) {
|
||||
print "unbalanced @\" ... \"@ pair"
|
||||
err=1
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
# Put any needed double quotes in
|
||||
gsub(/@'/,"\"")
|
||||
|
||||
# Remove any trailing spaces (not really required, but for
|
||||
# editorial consistency
|
||||
sub(/ *$/, "")
|
||||
|
||||
if (sort)
|
||||
array[$(sort)] = $0
|
||||
|
||||
else
|
||||
print $0 >out
|
||||
next
|
||||
}
|
||||
|
||||
/PNG_DFN/{
|
||||
print "line", NR, "incorrectly formated PNG_DFN line:"
|
||||
print $0
|
||||
err = 1
|
||||
}
|
||||
|
||||
END{
|
||||
if (out_count > 0 || err > 0)
|
||||
exit err
|
||||
|
||||
print "no definition lines found"
|
||||
exit 1
|
||||
}
|
19
scripts/intprefix.dfn
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
/* intprefix.dfn - generate an unprefixed internal symbol list
|
||||
*
|
||||
* Last changed in libpng version 1.6.0 [January 30, 2012]
|
||||
* Copyright (c) 2012 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
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL_DATA(type, name, array)\
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNGPREFIX_H /* self generation */
|
||||
#include "../pngpriv.h"
|
@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.6.0beta05
|
||||
version=1.6.1beta05
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.6.0beta05
|
||||
Version: 1.6.1beta05
|
||||
Libs: -L${libdir} -lpng16
|
||||
Cflags: -I${includedir}
|
||||
|
3
scripts/macro.lst
Normal file
@ -0,0 +1,3 @@
|
||||
get_uint_32(buf)
|
||||
get_uint_16(buf)
|
||||
get_int_32(buf)
|
@ -222,20 +222,20 @@ writelock:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
|
@ -222,20 +222,20 @@ writelock:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
|
@ -102,20 +102,20 @@ install: $(LIBNAME)$(A)
|
||||
clean:
|
||||
$(RM_F) *.o $(LIBNAME)$(A) pngtest 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
|
||||
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
|
||||
|