mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
254 Commits
v1.6.0beta
...
v1.6.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
847e9efb66 | ||
|
|
db56fa18c2 | ||
|
|
bc8e40d611 | ||
|
|
2b87a54d07 | ||
|
|
b23afad4a1 | ||
|
|
f5d7f438e5 | ||
|
|
b4ec1f8451 | ||
|
|
f5f1206778 | ||
|
|
497e7319f4 | ||
|
|
d5dd93f5d1 | ||
|
|
7f9a49aa65 | ||
|
|
573c9d434f | ||
|
|
56a1a66656 | ||
|
|
d992e05da8 | ||
|
|
870beb5279 | ||
|
|
b0d97356ce | ||
|
|
04d4e38ac2 | ||
|
|
67a46d17d8 | ||
|
|
bbc29a858d | ||
|
|
3948b94700 | ||
|
|
746bc7d883 | ||
|
|
f260f6d156 | ||
|
|
18dd07e3e6 | ||
|
|
0486b17fbd | ||
|
|
aa22442a9c | ||
|
|
4a43182924 | ||
|
|
810b6e51e4 | ||
|
|
88610994da | ||
|
|
1b9b970598 | ||
|
|
43f0311b57 | ||
|
|
421f95deb5 | ||
|
|
f96251291d | ||
|
|
cafa0eebb9 | ||
|
|
afd6cecb76 | ||
|
|
61dbc4c608 | ||
|
|
bea86bba24 | ||
|
|
7fc85a3f46 | ||
|
|
bb8d4f76f4 | ||
|
|
b79c98e57c | ||
|
|
4cf2465c71 | ||
|
|
4ea93e69bc | ||
|
|
ff141eb21e | ||
|
|
122bec17f2 | ||
|
|
9afb90f885 | ||
|
|
34b7d62488 | ||
|
|
3f2b5a6670 | ||
|
|
294d0b8408 | ||
|
|
62c6fbbd29 | ||
|
|
0c7ac064d3 | ||
|
|
db67cba8d4 | ||
|
|
2aa6c96e5d | ||
|
|
2fd3434fa4 | ||
|
|
2c0833e265 | ||
|
|
127b08a265 | ||
|
|
0f42908c0a | ||
|
|
f18a28cc13 | ||
|
|
56d6bc2e88 | ||
|
|
61946e0f56 | ||
|
|
49f9c24910 | ||
|
|
c62fda06a3 | ||
|
|
cd62215d61 | ||
|
|
ac09cd0fec | ||
|
|
529045cf26 | ||
|
|
7b1da52549 | ||
|
|
34d20f482f | ||
|
|
399430dac2 | ||
|
|
3f677d1c65 | ||
|
|
809355b4aa | ||
|
|
7fd71746d0 | ||
|
|
0ee3465fba | ||
|
|
a793120405 | ||
|
|
9bdba4e630 | ||
|
|
a74b70871c | ||
|
|
0d50d6562c | ||
|
|
453fbf942c | ||
|
|
6e1c74b39b | ||
|
|
fdc2d5f38f | ||
|
|
67a289ffa9 | ||
|
|
bf15ac7e86 | ||
|
|
7ef0c46488 | ||
|
|
8d9e494dfb | ||
|
|
0794df4062 | ||
|
|
7a69beda7b | ||
|
|
e4413a735b | ||
|
|
7fdb594e73 | ||
|
|
f1736a636b | ||
|
|
3b4c60f26b | ||
|
|
5c55ccdf4f | ||
|
|
5ec05b3d7c | ||
|
|
70eb0720a0 | ||
|
|
9bb775fc8c | ||
|
|
a8715cabd1 | ||
|
|
364acf40aa | ||
|
|
b44cd59ad9 | ||
|
|
e2d8e11407 | ||
|
|
43c07e1b48 | ||
|
|
2e0c5f0dff | ||
|
|
3a83aa328d | ||
|
|
5087805e7c | ||
|
|
4e6e2166a5 | ||
|
|
1affc5622b | ||
|
|
cd1cd2dafc | ||
|
|
caa3f296df | ||
|
|
2286a7cef4 | ||
|
|
3c8b422b0a | ||
|
|
0645b62528 | ||
|
|
0281dee877 | ||
|
|
e55b25a962 | ||
|
|
14638c1f20 | ||
|
|
59ae38984f | ||
|
|
1f24cb74f2 | ||
|
|
1cbfa24a93 | ||
|
|
8c87dc88d6 | ||
|
|
f3728100d9 | ||
|
|
e15b537825 | ||
|
|
e57f094fd6 | ||
|
|
4ea113b7f0 | ||
|
|
871b1d0fab | ||
|
|
f3af706c2a | ||
|
|
96cf4bde0e | ||
|
|
1118d6d985 | ||
|
|
e444514a94 | ||
|
|
efda7376c8 | ||
|
|
ccec786ca7 | ||
|
|
2621be1bdb | ||
|
|
45bb4530fd | ||
|
|
a97fc46e43 | ||
|
|
3fa1893804 | ||
|
|
f8a8ead5cb | ||
|
|
6df55cece7 | ||
|
|
09a5ca72ac | ||
|
|
0cc3e9e38c | ||
|
|
adb9613699 | ||
|
|
c0a0d4a6d2 | ||
|
|
2bad851ab3 | ||
|
|
f2350f3987 | ||
|
|
b4ef7c4af2 | ||
|
|
9e8fd50d76 | ||
|
|
ea3288f1c5 | ||
|
|
cc074dcaa6 | ||
|
|
3b8e7e869d | ||
|
|
765d145ec4 | ||
|
|
c9b11ff0d4 | ||
|
|
23a101e06d | ||
|
|
b724c812ec | ||
|
|
0695fcd834 | ||
|
|
42835d3d19 | ||
|
|
2d99978f67 | ||
|
|
9d2e875826 | ||
|
|
681de8c8dc | ||
|
|
c53778ff53 | ||
|
|
44db2cfb15 | ||
|
|
6db8e4dd11 | ||
|
|
88c5a2a068 | ||
|
|
bf9f74b657 | ||
|
|
0d270082d2 | ||
|
|
d000fb89c0 | ||
|
|
9fabbedcf3 | ||
|
|
d7dc03e371 | ||
|
|
b8d0534e9d | ||
|
|
f88ac51a2e | ||
|
|
bbac5e692f | ||
|
|
a4081f2990 | ||
|
|
1f8e81738a | ||
|
|
9002f5b1f0 | ||
|
|
f5a83fb2b3 | ||
|
|
154de9398a | ||
|
|
777044a856 | ||
|
|
fe5c8b9755 | ||
|
|
8d391c6cea | ||
|
|
32d6a74293 | ||
|
|
806477742a | ||
|
|
29890b0439 | ||
|
|
9f860f59d9 | ||
|
|
f8aa57e791 | ||
|
|
4567935fe4 | ||
|
|
2414bd99d8 | ||
|
|
1f76e62d6c | ||
|
|
e208108dfc | ||
|
|
590c8b0987 | ||
|
|
c5c8b542fb | ||
|
|
91a7ad9d2b | ||
|
|
9dd2bfafe5 | ||
|
|
ba35f1e4c1 | ||
|
|
5851280929 | ||
|
|
1c6e22a360 | ||
|
|
37109a9f5b | ||
|
|
a70216aa60 | ||
|
|
9477ecdfa6 | ||
|
|
408652acaf | ||
|
|
744f041adf | ||
|
|
86c739e8bc | ||
|
|
00634fdac8 | ||
|
|
79ee877fb4 | ||
|
|
e9d616321a | ||
|
|
24639a63ce | ||
|
|
5362c9d5e5 | ||
|
|
b6bfd40da2 | ||
|
|
a1d32d08e1 | ||
|
|
350cbf14df | ||
|
|
7bde6e23bb | ||
|
|
5d9dc4563f | ||
|
|
aa41547a4d | ||
|
|
8c3d4f387a | ||
|
|
6e265d137c | ||
|
|
7b26920d9b | ||
|
|
785a8b1505 | ||
|
|
6cf32b460f | ||
|
|
f758d6c813 | ||
|
|
5c2d76fdef | ||
|
|
e4f124e335 | ||
|
|
1f84bd7000 | ||
|
|
b76ab1260d | ||
|
|
026b295698 | ||
|
|
eb8e19baa3 | ||
|
|
661bc6f6b0 | ||
|
|
6dae6d8f3b | ||
|
|
5b9a28f2b8 | ||
|
|
5f4b95e513 | ||
|
|
70850fce0c | ||
|
|
9d1ddbb78f | ||
|
|
f2aacefb3f | ||
|
|
4314d63792 | ||
|
|
7b3eefbcfd | ||
|
|
bb39dc545c | ||
|
|
520803d57e | ||
|
|
7f912dbeb5 | ||
|
|
ab1477d662 | ||
|
|
f0fb1746b0 | ||
|
|
f8dfd123e2 | ||
|
|
e6b710cb3f | ||
|
|
be85fa6027 | ||
|
|
43648b02bc | ||
|
|
75fde9e99a | ||
|
|
9a82547afe | ||
|
|
a9f44be8c2 | ||
|
|
e15b1e8136 | ||
|
|
fa63beaa34 | ||
|
|
c39be26f5a | ||
|
|
6ae34790cc | ||
|
|
8de49d0921 | ||
|
|
48cbba8e8e | ||
|
|
b257147015 | ||
|
|
73f826cb49 | ||
|
|
933bc842ac | ||
|
|
329d033d25 | ||
|
|
9c06d78468 | ||
|
|
b98681b49a | ||
|
|
53f7051b1b | ||
|
|
d099973c4f | ||
|
|
97a77a6f7b | ||
|
|
b2aba47a6d | ||
|
|
ed3ca0e3eb | ||
|
|
fd043e5d0d |
559
ANNOUNCE
559
ANNOUNCE
@@ -1,486 +1,113 @@
|
||||
|
||||
Libpng 1.6.0beta28 - August 29, 2012
|
||||
Libpng 1.6.3 - July 18, 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.
|
||||
This is a public release of libpng, intended for use in production codes.
|
||||
|
||||
Files available for download:
|
||||
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
1.6.0beta28.tar.xz (LZMA-compressed, recommended)
|
||||
1.6.0beta28.tar.gz
|
||||
1.6.0beta28.tar.bz2
|
||||
libpng-1.6.3.tar.xz (LZMA-compressed, recommended)
|
||||
libpng-1.6.3.tar.gz
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
lp160b28.7z (LZMA-compressed, recommended)
|
||||
lp160b28.zip
|
||||
lpng163.7z (LZMA-compressed, recommended)
|
||||
lpng163.zip
|
||||
|
||||
Other information:
|
||||
|
||||
1.6.0beta28-README.txt
|
||||
1.6.0beta28-LICENSE.txt
|
||||
libpng-1.6.3-README.txt
|
||||
libpng-1.6.3-LICENSE.txt
|
||||
|
||||
Changes since the last public release (1.5.7):
|
||||
Changes since the last public release (1.6.2):
|
||||
|
||||
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.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.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.
|
||||
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
|
||||
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.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
|
||||
(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 atar 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. 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 tests for invalid palette index while reading and writing (work in
|
||||
progress, the latter isn't finished).
|
||||
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.
|
||||
Revised stack marking in arm/filter_neon.S and configure.ac.
|
||||
Ensure that NEON filter stuff is completely disabled when switched 'off'.
|
||||
Previously the ARM NEON specific files were still built if the option
|
||||
was switched 'off' as opposed to being explicitly disabled.
|
||||
Test for 'arm*' not just 'arm' in the host_cpu configure variable.
|
||||
Rebuilt the configure scripts.
|
||||
Expanded manual paragraph about writing private chunks, particularly
|
||||
the need to call png_set_keep_unknown_chunks() when writing them.
|
||||
Avoid dereferencing NULL pointer possibly returned from
|
||||
png_create_write_struct() (Andrew Church).
|
||||
Calculate our own zlib windowBits when decoding rather than trusting the
|
||||
CMF bytes in the PNG datastream.
|
||||
Added an option to force maximum window size for inflating, which was
|
||||
the behavior of libpng15 and earlier.
|
||||
Added png-fix-itxt and png-fix-too-far-back to the built programs and
|
||||
removed warnings from the source code and timepng that are revealed as
|
||||
a result.
|
||||
Detect wrong libpng versions linked to png-fix-too-far-back, which currently
|
||||
only works with libpng versions that can be made to reliably fail when
|
||||
the deflate data contains an out-of-window reference. This means only
|
||||
1.6 and later.
|
||||
Fixed gnu issues: g++ needs a static_cast, gcc 4.4.7 has a broken warning
|
||||
message which it is easier to work round than ignore.
|
||||
Updated contrib/pngminus/pnm2png.c (Paul Stewart):
|
||||
Check for EOF
|
||||
Ignore "#" delimited comments in input file to pnm2png.c.
|
||||
Fixed whitespace handling
|
||||
Added a call to png_set_packing()
|
||||
Initialize dimension values so if sscanf fails at least we have known
|
||||
invalid values.
|
||||
Attempt to detect configuration issues with png-fix-too-far-back, which
|
||||
requires both the correct libpng and the correct zlib to function
|
||||
correctly.
|
||||
Check ZLIB_VERNUM for mismatches, enclose #error in quotes
|
||||
Added information in the documentation about problems with and fixes for
|
||||
the bad CRC and bad iTXt chunk situations.
|
||||
Allow contrib/pngminus/pnm2png.c to compile without WRITE_INVERT and
|
||||
WRITE_PACK supported (writes error message that it can't read P1 or
|
||||
Improved png-fix-too-far-back usage message, added --suffix option.
|
||||
Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
|
||||
right zlib header files.
|
||||
Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile
|
||||
Removed a redundant test in png_set_IHDR().
|
||||
Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt)
|
||||
Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt
|
||||
Enclose the prototypes for the simplified write API in
|
||||
#ifdef PNG_STDIO_SUPPORTED/#endif
|
||||
Make ARM NEON support work at compile time (not just configure time).
|
||||
This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when
|
||||
using a compiler that compiles for multiple architectures at one time.
|
||||
Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from
|
||||
pnglibconf.h, allowing more of the decisions to be made internally
|
||||
(pngpriv.h) during the compile. Without this, symbol prefixing is broken
|
||||
under certain circumstances on ARM platforms. Now only the API parts of
|
||||
the optimizations ('check' vs 'api') are exposed in the public header files
|
||||
except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the
|
||||
decision about whether or not to use the optimizations.
|
||||
Protect symbol prefixing against CC/CPPFLAGS/CFLAGS useage.
|
||||
Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test
|
||||
on __ARM_NEON__ from configure time to compile time. This breaks symbol
|
||||
prefixing because the definition of the special png_init_filter_functions
|
||||
call was hidden at configure time if the relevant compiler arguments are
|
||||
passed in CFLAGS as opposed to CC. This change attempts to avoid all
|
||||
the confusion that would result by declaring the init function even when
|
||||
it is not used, so that it will always get prefixed.
|
||||
Revised libpng.3 so that "doclifter" can process it.
|
||||
Revised example.c to illustrate use of PNG_DEFAULT_sRGB and PNG_GAMMA_MAC_18
|
||||
as parameters for png_set_gamma(). These have been available since
|
||||
libpng-1.5.4.
|
||||
Renamed contrib/tools/png-fix-too-far-back.c to pngfix.c and revised it
|
||||
to check all compressed chunks known to libpng.
|
||||
Updated documentation to show default behavior of benign errors correctly.
|
||||
Only compile ARM code when PNG_READ_SUPPORTED is defined.
|
||||
Fixed undefined behavior in contrib/tools/pngfix.c and added new strip
|
||||
option. pngfix relied on undefined behavior and even a simple change from
|
||||
gcc to g++ caused it to fail. The new strip option 'unsafe' has been
|
||||
implemented and is the default if --max is given. Option names have
|
||||
been clarified, with --strip=transform now stripping the bKGD chunk,
|
||||
which was stripped previously with --strip=unused.
|
||||
Added all documented chunk types to pngpriv.h
|
||||
Unified pngfix.c source with libpng17.
|
||||
Revised manual about changes in iTXt chunk handling made in libpng-1.6.0.
|
||||
Added "/* SAFE */" comments in pngrutil.c and pngrtran.c where warnings
|
||||
may be erroneously issued by code-checking applications.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
391
CHANGES
391
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.
|
||||
@@ -4045,7 +4047,9 @@ Version 1.6.0beta17 [March 10, 2012]
|
||||
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.
|
||||
possible to call png_inflate() incrementally. A warning is no longer
|
||||
issued if the language tag or translated keyword in the iTXt chunk
|
||||
has zero length.
|
||||
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
|
||||
@@ -4233,6 +4237,387 @@ Version 1.6.0beta28 [August 29, 2012]
|
||||
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 1, 2013]
|
||||
Avoid a possible memory leak in contrib/gregbook/readpng.c
|
||||
|
||||
Version 1.6.1beta06 [March 4, 2013]
|
||||
Better documentation of unknown handling API interactions.
|
||||
Corrected Android builds and corrected libpng.vers with symbol
|
||||
prefixing This adds an API to set optimization options externally,
|
||||
providing an alternative and general solution for the non-portable
|
||||
run-time tests used by the ARM Neon code. It also makes those tests
|
||||
compile and link on Android.
|
||||
The order of settings vs options in pnglibconf.h is reversed to allow
|
||||
settings to depend on options and options can now set (or override) the
|
||||
defaults for settings.
|
||||
|
||||
Version 1.6.1beta07 [March 7, 2013]
|
||||
Corrected simplified API default gamma for color-mapped output, added
|
||||
a flag to change default. In 1.6.0 when the simplified API was used
|
||||
to produce color-mapped output from an input image with no gamma
|
||||
information the gamma assumed for the input could be different from
|
||||
that assumed for non-color-mapped output. In particular 16-bit depth
|
||||
input files were assumed to be sRGB encoded, whereas in the 'direct'
|
||||
case they were assumed to have linear data. This was an error. The
|
||||
fix makes the simplified API treat all input files the same way and
|
||||
adds a new flag to the png_image::flags member to allow the
|
||||
application/user to specify that 16-bit files contain sRGB data
|
||||
rather than the default linear.
|
||||
Fixed bugs in the pngpixel and makepng test programs.
|
||||
|
||||
Version 1.6.1beta08 [March 7, 2013]
|
||||
Fixed CMakelists.txt to allow building a single variant of the library
|
||||
(Claudio Bley):
|
||||
Introduced a PNG_LIB_TARGETS variable that lists all activated library
|
||||
targets. It is an error if this variable ends up empty, ie. you have
|
||||
to build at least one library variant.
|
||||
Made the *_COPY targets only depend on library targets actually being build.
|
||||
Use PNG_LIB_TARGETS to unify a code path.
|
||||
Changed the CREATE_SYMLINK macro to expect the full path to a file as the
|
||||
first argument. When symlinking the filename component of that path is
|
||||
determined and used as the link target.
|
||||
Use copy_if_different in the CREATE_SYMLINK macro.
|
||||
|
||||
Version 1.6.1beta09 [March 13, 2013]
|
||||
Eliminated two warnings from the Intel C compiler. The warnings are
|
||||
technically valid, although a reasonable treatment of division would
|
||||
show it to be incorrect.
|
||||
|
||||
Version 1.6.1rc01 [March 21, 2013]
|
||||
No changes.
|
||||
|
||||
Version 1.6.1 [March 28, 2013]
|
||||
No changes.
|
||||
|
||||
Version 1.6.2beta01 [April 14, 2013]
|
||||
Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling.
|
||||
Fixed incorrect warning of excess deflate data. End condition - the
|
||||
warning would be produced if the end of the deflate stream wasn't read
|
||||
in the last row. The warning is harmless.
|
||||
Corrected the test on user transform changes on read. It was in the
|
||||
png_set of the transform function, but that doesn't matter unless the
|
||||
transform function changes the rowbuf size, and that is only valid if
|
||||
transform_info is called.
|
||||
Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c
|
||||
(Flavio Medeiros).
|
||||
Corrected length written to uncompressed iTXt chunks (Samuli Suominen).
|
||||
Bug was introduced in libpng-1.6.0.
|
||||
|
||||
Version 1.6.2rc01 [April 18, 2013]
|
||||
Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length
|
||||
written by libpng-1.6.0 and 1.6.1.
|
||||
Disallow storing sRGB information when the sRGB is not supported.
|
||||
|
||||
Version 1.6.2rc02 [April 18, 2013]
|
||||
Merge pngtest.c with libpng-1.7.0
|
||||
|
||||
Version 1.6.2rc03 [April 22, 2013]
|
||||
Trivial spelling cleanup.
|
||||
|
||||
Version 1.6.2rc04 and 1.6.2rc05 [omitted]
|
||||
|
||||
Version 1.6.2rc06 [April 24, 2013]
|
||||
Reverted to version 1.6.2rc03. Recent changes to arm/neon support
|
||||
have been ported to libpng-1.7.0beta09 and will reappear in version
|
||||
1.6.3beta01.
|
||||
|
||||
Version 1.6.2 [April 25, 2013]
|
||||
No changes.
|
||||
|
||||
Version 1.6.3beta01 [April 25, 2013]
|
||||
Revised stack marking in arm/filter_neon.S and configure.ac.
|
||||
Ensure that NEON filter stuff is completely disabled when switched 'off'.
|
||||
Previously the ARM NEON specific files were still built if the option
|
||||
was switched 'off' as opposed to being explicitly disabled.
|
||||
|
||||
Version 1.6.3beta02 [April 26, 2013]
|
||||
Test for 'arm*' not just 'arm' in the host_cpu configure variable.
|
||||
Rebuilt the configure scripts.
|
||||
|
||||
Version 1.6.3beta03 [April 30, 2013]
|
||||
Expanded manual paragraph about writing private chunks, particularly
|
||||
the need to call png_set_keep_unknown_chunks() when writing them.
|
||||
Avoid dereferencing NULL pointer possibly returned from
|
||||
png_create_write_struct() (Andrew Church).
|
||||
|
||||
Version 1.6.3beta05 [May 9, 2013]
|
||||
Calculate our own zlib windowBits when decoding rather than trusting the
|
||||
CMF bytes in the PNG datastream.
|
||||
Added an option to force maximum window size for inflating, which was
|
||||
the behavior of libpng15 and earlier.
|
||||
Added png-fix-itxt and png-fix-too-far-back to the built programs and
|
||||
removed warnings from the source code and timepng that are revealed as
|
||||
a result.
|
||||
Detect wrong libpng versions linked to png-fix-too-far-back, which currently
|
||||
only works with libpng versions that can be made to reliably fail when
|
||||
the deflate data contains an out-of-window reference. This means only
|
||||
1.6 and later.
|
||||
Fixed gnu issues: g++ needs a static_cast, gcc 4.4.7 has a broken warning
|
||||
message which it is easier to work round than ignore.
|
||||
Updated contrib/pngminus/pnm2png.c (Paul Stewart):
|
||||
Check for EOF
|
||||
Ignore "#" delimited comments in input file to pnm2png.c.
|
||||
Fixed whitespace handling
|
||||
Added a call to png_set_packing()
|
||||
Initialize dimension values so if sscanf fails at least we have known
|
||||
invalid values.
|
||||
Attempt to detect configuration issues with png-fix-too-far-back, which
|
||||
requires both the correct libpng and the correct zlib to function
|
||||
correctly.
|
||||
Check ZLIB_VERNUM for mismatches, enclose #error in quotes
|
||||
Added information in the documentation about problems with and fixes for
|
||||
the bad CRC and bad iTXt chunk situations.
|
||||
|
||||
Version 1.6.3beta06 [May 12, 2013]
|
||||
Allow contrib/pngminus/pnm2png.c to compile without WRITE_INVERT and
|
||||
WRITE_PACK supported (writes error message that it can't read P1 or
|
||||
P4 PBM files).
|
||||
Improved png-fix-too-far-back usage message, added --suffix option.
|
||||
Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
|
||||
right zlib header files.
|
||||
Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile
|
||||
|
||||
Version 1.6.3beta07 [June 8, 2013]
|
||||
Removed a redundant test in png_set_IHDR().
|
||||
Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt)
|
||||
Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt
|
||||
Enclose the prototypes for the simplified write API in
|
||||
#ifdef PNG_STDIO_SUPPORTED/#endif
|
||||
Make ARM NEON support work at compile time (not just configure time).
|
||||
This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when
|
||||
using a compiler that compiles for multiple architectures at one time.
|
||||
Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from
|
||||
pnglibconf.h, allowing more of the decisions to be made internally
|
||||
(pngpriv.h) during the compile. Without this, symbol prefixing is broken
|
||||
under certain circumstances on ARM platforms. Now only the API parts of
|
||||
the optimizations ('check' vs 'api') are exposed in the public header files
|
||||
except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the
|
||||
decision about whether or not to use the optimizations.
|
||||
Protect symbol prefixing against CC/CPPFLAGS/CFLAGS useage.
|
||||
Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test
|
||||
on __ARM_NEON__ from configure time to compile time. This breaks symbol
|
||||
prefixing because the definition of the special png_init_filter_functions
|
||||
call was hidden at configure time if the relevant compiler arguments are
|
||||
passed in CFLAGS as opposed to CC. This change attempts to avoid all
|
||||
the confusion that would result by declaring the init function even when
|
||||
it is not used, so that it will always get prefixed.
|
||||
|
||||
Version 1.6.3beta08 [June 18, 2013]
|
||||
Revised libpng.3 so that "doclifter" can process it.
|
||||
|
||||
Version 1.6.3beta09 [June 27, 2013]
|
||||
Revised example.c to illustrate use of PNG_DEFAULT_sRGB and PNG_GAMMA_MAC_18
|
||||
as parameters for png_set_gamma(). These have been available since
|
||||
libpng-1.5.4.
|
||||
Renamed contrib/tools/png-fix-too-far-back.c to pngfix.c and revised it
|
||||
to check all compressed chunks known to libpng.
|
||||
|
||||
Version 1.6.3beta10 [July 5, 2013]
|
||||
Updated documentation to show default behavior of benign errors correctly.
|
||||
Only compile ARM code when PNG_READ_SUPPORTED is defined.
|
||||
Fixed undefined behavior in contrib/tools/pngfix.c and added new strip
|
||||
option. pngfix relied on undefined behavior and even a simple change from
|
||||
gcc to g++ caused it to fail. The new strip option 'unsafe' has been
|
||||
implemented and is the default if --max is given. Option names have
|
||||
been clarified, with --strip=transform now stripping the bKGD chunk,
|
||||
which was stripped previously with --strip=unused.
|
||||
Added all documented chunk types to pngpriv.h
|
||||
Unified pngfix.c source with libpng17.
|
||||
|
||||
Version 1.6.3rc01 [July 11, 2013]
|
||||
No changes.
|
||||
|
||||
Version 1.6.3 [July 18, 2013]
|
||||
Revised manual about changes in iTXt chunk handling made in libpng-1.6.0.
|
||||
Added "/* SAFE */" comments in pngrutil.c and pngrtran.c where warnings
|
||||
may be erroneously issued by code-checking applications.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
# Copyright (C) 2007-2011 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2007-2013 Glenn Randers-Pehrson
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@@ -9,33 +9,14 @@
|
||||
cmake_minimum_required(VERSION 2.4.4)
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||
|
||||
if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
|
||||
# workaround CMake 2.4.x bug
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
||||
"Choose the type of build, options are:
|
||||
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
|
||||
Debug
|
||||
Release
|
||||
RelWithDebInfo
|
||||
MinSizeRel.")
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
||||
"Choose the type of build, options are:
|
||||
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
|
||||
Debug
|
||||
Release
|
||||
RelWithDebInfo
|
||||
MinSizeRel.")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
|
||||
|
||||
project(libpng C)
|
||||
enable_testing()
|
||||
|
||||
set(PNGLIB_MAJOR 1)
|
||||
set(PNGLIB_MINOR 6)
|
||||
set(PNGLIB_RELEASE 0)
|
||||
set(PNGLIB_RELEASE 3)
|
||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||
|
||||
@@ -139,8 +120,11 @@ endif()
|
||||
# NOW BUILD OUR TARGET
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||
|
||||
unset(PNG_LIB_TARGETS)
|
||||
|
||||
if(PNG_SHARED)
|
||||
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
|
||||
set(PNG_LIB_TARGETS ${PNG_LIB_NAME})
|
||||
if(MSVC)
|
||||
# msvc does not append 'lib' - do it here to have consistent name
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
|
||||
@@ -153,6 +137,7 @@ if(PNG_STATIC)
|
||||
# does not work without changing name
|
||||
set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
|
||||
add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
|
||||
list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_STATIC})
|
||||
if(MSVC)
|
||||
# msvc does not append 'lib' - do it here to have consistent name
|
||||
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
|
||||
@@ -160,6 +145,12 @@ if(PNG_STATIC)
|
||||
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(NOT PNG_LIB_TARGETS)
|
||||
message(SEND_ERROR
|
||||
"No library variant selected to build. "
|
||||
"Please enable at least one of the following options: PNG_STATIC, PNG_SHARED")
|
||||
endif()
|
||||
|
||||
if(PNG_SHARED AND WIN32)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
||||
endif()
|
||||
@@ -222,14 +213,15 @@ macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||
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}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
DEPENDS ${PNG_LIB_TARGETS}
|
||||
)
|
||||
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
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})
|
||||
get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
endmacro()
|
||||
|
||||
@@ -260,7 +252,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.0beta28
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.3
|
||||
VERSION 16.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 16
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
@@ -287,40 +279,33 @@ endif()
|
||||
|
||||
# INSTALL
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
if(PNG_SHARED)
|
||||
install(TARGETS ${PNG_LIB_NAME}
|
||||
${PNG_EXPORT_RULE}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS ${PNG_LIB_TARGETS}
|
||||
${PNG_EXPORT_RULE}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
if(PNG_SHARED)
|
||||
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
|
||||
if(CYGWIN OR MINGW)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(CYGWIN OR MINGW)
|
||||
|
||||
if(NOT WIN32)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32)
|
||||
endif(PNG_SHARED)
|
||||
|
||||
if(PNG_STATIC)
|
||||
install(TARGETS ${PNG_LIB_NAME_STATIC}
|
||||
${PNG_EXPORT_RULE}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
|
||||
27
INSTALL
27
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
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.0beta28, August 29, 2012, are
|
||||
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.3, July 18, 2013, are
|
||||
Copyright (c) 2004, 2006-2013 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
|
||||
August 29, 2012
|
||||
July 18, 2013
|
||||
|
||||
117
Makefile.am
117
Makefile.am
@@ -7,24 +7,52 @@ 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
|
||||
|
||||
# Utilities - installed
|
||||
bin_PROGRAMS= pngfix png-fix-itxt
|
||||
|
||||
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 pngunknown
|
||||
pngvalid_SOURCES = contrib/libtests/pngvalid.c
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngunknown_SOURCES = contrib/libtests/pngunknown.c
|
||||
pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngunknown_SOURCES = contrib/libtests/pngunknown.c
|
||||
pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
TESTS += contrib/libtests/test-pngunknown.sh\
|
||||
contrib/libtests/test-pngvalid-simple.sh\
|
||||
contrib/libtests/test-pngvalid-full.sh\
|
||||
contrib/libtests/test-pngstest.sh
|
||||
|
||||
pngfix_SOURCES = contrib/tools/pngfix.c
|
||||
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
|
||||
|
||||
# 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
|
||||
@@ -43,7 +71,8 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||
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
|
||||
@@ -76,12 +105,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
|
||||
@@ -118,6 +149,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 $@
|
||||
@@ -156,14 +188,15 @@ endif
|
||||
$(srcdir)/scripts/pnglibconf.h.prebuilt:
|
||||
@echo "Attempting to build $@" >&2
|
||||
@echo "This is a machine generated file, but if you want to make" >&2
|
||||
@echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2
|
||||
@echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2
|
||||
@echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2
|
||||
@exit 1
|
||||
|
||||
# The following is necessary to ensure that the local pnglibconf.h is used, not
|
||||
# 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
|
||||
pngstest.o pngvalid.o pngtest.o pngunknown.o timepng.o: pnglibconf.h
|
||||
pngfix.o png-fix-itxt.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
|
||||
@@ -178,16 +211,14 @@ 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 pngusr.dfa $(DFA_XTRA)
|
||||
@@ -236,22 +267,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;\
|
||||
@@ -259,9 +292,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'
|
||||
|
||||
36
README
36
README
@@ -1,11 +1,11 @@
|
||||
README for libpng version 1.6.0beta28 - August 29, 2012 (shared library 16.0)
|
||||
README for libpng version 1.6.3 - July 18, 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.
|
||||
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
|
||||
libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings
|
||||
in the text files, or lpng*.zip if you want DOS-style line endings.
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
||||
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
|
||||
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been in
|
||||
@@ -77,17 +77,15 @@ compression library that is useful for more things than just PNG files.
|
||||
You can use zlib as a drop-in replacement for fread() and fwrite() if
|
||||
you are so inclined.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at.
|
||||
ftp://ftp.info-zip.org/pub/infozip/zlib
|
||||
zlib should be available at the same place that libpng is, or at zlib.net.
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/documents/
|
||||
|
||||
This code is currently being archived at libpng.sf.net in the
|
||||
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
|
||||
at GO GRAPHSUP. If you can't find it in any of those places,
|
||||
e-mail me, and I'll help you find it.
|
||||
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
|
||||
in any of those places, e-mail me, and I'll help you find it.
|
||||
|
||||
If you have any code changes, requests, problems, etc., please e-mail
|
||||
them to me. Also, I'd appreciate any make files or project files,
|
||||
@@ -123,7 +121,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for sixteen years now, and it is official and
|
||||
been discussing PNG for eighteen years now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used immediately,
|
||||
it may be used later.
|
||||
@@ -167,23 +165,25 @@ Files in this distribution:
|
||||
pngwrite.c => High-level write functions
|
||||
pngwtran.c => Write data transformations
|
||||
pngwutil.c => Write utility functions
|
||||
arm => Contains optimized code for the ARM platform
|
||||
contrib => Contributions
|
||||
examples => Example programs
|
||||
gregbook => source code for PNG reading and writing, from
|
||||
Greg Roelofs' "PNG: The Definitive Guide",
|
||||
O'Reilly, 1999
|
||||
msvctest => Builds and runs pngtest using a MSVC workspace
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
libtests => Test programs
|
||||
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||
programs demonstrating use of pngusr.dfa
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
tools => Various tools
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
projects => Contains project files and workspaces for
|
||||
building a DLL
|
||||
cbuilder5 => Contains a Borland workspace for building
|
||||
libpng and zlib
|
||||
visualc6 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
owatcom => Contains a WATCOM project for building libpng
|
||||
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
xcode => Contains an Apple xcode
|
||||
vstudio => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
(see scripts/README.txt for the list of scripts)
|
||||
|
||||
221
arm/arm_init.c
Normal file
221
arm/arm_init.c
Normal file
@@ -0,0 +1,221 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.5.17 [July 18, 2013]
|
||||
*
|
||||
* 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"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
#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!)
|
||||
*/
|
||||
PNG_UNUSED(png_ptr)
|
||||
return android_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_API_SUPPORTED
|
||||
switch ((pp->options >> PNG_ARM_NEON) & 3)
|
||||
{
|
||||
case PNG_OPTION_UNSET:
|
||||
/* Allow the run-time check to execute if it has been enabled -
|
||||
* thus both API and CHECK can be turned on. If it isn't supported
|
||||
* this case will fall through to the 'default' below, which just
|
||||
* returns.
|
||||
*/
|
||||
#endif /* PNG_ARM_NEON_API_SUPPORTED */
|
||||
#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;
|
||||
}
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
break;
|
||||
#endif
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
case PNG_OPTION_ON:
|
||||
/* Option turned on */
|
||||
break;
|
||||
|
||||
default: /* OFF or INVALID */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 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 /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
@@ -1,18 +1,28 @@
|
||||
|
||||
/* filter_neon.S - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.5.17 [July 18, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* This is required to get the symbol renames, which are #defines, and also
|
||||
* includes the definition (or not) of PNG_ARM_NEON_OPT.
|
||||
*/
|
||||
#define PNG_VERSION_INFO_ONLY
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
#ifdef __ELF__
|
||||
# define ELF
|
||||
#else
|
||||
@@ -223,3 +233,5 @@ func png_read_filter_row_paeth3_neon, export=1
|
||||
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
@@ -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\
|
||||
|
||||
109
configure.ac
109
configure.ac
@@ -18,7 +18,7 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.6.0beta28],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.6.3],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
@@ -26,9 +26,11 @@ AC_CONFIG_MACRO_DIR([scripts])
|
||||
# silent-rules requires automake 1.11 or later
|
||||
# dist-xz requires automake 1.11 or later
|
||||
# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
|
||||
AM_INIT_AUTOMAKE([1.12.2 foreign dist-xz dist-bzip2 color-tests silent-rules])
|
||||
# was:
|
||||
# AM_INIT_AUTOMAKE
|
||||
# 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.0beta28
|
||||
PNGLIB_VERSION=1.6.3
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_RELEASE=0
|
||||
PNGLIB_RELEASE=3
|
||||
|
||||
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
|
||||
@@ -233,18 +226,54 @@ AC_ARG_WITH(libpng-prefix,
|
||||
fi])
|
||||
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
|
||||
|
||||
# Because GCC by default assembles code with an executable stack, even though it
|
||||
# compiles C code with a non-executable stack, it is necessary to do a fixup
|
||||
# here (this may by GCC specific)
|
||||
AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
|
||||
# HOST SPECIFIC OPTIONS
|
||||
# =====================
|
||||
#
|
||||
# ARM
|
||||
# ===
|
||||
#
|
||||
# ARM NEON (SIMD) support.
|
||||
|
||||
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])
|
||||
fi])
|
||||
AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes])
|
||||
AS_HELP_STRING([[[--enable-arm-neon]]],
|
||||
[Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
|
||||
[no/off: disable the optimizations; check: use internal checking code]
|
||||
[(deprecated and poorly supported); api: disable by default, enable by]
|
||||
[a call to png_set_option; yes/on: turn on unconditionally.]
|
||||
[If not specified: determined by the compiler.]),
|
||||
[case "$enableval" in
|
||||
no|off)
|
||||
# disable the default enabling on __ARM_NEON__ systems:
|
||||
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
||||
[Disable ARM Neon optimizations])
|
||||
# Prevent inclusion of the assembler files below:
|
||||
enable_arm_neon=no;;
|
||||
check)
|
||||
AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
|
||||
[Check for ARM Neon support at run-time]);;
|
||||
api)
|
||||
AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
|
||||
[Turn on ARM Neon optimizations at run-time]);;
|
||||
yes|on)
|
||||
AC_DEFINE([PNG_ARM_NEON_OPT], [2],
|
||||
[Enable ARM Neon optimizations])
|
||||
AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
|
||||
[you want the optimizations unconditionally pass -mfpu=neon]
|
||||
[to the compiler.]);;
|
||||
*)
|
||||
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
|
||||
esac])
|
||||
|
||||
# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
|
||||
# where ARM optimizations were explicitly requested (this allows a fallback if a
|
||||
# future host CPU does not match 'arm*')
|
||||
|
||||
AM_CONDITIONAL([PNG_ARM_NEON],
|
||||
[test "$enable_arm_neon" != 'no' &&
|
||||
case "$host_cpu" in
|
||||
arm*) :;;
|
||||
*) test "$enable_arm_neon" != '';;
|
||||
esac])
|
||||
|
||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
* bytes wide. Since the row fitted into memory, however, the following must
|
||||
* work:
|
||||
*/
|
||||
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels + c);
|
||||
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
|
||||
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
|
||||
|
||||
row = (png_const_bytep)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
57
contrib/libtests/fakepng.c
Normal file
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);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# 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
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* makepng.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.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -10,7 +10,8 @@
|
||||
*
|
||||
* Make a test PNG image. The arguments are as follows:
|
||||
*
|
||||
* makepng [--sRGB|--linear|--1.8] color-type bit-depth [file-name]
|
||||
* makepng [--sRGB|--linear|--1.8] [--color=<color>] color-type bit-depth \
|
||||
* [file-name]
|
||||
*
|
||||
* The color-type may be numeric (and must match the numbers used by the PNG
|
||||
* specification) or one of the format names listed below. The bit-depth is the
|
||||
@@ -23,7 +24,8 @@
|
||||
* approximately value^(1/1.45) to the color values and so a gAMA chunk of 65909
|
||||
* is written (1.45/2.2).
|
||||
*
|
||||
* The image data is generated internally. The images used are as follows:
|
||||
* The image data is generated internally. Unless --color is given the images
|
||||
* used are as follows:
|
||||
*
|
||||
* 1 channel: a square image with a diamond, the least luminous colors are on
|
||||
* the edge of the image, the most luminous in the center.
|
||||
@@ -58,9 +60,14 @@
|
||||
* 16 bits: 256x256
|
||||
* More than 16 bits: 1024x1024
|
||||
*
|
||||
* Row filtering is turned off (the 'none' filter is used on every row) and the
|
||||
* Row filtering is turned off (the 'none' filter is used on every row) and the
|
||||
* images are not interlaced.
|
||||
*
|
||||
* If --color is given then the whole image has that color, color-mapped images
|
||||
* will have exactly one palette entry and all image files with be 16x16 in
|
||||
* size. The color value is 1 to 4 decimal numbers as appropriate for the color
|
||||
* type.
|
||||
*
|
||||
* If file-name is given then the PNG is written to that file, else it is
|
||||
* written to stdout. Notice that stdout is not supported on systems where, by
|
||||
* default, it assumes text output; this program makes no attempt to change the
|
||||
@@ -76,7 +83,7 @@
|
||||
#include <math.h>
|
||||
#include <errno.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
|
||||
|
||||
@@ -128,18 +135,24 @@ pixel_depth_of_type(int color_type, int bit_depth)
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
image_size_of_type(int color_type, int bit_depth)
|
||||
image_size_of_type(int color_type, int bit_depth, unsigned int *colors)
|
||||
{
|
||||
int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
|
||||
|
||||
if (pixel_depth < 8)
|
||||
return 64;
|
||||
|
||||
else if (pixel_depth > 16)
|
||||
return 1024;
|
||||
if (*colors)
|
||||
return 16;
|
||||
|
||||
else
|
||||
return 256;
|
||||
{
|
||||
int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
|
||||
|
||||
if (pixel_depth < 8)
|
||||
return 64;
|
||||
|
||||
else if (pixel_depth > 16)
|
||||
return 1024;
|
||||
|
||||
else
|
||||
return 256;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -155,7 +168,7 @@ set_color(png_colorp color, png_bytep trans, unsigned int red,
|
||||
|
||||
static int
|
||||
generate_palette(png_colorp palette, png_bytep trans, int bit_depth,
|
||||
png_const_bytep gamma_table)
|
||||
png_const_bytep gamma_table, unsigned int *colors)
|
||||
{
|
||||
/*
|
||||
* 1-bit: entry 0 is transparent-red, entry 1 is opaque-white
|
||||
@@ -166,39 +179,69 @@ generate_palette(png_colorp palette, png_bytep trans, int bit_depth,
|
||||
* 4-bit: the 16 combinations of the 2-bit case
|
||||
* 8-bit: the 256 combinations of the 4-bit case
|
||||
*/
|
||||
if (bit_depth == 1)
|
||||
switch (colors[0])
|
||||
{
|
||||
set_color(palette+0, trans+0, 255, 0, 0, 0, gamma_table);
|
||||
set_color(palette+1, trans+1, 255, 255, 255, 255, gamma_table);
|
||||
return 2;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "makepng: --colors=...: invalid count %u\n",
|
||||
colors[0]);
|
||||
exit(1);
|
||||
|
||||
else
|
||||
{
|
||||
unsigned int size = 1U << (bit_depth/2); /* 2, 4 or 16 */
|
||||
unsigned int x, y, ip;
|
||||
|
||||
for (x=0; x<size; ++x) for (y=0; y<size; ++y)
|
||||
{
|
||||
ip = x + (size * y);
|
||||
|
||||
/* size is at most 16, so the scaled value below fits in 16 bits */
|
||||
# define interp(pos, c1, c2) ((pos * c1) + ((size-pos) * c2))
|
||||
# define xyinterp(x, y, c1, c2, c3, c4) (((size * size / 2) +\
|
||||
(interp(x, c1, c2) * y + (size-y) * interp(x, c3, c4))) /\
|
||||
(size*size))
|
||||
|
||||
set_color(palette+ip, trans+ip,
|
||||
/* color: green, red,blue,white */
|
||||
xyinterp(x, y, 0, 255, 0, 255),
|
||||
xyinterp(x, y, 255, 0, 0, 255),
|
||||
xyinterp(x, y, 0, 0, 255, 255),
|
||||
/* alpha: 0, 102, 204, 255) */
|
||||
xyinterp(x, y, 0, 102, 204, 255),
|
||||
case 1:
|
||||
set_color(palette+0, trans+0, colors[1], colors[1], colors[1], 255,
|
||||
gamma_table);
|
||||
}
|
||||
return 1;
|
||||
|
||||
return ip+1;
|
||||
case 2:
|
||||
set_color(palette+0, trans+0, colors[1], colors[1], colors[1],
|
||||
colors[2], gamma_table);
|
||||
return 1;
|
||||
|
||||
case 3:
|
||||
set_color(palette+0, trans+0, colors[1], colors[2], colors[3], 255,
|
||||
gamma_table);
|
||||
return 1;
|
||||
|
||||
case 4:
|
||||
set_color(palette+0, trans+0, colors[1], colors[2], colors[3],
|
||||
colors[4], gamma_table);
|
||||
return 1;
|
||||
|
||||
case 0:
|
||||
if (bit_depth == 1)
|
||||
{
|
||||
set_color(palette+0, trans+0, 255, 0, 0, 0, gamma_table);
|
||||
set_color(palette+1, trans+1, 255, 255, 255, 255, gamma_table);
|
||||
return 2;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
unsigned int size = 1U << (bit_depth/2); /* 2, 4 or 16 */
|
||||
unsigned int x, y, ip;
|
||||
|
||||
for (x=0; x<size; ++x) for (y=0; y<size; ++y)
|
||||
{
|
||||
ip = x + (size * y);
|
||||
|
||||
/* size is at most 16, so the scaled value below fits in 16 bits
|
||||
*/
|
||||
# define interp(pos, c1, c2) ((pos * c1) + ((size-pos) * c2))
|
||||
# define xyinterp(x, y, c1, c2, c3, c4) (((size * size / 2) +\
|
||||
(interp(x, c1, c2) * y + (size-y) * interp(x, c3, c4))) /\
|
||||
(size*size))
|
||||
|
||||
set_color(palette+ip, trans+ip,
|
||||
/* color: green, red,blue,white */
|
||||
xyinterp(x, y, 0, 255, 0, 255),
|
||||
xyinterp(x, y, 255, 0, 0, 255),
|
||||
xyinterp(x, y, 0, 0, 255, 255),
|
||||
/* alpha: 0, 102, 204, 255) */
|
||||
xyinterp(x, y, 0, 102, 204, 255),
|
||||
gamma_table);
|
||||
}
|
||||
|
||||
return ip+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +251,7 @@ set_value(png_bytep row, size_t rowbytes, png_uint_32 x, unsigned int bit_depth,
|
||||
{
|
||||
unsigned int mask = (1U << bit_depth)-1;
|
||||
|
||||
x *= bit_depth; /* Maxium x is 4*1024, maxium bit_depth is 16 */
|
||||
x *= bit_depth; /* Maximum x is 4*1024, maximum bit_depth is 16 */
|
||||
|
||||
if (value <= mask)
|
||||
{
|
||||
@@ -265,12 +308,13 @@ set_value(png_bytep row, size_t rowbytes, png_uint_32 x, unsigned int bit_depth,
|
||||
|
||||
static void
|
||||
generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
int bit_depth, png_const_bytep gamma_table, double conv)
|
||||
int bit_depth, png_const_bytep gamma_table, double conv,
|
||||
unsigned int *colors)
|
||||
{
|
||||
png_uint_32 size_max = image_size_of_type(color_type, bit_depth)-1;
|
||||
png_uint_32 size_max = image_size_of_type(color_type, bit_depth, colors)-1;
|
||||
png_uint_32 depth_max = (1U << bit_depth)-1; /* up to 65536 */
|
||||
|
||||
switch (channels_of_type(color_type))
|
||||
if (colors[0] == 0) switch (channels_of_type(color_type))
|
||||
{
|
||||
/* 1 channel: a square image with a diamond, the least luminous colors are on
|
||||
* the edge of the image, the most luminous in the center.
|
||||
@@ -390,13 +434,130 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
fprintf(stderr, "makepng: internal bad channel count\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
else if (color_type & PNG_COLOR_MASK_PALETTE)
|
||||
{
|
||||
/* Palette with fixed color: the image rows are all 0 and the image width
|
||||
* is 16.
|
||||
*/
|
||||
memset(row, 0, rowbytes);
|
||||
}
|
||||
|
||||
else if (colors[0] == channels_of_type(color_type))
|
||||
switch (channels_of_type(color_type))
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
const png_uint_32 luma = colors[1];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
set_value(row, rowbytes, x, bit_depth, luma, gamma_table,
|
||||
conv);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
const png_uint_32 luma = colors[1];
|
||||
const png_uint_32 alpha = colors[2];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<size_max; ++x)
|
||||
{
|
||||
set_value(row, rowbytes, 2*x, bit_depth, luma, gamma_table,
|
||||
conv);
|
||||
set_value(row, rowbytes, 2*x+1, bit_depth, alpha, gamma_table,
|
||||
conv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
const png_uint_32 red = colors[1];
|
||||
const png_uint_32 green = colors[2];
|
||||
const png_uint_32 blue = colors[3];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
{
|
||||
set_value(row, rowbytes, 3*x+0, bit_depth, red, gamma_table,
|
||||
conv);
|
||||
set_value(row, rowbytes, 3*x+1, bit_depth, green, gamma_table,
|
||||
conv);
|
||||
set_value(row, rowbytes, 3*x+2, bit_depth, blue, gamma_table,
|
||||
conv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
{
|
||||
const png_uint_32 red = colors[1];
|
||||
const png_uint_32 green = colors[2];
|
||||
const png_uint_32 blue = colors[3];
|
||||
const png_uint_32 alpha = colors[4];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
{
|
||||
set_value(row, rowbytes, 4*x+0, bit_depth, red, gamma_table,
|
||||
conv);
|
||||
set_value(row, rowbytes, 4*x+1, bit_depth, green, gamma_table,
|
||||
conv);
|
||||
set_value(row, rowbytes, 4*x+2, bit_depth, blue, gamma_table,
|
||||
conv);
|
||||
set_value(row, rowbytes, 4*x+3, bit_depth, alpha, gamma_table,
|
||||
conv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "makepng: internal bad channel count\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr,
|
||||
"makepng: --color: count(%u) does not match channels(%u)\n",
|
||||
colors[0], channels_of_type(color_type));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void PNGCBAPI
|
||||
makepng_warning(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
const char **ep = png_get_error_ptr(png_ptr);
|
||||
const char *name;
|
||||
|
||||
if (ep != NULL && *ep != NULL)
|
||||
name = *ep;
|
||||
|
||||
else
|
||||
name = "makepng";
|
||||
|
||||
fprintf(stderr, "%s: warning: %s\n", name, message);
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
makepng_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
makepng_warning(png_ptr, message);
|
||||
png_longjmp(png_ptr, 1);
|
||||
}
|
||||
|
||||
static int /* 0 on success, else an error code */
|
||||
write_png(FILE *fp, int color_type, int bit_depth,
|
||||
volatile png_fixed_point gamma, chunk_insert * volatile insert)
|
||||
write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
volatile png_fixed_point gamma, chunk_insert * volatile insert,
|
||||
unsigned int filters, unsigned int *colors)
|
||||
{
|
||||
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
name, makepng_error, makepng_warning);
|
||||
volatile png_infop info_ptr = NULL;
|
||||
volatile png_bytep row = NULL;
|
||||
|
||||
@@ -427,7 +588,7 @@ write_png(FILE *fp, int color_type, int bit_depth,
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
{
|
||||
unsigned int size = image_size_of_type(color_type, bit_depth);
|
||||
unsigned int size = image_size_of_type(color_type, bit_depth, colors);
|
||||
png_fixed_point real_gamma = 45455; /* For sRGB */
|
||||
png_byte gamma_table[256];
|
||||
double conv;
|
||||
@@ -463,8 +624,8 @@ write_png(FILE *fp, int color_type, int bit_depth,
|
||||
|
||||
gamma_table[0] = 0;
|
||||
|
||||
for (i=0; i<255; ++i)
|
||||
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + 127.5);
|
||||
for (i=1; i<255; ++i)
|
||||
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + .5);
|
||||
|
||||
gamma_table[255] = 255;
|
||||
}
|
||||
@@ -479,7 +640,8 @@ write_png(FILE *fp, int color_type, int bit_depth,
|
||||
png_color palette[256];
|
||||
png_byte trans[256];
|
||||
|
||||
npalette = generate_palette(palette, trans, bit_depth, gamma_table);
|
||||
npalette = generate_palette(palette, trans, bit_depth, gamma_table,
|
||||
colors);
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, npalette);
|
||||
png_set_tRNS(png_ptr, info_ptr, trans, npalette-1,
|
||||
NULL/*transparent color*/);
|
||||
@@ -517,7 +679,7 @@ write_png(FILE *fp, int color_type, int bit_depth,
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
/* Restrict the filters */
|
||||
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS);
|
||||
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, filters);
|
||||
|
||||
{
|
||||
int passes = png_set_interlace_handling(png_ptr);
|
||||
@@ -536,7 +698,7 @@ write_png(FILE *fp, int color_type, int bit_depth,
|
||||
for (y=0; y<size; ++y)
|
||||
{
|
||||
generate_row(row, rowbytes, y, color_type, bit_depth,
|
||||
gamma_table, conv);
|
||||
gamma_table, conv, colors);
|
||||
png_write_row(png_ptr, row);
|
||||
}
|
||||
}
|
||||
@@ -604,7 +766,10 @@ load_file(png_const_charp name, png_bytepp result)
|
||||
|
||||
if (total > 0)
|
||||
{
|
||||
png_bytep data = malloc(total);
|
||||
/* Round up to a multiple of 4 here to allow an iCCP profile
|
||||
* to be padded to a 4x boundary.
|
||||
*/
|
||||
png_bytep data = malloc((total+3)&~3);
|
||||
|
||||
if (data != NULL)
|
||||
{
|
||||
@@ -729,12 +894,13 @@ insert_iCCP(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
case '<':
|
||||
{
|
||||
png_size_t filelen = load_file(params[1]+1, &profile);
|
||||
if (filelen > 0xffffffff) /* Maximum profile length */
|
||||
if (filelen > 0xfffffffc) /* Maximum profile length */
|
||||
{
|
||||
fprintf(stderr, "%s: file too long (%lu) for an ICC profile\n",
|
||||
params[1]+1, (unsigned long)filelen);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
proflen = (png_uint_32)filelen;
|
||||
}
|
||||
break;
|
||||
@@ -771,9 +937,14 @@ insert_iCCP(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
if (proflen & 3)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"--insert iCCP %s: profile length must be a multiple of 4\n",
|
||||
"makepng: --insert iCCP %s: profile length made a multiple of 4\n",
|
||||
params[1]);
|
||||
result = 0; /* Cannot fix this! */
|
||||
|
||||
/* load_file allocates extra space for this padding, the ICC spec requires
|
||||
* padding with zero bytes.
|
||||
*/
|
||||
while (proflen & 3)
|
||||
profile[proflen++] = 0;
|
||||
}
|
||||
|
||||
if (profile != NULL && proflen > 3)
|
||||
@@ -1060,6 +1231,48 @@ find_insert(png_const_charp what, png_charp param)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This is a not-very-good parser for a sequence of numbers (including 0). It
|
||||
* doesn't accept some apparently valid things, but it accepts all the sensible
|
||||
* combinations.
|
||||
*/
|
||||
static void
|
||||
parse_color(char *arg, unsigned int *colors)
|
||||
{
|
||||
unsigned int ncolors = 0;
|
||||
|
||||
while (*arg && ncolors < 4)
|
||||
{
|
||||
char *ep = arg;
|
||||
|
||||
unsigned long ul = strtoul(arg, &ep, 0);
|
||||
|
||||
if (ul > 65535)
|
||||
{
|
||||
fprintf(stderr, "makepng --color=...'%s': too big\n", arg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ep == arg)
|
||||
{
|
||||
fprintf(stderr, "makepng --color=...'%s': not a valid color\n", arg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (*ep) ++ep; /* skip a separator */
|
||||
arg = ep;
|
||||
|
||||
colors[++ncolors] = (unsigned int)ul; /* checked above */
|
||||
}
|
||||
|
||||
if (*arg)
|
||||
{
|
||||
fprintf(stderr, "makepng --color=...'%s': too many values\n", arg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*colors = ncolors;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@@ -1067,13 +1280,17 @@ main(int argc, char **argv)
|
||||
const char *file_name = NULL;
|
||||
int color_type = 8; /* invalid */
|
||||
int bit_depth = 32; /* invalid */
|
||||
unsigned int colors[5];
|
||||
unsigned int filters = PNG_ALL_FILTERS;
|
||||
png_fixed_point gamma = 0; /* not set */
|
||||
chunk_insert *head_insert = NULL;
|
||||
chunk_insert **insert_ptr = &head_insert;
|
||||
|
||||
memset(colors, 0, sizeof colors);
|
||||
|
||||
while (--argc > 0)
|
||||
{
|
||||
const char *arg = *++argv;
|
||||
char *arg = *++argv;
|
||||
|
||||
if (strcmp(arg, "--sRGB") == 0)
|
||||
{
|
||||
@@ -1093,6 +1310,18 @@ main(int argc, char **argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(arg, "--nofilters") == 0)
|
||||
{
|
||||
filters = PNG_FILTER_NONE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(arg, "--color=", 8) == 0)
|
||||
{
|
||||
parse_color(arg+8, colors);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (argc >= 3 && strcmp(arg, "--insert") == 0)
|
||||
{
|
||||
png_const_charp what = *++argv;
|
||||
@@ -1204,13 +1433,50 @@ main(int argc, char **argv)
|
||||
if (color_type == 8 || bit_depth == 32)
|
||||
{
|
||||
fprintf(stderr, "usage: makepng [--sRGB|--linear|--1.8] "
|
||||
"color-type bit-depth [file-name]\n"
|
||||
"[--color=...] color-type bit-depth [file-name]\n"
|
||||
" Make a test PNG file, by default writes to stdout.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Check the colors */
|
||||
{
|
||||
int ret = write_png(fp, color_type, bit_depth, gamma, head_insert);
|
||||
const unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U :
|
||||
(1U<<bit_depth)-1);
|
||||
unsigned int i;
|
||||
|
||||
for (i=1; i<=colors[0]; ++i)
|
||||
if (colors[i] > lim)
|
||||
{
|
||||
fprintf(stderr, "makepng: --color=...: %u out of range [0..%u]\n",
|
||||
colors[i], lim);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Restrict the filters for more speed to those we know are used for the
|
||||
* generated images.
|
||||
*/
|
||||
if (filters == PNG_ALL_FILTERS)
|
||||
{
|
||||
if ((color_type & PNG_COLOR_MASK_PALETTE) != 0 || bit_depth < 8)
|
||||
filters = PNG_FILTER_NONE;
|
||||
|
||||
else if (color_type & PNG_COLOR_MASK_COLOR) /* rgb */
|
||||
{
|
||||
if (bit_depth == 8)
|
||||
filters &= ~(PNG_FILTER_NONE | PNG_FILTER_AVG);
|
||||
|
||||
else
|
||||
filters = PNG_FILTER_SUB | PNG_FILTER_PAETH;
|
||||
}
|
||||
|
||||
else /* gray 8 or 16-bit */
|
||||
filters &= ~PNG_FILTER_NONE;
|
||||
}
|
||||
|
||||
{
|
||||
int ret = write_png(&file_name, fp, color_type, bit_depth, gamma,
|
||||
head_insert, filters, colors);
|
||||
|
||||
if (ret != 0 && file_name != NULL)
|
||||
remove(file_name);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*-
|
||||
* pngstest.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.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <ctype.h>
|
||||
#include <math.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
|
||||
|
||||
@@ -62,6 +62,12 @@
|
||||
# define aligncastconst(type, value) ((const void*)(value))
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* During parallel runs of pngstest each temporary file needs a unique name,
|
||||
* this is used to permit uniqueness using a command line argument which can be
|
||||
* up to 22 characters long.
|
||||
*/
|
||||
static char tmpf[23] = "TMP";
|
||||
|
||||
/* 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
|
||||
@@ -309,6 +315,7 @@ compare_16bit(int v1, int v2, int error_limit, int multiple_algorithms)
|
||||
#define KEEP_GOING 32
|
||||
#define ACCUMULATE 64
|
||||
#define FAST_WRITE 128
|
||||
#define sRGB_16BIT 256
|
||||
|
||||
static void
|
||||
print_opts(png_uint_32 opts)
|
||||
@@ -329,6 +336,8 @@ print_opts(png_uint_32 opts)
|
||||
printf(" --accumulate");
|
||||
if (!(opts & FAST_WRITE)) /* --fast is currently the default */
|
||||
printf(" --slow");
|
||||
if (opts & sRGB_16BIT)
|
||||
printf(" --sRGB-16bit");
|
||||
}
|
||||
|
||||
#define FORMAT_NO_CHANGE 0x80000000 /* additional flag */
|
||||
@@ -2625,7 +2634,7 @@ component_loc(png_byte loc[4], png_uint_32 format)
|
||||
else
|
||||
{
|
||||
channels = 1;
|
||||
loc[0] = loc[1] = loc[2] = 0;
|
||||
loc[1] = loc[2] = loc[3] = 0;
|
||||
}
|
||||
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
@@ -3020,6 +3029,10 @@ read_file(Image *image, png_uint_32 format, png_const_colorp background)
|
||||
return logerror(image, "file init: ", image->file_name, "");
|
||||
}
|
||||
|
||||
/* This must be set after the begin_read call: */
|
||||
if (image->opts & sRGB_16BIT)
|
||||
image->image.flags |= PNG_IMAGE_FLAG_16BIT_sRGB;
|
||||
|
||||
/* Have an initialized image with all the data we need plus, maybe, an
|
||||
* allocated file (myfile) or buffer (mybuffer) that need to be freed.
|
||||
*/
|
||||
@@ -3198,7 +3211,7 @@ write_one_file(Image *output, Image *image, int convert_to_8bit)
|
||||
static int counter = 0;
|
||||
char name[32];
|
||||
|
||||
sprintf(name, "TMP%d.png", ++counter);
|
||||
sprintf(name, "%s%d.png", tmpf, ++counter);
|
||||
|
||||
if (png_image_write_to_file(&image->image, name, convert_to_8bit,
|
||||
image->buffer+16, (png_int_32)image->stride, image->colormap))
|
||||
@@ -3482,6 +3495,34 @@ main(int argc, char **argv)
|
||||
opts &= ~KEEP_GOING;
|
||||
else if (strcmp(arg, "--strict") == 0)
|
||||
opts |= STRICT;
|
||||
else if (strcmp(arg, "--sRGB-16bit") == 0)
|
||||
opts |= sRGB_16BIT;
|
||||
else if (strcmp(arg, "--linear-16bit") == 0)
|
||||
opts &= ~sRGB_16BIT;
|
||||
else if (strcmp(arg, "--tmpfile") == 0)
|
||||
{
|
||||
if (c+1 < argc)
|
||||
{
|
||||
if (strlen(argv[++c]) >= sizeof tmpf)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: %s is too long for a temp file prefix\n",
|
||||
argv[0], argv[c]);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
/* Safe: checked above */
|
||||
strcpy(tmpf, argv[c]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: %s requires a temporary file prefix\n",
|
||||
argv[0], arg);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
else if (strcmp(arg, "--touch") == 0)
|
||||
{
|
||||
if (c+1 < argc)
|
||||
@@ -3492,7 +3533,7 @@ main(int argc, char **argv)
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: %s requires a file name argument\n",
|
||||
argv[0], arg);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
else if (arg[0] == '+')
|
||||
@@ -3500,7 +3541,7 @@ main(int argc, char **argv)
|
||||
png_uint_32 format = formatof(arg+1);
|
||||
|
||||
if (format > FORMAT_COUNT)
|
||||
exit(1);
|
||||
exit(99);
|
||||
|
||||
format_set(&formats, format);
|
||||
}
|
||||
@@ -3508,7 +3549,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: unknown option: %s\n", argv[0], arg);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3557,7 +3598,7 @@ main(int argc, char **argv)
|
||||
buffer[4095] = 0;
|
||||
fprintf(stderr, "%s...%s: file name too long\n", buffer,
|
||||
buffer+(4096-32));
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3676,7 +3717,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: write failed\n", touch);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3684,7 +3725,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: open failed\n", touch);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3695,6 +3736,7 @@ main(int argc, char **argv)
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "pngstest: no read support in libpng, test skipped\n");
|
||||
return 0;
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngunknown.c - test the read side unknown chunk handling
|
||||
*
|
||||
* 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.
|
||||
@@ -19,8 +19,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#include <png.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
|
||||
|
||||
@@ -131,23 +139,128 @@ static struct
|
||||
{ "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 },
|
||||
/* This is a mess but it seems to be the only way to do it - there is no way to
|
||||
* check for definition outside a #if.
|
||||
*/
|
||||
{ "bKGD", PNG_INFO_bKGD, png_bKGD,
|
||||
# ifdef PNG_READ_bKGD_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "cHRM", PNG_INFO_cHRM, png_cHRM,
|
||||
# ifdef PNG_READ_cHRM_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "gAMA", PNG_INFO_gAMA, png_gAMA,
|
||||
# ifdef PNG_READ_gAMA_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "hIST", PNG_INFO_hIST, png_hIST,
|
||||
# ifdef PNG_READ_hIST_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "iCCP", PNG_INFO_iCCP, png_iCCP,
|
||||
# ifdef PNG_READ_iCCP_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "iTXt", PNG_INFO_iTXt, png_iTXt,
|
||||
# ifdef PNG_READ_iTXt_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "oFFs", PNG_INFO_oFFs, png_oFFs,
|
||||
# ifdef PNG_READ_oFFs_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "pCAL", PNG_INFO_pCAL, png_pCAL,
|
||||
# ifdef PNG_READ_pCAL_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "pHYs", PNG_INFO_pHYs, png_pHYs,
|
||||
# ifdef PNG_READ_pHYs_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "sBIT", PNG_INFO_sBIT, png_sBIT,
|
||||
# ifdef PNG_READ_sBIT_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "sCAL", PNG_INFO_sCAL, png_sCAL,
|
||||
# ifdef PNG_READ_sCAL_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "sPLT", PNG_INFO_sPLT, png_sPLT,
|
||||
# ifdef PNG_READ_sPLT_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "sRGB", PNG_INFO_sRGB, png_sRGB,
|
||||
# ifdef PNG_READ_sRGB_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "tEXt", PNG_INFO_tEXt, png_tEXt,
|
||||
# ifdef PNG_READ_tEXt_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "tIME", PNG_INFO_tIME, png_tIME,
|
||||
# ifdef PNG_READ_tIME_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "tRNS", PNG_INFO_tRNS, png_tRNS,
|
||||
# ifdef PNG_READ_tRNS_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
0, ABSENT, 0 },
|
||||
{ "zTXt", PNG_INFO_zTXt, png_zTXt,
|
||||
# ifdef PNG_READ_zTXt_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, END, 0 },
|
||||
|
||||
/* No libpng handling */
|
||||
{ "sTER", PNG_INFO_sTER, png_sTER, 1, 1, START, 0 },
|
||||
@@ -156,6 +269,14 @@ static struct
|
||||
|
||||
#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)
|
||||
{
|
||||
@@ -205,34 +326,101 @@ ancillaryb(const png_byte *name)
|
||||
return PNG_CHUNK_ANCILLARY(PNG_CHUNK(name[0], name[1], name[2], name[3]));
|
||||
}
|
||||
|
||||
static int error_count = 0;
|
||||
static int warning_count = 0;
|
||||
/* 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
|
||||
error(png_structp png_ptr, const char *message)
|
||||
init_display(display *d, const char *program)
|
||||
{
|
||||
fprintf(stderr, "libpng error: %s\n", message);
|
||||
exit(1);
|
||||
(void)png_ptr;
|
||||
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)
|
||||
{
|
||||
++warning_count;
|
||||
fprintf(stderr, "libpng warning: %s\n", message);
|
||||
(void)png_ptr;
|
||||
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(const char *file, png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
get_valid(display *d, png_infop info_ptr)
|
||||
{
|
||||
png_uint_32 flags = png_get_valid(png_ptr, info_ptr, (png_uint_32)~0);
|
||||
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(png_ptr, info_ptr, &text, NULL);
|
||||
png_uint_32 ntext = png_get_text(d->png_ptr, info_ptr, &text, NULL);
|
||||
|
||||
while (ntext-- > 0) switch (text[ntext].compression)
|
||||
{
|
||||
@@ -247,9 +435,9 @@ get_valid(const char *file, png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
flags |= PNG_INFO_iTXt;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: unknown text compression %d\n", file,
|
||||
text[ntext].compression);
|
||||
exit(1);
|
||||
fprintf(stderr, "%s(%s): unknown text compression %d\n", d->file,
|
||||
d->test, text[ntext].compression);
|
||||
display_exit(d);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,14 +445,13 @@ get_valid(const char *file, png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
static png_uint_32
|
||||
get_unknown(const char *file, int def, png_const_structp png_ptr,
|
||||
png_const_infop info_ptr)
|
||||
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(png_ptr, info_ptr, &unknown);
|
||||
int num_unknown = png_get_unknown_chunks(d->png_ptr, info_ptr, &unknown);
|
||||
|
||||
while (--num_unknown >= 0)
|
||||
{
|
||||
@@ -279,18 +466,19 @@ get_unknown(const char *file, int def, png_const_structp png_ptr,
|
||||
default: /* impossible */
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
fprintf(stderr, "%s: %s: %s: unknown chunk saved\n",
|
||||
file, def ? "discard" : "default", unknown[num_unknown].name);
|
||||
++error_count;
|
||||
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: if-safe: %s: unknown critical chunk saved\n",
|
||||
file, unknown[num_unknown].name);
|
||||
++error_count;
|
||||
"%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) */
|
||||
@@ -307,35 +495,42 @@ get_unknown(const char *file, int def, png_const_structp png_ptr,
|
||||
}
|
||||
|
||||
static int
|
||||
check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
display *d)
|
||||
{
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr, end_ptr;
|
||||
int i, def = PNG_HANDLE_CHUNK_AS_DEFAULT, npasses, ipass;
|
||||
png_uint_32 height;
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, error, warning);
|
||||
if (png_ptr == NULL)
|
||||
/* 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: could not allocate png struct\n", argv[argc]);
|
||||
fprintf(stderr, "%s(%s): could not allocate png struct\n", d->file,
|
||||
d->test);
|
||||
/* Terminate here, this error is not test specific. */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
end_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL || end_ptr == NULL)
|
||||
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: could not allocate png info\n", argv[argc]);
|
||||
fprintf(stderr, "%s(%s): could not allocate png info\n", d->file,
|
||||
d->test);
|
||||
clean_display(d);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
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=1; i<argc; ++i)
|
||||
for (i=0; i<argc; ++i)
|
||||
{
|
||||
const char *equals = strchr(argv[i], '=');
|
||||
|
||||
@@ -353,8 +548,9 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
option = PNG_HANDLE_CHUNK_ALWAYS;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: unrecognized chunk option\n", argv[i]);
|
||||
exit(2);
|
||||
fprintf(stderr, "%s(%s): %s: unrecognized chunk option\n", d->file,
|
||||
d->test, argv[i]);
|
||||
display_exit(d);
|
||||
}
|
||||
|
||||
switch (equals - argv[i])
|
||||
@@ -373,10 +569,8 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
png_byte name[5];
|
||||
|
||||
memcpy(name, chunk_info[chunk].name, 5);
|
||||
png_set_keep_unknown_chunks(png_ptr, option, name, 1);
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, name, 1);
|
||||
chunk_info[chunk].keep = option;
|
||||
# else
|
||||
(void)option;
|
||||
# endif
|
||||
continue;
|
||||
}
|
||||
@@ -387,9 +581,9 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
if (memcmp(argv[i], "default", 7) == 0)
|
||||
{
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(png_ptr, option, NULL, 0);
|
||||
def = option;
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0);
|
||||
# endif
|
||||
def = option;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -399,7 +593,7 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
if (memcmp(argv[i], "all", 3) == 0)
|
||||
{
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(png_ptr, option, NULL, -1);
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1);
|
||||
def = option;
|
||||
|
||||
for (chunk = 0; chunk < NINFO; ++chunk)
|
||||
@@ -417,13 +611,14 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: unrecognized chunk argument\n", argv[i]);
|
||||
exit(2);
|
||||
fprintf(stderr, "%s(%s): %s: unrecognized chunk argument\n", d->file,
|
||||
d->test, argv[i]);
|
||||
display_exit(d);
|
||||
}
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
png_read_info(d->png_ptr, d->info_ptr);
|
||||
|
||||
switch (png_get_interlace_type(png_ptr, info_ptr))
|
||||
switch (png_get_interlace_type(d->png_ptr, d->info_ptr))
|
||||
{
|
||||
case PNG_INTERLACE_NONE:
|
||||
npasses = 1;
|
||||
@@ -434,7 +629,9 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: invalid interlace type\n", argv[argc]);
|
||||
/* 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);
|
||||
}
|
||||
|
||||
@@ -443,12 +640,12 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
*/
|
||||
if (chunk_info[0/*IDAT*/].keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
{
|
||||
png_start_read_image(png_ptr);
|
||||
height = png_get_image_height(png_ptr, info_ptr);
|
||||
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(png_ptr, info_ptr);
|
||||
png_uint_32 width = png_get_image_width(d->png_ptr, d->info_ptr);
|
||||
|
||||
for (ipass=0; ipass<npasses; ++ipass)
|
||||
{
|
||||
@@ -459,7 +656,7 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
png_uint_32 y;
|
||||
|
||||
for (y=0; y<height; ++y) if (PNG_ROW_IN_INTERLACE_PASS(y, ipass))
|
||||
png_read_row(png_ptr, NULL, NULL);
|
||||
png_read_row(d->png_ptr, NULL, NULL);
|
||||
}
|
||||
}
|
||||
} /* interlaced */
|
||||
@@ -469,49 +666,50 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/)
|
||||
png_uint_32 y;
|
||||
|
||||
for (y=0; y<height; ++y)
|
||||
png_read_row(png_ptr, NULL, NULL);
|
||||
png_read_row(d->png_ptr, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
png_read_end(png_ptr, end_ptr);
|
||||
png_read_end(d->png_ptr, d->end_ptr);
|
||||
|
||||
flags[0] = get_valid(argv[argc], png_ptr, info_ptr);
|
||||
flags[1] = get_unknown(argv[argc], def, png_ptr, info_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(argv[argc], png_ptr, end_ptr);
|
||||
flags[3] = get_unknown(argv[argc], def, png_ptr, end_ptr);
|
||||
flags[2] = get_valid(d, d->end_ptr);
|
||||
flags[3] = get_unknown(d, def, d->end_ptr);
|
||||
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, &end_ptr);
|
||||
clean_display(d);
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
static void
|
||||
check_error(const char *file, png_uint_32 flags, const char *message)
|
||||
check_error(display *d, png_uint_32 flags, const char *message)
|
||||
{
|
||||
while (flags)
|
||||
{
|
||||
png_uint_32 flag = flags & -flags;
|
||||
png_uint_32 flag = flags & -(png_int_32)flags;
|
||||
int i = find_by_flag(flag);
|
||||
|
||||
fprintf(stderr, "%s: chunk %s: %s\n", file, chunk_info[i].name, message);
|
||||
++error_count;
|
||||
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(const char *file, int def, png_uint_32 chunks, png_uint_32 known,
|
||||
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 & -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;
|
||||
@@ -613,71 +811,36 @@ check_handling(const char *file, int def, png_uint_32 chunks, png_uint_32 known,
|
||||
|
||||
if (errorx != NULL)
|
||||
{
|
||||
++error_count;
|
||||
fprintf(stderr, "%s: %s %s %s: %s\n",
|
||||
file, type, chunk_info[i].name, position, errorx);
|
||||
++(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;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
static void
|
||||
perform_one_test(FILE *fp, int argc, const char **argv,
|
||||
png_uint_32 *default_flags, display *d)
|
||||
{
|
||||
FILE *fp;
|
||||
png_uint_32 flags[2/*default/+options*/][4/*valid,unknown{before,after}*/];
|
||||
int def, strict = 0;
|
||||
const char *program = argv[0];
|
||||
const char *count_argv[3];
|
||||
int def;
|
||||
png_uint_32 flags[2][4];
|
||||
|
||||
if (argc > 1 && strcmp(argv[1], "--strict") == 0)
|
||||
{
|
||||
strict = 1;
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (--argc < 1)
|
||||
{
|
||||
fprintf(stderr, "pngunknown: usage:\n"
|
||||
" %s {(CHNK|default|all)=(default|discard|if-safe|save)} testfile.png\n",
|
||||
program);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
# ifndef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
fprintf(stderr,
|
||||
"pngunknown: warning: no 'save' support so arguments ignored\n");
|
||||
# endif
|
||||
fp = fopen(argv[argc], "rb");
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror(argv[argc]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/* First find all the chunks, known and unknown, in the test file: */
|
||||
count_argv[0] = program;
|
||||
count_argv[1] = "default=save";
|
||||
count_argv[2] = argv[argc];
|
||||
(void)check(fp, 2, count_argv, flags[0]);
|
||||
|
||||
/* Now find what the various supplied options cause to change: */
|
||||
rewind(fp);
|
||||
def = check(fp, argc, argv, flags[1]);
|
||||
fclose(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(argc[argv],
|
||||
(flags[0][0]|flags[0][2]) & (flags[0][1]|flags[0][3]),
|
||||
check_error(d, (flags[0][0]|flags[0][2]) & (flags[0][1]|flags[0][3]),
|
||||
"chunk handled inconsistently in count tests");
|
||||
check_error(argc[argv],
|
||||
(flags[1][0]|flags[1][2]) & (flags[1][1]|flags[1][3]),
|
||||
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
|
||||
@@ -689,25 +852,206 @@ main(int argc, const char **argv)
|
||||
png_uint_32 test;
|
||||
|
||||
test = flags[1][0] & ~flags[0][0];
|
||||
check_error(argv[argc], test, "new known chunk before IDAT");
|
||||
check_error(d, test, "new known chunk before IDAT");
|
||||
test = flags[1][1] & ~(flags[0][0] | flags[0][1]);
|
||||
check_error(argv[argc], test, "new unknown chunk before IDAT");
|
||||
check_error(d, test, "new unknown chunk before IDAT");
|
||||
test = flags[1][2] & ~flags[0][2];
|
||||
check_error(argv[argc], test, "new known chunk after IDAT");
|
||||
check_error(d, test, "new known chunk after IDAT");
|
||||
test = flags[1][3] & ~(flags[0][2] | flags[0][3]);
|
||||
check_error(argv[argc], test, "new unknown chunk after IDAT");
|
||||
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(argv[argc], def, flags[0][0] | flags[0][1], flags[1][0],
|
||||
flags[1][1], "before IDAT");
|
||||
check_handling(argv[argc], def, flags[0][2] | flags[0][3], flags[1][2],
|
||||
flags[1][3], "after IDAT");
|
||||
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");
|
||||
}
|
||||
|
||||
return error_count + (strict ? warning_count : 0);
|
||||
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
|
||||
@@ -716,6 +1060,7 @@ main(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
" test ignored because libpng was not built with unknown chunk support\n");
|
||||
return 0;
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
#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.1 [March 28, 2013]
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by John Cunningham Bowler
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
@@ -26,7 +26,7 @@
|
||||
#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
|
||||
|
||||
@@ -107,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
|
||||
@@ -187,7 +191,8 @@ fix(double d)
|
||||
* 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)
|
||||
@@ -240,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)
|
||||
{
|
||||
@@ -249,6 +255,7 @@ random_choice(void)
|
||||
|
||||
return x & 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* A numeric ID based on PNG file characteristics. The 'do_interlace' field
|
||||
@@ -1710,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)
|
||||
{
|
||||
@@ -1729,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,
|
||||
@@ -1963,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)
|
||||
{
|
||||
@@ -1987,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
|
||||
@@ -1999,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
|
||||
@@ -2116,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
|
||||
@@ -2168,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)
|
||||
{
|
||||
@@ -2179,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,
|
||||
@@ -2804,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;
|
||||
@@ -2870,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 *****************************/
|
||||
@@ -3337,7 +3357,7 @@ 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)
|
||||
# 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
|
||||
@@ -4579,9 +4599,13 @@ progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass)
|
||||
}
|
||||
else
|
||||
png_progressive_combine_row(pp, row, new_row);
|
||||
} else if (dp->interlace_type == PNG_INTERLACE_ADAM7 &&
|
||||
PNG_ROW_IN_INTERLACE_PASS(y, pass) &&
|
||||
PNG_PASS_COLS(dp->w, pass) > 0)
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
else if (dp->interlace_type == PNG_INTERLACE_ADAM7 &&
|
||||
PNG_ROW_IN_INTERLACE_PASS(y, pass) &&
|
||||
PNG_PASS_COLS(dp->w, pass) > 0)
|
||||
png_error(pp, "missing row in progressive de-interlacing");
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
}
|
||||
@@ -4734,7 +4758,7 @@ standard_check_text(png_const_structp pp, png_const_textp tp,
|
||||
|
||||
static void
|
||||
standard_text_validate(standard_display *dp, png_const_structp pp,
|
||||
png_const_infop pi)
|
||||
png_infop pi)
|
||||
{
|
||||
png_textp tp = NULL;
|
||||
png_uint_32 num_text = png_get_text(pp, pi, &tp, NULL);
|
||||
@@ -5996,6 +6020,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)
|
||||
@@ -6008,6 +6033,7 @@ image_transform_default_add(image_transform *this,
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
/* png_set_palette_to_rgb */
|
||||
@@ -7686,6 +7712,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:
|
||||
@@ -7703,6 +7730,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:
|
||||
@@ -7735,6 +7763,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;
|
||||
}
|
||||
|
||||
@@ -8134,11 +8165,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:
|
||||
@@ -8866,8 +8899,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,
|
||||
@@ -9057,7 +9090,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)
|
||||
@@ -10090,6 +10125,12 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: open failed\n", touch);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -10098,6 +10139,7 @@ int main(int argc, char **argv)
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "pngvalid: no write support in libpng, all tests skipped\n");
|
||||
return 0;
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
#endif
|
||||
|
||||
104
contrib/libtests/readpng.c
Normal file
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.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
/* tarith.c
|
||||
*
|
||||
* Copyright (c) 2011,2012 John Cunningham Bowler
|
||||
* Copyright (c) 2011-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
|
||||
@@ -92,12 +92,12 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
showall = 1;
|
||||
else if (strcmp(*argv, "-e") == 0 && argc > 0)
|
||||
{
|
||||
--argc;
|
||||
--argc;
|
||||
max_error = atof(*++argv);
|
||||
}
|
||||
else if (strcmp(*argv, "-E") == 0 && argc > 0)
|
||||
{
|
||||
--argc;
|
||||
--argc;
|
||||
max_error_abs = atof(*++argv);
|
||||
}
|
||||
else
|
||||
@@ -118,7 +118,7 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
++nonfinite;
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "%.*g %d\n", DBL_DIG, test, precision);
|
||||
fprintf(stderr, "%.*g %d\n", DBL_DIG, test, precision);
|
||||
|
||||
/* Check for overflow in the buffer by setting a marker. */
|
||||
memset(buffer, 71, sizeof buffer);
|
||||
@@ -131,8 +131,8 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
if (buffer[precision+7] != 71)
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s'[%lu] buffer overflow\n", test,
|
||||
precision, buffer, (unsigned long)strlen(buffer));
|
||||
failed = 1;
|
||||
precision, buffer, (unsigned long)strlen(buffer));
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
/* Following are used for the number parser below and must be
|
||||
@@ -143,19 +143,19 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
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;
|
||||
}
|
||||
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]);
|
||||
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))
|
||||
@@ -185,21 +185,21 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
else
|
||||
{
|
||||
/* Check the result against the original. */
|
||||
double out = atof(buffer);
|
||||
double change = fabs((out - test)/test);
|
||||
double allow = .5/pow(10,
|
||||
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))
|
||||
{
|
||||
/* 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;
|
||||
|
||||
@@ -213,16 +213,16 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,15 +239,15 @@ skip:
|
||||
|
||||
/* Generate random numbers. */
|
||||
if (test == 0 || !isfinite(test))
|
||||
test = precision+1;
|
||||
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 */
|
||||
/* 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
|
||||
@@ -646,17 +646,17 @@ int validation_muldiv(int count, int argc, char **argv)
|
||||
*/
|
||||
{
|
||||
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;
|
||||
}
|
||||
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;
|
||||
@@ -664,48 +664,48 @@ int validation_muldiv(int count, int argc, char **argv)
|
||||
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;
|
||||
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;
|
||||
/* 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;
|
||||
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");
|
||||
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);
|
||||
++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);
|
||||
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);
|
||||
fp);
|
||||
}
|
||||
else
|
||||
++passed;
|
||||
@@ -775,7 +775,7 @@ int validation_gamma(int argc, char **argv)
|
||||
/* Silence the output with -s, just test the gamma functions with -g: */
|
||||
while (--argc > 0)
|
||||
if (strcmp(*++argv, "-s") == 0)
|
||||
silent = 1;
|
||||
silent = 1;
|
||||
else if (strcmp(*argv, "-g") == 0)
|
||||
onlygamma = 1;
|
||||
else
|
||||
@@ -790,100 +790,100 @@ int validation_gamma(int argc, char **argv)
|
||||
maxerr = 0;
|
||||
for (i=0; i<256; ++i)
|
||||
{
|
||||
double correct = -log(i/255.)/log(2.)*65536;
|
||||
double error = png_log8bit(i) - correct;
|
||||
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 && 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 (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);
|
||||
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;
|
||||
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 && 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 (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);
|
||||
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;
|
||||
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 (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);
|
||||
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;
|
||||
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 (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);
|
||||
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;
|
||||
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 (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);
|
||||
printf("maximum 16 bit exp error = %f\n", maxerr);
|
||||
} /* !onlygamma */
|
||||
|
||||
/* Test the overall gamma correction. */
|
||||
@@ -894,45 +894,45 @@ int validation_gamma(int argc, char **argv)
|
||||
png_fixed_point gfp = floor(g * PNG_FP_1 + .5);
|
||||
|
||||
if (!silent)
|
||||
printf("Test gamma %f\n", g);
|
||||
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;
|
||||
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 (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);
|
||||
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;
|
||||
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 (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);
|
||||
printf("gamma %f: maximum 16 bit error %f\n", g, maxerr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run the simplified API tests
|
||||
err=0
|
||||
|
||||
echo >> pngtest-log.txt
|
||||
echo "============ pngstest.sh ==============" >> pngtest-log.txt
|
||||
|
||||
echo "Running test-pngstest.sh"
|
||||
for image in ${srcdir}/contrib/pngsuite/*.png
|
||||
do
|
||||
for opts in ""
|
||||
do
|
||||
if ./pngstest --strict --log "$@" $opts $image >>pngtest-log.txt 2>&1
|
||||
then
|
||||
echo " PASS: pngstest $opts $image"
|
||||
else
|
||||
echo " FAIL: pngstest $opts $image"
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
exit $err
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run the unknown API tests
|
||||
err=0
|
||||
image="${srcdir}/pngtest.png"
|
||||
#
|
||||
# stream 4 is used for the output of the shell, pngtest-log.txt gets all the
|
||||
# normal program output.
|
||||
exec 4>&1 1>>pngtest-log.txt 2>&1
|
||||
|
||||
echo
|
||||
echo "============ test-pngunknown.sh =============="
|
||||
|
||||
echo "Running test-pngunknown.sh" >&4
|
||||
|
||||
for tests in \
|
||||
"discard default=discard"\
|
||||
"save default=save"\
|
||||
"if-safe default=if-safe"\
|
||||
"vpAg vpAg=if-safe"\
|
||||
"sTER sTER=if-safe"\
|
||||
"IDAT default=discard IDAT=save"\
|
||||
"sAPI bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save"
|
||||
do
|
||||
set $tests
|
||||
test="$1"
|
||||
shift
|
||||
|
||||
if ./pngunknown "$@" "$image" 4>&-
|
||||
then
|
||||
echo " PASS: test-pngunknown $test" >&4
|
||||
else
|
||||
echo " FAIL: test-pngunknown $test" >&4
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $err
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run a sequence of gamma tests quietly
|
||||
err=0
|
||||
|
||||
echo >> pngtest-log.txt
|
||||
echo "============ pngvalid-full.sh ==============" >> pngtest-log.txt
|
||||
|
||||
echo "Running test-pngvalid-full.sh"
|
||||
for gamma in threshold transform sbit 16-to-8 background alpha-mode "transform --expand16" "background --expand16" "alpha-mode --expand16"
|
||||
do
|
||||
if ./pngvalid "$@" --gamma-$gamma >> pngtest-log.txt 2>&1
|
||||
then
|
||||
echo " PASS: pngvalid" "$@" "--gamma-$gamma"
|
||||
else
|
||||
echo " FAIL: pngvalid" "$@" "--gamma-$gamma"
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $err
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run a sequence of tests quietly, without the slow
|
||||
# gamma tests
|
||||
err=0
|
||||
|
||||
echo >> pngtest-log.txt
|
||||
echo "============ pngvalid-simple.sh ==============" >> pngtest-log.txt
|
||||
echo "Running test-pngvalid-simple.sh"
|
||||
# The options to test are:
|
||||
#
|
||||
# standard tests with and without progressive reading and interlace
|
||||
# size images with and without progressive reading
|
||||
# transform tests (standard, non-interlaced only)
|
||||
#
|
||||
for opts in "--standard" "--standard --progressive-read" \
|
||||
"--standard --interlace" "--standard --progressive-read --interlace" \
|
||||
"--size" "--size --progressive-read" \
|
||||
"--transform"
|
||||
do
|
||||
if ./pngvalid "$@" $opts >> pngtest-log.txt 2>&1
|
||||
then
|
||||
echo " PASS: pngvalid" "$@" $opts
|
||||
else
|
||||
echo " FAIL: pngvalid" "$@" $opts
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $err
|
||||
@@ -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.1 [March 28, 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
|
||||
|
||||
@@ -252,7 +252,7 @@ int main(int argc, char **argv)
|
||||
|
||||
while (fgets(filename, FILENAME_MAX+1, stdin))
|
||||
{
|
||||
int len = strlen(filename);
|
||||
size_t len = strlen(filename);
|
||||
|
||||
if (filename[len-1] == '\n')
|
||||
{
|
||||
|
||||
@@ -14,7 +14,8 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. -O1
|
||||
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@@ -81,7 +82,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
|
||||
# note: dependencies do not work on implicit rule lines
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
|
||||
|
||||
# dependencies
|
||||
|
||||
@@ -95,12 +96,12 @@ pngm2pnm$(E): $(OBJS)
|
||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||
# both the build of pnglibconf.h and, subsequently, when
|
||||
# building libpng itself.
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,8 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZIP -I. -O1
|
||||
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@@ -80,7 +81,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
|
||||
|
||||
# dependencies
|
||||
|
||||
@@ -94,12 +95,12 @@ pnm2pngm$(E): $(OBJS)
|
||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||
# both the build of pnglibconf.h and, subsequently, when
|
||||
# building libpng itself.
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
|
||||
@@ -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
|
||||
@@ -13,6 +13,9 @@ everything = off
|
||||
# Switch on the write code - this makes a minimalist encoder
|
||||
|
||||
option WRITE on
|
||||
# These 2 options are required if you need to read PGM (P1 or P4) PGM files.
|
||||
# option WRITE_INVERT on
|
||||
# option WRITE_PACK on
|
||||
|
||||
# You must choose fixed or floating point arithmetic:
|
||||
# option FLOATING_POINT on
|
||||
|
||||
@@ -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,8 @@ 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
|
||||
CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@@ -96,7 +97,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
|
||||
|
||||
# dependencies
|
||||
|
||||
@@ -110,12 +111,12 @@ rpng2-x$(E): $(OBJS)
|
||||
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||
# both the build of pnglibconf.h and, subsequently, when
|
||||
# building libpng itself.
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -198,9 +198,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
char height_token[16];
|
||||
char maxval_token[16];
|
||||
int color_type;
|
||||
unsigned long ul_width, ul_alpha_width;
|
||||
unsigned long ul_height, ul_alpha_height;
|
||||
unsigned long ul_maxval;
|
||||
unsigned long ul_width=0, ul_alpha_width=0;
|
||||
unsigned long ul_height=0, ul_alpha_height=0;
|
||||
unsigned long ul_maxval=0;
|
||||
png_uint_32 width, alpha_width;
|
||||
png_uint_32 height, alpha_height;
|
||||
png_uint_32 maxval;
|
||||
@@ -210,6 +210,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
int alpha_present;
|
||||
int row, col;
|
||||
BOOL raw, alpha_raw = FALSE;
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
BOOL packed_bitmap = FALSE;
|
||||
#endif
|
||||
png_uint_32 tmp16;
|
||||
int i;
|
||||
|
||||
@@ -222,9 +225,21 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
}
|
||||
else if ((type_token[1] == '1') || (type_token[1] == '4'))
|
||||
{
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
raw = (type_token[1] == '4');
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
get_token(pnm_file, width_token);
|
||||
sscanf (width_token, "%lu", &ul_width);
|
||||
width = (png_uint_32) ul_width;
|
||||
get_token(pnm_file, height_token);
|
||||
sscanf (height_token, "%lu", &ul_height);
|
||||
height = (png_uint_32) ul_height;
|
||||
bit_depth = 1;
|
||||
packed_bitmap = TRUE;
|
||||
#else
|
||||
fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n");
|
||||
fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
|
||||
#endif
|
||||
}
|
||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||
{
|
||||
@@ -343,8 +358,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
|
||||
alpha_present = (channels - 1) % 2;
|
||||
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap)
|
||||
/* row data is as many bytes as can fit width x channels x bit_depth */
|
||||
row_bytes = (width * channels * bit_depth + 7) / 8;
|
||||
else
|
||||
#endif
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
|
||||
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL)
|
||||
return FALSE;
|
||||
@@ -354,40 +375,48 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
for (col = 0; col < width; col++)
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap) {
|
||||
for (i = 0; i < row_bytes; i++)
|
||||
/* png supports this format natively so no conversion is needed */
|
||||
*pix_ptr++ = get_data (pnm_file, 8);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
if (raw)
|
||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
||||
else
|
||||
if (bit_depth <= 8)
|
||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
{
|
||||
if (raw)
|
||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (pnm_file, bit_depth);
|
||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
pix_ptr++;
|
||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
||||
pix_ptr++;
|
||||
}
|
||||
}
|
||||
if (bit_depth <= 8)
|
||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (pnm_file, bit_depth);
|
||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
pix_ptr++;
|
||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
||||
pix_ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
if (alpha) /* read alpha-channel from pgm file */
|
||||
{
|
||||
if (alpha_raw)
|
||||
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
||||
else
|
||||
if (alpha_depth <= 8)
|
||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||
if (alpha) /* read alpha-channel from pgm file */
|
||||
{
|
||||
if (alpha_raw)
|
||||
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||
}
|
||||
} /* if alpha */
|
||||
|
||||
if (alpha_depth <= 8)
|
||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||
}
|
||||
} /* if alpha */
|
||||
} /* if packed_bitmap */
|
||||
} /* end for col */
|
||||
} /* end for row */
|
||||
|
||||
@@ -404,6 +433,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap == TRUE)
|
||||
{
|
||||
png_set_packing (png_ptr);
|
||||
png_set_invert_mono (png_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
{
|
||||
@@ -460,19 +497,32 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
void get_token(FILE *pnm_file, char *token)
|
||||
{
|
||||
int i = 0;
|
||||
int ret;
|
||||
|
||||
/* remove white-space */
|
||||
/* remove white-space and comment lines */
|
||||
do
|
||||
{
|
||||
token[i] = (unsigned char) fgetc (pnm_file);
|
||||
ret = fgetc(pnm_file);
|
||||
if (ret == '#') {
|
||||
/* the rest of this line is a comment */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
}
|
||||
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
|
||||
}
|
||||
if (ret == EOF) break;
|
||||
token[i] = (unsigned char) ret;
|
||||
}
|
||||
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
|
||||
|
||||
/* read string */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
if (ret == EOF) break;
|
||||
i++;
|
||||
token[i] = (unsigned char) fgetc (pnm_file);
|
||||
token[i] = (unsigned char) ret;
|
||||
}
|
||||
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* checksum-icc.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
|
||||
|
||||
@@ -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.
|
||||
|
||||
153
contrib/tools/png-fix-itxt.c
Normal file
153
contrib/tools/png-fix-itxt.c
Normal file
@@ -0,0 +1,153 @@
|
||||
|
||||
/* png-fix-itxt version 1.0.0
|
||||
*
|
||||
* Copyright 2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.3 [July 18, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* png-fix-itxt.exe < bad.png > good.png
|
||||
*
|
||||
* Fixes a PNG file written with libpng-1.6.0 or 1.6.1 that has one or more
|
||||
* uncompressed iTXt chunks. Assumes that the actual length is greater
|
||||
* than or equal to the value in the length byte, and that the CRC is
|
||||
* correct for the actual length. This program hunts for the CRC and
|
||||
* adjusts the length byte accordingly. It is not an error to process a
|
||||
* PNG file that has no iTXt chunks or one that has valid iTXt chunks;
|
||||
* such files will simply be copied.
|
||||
*
|
||||
* Requires zlib (for crc32 and Z_NULL); build with
|
||||
*
|
||||
* gcc -O -o png-fix-itxt png-fix-itxt.c -lz
|
||||
*
|
||||
* If you need to handle iTXt chunks larger than 500000 kbytes you must
|
||||
* rebuild png-fix-itxt with a larger values of MAX_LENGTH (or a smaller value
|
||||
* if you know you will never encounter such huge iTXt chunks).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#define MAX_LENGTH 500000
|
||||
|
||||
#define GETBREAK ((unsigned char)(inchar=getchar())); if (inchar == EOF) break
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned char buf[MAX_LENGTH];
|
||||
unsigned long crc;
|
||||
unsigned char c;
|
||||
int inchar;
|
||||
|
||||
/* Skip 8-byte signature */
|
||||
for (i=8; i; i--)
|
||||
{
|
||||
c=GETBREAK;
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
if (inchar != EOF)
|
||||
for (;;)
|
||||
{
|
||||
/* Read the length */
|
||||
unsigned long length; /* must be 32 bits! */
|
||||
c=GETBREAK; buf[0] = c; length = c; length <<= 8;
|
||||
c=GETBREAK; buf[1] = c; length += c; length <<= 8;
|
||||
c=GETBREAK; buf[2] = c; length += c; length <<= 8;
|
||||
c=GETBREAK; buf[3] = c; length += c;
|
||||
|
||||
/* Read the chunkname */
|
||||
c=GETBREAK; buf[4] = c;
|
||||
c=GETBREAK; buf[5] = c;
|
||||
c=GETBREAK; buf[6] = c;
|
||||
c=GETBREAK; buf[7] = c;
|
||||
|
||||
|
||||
/* The iTXt chunk type expressed as integers is (105, 84, 88, 116) */
|
||||
if (buf[4] == 105 && buf[5] == 84 && buf[6] == 88 && buf[7] == 116)
|
||||
{
|
||||
if (length >= MAX_LENGTH-12)
|
||||
break; /* To do: handle this more gracefully */
|
||||
|
||||
/* Initialize the CRC */
|
||||
crc = crc32(0, Z_NULL, 0);
|
||||
|
||||
/* Copy the data bytes */
|
||||
for (i=8; i < length + 12; i++)
|
||||
{
|
||||
c=GETBREAK; buf[i] = c;
|
||||
}
|
||||
|
||||
/* Calculate the CRC */
|
||||
crc = crc32(crc, buf+4, (uInt)length+4);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Check the CRC */
|
||||
if (((crc >> 24) & 0xff) == buf[length+8] &&
|
||||
((crc >> 16) & 0xff) == buf[length+9] &&
|
||||
((crc >> 8) & 0xff) == buf[length+10] &&
|
||||
((crc ) & 0xff) == buf[length+11])
|
||||
break;
|
||||
|
||||
length++;
|
||||
|
||||
if (length >= MAX_LENGTH-12)
|
||||
break;
|
||||
|
||||
c=GETBREAK;
|
||||
buf[length+11]=c;
|
||||
|
||||
/* Update the CRC */
|
||||
crc = crc32(crc, buf+7+length, 1);
|
||||
}
|
||||
|
||||
/* Update length bytes */
|
||||
buf[0] = (unsigned char)((length << 24) & 0xff);
|
||||
buf[1] = (unsigned char)((length << 16) & 0xff);
|
||||
buf[2] = (unsigned char)((length << 8) & 0xff);
|
||||
buf[3] = (unsigned char)((length ) & 0xff);
|
||||
|
||||
/* Write the fixed iTXt chunk (length, name, data, crc) */
|
||||
for (i=0; i<length+12; i++)
|
||||
putchar(buf[i]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Copy bytes that were already read (length and chunk name) */
|
||||
for (i=0; i<8; i++)
|
||||
putchar(buf[i]);
|
||||
|
||||
/* Copy data bytes and CRC */
|
||||
for (i=8; i< length+12; i++)
|
||||
{
|
||||
c=GETBREAK;
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
if (inchar == EOF)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* The IEND chunk type expressed as integers is (73, 69, 78, 68) */
|
||||
if (buf[4] == 73 && buf[5] == 69 && buf[6] == 78 && buf[7] == 68)
|
||||
break;
|
||||
}
|
||||
|
||||
if (inchar == EOF)
|
||||
break;
|
||||
|
||||
if (buf[4] == 73 && buf[5] == 69 && buf[6] == 78 && buf[7] == 68)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
4010
contrib/tools/pngfix.c
Normal file
4010
contrib/tools/pngfix.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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.
|
||||
|
||||
31
example.c
31
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.3 [July 18, 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
|
||||
@@ -49,6 +49,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
/* Initialize the 'png_image' structure. */
|
||||
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);
|
||||
@@ -428,9 +441,9 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
/* If we don't have another value */
|
||||
else
|
||||
{
|
||||
screen_gamma = 2.2; /* A good guess for a PC monitor in a dimly
|
||||
lit room */
|
||||
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
||||
screen_gamma = PNG_DEFAULT_sRGB; /* A good guess for a PC monitor
|
||||
in a dimly lit room */
|
||||
screen_gamma = PNG_GAMMA_MAC_18 or 1.0; /* Good guesses for Mac systems */
|
||||
}
|
||||
|
||||
/* Tell libpng to handle the gamma conversion for you. The final call
|
||||
@@ -442,7 +455,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
int intent;
|
||||
|
||||
if (png_get_sRGB(png_ptr, info_ptr, &intent))
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||
png_set_gamma(png_ptr, screen_gamma, PNG_DEFAULT_sRGB);
|
||||
else
|
||||
{
|
||||
double image_gamma;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.6.0beta28 - August 29, 2012
|
||||
libpng version 1.6.3 - July 18, 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.0beta28 - August 29, 2012
|
||||
libpng versions 0.97, January 1998, through 1.6.3 - July 18, 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
|
||||
@@ -50,9 +50,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
I. Introduction
|
||||
|
||||
This file describes how to use and modify the PNG reference library
|
||||
(known as libpng) for your own use. There are five sections to this
|
||||
file: introduction, structures, reading, writing, and modification and
|
||||
configuration notes for various special platforms. In addition to this
|
||||
(known as libpng) for your own use. In addition to this
|
||||
file, example.c is a good starting point for using the library, as
|
||||
it is heavily commented and should include everything most people
|
||||
will need. We assume that libpng is already installed; see the
|
||||
@@ -67,7 +65,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.
|
||||
|
||||
@@ -527,9 +525,14 @@ you can retrieve with
|
||||
png_get_user_chunk_ptr(png_ptr);
|
||||
|
||||
If you call the png_set_read_user_chunk_fn() function, then all unknown
|
||||
chunks will be saved when read, in case your callback function will need
|
||||
one or more of them. This behavior can be changed with the
|
||||
png_set_keep_unknown_chunks() function, described below.
|
||||
chunks which the callback does not handle will be saved when read. You can
|
||||
cause them to be discarded by returning '1' ("handled") instead of '0'. This
|
||||
behavior will change in libpng 1.7 and the default handling set by the
|
||||
png_set_keep_unknown_chunks() function, described below, will be used when the
|
||||
callback returns 0. If you want the existing behavior you should set the global
|
||||
default to PNG_HANDLE_CHUNK_IF_SAFE now; this is compatible with all current
|
||||
versions of libpng and with 1.7. Libpng 1.6 issues a warning if you keep the
|
||||
default, or PNG_HANDLE_CHUNK_NEVER, and the callback returns 0.
|
||||
|
||||
At this point, you can set up a callback function that will be
|
||||
called after each row has been read, which you can use to control
|
||||
@@ -628,15 +631,17 @@ callback function:
|
||||
...
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* ignore all unknown chunks: */
|
||||
png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
|
||||
/* ignore all unknown chunks
|
||||
* (use global setting "2" for libpng16 and earlier):
|
||||
*/
|
||||
png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0);
|
||||
|
||||
/* except for vpAg: */
|
||||
png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
|
||||
|
||||
/* 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
|
||||
@@ -675,9 +680,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
|
||||
|
||||
@@ -991,7 +993,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");
|
||||
|
||||
@@ -1000,7 +1002,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 */
|
||||
@@ -2287,7 +2289,7 @@ For a more compact example of reading a PNG image, see the file example.c.
|
||||
|
||||
Reading PNG files progressively
|
||||
|
||||
The progressive reader is slightly different then the non-progressive
|
||||
The progressive reader is slightly different from the non-progressive
|
||||
reader. Instead of calling png_read_info(), png_read_rows(), and
|
||||
png_read_end(), you make one call to png_process_data(), which calls
|
||||
callbacks when it has the info, a row, or the end of the image. You
|
||||
@@ -2567,6 +2569,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
|
||||
@@ -3069,19 +3085,53 @@ 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_buffer(buffer, png_timep) is provided to convert
|
||||
from PNG time to an RFC 1123 format string. The caller must provide
|
||||
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
|
||||
|
||||
You can use the png_set_unknown_chunks function to queue up chunks
|
||||
for writing. You give it a chunk name, raw data, and a size; that's
|
||||
all there is to it. The chunks will be written by the next following
|
||||
png_write_info_before_PLTE, png_write_info, or png_write_end function.
|
||||
Any chunks previously read into the info structure's unknown-chunk
|
||||
list will also be written out in a sequence that satisfies the PNG
|
||||
specification's ordering rules.
|
||||
You can use the png_set_unknown_chunks function to queue up private chunks
|
||||
for writing. You give it a chunk name, location, raw data, and a size. You
|
||||
also must use png_set_keep_unknown_chunks() to ensure that libpng will
|
||||
handle them. That's all there is to it. The chunks will be written by the
|
||||
next following png_write_info_before_PLTE, png_write_info, or png_write_end
|
||||
function, depending upon the specified location. Any chunks previously
|
||||
read into the info structure's unknown-chunk list will also be written out
|
||||
in a sequence that satisfies the PNG specification's ordering rules.
|
||||
|
||||
Here is an example of writing two private chunks, prVt and miNE:
|
||||
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Set unknown chunk data */
|
||||
png_unknown_chunk unk_chunk[2];
|
||||
strcpy((char *) unk_chunk[0].name, "prVt";
|
||||
unk_chunk[0].data = (unsigned char *) "PRIVATE DATA";
|
||||
unk_chunk[0].size = strlen(unk_chunk[0].data)+1;
|
||||
unk_chunk[0].location = PNG_HAVE_IHDR;
|
||||
strcpy((char *) unk_chunk[1].name, "miNE";
|
||||
unk_chunk[1].data = (unsigned char *) "MY CHUNK DATA";
|
||||
unk_chunk[1].size = strlen(unk_chunk[0].data)+1;
|
||||
unk_chunk[1].location = PNG_AFTER_IDAT;
|
||||
png_set_unknown_chunks(write_ptr, write_info_ptr,
|
||||
unk_chunk, 2);
|
||||
/* Needed because miNE is not safe-to-copy */
|
||||
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
|
||||
(png_bytep) "miNE", 1);
|
||||
# if PNG_LIBPNG_VER < 10600
|
||||
/* Deal with unknown chunk location bug in 1.5.x and earlier */
|
||||
png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
|
||||
png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT);
|
||||
# endif
|
||||
# if PNG_LIBPNG_VER < 10500
|
||||
/* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0,
|
||||
* one before IDAT and another after IDAT, so don't use it; only use
|
||||
* PNG_HAVE_IHDR location. This call resets the location previously
|
||||
* set by assignment and png_set_unknown_chunk_location() for chunk 1.
|
||||
*/
|
||||
png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
The high-level write interface
|
||||
|
||||
@@ -3524,16 +3574,17 @@ 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
|
||||
png_const_bytep colormap A pointer to the application color-map
|
||||
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 wrning_or_error
|
||||
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
|
||||
@@ -3689,6 +3740,22 @@ First the information about the samples.
|
||||
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)
|
||||
@@ -3747,7 +3814,8 @@ 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.
|
||||
@@ -3784,6 +3852,7 @@ 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
|
||||
@@ -3791,15 +3860,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*).
|
||||
|
||||
@@ -3949,6 +4020,18 @@ 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: treat png_benign_error() as an error.
|
||||
1: treat png_benign_error() as a warning.
|
||||
|
||||
As of libpng-1.6.0, the default condition is to treat benign errors as
|
||||
warnings while reading and as errors while writing.
|
||||
|
||||
Custom chunks
|
||||
|
||||
If you need to read or write custom chunks, you may need to get deeper
|
||||
@@ -4219,7 +4302,7 @@ the message, "message" is the formatted string to be printed,
|
||||
and p1 and p2 are parameters that are to be embedded in the string
|
||||
according to printf-style formatting directives. For example,
|
||||
|
||||
png_debug1(2, "foo=%d\n", foo);
|
||||
png_debug1(2, "foo=%d", foo);
|
||||
|
||||
is expanded to
|
||||
|
||||
@@ -4541,13 +4624,34 @@ 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 but can be disabled in each png_ptr with
|
||||
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
|
||||
1: enable
|
||||
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
|
||||
|
||||
@@ -4854,25 +4958,44 @@ 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.
|
||||
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
|
||||
need access to information in string.h must add an '#include "string.h"'
|
||||
need access to information in string.h must add an '#include <string.h>'
|
||||
directive. It does not matter whether this is placed prior to or after
|
||||
the '"#include png.h"' directive.
|
||||
the '#include "png.h"' directive.
|
||||
|
||||
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
|
||||
@@ -4880,7 +5003,62 @@ The following has been removed:
|
||||
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
|
||||
since libpng-1.5.0.
|
||||
(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 PNG spec requirement that
|
||||
only grayscale profiles may appear in images with color type 0 or 4 and that
|
||||
even if the image only contains gray pixels, only RGB profiles may appear
|
||||
in images with color type 2, 3, or 6, is now enforced. The sRGB chunk
|
||||
is allowed to appear in images with any color type.
|
||||
|
||||
Prior to libpng-1.6.0 a warning would be issued if the iTXt chunk contained
|
||||
an empty language field or an empty translated keyword. Both of these
|
||||
are allowed by the PNG specification, so these warnings are no longer issued.
|
||||
|
||||
The library now issues an error if the application attempts to set a
|
||||
transform after it calls png_read_update_info().
|
||||
|
||||
The default condition for benign_errors is now to treat benign errors as
|
||||
warnings while reading and as errors while writing.
|
||||
|
||||
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.
|
||||
|
||||
Libpng-1.6.0 and later use the CMF bytes at the beginning of the IDAT stream
|
||||
to set the size of the sliding window for reading instead of using the default
|
||||
32-kbyte sliding window size. It was discovered that there are hundreds of PNG
|
||||
files in the wild that have incorrect CMF bytes that cause libpng to now issue
|
||||
a "too far back" error and reject the file. Libpng-1.6.3 provides a way to
|
||||
revert to the libpng-1.5.x behavior (ignoring the CMF bytes and using a
|
||||
32-kbyte sliding window), and provides a tool
|
||||
(contrib/tools/png-fix-too-far-back) for optimizing the CMF bytes
|
||||
correctly.
|
||||
|
||||
Libpng-1.6.0 and libpng-1.6.1 wrote uncompressed iTXt chunks with the wrong
|
||||
length, which resulted in PNG files that cannot be read beyond the bad iTXt
|
||||
chunk. This error was fixed in libpng-1.6.3, and a tool (called
|
||||
contrib/tools/png-fix-itxt) has been added to the libpng distribution.
|
||||
|
||||
XIII. Detecting libpng
|
||||
|
||||
@@ -4898,11 +5076,11 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files
|
||||
going back to version 0.70. You can access the git repository (read only)
|
||||
at
|
||||
|
||||
git://libpng.git.sourceforge.net/gitroot/libpng
|
||||
git://git.code.sf.net/p/libpng/code
|
||||
|
||||
or you can browse it via "gitweb" at
|
||||
or you can browse it with a web browser by selecting the "code" button at
|
||||
|
||||
http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng
|
||||
https://sourceforge.net/projects/libpng
|
||||
|
||||
Patches can be sent to glennrp at users.sourceforge.net or to
|
||||
png-mng-implement at lists.sourceforge.net or you can upload them to
|
||||
@@ -4998,7 +5176,7 @@ 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
|
||||
@@ -5012,7 +5190,7 @@ 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
|
||||
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.
|
||||
|
||||
@@ -5026,8 +5204,9 @@ 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).
|
||||
@@ -5043,13 +5222,13 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
XVI. Y2K Compliance in libpng
|
||||
|
||||
August 29, 2012
|
||||
July 18, 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.0beta28 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.6.3 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
|
||||
16
libpngpf.3
16
libpngpf.3
@@ -1,21 +1,11 @@
|
||||
.TH LIBPNGPF 3 "August 29, 2012"
|
||||
.TH LIBPNGPF 3 "July 18, 2013"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.0beta28
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.3
|
||||
(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
2
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "August 29, 2012"
|
||||
.TH PNG 5 "July 18, 2013"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
||||
161
png.h
161
png.h
@@ -1,8 +1,8 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.0beta28 - August 29, 2012
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* libpng version 1.6.3 - July 18, 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.)
|
||||
*
|
||||
@@ -11,7 +11,7 @@
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.0beta28 - August 29, 2012: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.6.3 - July 18, 2013: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
@@ -166,7 +166,18 @@
|
||||
* 1.5.7beta01-05 15 10507 15.so.15.7[.0]
|
||||
* 1.5.7rc01-03 15 10507 15.so.15.7[.0]
|
||||
* 1.5.7 15 10507 15.so.15.7[.0]
|
||||
* 1.6.0beta01-28 16 10600 16.so.16.0[.0]
|
||||
* 1.6.0beta01-40 16 10600 16.so.16.0[.0]
|
||||
* 1.6.0rc01-08 16 10600 16.so.16.0[.0]
|
||||
* 1.6.0 16 10600 16.so.16.0[.0]
|
||||
* 1.6.1beta01-09 16 10601 16.so.16.1[.0]
|
||||
* 1.6.1rc01 16 10601 16.so.16.1[.0]
|
||||
* 1.6.1 16 10601 16.so.16.1[.0]
|
||||
* 1.6.2beta01 16 10602 16.so.16.2[.0]
|
||||
* 1.6.2rc01-06 16 10602 16.so.16.2[.0]
|
||||
* 1.6.2 16 10602 16.so.16.2[.0]
|
||||
* 1.6.3beta01-11 16 10603 16.so.16.3[.0]
|
||||
* 1.6.3rc01 16 10603 16.so.16.3[.0]
|
||||
* 1.6.3 16 10603 16.so.16.3[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
@@ -198,8 +209,8 @@
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.0beta28, August 29, 2012, are
|
||||
* Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.3, July 18, 2013, are
|
||||
* Copyright (c) 2004, 2006-2013 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:
|
||||
*
|
||||
@@ -310,13 +321,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* August 29, 2012
|
||||
* July 18, 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.0beta28 are Y2K compliant. It is my belief that
|
||||
* upward through 1.6.3 are Y2K compliant. It is my belief that
|
||||
* earlier versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
@@ -376,9 +387,9 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.0beta28"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.3"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.6.0beta28 - August 29, 2012\n"
|
||||
" libpng version 1.6.3 - July 18, 2013\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
@@ -386,13 +397,13 @@
|
||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 6
|
||||
#define PNG_LIBPNG_VER_RELEASE 0
|
||||
#define PNG_LIBPNG_VER_RELEASE 3
|
||||
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
*/
|
||||
|
||||
#define PNG_LIBPNG_VER_BUILD 28
|
||||
#define PNG_LIBPNG_VER_BUILD 0
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@@ -409,7 +420,7 @@
|
||||
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
|
||||
PNG_LIBPNG_BUILD_PRIVATE */
|
||||
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
|
||||
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||
* We must not include leading zeros.
|
||||
@@ -417,7 +428,7 @@
|
||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10600 /* 1.6.0 */
|
||||
#define PNG_LIBPNG_VER 10603 /* 1.6.3 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
@@ -522,7 +533,7 @@ extern "C" {
|
||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_6_0beta28;
|
||||
typedef char* png_libpng_version_1_6_3;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
@@ -1835,7 +1846,7 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* This callback is called only for *unknown* chunks, if
|
||||
/* This callback is called only for *unknown* chunks. If
|
||||
* PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known
|
||||
* chunks to be treated as unknown, however in this case the callback must do
|
||||
* any processing required by the chunk (e.g. by calling the appropriate
|
||||
@@ -1847,12 +1858,12 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
|
||||
* The integer return from the callback function is interpreted thus:
|
||||
*
|
||||
* negative: An error occured, png_chunk_error will be called.
|
||||
* zero: The chunk was not handled, the chunk will be discarded unless
|
||||
* png_set_keep_unknown_chunks has been used to set a 'keep' behavior
|
||||
* for this particular chunk, in which case that will be used. A
|
||||
* critical chunk will cause an error at this point unless it is to be
|
||||
* saved.
|
||||
* zero: The chunk was not handled, the chunk will be saved. A critical
|
||||
* chunk will cause an error at this point unless it is to be saved.
|
||||
* positive: The chunk was handled, libpng will ignore/discard it.
|
||||
*
|
||||
* See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about
|
||||
* how this behavior will change in libpng 1.7
|
||||
*/
|
||||
PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,
|
||||
png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
|
||||
@@ -2182,7 +2193,7 @@ PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_uint_16p *hist));
|
||||
png_inforp info_ptr, png_uint_16p *hist));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
@@ -2214,7 +2225,7 @@ PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_charp *purpose, png_int_32 *X0,
|
||||
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));
|
||||
#endif
|
||||
@@ -2237,7 +2248,7 @@ PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_colorp *palette, int *num_palette));
|
||||
png_inforp info_ptr, png_colorp *palette, int *num_palette));
|
||||
|
||||
PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_colorp palette, int num_palette));
|
||||
@@ -2266,7 +2277,7 @@ PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_charpp name, int *compression_type,
|
||||
png_inforp info_ptr, png_charpp name, int *compression_type,
|
||||
png_bytepp profile, png_uint_32 *proflen));
|
||||
#endif
|
||||
|
||||
@@ -2277,8 +2288,8 @@ PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
PNG_EXPORT(160, png_uint_32, png_get_sPLT, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_sPLT_tpp entries));
|
||||
PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_sPLT_tpp entries));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
@@ -2288,8 +2299,8 @@ PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
/* png_get_text also returns the number of text chunks in *num_text */
|
||||
PNG_EXPORT(162, png_uint_32, png_get_text, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_textp *text_ptr, int *num_text));
|
||||
PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_textp *text_ptr, int *num_text));
|
||||
#endif
|
||||
|
||||
/* Note while png_set_text() will accept a structure whose text,
|
||||
@@ -2329,8 +2340,8 @@ PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, int *unit, double *width, double *height))
|
||||
#if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||
(defined PNG_FLOATING_POINT_SUPPORTED)
|
||||
#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* NOTE: this API is currently implemented using floating point arithmetic,
|
||||
* consequently it can only be used on systems with floating point support.
|
||||
* In any case the range of values supported by png_fixed_point is small and it
|
||||
@@ -2370,7 +2381,7 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
|
||||
* READ:
|
||||
* PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
* Known chunks: do normal libpng processing, do not keep the chunk (but
|
||||
* set the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
* see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
* Unknown chunks: for a specific chunk use the global default, when used
|
||||
* as the default discard the chunk data.
|
||||
* PNG_HANDLE_CHUNK_NEVER:
|
||||
@@ -2386,12 +2397,21 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
|
||||
* to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks
|
||||
* it simply resets the behavior to the libpng default.
|
||||
*
|
||||
* INTERACTION WTIH USER CHUNK CALLBACKS:
|
||||
* The per-chunk handling is always used when there is a png_user_chunk_ptr
|
||||
* callback and the callback returns 0; the chunk is then always stored *unless*
|
||||
* it is critical and the per-chunk setting is other than ALWAYS. Notice that
|
||||
* the global default is *not* used in this case. (In effect the per-chunk
|
||||
* value is incremented to at least IF_SAFE.)
|
||||
*
|
||||
* IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and
|
||||
* per-chunk defaults will be honored. If you want to preserve the current
|
||||
* behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE
|
||||
* as the default - if you don't do this libpng 1.6 will issue a warning.
|
||||
*
|
||||
* If you want unhandled unknown chunks to be discarded in libpng 1.6 and
|
||||
* earlier simply return '1' (handled).
|
||||
*
|
||||
* PNG_HANDLE_AS_UNKNOWN_SUPPORTED:
|
||||
* If this is *not* set known chunks will always be handled by libpng and
|
||||
* will never be stored in the unknown chunk list. Known chunks listed to
|
||||
@@ -2472,7 +2492,7 @@ PNG_EXPORT(175, void, png_set_unknown_chunk_location,
|
||||
(png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));
|
||||
|
||||
PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_unknown_chunkpp entries));
|
||||
png_inforp info_ptr, png_unknown_chunkpp entries));
|
||||
#endif
|
||||
|
||||
/* Png_free_data() will turn off the "valid" flag for anything it frees.
|
||||
@@ -3086,6 +3106,24 @@ typedef struct
|
||||
* slight speed gain.
|
||||
*/
|
||||
|
||||
#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04
|
||||
/* On read if the image is a 16-bit per component image and there is no gAMA
|
||||
* or sRGB chunk assume that the components are sRGB encoded. Notice that
|
||||
* images output by the simplified API always have gamma information; setting
|
||||
* this flag only affects the interpretation of 16-bit images from an
|
||||
* external source. It is recommended that the application expose this flag
|
||||
* to the user; the user can normally easily recognize the difference between
|
||||
* linear and sRGB encoding. This flag has no effect on write - the data
|
||||
* passed to the write APIs must have the correct encoding (as defined
|
||||
* above.)
|
||||
*
|
||||
* If the flag is not set (the default) input 16-bit per component data is
|
||||
* assumed to be linear.
|
||||
*
|
||||
* NOTE: the flag can only be set after the png_image_begin_read_ call,
|
||||
* because that call initializes the 'flags' field.
|
||||
*/
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
/* READ APIs
|
||||
* ---------
|
||||
@@ -3136,7 +3174,7 @@ PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,
|
||||
* PNG_FORMAT_FLAG_LINEAR *not* set.
|
||||
*
|
||||
* For linear output removing the alpha channel is always done by compositing
|
||||
* on black and background is ignored.:
|
||||
* on black and background is ignored.
|
||||
*
|
||||
* colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must
|
||||
* be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.
|
||||
@@ -3151,6 +3189,7 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
|
||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
/* WRITE APIS
|
||||
* ----------
|
||||
* For write you must initialize a png_image structure to describe the image to
|
||||
@@ -3193,19 +3232,65 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
||||
*
|
||||
* Note that the write API does not support interlacing or sub-8-bit pixels.
|
||||
*/
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */
|
||||
/*******************************************************************************
|
||||
* END OF SIMPLIFIED API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
|
||||
(png_structrp png_ptr, int allowed));
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
|
||||
png_const_infop info_ptr));
|
||||
# endif
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
|
||||
/*******************************************************************************
|
||||
* IMPLEMENTATION OPTIONS
|
||||
*******************************************************************************
|
||||
*
|
||||
* Support for arbitrary implementation-specific optimizations. The API allows
|
||||
* particular options to be turned on or off. 'Option' is the number of the
|
||||
* option and 'onoff' is 0 (off) or non-0 (on). The value returned is given
|
||||
* by the PNG_OPTION_ defines below.
|
||||
*
|
||||
* HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
|
||||
* are detected at run time, however sometimes it may be impossible
|
||||
* to do this in user mode, in which case it is necessary to discover
|
||||
* the capabilities in an OS specific way. Such capabilities are
|
||||
* listed here when libpng has support for them and must be turned
|
||||
* ON by the application if present.
|
||||
*
|
||||
* SOFTWARE: sometimes software optimizations actually result in performance
|
||||
* decrease on some architectures or systems, or with some sets of
|
||||
* PNG images. 'Software' options allow such optimizations to be
|
||||
* selected at run time.
|
||||
*/
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
|
||||
#endif
|
||||
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
|
||||
#define PNG_OPTION_NEXT 4 /* Next option - numbers must be even */
|
||||
|
||||
/* Return values: NOTE: there are four values and 'off' is *not* zero */
|
||||
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
|
||||
#define PNG_OPTION_INVALID 1 /* Option number out of range */
|
||||
#define PNG_OPTION_OFF 2
|
||||
#define PNG_OPTION_ON 3
|
||||
|
||||
PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
|
||||
int onoff));
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* END OF HARDWARE OPTIONS
|
||||
******************************************************************************/
|
||||
|
||||
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
|
||||
* defs
|
||||
* defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt
|
||||
*/
|
||||
|
||||
/* The last ordinal number (this is the *last* one already used; the next
|
||||
@@ -3213,7 +3298,7 @@ PNG_EXPORT(242, void, png_set_check_for_invalid_index,
|
||||
* scripts/symbols.def as well.
|
||||
*/
|
||||
#ifdef PNG_EXPORT_LAST_ORDINAL
|
||||
PNG_EXPORT_LAST_ORDINAL(242);
|
||||
PNG_EXPORT_LAST_ORDINAL(244);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
28
pngconf.h
28
pngconf.h
@@ -1,9 +1,9 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.0beta28 - August 29, 2012
|
||||
* libpng version 1.6.3 - July 18, 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.)
|
||||
*
|
||||
@@ -198,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
|
||||
@@ -220,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
|
||||
@@ -237,6 +238,7 @@
|
||||
# define PNGAPI _stdcall
|
||||
# endif
|
||||
# endif /* compiler/api */
|
||||
|
||||
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
||||
|
||||
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
||||
@@ -260,7 +262,7 @@
|
||||
# endif
|
||||
# endif /* compiler */
|
||||
|
||||
#else /* !Windows/x86 */
|
||||
#else /* !Windows */
|
||||
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
||||
# define PNGAPI _System
|
||||
# else /* !Windows/x86 && !OS/2 */
|
||||
|
||||
47
pngerror.c
47
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 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -163,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];
|
||||
@@ -173,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];
|
||||
@@ -510,6 +510,41 @@ png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||
#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,
|
||||
@@ -809,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:
|
||||
|
||||
55
pngget.c
55
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 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -552,14 +552,14 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
*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, info_ptr->colorspace.end_points_XYZ.blue_X,
|
||||
"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, info_ptr->colorspace.end_points_XYZ.blue_Y,
|
||||
"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, info_ptr->colorspace.end_points_XYZ.blue_Z,
|
||||
"cHRM blue Z");
|
||||
*blue_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@@ -701,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)
|
||||
{
|
||||
@@ -726,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);
|
||||
@@ -742,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");
|
||||
@@ -818,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)
|
||||
{
|
||||
@@ -844,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)
|
||||
@@ -938,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");
|
||||
@@ -974,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)
|
||||
@@ -989,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)
|
||||
@@ -1064,7 +1064,7 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
#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)
|
||||
@@ -1161,4 +1161,17 @@ png_get_io_chunk_type (png_const_structrp png_ptr)
|
||||
}
|
||||
#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 */
|
||||
|
||||
14
pnginfo.h
14
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 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -88,7 +88,7 @@ struct png_info_def
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined PNG_COLORSPACE_SUPPORTED || defined PNG_GAMMA_SUPPORTED
|
||||
#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
|
||||
@@ -223,13 +223,17 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
unsigned int unknown_chunks_num;
|
||||
|
||||
/* 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
|
||||
|
||||
68
pngmem.c
68
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.)
|
||||
*
|
||||
@@ -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.
|
||||
|
||||
@@ -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.)
|
||||
*
|
||||
@@ -151,7 +151,7 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
|
||||
void /* PRIVATE */
|
||||
png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
png_size_t num_checked = png_ptr->sig_bytes,
|
||||
png_size_t num_checked = png_ptr->sig_bytes, /* SAFE, does not exceed 8 */
|
||||
num_to_check = 8 - num_checked;
|
||||
|
||||
if (png_ptr->buffer_size < num_to_check)
|
||||
@@ -272,7 +272,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if ((keep = 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)
|
||||
{
|
||||
|
||||
319
pngpriv.h
319
pngpriv.h
@@ -2,11 +2,11 @@
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* 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.3 [July 18, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -39,9 +39,11 @@
|
||||
*/
|
||||
#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
|
||||
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
/* Standard library headers not required by png.h: */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#define PNGLIB_BUILD /*libpng is being built, not used*/
|
||||
|
||||
@@ -54,7 +56,7 @@
|
||||
* configure generated config.h. Libpng is expected to compile without *any*
|
||||
* special build system support on a reasonably ANSI-C compliant system.
|
||||
*/
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
|
||||
/* Pick up the definition of 'restrict' from config.h if it was read: */
|
||||
@@ -71,7 +73,7 @@
|
||||
#endif
|
||||
|
||||
/* Local renames may change non-exported API functions from png.h */
|
||||
#if defined PNG_PREFIX && !defined PNGPREFIX_H
|
||||
#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)
|
||||
# include "pngprefix.h"
|
||||
#endif
|
||||
|
||||
@@ -86,6 +88,46 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Compile time options.
|
||||
* =====================
|
||||
* In a multi-arch build the compiler may compile the code several times for the
|
||||
* same object module, producing different binaries for different architectures.
|
||||
* When this happens configure-time setting of the target host options cannot be
|
||||
* done and this interferes with the handling of the ARM NEON optimizations, and
|
||||
* possibly other similar optimizations. Put additional tests here; in general
|
||||
* this is needed when the same option can be changed at both compile time and
|
||||
* run time depending on the target OS (i.e. iOS vs Android.)
|
||||
*
|
||||
* NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because
|
||||
* this is not possible with certain compilers (Oracle SUN OS CC), as a result
|
||||
* it is necessary to ensure that all extern functions that *might* be used
|
||||
* regardless of $(CFLAGS) get declared in this file. The test on __ARM_NEON__
|
||||
* below is one example of this behavior because it is controlled by the
|
||||
* presence or not of -mfpu=neon on the GCC command line, it is possible to do
|
||||
* this in $(CC), e.g. "CC=gcc -mfpu=neon", but people who build libpng rarely
|
||||
* do this.
|
||||
*/
|
||||
#ifndef PNG_ARM_NEON_OPT
|
||||
/* ARM NEON optimizations are being controlled by the compiler settings,
|
||||
* typically the target FPU. If the FPU has been set to NEON (-mfpu=neon
|
||||
* with GCC) then the compiler will define __ARM_NEON__ and we can rely
|
||||
* unconditionally on NEON instructions not crashing, otherwise we must
|
||||
* disable use of NEON instructions:
|
||||
*/
|
||||
# ifdef __ARM_NEON__
|
||||
# define PNG_ARM_NEON_OPT 2
|
||||
# else
|
||||
# define PNG_ARM_NEON_OPT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
/* NEON optimizations are to be at least considered by libpng, so enable the
|
||||
* callbacks to do this.
|
||||
*/
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon
|
||||
#endif
|
||||
|
||||
/* Is this a build of a DLL where compilation of the object modules requires
|
||||
* different preprocessor settings to those required for a simple library? If
|
||||
* so PNG_BUILD_DLL must be set.
|
||||
@@ -177,10 +219,12 @@
|
||||
# ifndef PNG_FLOATING_POINT_SUPPORTED
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||
PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);
|
||||
typedef struct png_incomplete png_double;
|
||||
typedef png_double* png_doublep;
|
||||
typedef const png_double* png_const_doublep;
|
||||
typedef png_double** png_doublepp;
|
||||
# ifndef PNG_VERSION_INFO_ONLY
|
||||
typedef struct png_incomplete png_double;
|
||||
typedef png_double* png_doublep;
|
||||
typedef const png_double* png_const_doublep;
|
||||
typedef png_double** png_doublepp;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_FIXED_EXPORT
|
||||
@@ -191,8 +235,6 @@
|
||||
#endif
|
||||
|
||||
#include "png.h"
|
||||
#include "pngstruct.h"
|
||||
#include "pnginfo.h"
|
||||
|
||||
/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */
|
||||
#ifndef PNG_DLL_EXPORT
|
||||
@@ -238,11 +280,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This is used for 16 bit gamma tables -- only the top level pointers are
|
||||
* const; this could be changed:
|
||||
*/
|
||||
typedef const png_uint_16p * png_const_uint_16pp;
|
||||
|
||||
/* Moved to pngpriv.h at libpng-1.5.0 */
|
||||
/* NOTE: some of these may have been used in external applications as
|
||||
* these definitions were exposed in pngconf.h prior to 1.5.
|
||||
@@ -331,6 +368,7 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
# define PNGFAPI /* PRIVATE */
|
||||
#endif
|
||||
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
/* Other defines specific to compilers can go here. Try to keep
|
||||
* them inside an appropriate ifdef/endif pair for portability.
|
||||
*/
|
||||
@@ -375,6 +413,7 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
defined(_WIN32) || defined(__WIN32__)
|
||||
# include <windows.h> /* defines _WINDOWS_ macro */
|
||||
#endif
|
||||
#endif /* PNG_VERSION_INFO_ONLY */
|
||||
|
||||
/* Moved here around 1.5.0beta36 from pngconf.h */
|
||||
/* Users may want to use these so they are not private. Any library
|
||||
@@ -411,7 +450,7 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE
|
||||
/* This is used because in some compiler implementations non-aligned
|
||||
* structure members are supported, so the offsetof approach below fails.
|
||||
* Set PNG_ALIGN_TO_SIZE=0 for compiler combinations where unaligned access
|
||||
* Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access
|
||||
* is good for performance. Do not do this unless you have tested the result
|
||||
* and understand it.
|
||||
*/
|
||||
@@ -553,26 +592,6 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
abs((int)((c1).green) - (int)((c2).green)) + \
|
||||
abs((int)((c1).blue) - (int)((c2).blue)))
|
||||
|
||||
/* Added to libpng-1.5.7: sRGB conversion tables */
|
||||
#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\
|
||||
defined PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
|
||||
/* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,
|
||||
* 0..65535. This table gives the closest 16-bit answers (no errors).
|
||||
*/
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
|
||||
PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
|
||||
#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
|
||||
((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
|
||||
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
|
||||
* encoded value with maximum error 0.646365. Note that the input is not a
|
||||
* 16-bit value; it has been multiplied by 255! */
|
||||
#endif /* PNG_SIMPLIFIED_READ/WRITE */
|
||||
|
||||
/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255
|
||||
* by dividing by 257 *with rounding*. This macro is exact for the given range.
|
||||
* See the discourse in pngrtran.c png_do_scale_16_to_8. The values in the
|
||||
@@ -651,37 +670,64 @@ PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
* architectures where (int) is only 16 bits.
|
||||
*/
|
||||
#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
|
||||
#define PNG_CHUNK(b1,b2,b3,b4) \
|
||||
#define PNG_U32(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)
|
||||
/* Constants for known chunk types.
|
||||
*
|
||||
* MAINTAINERS: If you need to add a chunk, define the name here.
|
||||
* For historical reasons these constants have the form png_<name>; i.e.
|
||||
* the prefix is lower case. Please use decimal values as the parameters to
|
||||
* match the ISO PNG specification and to avoid relying on the C locale
|
||||
* interpretation of character values. Please keep the list sorted.
|
||||
*
|
||||
* Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk
|
||||
* type. In fact the specification does not express chunk types this way,
|
||||
* however using a 32-bit value means that the chunk type can be read from the
|
||||
* stream using exactly the same code as used for a 32-bit unsigned value and
|
||||
* can be examined far more efficiently (using one arithmetic compare).
|
||||
*
|
||||
* Prior to 1.5.6 the chunk type constants were expressed as C strings. The
|
||||
* libpng API still uses strings for 'unknown' chunks and a macro,
|
||||
* PNG_STRING_FROM_CHUNK, allows a string to be generated if required. Notice
|
||||
* that for portable code numeric values must still be used; the string "IHDR"
|
||||
* is not portable and neither is PNG_U32('I', 'H', 'D', 'R').
|
||||
*
|
||||
* In 1.7.0 the definitions will be made public in png.h to avoid having to
|
||||
* duplicate the same definitions in application code.
|
||||
*/
|
||||
#define png_IDAT PNG_U32( 73, 68, 65, 84)
|
||||
#define png_IEND PNG_U32( 73, 69, 78, 68)
|
||||
#define png_IHDR PNG_U32( 73, 72, 68, 82)
|
||||
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
||||
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
||||
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
|
||||
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
||||
#define png_gIFg PNG_U32(103, 73, 70, 103)
|
||||
#define png_gIFt PNG_U32(103, 73, 70, 116) /* deprecated */
|
||||
#define png_gIFx PNG_U32(103, 73, 70, 120)
|
||||
#define png_hIST PNG_U32(104, 73, 83, 84)
|
||||
#define png_iCCP PNG_U32(105, 67, 67, 80)
|
||||
#define png_iTXt PNG_U32(105, 84, 88, 116)
|
||||
#define png_oFFs PNG_U32(111, 70, 70, 115)
|
||||
#define png_pCAL PNG_U32(112, 67, 65, 76)
|
||||
#define png_pHYs PNG_U32(112, 72, 89, 115)
|
||||
#define png_sBIT PNG_U32(115, 66, 73, 84)
|
||||
#define png_sCAL PNG_U32(115, 67, 65, 76)
|
||||
#define png_sPLT PNG_U32(115, 80, 76, 84)
|
||||
#define png_sRGB PNG_U32(115, 82, 71, 66)
|
||||
#define png_sTER PNG_U32(115, 84, 69, 82)
|
||||
#define png_tEXt PNG_U32(116, 69, 88, 116)
|
||||
#define png_tIME PNG_U32(116, 73, 77, 69)
|
||||
#define png_tRNS PNG_U32(116, 82, 78, 83)
|
||||
#define png_zTXt PNG_U32(122, 84, 88, 116)
|
||||
|
||||
/* The following will work on (signed char*) strings, whereas the get_uint_32
|
||||
* macro will fail on top-bit-set values because of the sign extension.
|
||||
*/
|
||||
#define PNG_CHUNK_FROM_STRING(s)\
|
||||
PNG_CHUNK(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
|
||||
PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
|
||||
|
||||
/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
|
||||
* signed and the argument is a (char[]) This macro will fail miserably on
|
||||
@@ -696,8 +742,8 @@ PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
(void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)
|
||||
|
||||
/* Test on flag values as defined in the spec (section 5.4): */
|
||||
#define PNG_CHUNK_ANCILLIARY(c) (1 & ((c) >> 29))
|
||||
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLIARY(c))
|
||||
#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))
|
||||
@@ -707,6 +753,57 @@ PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
#define PNG_GAMMA_MAC_INVERSE 65909
|
||||
#define PNG_GAMMA_sRGB_INVERSE 45455
|
||||
|
||||
/* Almost everything below is C specific; the #defines above can be used in
|
||||
* non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.
|
||||
*/
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
|
||||
#include "pngstruct.h"
|
||||
#include "pnginfo.h"
|
||||
|
||||
/* Validate the include paths - the include path used to generate pnglibconf.h
|
||||
* must match that used in the build, or we must be using pnglibconf.h.prebuilt:
|
||||
*/
|
||||
#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM
|
||||
# error ZLIB_VERNUM != PNG_ZLIB_VERNUM \
|
||||
"-I (include path) error: see the notes in pngpriv.h"
|
||||
/* This means that when pnglibconf.h was built the copy of zlib.h that it
|
||||
* used is not the same as the one being used here. Because the build of
|
||||
* libpng makes decisions to use inflateInit2 and inflateReset2 based on the
|
||||
* zlib version number and because this affects handling of certain broken
|
||||
* PNG files the -I directives must match.
|
||||
*
|
||||
* The most likely explanation is that you passed a -I in CFLAGS, this will
|
||||
* not work; all the preprocessor directories and in particular all the -I
|
||||
* directives must be in CPPFLAGS.
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* This is used for 16 bit gamma tables -- only the top level pointers are
|
||||
* const; this could be changed:
|
||||
*/
|
||||
typedef const png_uint_16p * png_const_uint_16pp;
|
||||
|
||||
/* Added to libpng-1.5.7: sRGB conversion tables */
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
|
||||
/* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,
|
||||
* 0..65535. This table gives the closest 16-bit answers (no errors).
|
||||
*/
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
|
||||
PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
|
||||
#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
|
||||
((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
|
||||
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
|
||||
* encoded value with maximum error 0.646365. Note that the input is not a
|
||||
* 16-bit value; it has been multiplied by 255! */
|
||||
#endif /* PNG_SIMPLIFIED_READ/WRITE */
|
||||
|
||||
|
||||
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
|
||||
#ifdef __cplusplus
|
||||
@@ -757,6 +854,23 @@ PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,
|
||||
PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,
|
||||
png_alloc_size_t size),PNG_ALLOCATED);
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
|
||||
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* Internal array allocator, outputs no error or warning messages on failure,
|
||||
* just returns NULL.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,
|
||||
int nelements, size_t element_size),PNG_ALLOCATED);
|
||||
|
||||
/* The same but an existing array is extended by add_elements. This function
|
||||
* also memsets the new elements to 0 and copies the old elements. The old
|
||||
* array is not freed or altered.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,
|
||||
png_const_voidp array, int old_elements, int add_elements,
|
||||
size_t element_size),PNG_ALLOCATED);
|
||||
#endif /* text, sPLT or unknown chunks */
|
||||
|
||||
/* Magic to create a struct when there is no struct to call the user supplied
|
||||
* memory allocators. Because error handling has not been set up the memory
|
||||
* handlers can't safely call png_error, but this is an obscure and undocumented
|
||||
@@ -1406,9 +1520,12 @@ PNG_INTERNAL_FUNCTION(void,png_do_write_intrapixel,(png_row_infop row_info,
|
||||
|
||||
/* Added at libpng version 1.6.0 */
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(int,png_colorspace_set_gamma,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_fixed_point gAMA, int preferred),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY);
|
||||
/* Set the colorspace gamma with a value provided by the application or by
|
||||
* the gAMA chunk on read. The value will override anything set by an ICC
|
||||
* profile.
|
||||
*/
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,
|
||||
png_inforp info_ptr), PNG_EMPTY);
|
||||
@@ -1436,14 +1553,19 @@ PNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints,
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, int intent, int preferred), PNG_EMPTY);
|
||||
png_colorspacerp colorspace, int intent), PNG_EMPTY);
|
||||
/* This does set the colorspace gAMA and cHRM values too, but doesn't set the
|
||||
* flags to write them, if it returns false there was a problem and an error
|
||||
* message has already been output (but the colorspace may still need to be
|
||||
* synced to record the invalid flag).
|
||||
*/
|
||||
#endif /* sRGB */
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_charp name,
|
||||
png_uint_32 profile_length, png_const_bytep profile, int preferred,
|
||||
int color_type), PNG_EMPTY);
|
||||
png_uint_32 profile_length, png_const_bytep profile, int color_type),
|
||||
PNG_EMPTY);
|
||||
/* The 'name' is used for information only */
|
||||
|
||||
/* Routines for checking parts of an ICC profile. */
|
||||
@@ -1459,16 +1581,15 @@ PNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_charp name,
|
||||
png_uint_32 profile_length,
|
||||
png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(int,png_icc_set_gAMA_and_cHRM,(
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(
|
||||
png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_charp name, png_const_bytep profile, uLong adler, int preferred),
|
||||
PNG_EMPTY);
|
||||
png_const_bytep profile, uLong adler), PNG_EMPTY);
|
||||
/* 'adler' is the Adler32 checksum of the uncompressed profile data. It may
|
||||
* be zero to indicate that it is not available. It is used, if provided,
|
||||
* as a fast check on the profile when checking to see if it is sRGB. The
|
||||
* result is false only if an error is detected in the profile; the routine
|
||||
* may return true without actually setting cHRM and gAMA values.
|
||||
* as a fast check on the profile when checking to see if it is sRGB.
|
||||
*/
|
||||
#endif
|
||||
#endif /* iCCP */
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
@@ -1599,6 +1720,21 @@ PNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr,
|
||||
# define png_app_error(pp,s) png_error(pp,s)
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,
|
||||
png_const_charp message, int error),PNG_EMPTY);
|
||||
/* Report a recoverable issue in chunk data. On read this is used to report
|
||||
* a problem found while reading a particular chunk and the
|
||||
* png_chunk_benign_error or png_chunk_warning function is used as
|
||||
* appropriate. On write this is used to report an error that comes from
|
||||
* data set via an application call to a png_set_ API and png_app_error or
|
||||
* png_app_warning is used as appropriate.
|
||||
*
|
||||
* The 'error' parameter must have one of the following values:
|
||||
*/
|
||||
#define PNG_CHUNK_WARNING 0 /* never an error */
|
||||
#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */
|
||||
#define PNG_CHUNK_ERROR 2 /* always an error */
|
||||
|
||||
/* ASCII to FP interfaces, currently only implemented if sCAL
|
||||
* support is required.
|
||||
*/
|
||||
@@ -1695,14 +1831,14 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
|
||||
#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)
|
||||
#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)
|
||||
|
||||
/* The actual parser. This can be called repeatedly, it updates
|
||||
/* The actual parser. This can be called repeatedly. It updates
|
||||
* the index into the string and the state variable (which must
|
||||
* be initialzed to 0). It returns a result code, as above. There
|
||||
* be initialized to 0). It returns a result code, as above. There
|
||||
* is no point calling the parser any more if it fails to advance to
|
||||
* the end of the string - it is stuck on an invalid character (or
|
||||
* terminated by '\0').
|
||||
*
|
||||
* Note that the pointer will consume an E or even an E+ then leave
|
||||
* Note that the pointer will consume an E or even an E+ and then leave
|
||||
* a 'maybe' state even though a preceding integer.fraction is valid.
|
||||
* The PNG_FP_WAS_VALID flag indicates that a preceding substring was
|
||||
* a valid number. It's possible to recover from this by calling
|
||||
@@ -1785,8 +1921,8 @@ PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
/* SIMPLIFIED READ/WRITE SUPPORT */
|
||||
#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\
|
||||
defined PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
/* The internal structure that png_image::opaque points to. */
|
||||
typedef struct png_control
|
||||
{
|
||||
@@ -1840,7 +1976,25 @@ PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);
|
||||
|
||||
#endif /* SIMPLIFIED READ/WRITE */
|
||||
|
||||
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
|
||||
/* These are initialization functions for hardware specific PNG filter
|
||||
* optimizations; list these here then select the appropriate one at compile
|
||||
* time using the macro PNG_FILTER_OPTIMIZATIONS. If the macro is not defined
|
||||
* the generic code is used.
|
||||
*/
|
||||
#ifdef PNG_FILTER_OPTIMIZATIONS
|
||||
PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
|
||||
unsigned int bpp), PNG_EMPTY);
|
||||
/* Just declare the optimization that will be used */
|
||||
#else
|
||||
/* List *all* the possible optimizations here - this branch is required if
|
||||
* the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in
|
||||
* CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* Maintainer: Put new private prototypes here ^ */
|
||||
|
||||
#include "pngdebug.h"
|
||||
|
||||
@@ -1848,4 +2002,5 @@ PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PNG_VERSION_INFO_ONLY */
|
||||
#endif /* PNGPRIV_H */
|
||||
|
||||
55
pngread.c
55
pngread.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "pngpriv.h"
|
||||
#if defined PNG_SIMPLIFIED_READ_SUPPORTED && defined PNG_STDIO_SUPPORTED
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
@@ -139,7 +139,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)))
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||
{
|
||||
png_handle_unknown(png_ptr, info_ptr, length, keep);
|
||||
|
||||
@@ -723,7 +723,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)))
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||
{
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
@@ -877,8 +877,8 @@ png_read_destroy(png_structrp png_ptr)
|
||||
png_free(png_ptr, png_ptr->save_buffer);
|
||||
#endif
|
||||
|
||||
#if (defined PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) &&\
|
||||
(defined PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) &&\
|
||||
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||
#endif
|
||||
|
||||
@@ -1357,6 +1357,10 @@ png_image_begin_read_from_stdio(png_imagep image, FILE* file)
|
||||
"png_image_begin_read_from_stdio: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1391,6 +1395,10 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name)
|
||||
"png_image_begin_read_from_file: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
@@ -1452,6 +1460,10 @@ int PNGAPI png_image_begin_read_from_memory(png_imagep image,
|
||||
"png_image_begin_read_from_memory: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1992,6 +2004,28 @@ png_image_read_colormap(png_voidp argument)
|
||||
else
|
||||
back_b = back_r = back_g = 255;
|
||||
|
||||
/* Default the input file gamma if required - this is necessary because
|
||||
* libpng assumes that if no gamma information is present the data is in the
|
||||
* output format, but the simplified API deduces the gamma from the input
|
||||
* format.
|
||||
*/
|
||||
if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0)
|
||||
{
|
||||
/* Do this directly, not using the png_colorspace functions, to ensure
|
||||
* that it happens even if the colorspace is invalid (though probably if
|
||||
* it is the setting will be ignored) Note that the same thing can be
|
||||
* achieved at the application interface with png_set_gAMA.
|
||||
*/
|
||||
if (png_ptr->bit_depth == 16 &&
|
||||
(image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
|
||||
png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR;
|
||||
|
||||
else
|
||||
png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE;
|
||||
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
}
|
||||
|
||||
/* Decide what to do based on the PNG color type of the input data. The
|
||||
* utility function png_create_colormap_entry deals with most aspects of the
|
||||
* output transformations; this code works out how to produce bytes of
|
||||
@@ -3535,7 +3569,8 @@ png_image_read_direct(png_voidp argument)
|
||||
{
|
||||
png_fixed_point input_gamma_default;
|
||||
|
||||
if (base_format & PNG_FORMAT_FLAG_LINEAR)
|
||||
if ((base_format & PNG_FORMAT_FLAG_LINEAR) &&
|
||||
(image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
|
||||
input_gamma_default = PNG_GAMMA_LINEAR;
|
||||
else
|
||||
input_gamma_default = PNG_DEFAULT_sRGB;
|
||||
@@ -3954,6 +3989,10 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
"png_image_finish_read: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_finish_read: damaged PNG_IMAGE_VERSION");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
4
pngrio.c
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.)
|
||||
*
|
||||
|
||||
35
pngrtran.c
35
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.2 [April 25, 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.)
|
||||
*
|
||||
@@ -223,6 +223,8 @@ translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma,
|
||||
*/
|
||||
# ifdef PNG_READ_sRGB_SUPPORTED
|
||||
png_ptr->flags |= PNG_FLAG_ASSUME_sRGB;
|
||||
# else
|
||||
PNG_UNUSED(png_ptr)
|
||||
# endif
|
||||
if (is_screen)
|
||||
output_gamma = PNG_GAMMA_sRGB;
|
||||
@@ -1056,9 +1058,6 @@ 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_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
||||
@@ -1245,7 +1244,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 */
|
||||
@@ -1412,7 +1411,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#if defined PNG_READ_EXPAND_SUPPORTED && defined PNG_READ_BACKGROUND_SUPPORTED
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* Detect gray background and attempt to enable optimization for
|
||||
* gray --> RGB case.
|
||||
*
|
||||
@@ -2239,8 +2238,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
|
||||
@@ -2251,8 +2250,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.)
|
||||
*/
|
||||
@@ -3284,7 +3283,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
|
||||
@@ -3361,7 +3360,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;
|
||||
@@ -3518,8 +3517,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.
|
||||
@@ -3535,12 +3534,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");
|
||||
@@ -3968,7 +3967,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4037,7 +4036,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);
|
||||
}
|
||||
|
||||
258
pngrutil.c
258
pngrutil.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.3 [July 18, 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.)
|
||||
*
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#define png_strtod(p,a,b) strtod(a,b)
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
|
||||
{
|
||||
@@ -196,7 +194,7 @@ png_crc_read(png_structrp png_ptr, png_bytep buf, png_uint_32 length)
|
||||
}
|
||||
|
||||
/* Optionally skip data and then check the CRC. Depending on whether we
|
||||
* are reading a ancillary or critical chunk, and how the program has set
|
||||
* are reading an ancillary or critical chunk, and how the program has set
|
||||
* things up, we may calculate the CRC on the data and print a message.
|
||||
* Returns '1' if there was a CRC error, '0' otherwise.
|
||||
*/
|
||||
@@ -221,7 +219,7 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
|
||||
|
||||
if (png_crc_error(png_ptr))
|
||||
{
|
||||
if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name) ?
|
||||
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) ?
|
||||
!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) :
|
||||
(png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))
|
||||
{
|
||||
@@ -250,7 +248,7 @@ png_crc_error(png_structrp png_ptr)
|
||||
png_uint_32 crc;
|
||||
int need_crc = 1;
|
||||
|
||||
if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))
|
||||
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
|
||||
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
|
||||
@@ -282,7 +280,7 @@ png_crc_error(png_structrp png_ptr)
|
||||
|
||||
/* Manage the read buffer; this simply reallocates the buffer if it is not small
|
||||
* enough (or if it is not allocated). The routine returns a pointer to the
|
||||
* buffer, if an error occurs and 'warn' is set the routine returns NULL, else
|
||||
* buffer; if an error occurs and 'warn' is set the routine returns NULL, else
|
||||
* it will call png_error (via png_malloc) on failure. (warn == 2 means
|
||||
* 'silent').
|
||||
*/
|
||||
@@ -334,7 +332,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
|
||||
* chunk apparently owns the stream. Prior to release it does a png_error.
|
||||
*/
|
||||
static int
|
||||
png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
||||
{
|
||||
if (png_ptr->zowner != 0)
|
||||
{
|
||||
@@ -357,11 +355,11 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
/* Implementation note: unlike 'png_deflate_claim' this internal function
|
||||
* does not take the size of the data as an argument. Some efficiency could
|
||||
* be gained by using this when it is known *if* the zlib stream itself does
|
||||
* not record the number, however this is a chimera: the original writer of
|
||||
* the PNG may have selected a lower window size, and we really must follow
|
||||
* that because, for systems with with limited capabilities, we would
|
||||
* otherwise reject the applications attempts to use a smaller window size.
|
||||
* (zlib doesn't have an interface to say "this or lower"!)
|
||||
* not record the number; however, this is an illusion: the original writer
|
||||
* of the PNG may have selected a lower window size, and we really must
|
||||
* follow that because, for systems with with limited capabilities, we
|
||||
* would otherwise reject the application's attempts to use a smaller window
|
||||
* size (zlib doesn't have an interface to say "this or lower"!).
|
||||
*
|
||||
* inflateReset2 was added to zlib 1.2.4; before this the window could not be
|
||||
* reset, therefore it is necessary to always allocate the maximum window
|
||||
@@ -369,6 +367,22 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
*/
|
||||
{
|
||||
int ret; /* zlib return code */
|
||||
# if PNG_ZLIB_VERNUM >= 0x1240
|
||||
|
||||
# if defined(PNG_SET_OPTION_SUPPORTED) && \
|
||||
defined(PNG_MAXIMUM_INFLATE_WINDOW)
|
||||
int window_bits;
|
||||
|
||||
if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
|
||||
PNG_OPTION_ON)
|
||||
window_bits = 15;
|
||||
|
||||
else
|
||||
window_bits = 0;
|
||||
# else
|
||||
# define window_bits 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Set this for safety, just in case the previous owner left pointers to
|
||||
* memory allocations.
|
||||
@@ -380,8 +394,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
|
||||
if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
|
||||
{
|
||||
# if ZLIB_VERNUM < 0x1240
|
||||
PNG_UNUSED(window_bits)
|
||||
# if PNG_ZLIB_VERNUM < 0x1240
|
||||
ret = inflateReset(&png_ptr->zstream);
|
||||
# else
|
||||
ret = inflateReset2(&png_ptr->zstream, window_bits);
|
||||
@@ -390,7 +403,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
|
||||
else
|
||||
{
|
||||
# if ZLIB_VERNUM < 0x1240
|
||||
# if PNG_ZLIB_VERNUM < 0x1240
|
||||
ret = inflateInit(&png_ptr->zstream);
|
||||
# else
|
||||
ret = inflateInit2(&png_ptr->zstream, window_bits);
|
||||
@@ -408,6 +421,10 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
# ifdef window_bits
|
||||
# undef window_bits
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
@@ -580,14 +597,8 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
if (limit < *newlength)
|
||||
*newlength = limit;
|
||||
|
||||
/* Now try to claim the stream; the 'warn' setting causes zlib to be told
|
||||
* to use the maximum window size during inflate; this hides errors in the
|
||||
* deflate header window bits value which is used if '0' is passed. In
|
||||
* fact this only has an effect with zlib versions 1.2.4 and later - see
|
||||
* the comments in png_inflate_claim above.
|
||||
*/
|
||||
ret = png_inflate_claim(png_ptr, png_ptr->chunk_name,
|
||||
png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN ? 15 : 0);
|
||||
/* Now try to claim the stream. */
|
||||
ret = png_inflate_claim(png_ptr, png_ptr->chunk_name);
|
||||
|
||||
if (ret == Z_OK)
|
||||
{
|
||||
@@ -1087,31 +1098,7 @@ png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
igamma = png_get_fixed_point(NULL, buf);
|
||||
|
||||
/* The gAMA value is unsigned (and is a power law correction, so 0 is
|
||||
* meaningless.)
|
||||
*/
|
||||
if (igamma <= 0)
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "out of range");
|
||||
return;
|
||||
}
|
||||
|
||||
/* If a colorspace error has already been output skip this chunk */
|
||||
if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)
|
||||
return;
|
||||
|
||||
if (png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA)
|
||||
{
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
|
||||
png_colorspace_sync(png_ptr, info_ptr);
|
||||
|
||||
png_chunk_benign_error(png_ptr, "duplicate");
|
||||
return;
|
||||
}
|
||||
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_gAMA;
|
||||
(void)png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma,
|
||||
1/*prefer gAMA values*/);
|
||||
png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma);
|
||||
png_colorspace_sync(png_ptr, info_ptr);
|
||||
}
|
||||
#endif
|
||||
@@ -1285,13 +1272,6 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (png_crc_finish(png_ptr, 0))
|
||||
return;
|
||||
|
||||
/* Check for bad intent */
|
||||
if (intent >= PNG_sRGB_INTENT_LAST)
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "Unknown sRGB intent");
|
||||
return;
|
||||
}
|
||||
|
||||
/* If a colorspace error has already been output skip this chunk */
|
||||
if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)
|
||||
return;
|
||||
@@ -1307,16 +1287,7 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Do not override gAMA or cHRM from the PNG file; just check they match.
|
||||
* This is because we write a cHRM which corresponds to D65, however there is
|
||||
* an issue with CMMs that assume a D50 environment that requires adaptation
|
||||
* of the white point. This way at least it is possible to supply an
|
||||
* adapated value (so long as it is within the tolerance limits for a match
|
||||
* against the D65 chromaticities.)
|
||||
*
|
||||
* TODO: get expert opinions on this issue
|
||||
*/
|
||||
(void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent, 0);
|
||||
(void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);
|
||||
png_colorspace_sync(png_ptr, info_ptr);
|
||||
}
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
@@ -1397,8 +1368,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
read_length -= keyword_length+2;
|
||||
|
||||
if (png_inflate_claim(png_ptr, png_iCCP,
|
||||
png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN ? 15 : 0) == Z_OK)
|
||||
if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK)
|
||||
{
|
||||
Byte profile_header[132];
|
||||
Byte local_buffer[PNG_INFLATE_BUF_SIZE];
|
||||
@@ -1475,8 +1445,6 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
/* But otherwise allow extra data: */
|
||||
else if (size == 0)
|
||||
{
|
||||
int ok;
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
/* This can be handled completely, so
|
||||
@@ -1489,17 +1457,15 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
png_crc_finish(png_ptr, length);
|
||||
finished = 1;
|
||||
|
||||
/* Set the gAMA and cHRM information, this
|
||||
* checks for a known sRGB profile. The
|
||||
* result is 0 on error.
|
||||
*/
|
||||
ok = png_icc_set_gAMA_and_cHRM(png_ptr,
|
||||
&png_ptr->colorspace, keyword, profile,
|
||||
png_ptr->zstream.adler,
|
||||
0/*prefer explicit gAMA/cHRM*/);
|
||||
# ifdef PNG_sRGB_SUPPORTED
|
||||
/* Check for a match against sRGB */
|
||||
png_icc_set_sRGB(png_ptr,
|
||||
&png_ptr->colorspace, profile,
|
||||
png_ptr->zstream.adler);
|
||||
# endif
|
||||
|
||||
/* Steal the profile for info_ptr. */
|
||||
if (ok && info_ptr != NULL)
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
png_free_data(png_ptr, info_ptr,
|
||||
PNG_FREE_ICCP, 0);
|
||||
@@ -1535,15 +1501,11 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (info_ptr != NULL)
|
||||
png_colorspace_sync(png_ptr, info_ptr);
|
||||
|
||||
if (errmsg == NULL && ok)
|
||||
if (errmsg == NULL)
|
||||
{
|
||||
png_ptr->zowner = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* else png_icc_set_gAMA_and_cHRM has
|
||||
* already output an error.
|
||||
*/
|
||||
}
|
||||
|
||||
else if (size > 0)
|
||||
@@ -2852,21 +2814,26 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
/* If the keep value is 'default' or 'never' override it, but
|
||||
* still error out on critical chunks unless the keep value is
|
||||
* 'always' While this is weird it is the behavior in 1.4.12. A
|
||||
* possible improvement would be to obey the value set for the
|
||||
* 'always' While this is weird it is the behavior in 1.4.12.
|
||||
* A possible improvement would be to obey the value set for the
|
||||
* chunk, but this would be an API change that would probably
|
||||
* damage some applications.
|
||||
*
|
||||
* The png_app_warning below catches the case that matters, where
|
||||
* the application has neither set specific save for this chunk
|
||||
* or global save.
|
||||
* the application has not set specific save or ignore for this
|
||||
* chunk or global save or ignore.
|
||||
*/
|
||||
if (keep < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
{
|
||||
# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
{
|
||||
png_chunk_warning(png_ptr, "Saving unknown chunk:");
|
||||
png_app_warning(png_ptr,
|
||||
"forcing save of an unhandled chunk; please call png_set_keep_unknown_chunks");
|
||||
"forcing save of an unhandled chunk;"
|
||||
" please call png_set_keep_unknown_chunks");
|
||||
/* with keep = PNG_HANDLE_CHUNK_IF_SAFE */
|
||||
}
|
||||
# endif
|
||||
keep = PNG_HANDLE_CHUNK_IF_SAFE;
|
||||
}
|
||||
@@ -2900,7 +2867,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
|
||||
PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name)))
|
||||
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
|
||||
{
|
||||
if (!png_cache_unknown_chunk(png_ptr, length))
|
||||
keep = PNG_HANDLE_CHUNK_NEVER;
|
||||
@@ -2934,7 +2901,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
*/
|
||||
if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
|
||||
PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name)))
|
||||
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
|
||||
{
|
||||
# ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
switch (png_ptr->user_chunk_cache_max)
|
||||
@@ -3398,7 +3365,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
png_uint_32p dp32 = png_aligncast(png_uint_32p,dp);
|
||||
png_const_uint_32p sp32 = png_aligncastconst(
|
||||
png_const_uint_32p, sp);
|
||||
unsigned int skip = (bytes_to_jump-bytes_to_copy) /
|
||||
size_t skip = (bytes_to_jump-bytes_to_copy) /
|
||||
(sizeof (png_uint_32));
|
||||
|
||||
do
|
||||
@@ -3440,7 +3407,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
png_uint_16p dp16 = png_aligncast(png_uint_16p, dp);
|
||||
png_const_uint_16p sp16 = png_aligncastconst(
|
||||
png_const_uint_16p, sp);
|
||||
unsigned int skip = (bytes_to_jump-bytes_to_copy) /
|
||||
size_t skip = (bytes_to_jump-bytes_to_copy) /
|
||||
(sizeof (png_uint_16));
|
||||
|
||||
do
|
||||
@@ -3727,7 +3694,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
png_byte v[8];
|
||||
png_byte v[8]; /* SAFE; pixel_depth does not exceed 64 */
|
||||
int j;
|
||||
|
||||
memcpy(v, sp, pixel_bytes);
|
||||
@@ -3911,68 +3878,16 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_ARM_NEON
|
||||
|
||||
#ifdef __linux__
|
||||
#include <stdio.h>
|
||||
#include <elf.h>
|
||||
#include <asm/hwcap.h>
|
||||
|
||||
static int png_have_hwcap(unsigned cap)
|
||||
{
|
||||
FILE *f = fopen("/proc/self/auxv", "r");
|
||||
Elf32_auxv_t aux;
|
||||
int have_cap = 0;
|
||||
|
||||
if (!f)
|
||||
return 0;
|
||||
|
||||
while (fread(&aux, (sizeof aux), 1, f) > 0)
|
||||
{
|
||||
if (aux.a_type == AT_HWCAP &&
|
||||
aux.a_un.a_val & cap)
|
||||
{
|
||||
have_cap = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
return have_cap;
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
|
||||
static void
|
||||
png_init_filter_functions_neon(png_structrp pp, unsigned int bpp)
|
||||
{
|
||||
#ifdef __linux__
|
||||
if (!png_have_hwcap(HWCAP_NEON))
|
||||
return;
|
||||
#endif
|
||||
|
||||
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 /* PNG_ARM_NEON */
|
||||
|
||||
static void
|
||||
png_init_filter_functions(png_structrp pp)
|
||||
/* This function is called once for every PNG image to set the
|
||||
* implementations required to reverse the filtering of PNG rows. Reversing
|
||||
* the filter is the first transformation performed on the row data. It is
|
||||
* performed in place, therefore an implementation can be selected based on
|
||||
* the image pixel format. If the implementation depends on image width then
|
||||
* take care to ensure that it works correctly if the image is interlaced -
|
||||
* interlacing causes the actual row width to vary.
|
||||
*/
|
||||
{
|
||||
unsigned int bpp = (pp->pixel_depth + 7) >> 3;
|
||||
|
||||
@@ -3986,8 +3901,16 @@ png_init_filter_functions(png_structrp pp)
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth_multibyte_pixel;
|
||||
|
||||
#ifdef PNG_ARM_NEON
|
||||
png_init_filter_functions_neon(pp, bpp);
|
||||
#ifdef PNG_FILTER_OPTIMIZATIONS
|
||||
/* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to
|
||||
* call to install hardware optimizations for the above functions; simply
|
||||
* replace whatever elements of the pp->read_filter[] array with a hardware
|
||||
* specific (or, for that matter, generic) optimization.
|
||||
*
|
||||
* To see an example of this examine what configure.ac does when
|
||||
* --enable-arm-neon is specified on the command line.
|
||||
*/
|
||||
PNG_FILTER_OPTIMIZATIONS(pp, bpp);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3995,6 +3918,10 @@ void /* PRIVATE */
|
||||
png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row, int filter)
|
||||
{
|
||||
/* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define
|
||||
* PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic
|
||||
* implementations. See png_init_filter_functions above.
|
||||
*/
|
||||
if (pp->read_filter[0] == NULL)
|
||||
png_init_filter_functions(pp);
|
||||
if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST)
|
||||
@@ -4066,7 +3993,7 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
|
||||
png_ptr->zstream.avail_out = out;
|
||||
}
|
||||
|
||||
else /* check for end */
|
||||
else /* after last row, checking for end */
|
||||
{
|
||||
png_ptr->zstream.next_out = tmpbuf;
|
||||
png_ptr->zstream.avail_out = (sizeof tmpbuf);
|
||||
@@ -4081,10 +4008,13 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
|
||||
*/
|
||||
ret = inflate(&png_ptr->zstream, Z_NO_FLUSH);
|
||||
|
||||
/* Take the unconsumed output back (so, in the 'check' case this just
|
||||
* counts up).
|
||||
*/
|
||||
avail_out += png_ptr->zstream.avail_out;
|
||||
/* Take the unconsumed output back. */
|
||||
if (output != NULL)
|
||||
avail_out += png_ptr->zstream.avail_out;
|
||||
|
||||
else /* avail_out counts the extra bytes */
|
||||
avail_out += (sizeof tmpbuf) - png_ptr->zstream.avail_out;
|
||||
|
||||
png_ptr->zstream.avail_out = 0;
|
||||
|
||||
if (ret == Z_STREAM_END)
|
||||
@@ -4123,7 +4053,7 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
|
||||
if (output != NULL)
|
||||
png_error(png_ptr, "Not enough image data");
|
||||
|
||||
else /* checking */
|
||||
else /* the deflate stream contained extra data */
|
||||
png_chunk_benign_error(png_ptr, "Too much image data");
|
||||
}
|
||||
}
|
||||
@@ -4534,7 +4464,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
* IDAT stream has a bogus deflate header window_bits value, but this should
|
||||
* not be happening any longer!)
|
||||
*/
|
||||
if (png_inflate_claim(png_ptr, png_IDAT, 0) != Z_OK)
|
||||
if (png_inflate_claim(png_ptr, png_IDAT) != Z_OK)
|
||||
png_error(png_ptr, png_ptr->zstream.msg);
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ROW_INIT;
|
||||
|
||||
355
pngset.c
355
pngset.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.3 [July 18, 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.)
|
||||
*
|
||||
@@ -143,25 +143,8 @@ png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
|
||||
* occur. Since the fixed point representation is assymetrical it is
|
||||
* possible for 1/gamma to overflow the limit of 21474 and this means the
|
||||
* gamma value must be at least 5/100000 and hence at most 20000.0. For
|
||||
* safety the limits here are a little narrower. The values are 0.00016 to
|
||||
* 6250.0, which are truly ridiculous gamma values (and will produce
|
||||
* displays that are all black or all white.)
|
||||
*/
|
||||
if (file_gamma < 16 || file_gamma > 625000000)
|
||||
png_app_error(png_ptr, "Out of range gamma value ignored");
|
||||
|
||||
else
|
||||
{
|
||||
if (png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma,
|
||||
2/* overrided with app value */))
|
||||
info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_gAMA;
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
}
|
||||
png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma);
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@@ -255,16 +238,7 @@ png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
||||
|
||||
/* Check for potential overflow */
|
||||
if (width >
|
||||
(PNG_UINT_32_MAX >> 3) /* 8-byte RRGGBBAA pixels */
|
||||
- 48 /* bigrowbuf hack */
|
||||
- 1 /* filter byte */
|
||||
- 7*8 /* rounding of width to multiple of 8 pixels */
|
||||
- 8) /* extra max_pixel_depth pad */
|
||||
info_ptr->rowbytes = 0;
|
||||
else
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
|
||||
}
|
||||
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
@@ -531,7 +505,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
png_debug1(1, "in %s storage function", "PLTE");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || palette == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
|
||||
@@ -546,6 +520,17 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
if ((num_palette > 0 && palette == NULL) ||
|
||||
(num_palette == 0
|
||||
# ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
&& (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0
|
||||
# endif
|
||||
))
|
||||
{
|
||||
png_chunk_report(png_ptr, "Invalid palette", PNG_CHUNK_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* It may not actually be necessary to set png_ptr->palette here;
|
||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||
* function used to do the allocation.
|
||||
@@ -562,7 +547,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
||||
|
||||
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
||||
if (num_palette > 0)
|
||||
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
||||
info_ptr->palette = png_ptr->palette;
|
||||
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
||||
|
||||
@@ -595,9 +581,7 @@ png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
(void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent,
|
||||
2/* app value overrides*/);
|
||||
|
||||
(void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent);
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
@@ -610,10 +594,9 @@ png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent,
|
||||
2/* app value overrides*/))
|
||||
if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent))
|
||||
{
|
||||
/* And cause the gAMA and cHRM to be written too */
|
||||
/* This causes the gAMA and cHRM to be written too */
|
||||
info_ptr->colorspace.flags |=
|
||||
PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
|
||||
}
|
||||
@@ -649,8 +632,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
*/
|
||||
{
|
||||
int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name,
|
||||
proflen, profile, 0/* do *not* override the app cHRM or gAMA */,
|
||||
info_ptr->color_type);
|
||||
proflen, profile, info_ptr->color_type);
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
|
||||
@@ -717,63 +699,62 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" :
|
||||
(unsigned long)png_ptr->chunk_name);
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
|
||||
return(0);
|
||||
|
||||
/* Make sure we have enough space in the "text" array in info_struct
|
||||
* to hold all of the incoming text_ptr objects.
|
||||
* to hold all of the incoming text_ptr objects. This compare can't overflow
|
||||
* because max_text >= num_text (anyway, subtract of two positive integers
|
||||
* can't overflow in any case.)
|
||||
*/
|
||||
if (info_ptr->num_text + num_text > info_ptr->max_text)
|
||||
if (num_text > info_ptr->max_text - info_ptr->num_text)
|
||||
{
|
||||
int old_max_text = info_ptr->max_text;
|
||||
int old_num_text = info_ptr->num_text;
|
||||
int max_text;
|
||||
png_textp new_text = NULL;
|
||||
|
||||
if (info_ptr->text != NULL)
|
||||
/* Calculate an appropriate max_text, checking for overflow. */
|
||||
max_text = old_num_text;
|
||||
if (num_text <= INT_MAX - max_text)
|
||||
{
|
||||
png_textp old_text;
|
||||
max_text += num_text;
|
||||
|
||||
info_ptr->max_text = info_ptr->num_text + num_text + 8;
|
||||
old_text = info_ptr->text;
|
||||
/* Round up to a multiple of 8 */
|
||||
if (max_text < INT_MAX-8)
|
||||
max_text = (max_text + 8) & ~0x7;
|
||||
|
||||
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)(info_ptr->max_text * (sizeof (png_text))));
|
||||
else
|
||||
max_text = INT_MAX;
|
||||
|
||||
if (info_ptr->text == NULL)
|
||||
{
|
||||
/* Restore to previous condition */
|
||||
info_ptr->max_text = old_max_text;
|
||||
info_ptr->text = old_text;
|
||||
return(1);
|
||||
}
|
||||
|
||||
memcpy(info_ptr->text, old_text, (png_size_t)(old_max_text *
|
||||
(sizeof (png_text))));
|
||||
png_free(png_ptr, old_text);
|
||||
/* Now allocate a new array and copy the old members in, this does all
|
||||
* the overflow checks.
|
||||
*/
|
||||
new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
|
||||
info_ptr->text, old_num_text, max_text-old_num_text,
|
||||
sizeof *new_text));
|
||||
}
|
||||
|
||||
else
|
||||
if (new_text == NULL)
|
||||
{
|
||||
info_ptr->max_text = num_text + 8;
|
||||
info_ptr->num_text = 0;
|
||||
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)(info_ptr->max_text * (sizeof (png_text))));
|
||||
if (info_ptr->text == NULL)
|
||||
{
|
||||
/* Restore to previous condition */
|
||||
info_ptr->num_text = old_num_text;
|
||||
info_ptr->max_text = old_max_text;
|
||||
return(1);
|
||||
}
|
||||
info_ptr->free_me |= PNG_FREE_TEXT;
|
||||
png_chunk_report(png_ptr, "too many text chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
png_debug1(3, "allocated %d entries for info_ptr->text",
|
||||
info_ptr->max_text);
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
|
||||
info_ptr->text = new_text;
|
||||
info_ptr->free_me |= PNG_FREE_TEXT;
|
||||
info_ptr->max_text = max_text;
|
||||
/* num_text is adjusted below as the entries are copied in */
|
||||
|
||||
png_debug1(3, "allocated %d entries for info_ptr->text", max_text);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text; i++)
|
||||
{
|
||||
png_size_t text_length, key_len;
|
||||
png_size_t lang_len, lang_key_len;
|
||||
size_t text_length, key_len;
|
||||
size_t lang_len, lang_key_len;
|
||||
png_textp textp = &(info_ptr->text[info_ptr->num_text]);
|
||||
|
||||
if (text_ptr[i].key == NULL)
|
||||
@@ -782,7 +763,8 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||
|
||||
text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
|
||||
{
|
||||
png_warning(png_ptr, "text compression mode is out of range");
|
||||
png_chunk_report(png_ptr, "text compression mode is out of range",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -813,7 +795,8 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
# else /* PNG_iTXt_SUPPORTED */
|
||||
{
|
||||
png_warning(png_ptr, "iTXt chunk not supported");
|
||||
png_chunk_report(png_ptr, "iTXt chunk not supported",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
continue;
|
||||
}
|
||||
# endif
|
||||
@@ -836,19 +819,22 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
textp->compression = text_ptr[i].compression;
|
||||
}
|
||||
|
||||
textp->key = (png_charp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)
|
||||
(key_len + text_length + lang_len + lang_key_len + 4));
|
||||
textp->key = png_voidcast(png_charp,png_malloc_base(png_ptr,
|
||||
key_len + text_length + lang_len + lang_key_len + 4));
|
||||
|
||||
if (textp->key == NULL)
|
||||
return(1);
|
||||
{
|
||||
png_chunk_report(png_ptr, "text chunk: out of memory",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
png_debug2(2, "Allocated %lu bytes at %p in png_set_text",
|
||||
(unsigned long)(png_uint_32)
|
||||
(key_len + lang_len + lang_key_len + text_length + 4),
|
||||
textp->key);
|
||||
|
||||
memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
|
||||
memcpy(textp->key, text_ptr[i].key, key_len);
|
||||
*(textp->key + key_len) = '\0';
|
||||
|
||||
if (text_ptr[i].compression > 0)
|
||||
@@ -870,8 +856,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
|
||||
if (text_length)
|
||||
memcpy(textp->text, text_ptr[i].text,
|
||||
(png_size_t)(text_length));
|
||||
memcpy(textp->text, text_ptr[i].text, text_length);
|
||||
|
||||
*(textp->text + text_length) = '\0';
|
||||
|
||||
@@ -892,6 +877,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
info_ptr->num_text++;
|
||||
png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
@@ -995,84 +981,93 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
*/
|
||||
{
|
||||
png_sPLT_tp np;
|
||||
int i;
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 ||
|
||||
entries == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL)
|
||||
return;
|
||||
|
||||
np = png_voidcast(png_sPLT_tp, png_malloc_warn(png_ptr,
|
||||
(info_ptr->splt_palettes_num + nentries) * (sizeof (png_sPLT_t))));
|
||||
/* Use the internal realloc function, which checks for all the possible
|
||||
* overflows. Notice that the parameters are (int) and (size_t)
|
||||
*/
|
||||
np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr,
|
||||
info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
|
||||
sizeof *np));
|
||||
|
||||
if (np == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "No memory for sPLT palettes");
|
||||
/* Out of memory or too many chunks */
|
||||
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(np, info_ptr->splt_palettes,
|
||||
info_ptr->splt_palettes_num * (sizeof (png_sPLT_t)));
|
||||
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes=NULL;
|
||||
info_ptr->splt_palettes = np;
|
||||
info_ptr->free_me |= PNG_FREE_SPLT;
|
||||
|
||||
/* TODO: fix this, it apparently leaves NULL entries in the event of OOM
|
||||
* below.
|
||||
*/
|
||||
for (i = 0; i < nentries; i++)
|
||||
np += info_ptr->splt_palettes_num;
|
||||
|
||||
do
|
||||
{
|
||||
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
||||
png_const_sPLT_tp from = entries + i;
|
||||
png_size_t length;
|
||||
|
||||
/* In event of error below the name and entries fields must be set to
|
||||
* NULL, otherwise libpng will crash later on while trying to free the
|
||||
* uninitialized pointers.
|
||||
/* Skip invalid input entries */
|
||||
if (entries->name == NULL || entries->entries == NULL)
|
||||
{
|
||||
/* png_handle_sPLT doesn't do this, so this is an app error */
|
||||
png_app_error(png_ptr, "png_set_sPLT: invalid sPLT");
|
||||
/* Just skip the invalid entry */
|
||||
continue;
|
||||
}
|
||||
|
||||
np->depth = entries->depth;
|
||||
|
||||
/* In the even of out-of-memory just return - there's no point keeping on
|
||||
* trying to add sPLT chunks.
|
||||
*/
|
||||
memset(to, 0, (sizeof *to));
|
||||
length = strlen(entries->name) + 1;
|
||||
np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));
|
||||
|
||||
if (from->name == NULL || from->entries == NULL)
|
||||
continue;
|
||||
if (np->name == NULL)
|
||||
break;
|
||||
|
||||
length = strlen(from->name) + 1;
|
||||
to->name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
|
||||
memcpy(np->name, entries->name, length);
|
||||
|
||||
if (to->name == NULL)
|
||||
/* IMPORTANT: we have memory now that won't get freed if something else
|
||||
* goes wrong, this code must free it. png_malloc_array produces no
|
||||
* warnings, use a png_chunk_report (below) if there is an error.
|
||||
*/
|
||||
np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr,
|
||||
entries->nentries, sizeof (png_sPLT_entry)));
|
||||
|
||||
if (np->entries == NULL)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Out of memory while processing sPLT chunk");
|
||||
continue;
|
||||
png_free(png_ptr, np->name);
|
||||
break;
|
||||
}
|
||||
|
||||
memcpy(to->name, from->name, length);
|
||||
to->entries = png_voidcast(png_sPLT_entryp, png_malloc_warn(png_ptr,
|
||||
from->nentries * (sizeof (png_sPLT_entry))));
|
||||
np->nentries = entries->nentries;
|
||||
/* This multiply can't overflow because png_malloc_array has already
|
||||
* checked it when doing the allocation.
|
||||
*/
|
||||
memcpy(np->entries, entries->entries,
|
||||
entries->nentries * sizeof (png_sPLT_entry));
|
||||
|
||||
if (to->entries == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Out of memory while processing sPLT chunk");
|
||||
png_free(png_ptr, to->name);
|
||||
to->name = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(to->entries, from->entries,
|
||||
from->nentries * (sizeof (png_sPLT_entry)));
|
||||
|
||||
to->nentries = from->nentries;
|
||||
to->depth = from->depth;
|
||||
/* Note that 'continue' skips the advance of the out pointer and out
|
||||
* count, so an invalid entry is not added.
|
||||
*/
|
||||
info_ptr->valid |= PNG_INFO_sPLT;
|
||||
++(info_ptr->splt_palettes_num);
|
||||
++np;
|
||||
}
|
||||
while (++entries, --nentries);
|
||||
|
||||
info_ptr->splt_palettes = np;
|
||||
info_ptr->splt_palettes_num += nentries;
|
||||
info_ptr->valid |= PNG_INFO_sPLT;
|
||||
info_ptr->free_me |= PNG_FREE_SPLT;
|
||||
if (nentries > 0)
|
||||
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
|
||||
}
|
||||
#endif /* PNG_sPLT_SUPPORTED */
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
static png_byte
|
||||
check_location(png_const_structrp png_ptr, unsigned int location)
|
||||
check_location(png_const_structrp png_ptr, int location)
|
||||
{
|
||||
location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT);
|
||||
|
||||
@@ -1086,10 +1081,13 @@ check_location(png_const_structrp png_ptr, unsigned int location)
|
||||
png_app_warning(png_ptr,
|
||||
"png_set_unknown_chunks now expects a valid location");
|
||||
/* Use the old behavior */
|
||||
location = png_ptr->mode &
|
||||
(PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT);
|
||||
location = (png_byte)(png_ptr->mode &
|
||||
(PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));
|
||||
}
|
||||
|
||||
/* This need not be an internal error - if the app calls
|
||||
* png_set_unknown_chunks on a read pointer it must get the location right.
|
||||
*/
|
||||
if (location == 0)
|
||||
png_error(png_ptr, "invalid location in png_set_unknown_chunks");
|
||||
|
||||
@@ -1097,7 +1095,7 @@ check_location(png_const_structrp png_ptr, unsigned int location)
|
||||
* significant bit in turn.
|
||||
*/
|
||||
while (location != (location & -location))
|
||||
location &= (png_byte)~(location & -location);
|
||||
location &= ~(location & -location);
|
||||
|
||||
/* The cast is safe because 'location' is a bit mask and only the low four
|
||||
* bits are significant.
|
||||
@@ -1111,7 +1109,8 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
{
|
||||
png_unknown_chunkp np;
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0)
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 ||
|
||||
unknowns == NULL)
|
||||
return;
|
||||
|
||||
/* Check for the failure cases where support has been disabled at compile
|
||||
@@ -1120,16 +1119,16 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
* code) but may be meaningless if the read or write handling of unknown
|
||||
* chunks is not compiled in.
|
||||
*/
|
||||
# if !(defined PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
(defined PNG_READ_SUPPORTED)
|
||||
# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_READ_SUPPORTED)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on read");
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
# if !(defined PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
(defined PNG_WRITE_SUPPORTED)
|
||||
# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_WRITE_SUPPORTED)
|
||||
if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on write");
|
||||
@@ -1137,20 +1136,21 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Prior to 1.6.0 this code used png_malloc_warn, however this meant that
|
||||
/* Prior to 1.6.0 this code used png_malloc_warn; however, this meant that
|
||||
* unknown critical chunks could be lost with just a warning resulting in
|
||||
* undefined behavior. Changing to png_malloc fixes this by producing a
|
||||
* png_error. The (png_size_t) cast was also removed as it hides a potential
|
||||
* overflow.
|
||||
*
|
||||
* TODO: fix the potential overflow in the multiply
|
||||
* undefined behavior. Now png_chunk_report is used to provide behavior
|
||||
* appropriate to read or write.
|
||||
*/
|
||||
np = png_voidcast(png_unknown_chunkp, png_malloc(png_ptr,
|
||||
(info_ptr->unknown_chunks_num + (unsigned int)num_unknowns) *
|
||||
(sizeof (png_unknown_chunk))));
|
||||
np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr,
|
||||
info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns,
|
||||
sizeof *np));
|
||||
|
||||
memcpy(np, info_ptr->unknown_chunks,
|
||||
info_ptr->unknown_chunks_num * (sizeof (png_unknown_chunk)));
|
||||
if (np == NULL)
|
||||
{
|
||||
png_chunk_report(png_ptr, "too many unknown chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
info_ptr->unknown_chunks = np; /* safe because it is initialized */
|
||||
@@ -1161,24 +1161,41 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
/* Increment unknown_chunks_num each time round the loop to protect the
|
||||
* just-allocated chunk data.
|
||||
*/
|
||||
for (; --num_unknowns >= 0;
|
||||
++np, ++unknowns, ++(info_ptr->unknown_chunks_num))
|
||||
for (; num_unknowns > 0; --num_unknowns, ++unknowns)
|
||||
{
|
||||
memcpy(np->name, unknowns->name, (sizeof unknowns->name));
|
||||
memcpy(np->name, unknowns->name, (sizeof np->name));
|
||||
np->name[(sizeof np->name)-1] = '\0';
|
||||
np->size = unknowns->size;
|
||||
np->location = check_location(png_ptr, unknowns->location);
|
||||
|
||||
if (unknowns->size == 0)
|
||||
{
|
||||
np->data = NULL;
|
||||
np->size = 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* png_error is safe here because the list is stored in png_ptr */
|
||||
np->data = png_voidcast(png_bytep,
|
||||
png_malloc(png_ptr, unknowns->size));
|
||||
png_malloc_base(png_ptr, unknowns->size));
|
||||
|
||||
if (np->data == NULL)
|
||||
{
|
||||
png_chunk_report(png_ptr, "unknown chunk: out of memory",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
/* But just skip storing the unknown chunk */
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(np->data, unknowns->data, unknowns->size);
|
||||
np->size = unknowns->size;
|
||||
}
|
||||
|
||||
/* These increments are skipped on out-of-memory for the data - the
|
||||
* unknown chunk entry gets overwritten if the png_chunk_report returns.
|
||||
* This is correct in the read case (the chunk is just dropped.)
|
||||
*/
|
||||
++np;
|
||||
++(info_ptr->unknown_chunks_num);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1192,7 +1209,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
* TODO: add a png_app_warning in 1.7
|
||||
*/
|
||||
if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 &&
|
||||
(unsigned int)chunk < info_ptr->unknown_chunks_num)
|
||||
chunk < info_ptr->unknown_chunks_num)
|
||||
{
|
||||
if ((location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0)
|
||||
{
|
||||
@@ -1206,7 +1223,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
|
||||
info_ptr->unknown_chunks[chunk].location =
|
||||
check_location(png_ptr, (png_byte)location);
|
||||
check_location(png_ptr, location);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1557,7 +1574,14 @@ png_set_benign_errors(png_structrp png_ptr, int allowed)
|
||||
#endif /* PNG_BENIGN_ERRORS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Do not report invalid palette index; added at libng-1.5.10 */
|
||||
/* Whether to report invalid palette index; added at libng-1.5.10.
|
||||
* It is possible for an indexed (color-type==3) PNG file to contain
|
||||
* pixels with invalid (out-of-range) indexes if the PLTE chunk has
|
||||
* fewer entries than the image's bit-depth would allow. We recover
|
||||
* from this gracefully by filling any incomplete palette with zeroes
|
||||
* (opaque black). By default, when this occurs libpng will issue
|
||||
* a benign error. This API can be used to override that behavior.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
|
||||
{
|
||||
@@ -1570,5 +1594,4 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
|
||||
png_ptr->num_palette_max = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
||||
20
pngstruct.h
20
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 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -100,7 +100,7 @@ typedef struct png_XYZ
|
||||
} png_XYZ;
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#if defined PNG_COLORSPACE_SUPPORTED || defined PNG_GAMMA_SUPPORTED
|
||||
#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
|
||||
@@ -128,13 +128,15 @@ typedef struct png_colorspace
|
||||
|
||||
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_ENDPOINTS_MATCH_sRGB 0x0020
|
||||
#define PNG_COLORSPACE_MATCHES_sRGB 0x0040 /* exact match on profile */
|
||||
#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 */
|
||||
@@ -355,6 +357,11 @@ struct png_struct_def
|
||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||
#endif
|
||||
|
||||
/* Options */
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
png_byte options; /* On/off state (up to 4 options) */
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* To do: remove this from libpng-1.7 */
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
@@ -469,11 +476,12 @@ 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
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
108
pngtest.c
108
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.2 [April 25, 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.)
|
||||
*
|
||||
@@ -43,7 +43,23 @@
|
||||
|
||||
#include "png.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED /* else nothing can be done */
|
||||
/* Known chunks that exist in pngtest.png must be supported or pngtest will fail
|
||||
* simply as a result of re-ordering them. This may be fixed in 1.7
|
||||
*/
|
||||
#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
|
||||
defined PNG_READ_bKGD_SUPPORTED &&\
|
||||
defined PNG_READ_cHRM_SUPPORTED &&\
|
||||
defined PNG_READ_gAMA_SUPPORTED &&\
|
||||
defined PNG_READ_oFFs_SUPPORTED &&\
|
||||
defined PNG_READ_pCAL_SUPPORTED &&\
|
||||
defined PNG_READ_pHYs_SUPPORTED &&\
|
||||
defined PNG_READ_sBIT_SUPPORTED &&\
|
||||
defined PNG_READ_sCAL_SUPPORTED &&\
|
||||
defined PNG_READ_sRGB_SUPPORTED &&\
|
||||
defined PNG_READ_tEXt_SUPPORTED &&\
|
||||
defined PNG_READ_tIME_SUPPORTED &&\
|
||||
defined PNG_READ_zTXt_SUPPORTED
|
||||
|
||||
#include "zlib.h"
|
||||
/* Copied from pngpriv.h but only used in error messages below. */
|
||||
#ifndef PNG_ZBUF_SIZE
|
||||
@@ -95,6 +111,7 @@ static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
|
||||
|
||||
static int verbose = 0;
|
||||
static int strict = 0;
|
||||
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 */
|
||||
@@ -395,26 +412,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);
|
||||
|
||||
++warning_count;
|
||||
|
||||
if (test == NULL)
|
||||
fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
|
||||
if (test != NULL && test->file_name != NULL)
|
||||
name = test->file_name;
|
||||
|
||||
else
|
||||
fprintf(STDERR, "%s: libpng warning: %s\n", test, message);
|
||||
fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
|
||||
}
|
||||
|
||||
/* This is the default error handling function. Note that replacements for
|
||||
@@ -432,7 +454,7 @@ pngtest_error(png_structp png_ptr, png_const_charp message)
|
||||
* 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 */
|
||||
@@ -799,6 +821,7 @@ 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
|
||||
@@ -817,6 +840,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int bit_depth, color_type;
|
||||
|
||||
row_buf = NULL;
|
||||
error_parameters.file_name = inname;
|
||||
|
||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||
{
|
||||
@@ -840,10 +864,8 @@ 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_WRITE_SUPPORTED
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
@@ -854,10 +876,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);
|
||||
@@ -918,7 +938,20 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_set_benign_errors(write_ptr, 0);
|
||||
#endif
|
||||
|
||||
/* if strict is not set, then both are treated as warnings. */
|
||||
/* 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");
|
||||
@@ -939,14 +972,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
|
||||
@@ -1164,7 +1189,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
|
||||
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
|
||||
{
|
||||
int unit;
|
||||
double scal_width, scal_height;
|
||||
@@ -1451,9 +1477,18 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#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
|
||||
* 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);
|
||||
@@ -1703,6 +1738,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
|
||||
@@ -1917,9 +1962,10 @@ main(void)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" test ignored because libpng was not built with read support\n");
|
||||
return 0;
|
||||
/* And skip this test */
|
||||
return 77;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_0beta28 Your_png_h_is_not_version_1_6_0beta28;
|
||||
typedef png_libpng_version_1_6_3 Your_png_h_is_not_version_1_6_3;
|
||||
|
||||
15
pngtrans.c
15
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.2 [April 25, 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.)
|
||||
*
|
||||
@@ -782,6 +782,17 @@ png_set_user_transform_info(png_structrp png_ptr, png_voidp
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
(png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
|
||||
{
|
||||
png_app_error(png_ptr,
|
||||
"info change after png_start_read_image or png_read_update_info");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
|
||||
4
pngwio.c
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.)
|
||||
*
|
||||
|
||||
87
pngwrite.c
87
pngwrite.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.2 [April 25, 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.)
|
||||
*
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
#include "pngpriv.h"
|
||||
#if defined PNG_SIMPLIFIED_WRITE_SUPPORTED && defined PNG_STDIO_SUPPORTED
|
||||
#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
@@ -447,7 +447,6 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
/* "tm" structure is not supported on WindowsCE */
|
||||
void PNGAPI
|
||||
png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime)
|
||||
{
|
||||
@@ -495,47 +494,50 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
|
||||
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* Set the zlib control values to defaults; they can be overridden by the
|
||||
* application after the struct has been created.
|
||||
*/
|
||||
png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
|
||||
|
||||
/* Set the zlib control values to defaults; they can be overridden by the
|
||||
* application after the struct has been created.
|
||||
*/
|
||||
png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
|
||||
|
||||
png_ptr->zlib_strategy = Z_FILTERED; /* may be overridden if no filters */
|
||||
png_ptr->zlib_level = Z_DEFAULT_COMPRESSION;
|
||||
png_ptr->zlib_mem_level = 8;
|
||||
png_ptr->zlib_window_bits = 15;
|
||||
png_ptr->zlib_method = 8;
|
||||
/* The 'zlib_strategy' setting is irrelevant because png_default_claim in
|
||||
* pngwutil.c defaults it according to whether or not filters will be
|
||||
* used, and ignores this setting.
|
||||
*/
|
||||
png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY;
|
||||
png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION;
|
||||
png_ptr->zlib_mem_level = 8;
|
||||
png_ptr->zlib_window_bits = 15;
|
||||
png_ptr->zlib_method = 8;
|
||||
|
||||
#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||
png_ptr->zlib_text_strategy = Z_DEFAULT_STRATEGY;
|
||||
png_ptr->zlib_text_level = Z_DEFAULT_COMPRESSION;
|
||||
png_ptr->zlib_text_mem_level = 8;
|
||||
png_ptr->zlib_text_window_bits = 15;
|
||||
png_ptr->zlib_text_method = 8;
|
||||
png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY;
|
||||
png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION;
|
||||
png_ptr->zlib_text_mem_level = 8;
|
||||
png_ptr->zlib_text_window_bits = 15;
|
||||
png_ptr->zlib_text_method = 8;
|
||||
#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
|
||||
|
||||
/* This is a highly dubious configuration option; by default it is off, but
|
||||
* it may be appropriate for private builds that are testing extensions not
|
||||
* conformant to the current specification, or of applications that must not
|
||||
* fail to write at all costs!
|
||||
*/
|
||||
# ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
|
||||
/* This is a highly dubious configuration option; by default it is off,
|
||||
* but it may be appropriate for private builds that are testing
|
||||
* extensions not conformant to the current specification, or of
|
||||
* applications that must not fail to write at all costs!
|
||||
*/
|
||||
#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
|
||||
png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
|
||||
/* In stable builds only warn if an application error can be completely
|
||||
* handled.
|
||||
*/
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* App warnings are warnings in release (or release candidate) builds but
|
||||
* are errors during development.
|
||||
*/
|
||||
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
/* App warnings are warnings in release (or release candidate) builds but
|
||||
* are errors during development.
|
||||
*/
|
||||
#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* TODO: delay this, it can be done in png_init_io() (if the app doesn't
|
||||
* do it itself) avoiding setting the default function if it is not
|
||||
* required.
|
||||
@@ -936,7 +938,8 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
case 5:
|
||||
case 6:
|
||||
case 7: png_warning(png_ptr, "Unknown row filter for method 0");
|
||||
case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
|
||||
/* FALL THROUGH */
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
case PNG_FILTER_VALUE_NONE:
|
||||
png_ptr->do_filter = PNG_FILTER_NONE; break;
|
||||
@@ -958,7 +961,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
png_ptr->do_filter = (png_byte)filters; break;
|
||||
#else
|
||||
default:
|
||||
png_warning(png_ptr, "Unknown row filter for method 0");
|
||||
png_app_error(png_ptr, "Unknown row filter for method 0");
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
}
|
||||
|
||||
@@ -1595,7 +1598,7 @@ png_image_write_init(png_imagep image)
|
||||
png_destroy_write_struct(&png_ptr, NULL);
|
||||
}
|
||||
|
||||
return png_image_error(image, "png_image_read: out of memory");
|
||||
return png_image_error(image, "png_image_write_: out of memory");
|
||||
}
|
||||
|
||||
/* Arguments to png_image_write_main: */
|
||||
@@ -2212,7 +2215,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||
const void *buffer, png_int_32 row_stride, const void *colormap)
|
||||
{
|
||||
/* Write the image to the given (FILE*). */
|
||||
if (image != NULL || image->version != PNG_IMAGE_VERSION)
|
||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||
{
|
||||
if (file != NULL)
|
||||
{
|
||||
@@ -2248,6 +2251,10 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||
"png_image_write_to_stdio: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -2258,7 +2265,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
||||
const void *colormap)
|
||||
{
|
||||
/* Write the image to the named file. */
|
||||
if (image != NULL || image->version != PNG_IMAGE_VERSION)
|
||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||
{
|
||||
if (file_name != NULL)
|
||||
{
|
||||
@@ -2311,6 +2318,10 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
||||
"png_image_write_to_file: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_write_to_file: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -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.)
|
||||
*
|
||||
|
||||
37
pngwutil.c
37
pngwutil.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.2 [April 25, 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.)
|
||||
*
|
||||
@@ -29,23 +29,6 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
|
||||
buf[3] = (png_byte)(i & 0xff);
|
||||
}
|
||||
|
||||
#ifdef PNG_SAVE_INT_32_SUPPORTED
|
||||
/* The png_save_int_32 function assumes integers are stored in two's
|
||||
* complement format. If this isn't the case, then this routine needs to
|
||||
* be modified to write data in two's complement format. Note that,
|
||||
* the following works correctly even if png_int_32 has more than 32 bits
|
||||
* (compare the more complex code required on read for sign extention.)
|
||||
*/
|
||||
void PNGAPI
|
||||
png_save_int_32(png_bytep buf, png_int_32 i)
|
||||
{
|
||||
buf[0] = (png_byte)((i >> 24) & 0xff);
|
||||
buf[1] = (png_byte)((i >> 16) & 0xff);
|
||||
buf[2] = (png_byte)((i >> 8) & 0xff);
|
||||
buf[3] = (png_byte)(i & 0xff);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Place a 16-bit number into a buffer in PNG byte order.
|
||||
* The parameter is declared unsigned int, not png_uint_16,
|
||||
* just to avoid potential problems on pre-ANSI C compilers.
|
||||
@@ -355,10 +338,10 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
strategy = png_ptr->zlib_strategy;
|
||||
|
||||
else if (png_ptr->do_filter != PNG_FILTER_NONE)
|
||||
strategy = Z_FILTERED;
|
||||
strategy = PNG_Z_DEFAULT_STRATEGY;
|
||||
|
||||
else
|
||||
strategy = Z_DEFAULT_STRATEGY;
|
||||
strategy = PNG_Z_DEFAULT_NOFILTER_STRATEGY;
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1444,7 +1427,8 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
||||
{
|
||||
if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid number of transparent colors specified");
|
||||
png_app_warning(png_ptr,
|
||||
"Invalid number of transparent colors specified");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1458,7 +1442,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
||||
/* One 16 bit value */
|
||||
if (tran->gray >= (1 << png_ptr->bit_depth))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
png_app_warning(png_ptr,
|
||||
"Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
|
||||
|
||||
return;
|
||||
@@ -1480,7 +1464,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
||||
if (buf[0] | buf[2] | buf[4])
|
||||
#endif
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
png_app_warning(png_ptr,
|
||||
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
|
||||
return;
|
||||
}
|
||||
@@ -1490,7 +1474,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
||||
|
||||
else
|
||||
{
|
||||
png_warning(png_ptr, "Can't write tRNS with an alpha channel");
|
||||
png_app_warning(png_ptr, "Can't write tRNS with an alpha channel");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1760,6 +1744,9 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
|
||||
{
|
||||
if (comp.input_len > PNG_UINT_31_MAX-prefix_len)
|
||||
png_error(png_ptr, "iTXt: uncompressed text too long");
|
||||
|
||||
/* So the string will fit in a chunk: */
|
||||
comp.output_len = (png_uint_32)/*SAFE*/comp.input_len;
|
||||
}
|
||||
|
||||
png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len);
|
||||
|
||||
27
projects/vstudio/WARNING
Normal file
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,11 +91,12 @@
|
||||
<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>
|
||||
@@ -162,7 +163,7 @@
|
||||
<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>
|
||||
|
||||
@@ -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
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.0beta28 - August 29, 2012
|
||||
libpng version 1.6.3 - July 18, 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.0beta28 - August 29, 2012
|
||||
* libpng version 1.6.3 - July 18, 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>
|
||||
@@ -106,6 +108,7 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Makefiles for libpng version 1.6.0beta28 - August 29, 2012
|
||||
Makefiles for libpng version 1.6.3 - July 18, 2013
|
||||
|
||||
pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng16.so.16.1.6.0beta28)
|
||||
(gcc, creates libpng16.so.16.1.6.3)
|
||||
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.0beta28)
|
||||
(gcc, creates libpng16.so.16.1.6.3)
|
||||
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.0beta28)
|
||||
creates libpng16.so.16.1.6.3)
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc,
|
||||
creates libpng16.so.16.1.6.0beta28)
|
||||
creates libpng16.so.16.1.6.3)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng16.so.16.1.6.0beta28)
|
||||
creates libpng16.so.16.1.6.3)
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
|
||||
@@ -113,6 +113,16 @@ END{
|
||||
err = 1
|
||||
}
|
||||
unexported=0
|
||||
# Add a standard header to symbols.new:
|
||||
print ";Version INSERT-VERSION-HERE" >of
|
||||
print ";--------------------------------------------------------------" >of
|
||||
print "; LIBPNG symbol list as a Win32 DEF file" >of
|
||||
print "; Contains all the symbols that can be exported from libpng" >of
|
||||
print ";--------------------------------------------------------------" >of
|
||||
print "LIBRARY" >of
|
||||
print "" >of
|
||||
print "EXPORTS" >of
|
||||
|
||||
for (o=1; o<=lasto; ++o) {
|
||||
if (symbol[o] == "" && removed[o] == "") {
|
||||
if (unexported == 0) unexported = o
|
||||
|
||||
@@ -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.3"
|
||||
|
||||
/* 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"
|
||||
|
||||
203
scripts/dfn.awk
Normal file
203
scripts/dfn.awk
Normal file
@@ -0,0 +1,203 @@
|
||||
#!/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
|
||||
#
|
||||
# Sometimes GCC splits the PNG_DFN lines, we know this has happened
|
||||
# if the quotes aren't closed and must read another line. In this
|
||||
# case it is essential to reject lines that start '#' because those
|
||||
# are introduced #line directives.
|
||||
orig=$0
|
||||
line=$0
|
||||
lineno=FNR
|
||||
if (lineno == "") lineno=NR
|
||||
|
||||
if (sub(/^[^"]*PNG_DFN *"/,"",line) != 1) {
|
||||
print "line", lineno ": processing failed:"
|
||||
print orig
|
||||
err=1
|
||||
next
|
||||
} else {
|
||||
++out_count
|
||||
}
|
||||
|
||||
# Now examine quotes within the value:
|
||||
#
|
||||
# @" - delete this and any following spaces
|
||||
# "@ - delete this and any preceding 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 (1) {
|
||||
# While there is an @" remove it and the next "@
|
||||
if (line ~ /@"/) {
|
||||
if (line ~ /@".*"@/) {
|
||||
# Do this special case first to avoid swallowing extra spaces
|
||||
# before or after the @ stuff:
|
||||
if (!sub(/@" *"@/, "", line)) {
|
||||
# Ok, do it in pieces - there has to be a non-space between the
|
||||
# two. NOTE: really weird things happen if a leading @" is
|
||||
# lost - the code will error out below (I believe).
|
||||
if (!sub(/@" */, "", line) || !sub(/ *"@/, "", line)) {
|
||||
print "line", lineno, ": internal error:", orig
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# There is no matching "@. Assume a split line
|
||||
else while (1) {
|
||||
if (getline nextline) {
|
||||
# If the line starts with '#' it is a preprocesor line directive
|
||||
# from cc -E, skip it:
|
||||
if (nextline !~ /^#/) {
|
||||
line = line " " nextline
|
||||
break
|
||||
}
|
||||
} else {
|
||||
# This is end-of-input - probably a missig "@ on the first line:
|
||||
print "line", lineno ": unbalanced @\" ... \"@ pair"
|
||||
err=1
|
||||
next
|
||||
}
|
||||
}
|
||||
|
||||
# Keep going until all the @" have gone
|
||||
continue
|
||||
}
|
||||
|
||||
# Attempt to remove a trailing " (not preceded by '@') - if this can
|
||||
# be done stop now, if not assume a split line again
|
||||
if (sub(/"[^"]*$/, "", line))
|
||||
break
|
||||
|
||||
# Read another line
|
||||
while (1) {
|
||||
if (getline nextline) {
|
||||
if (nextline !~ /^#/) {
|
||||
line = line " " nextline
|
||||
# Go back to stripping @" "@ pairs
|
||||
break
|
||||
}
|
||||
} else {
|
||||
print "line", lineno ": unterminated PNG_DFN string"
|
||||
err=1
|
||||
next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Put any needed double quotes in (at the end, because these would otherwise
|
||||
# interfere with the processing above.)
|
||||
gsub(/@'/,"\"", line)
|
||||
|
||||
# Remove any trailing spaces (not really required, but for
|
||||
# editorial consistency
|
||||
sub(/ *$/, "", line)
|
||||
|
||||
# Remove trailing CR
|
||||
sub(/
|
||||
$/, "", line)
|
||||
|
||||
if (sort) {
|
||||
if (split(line, parts) < sort) {
|
||||
print "line", lineno ": missing sort field:", line
|
||||
err=1
|
||||
} else
|
||||
array[parts[sort]] = line
|
||||
}
|
||||
|
||||
else
|
||||
print line >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
|
||||
@@ -10,10 +10,10 @@
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL_DATA(type, name, array)\
|
||||
PNG_DEFN_MAGIC-name-PNG_DEFN_END
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
|
||||
PNG_DEFN_MAGIC-name-PNG_DEFN_END
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNGPREFIX_H /* self generation */
|
||||
#include "../pngpriv.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.6.0beta28
|
||||
version=1.6.3
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
||||
@@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.6.0beta28
|
||||
Version: 1.6.3
|
||||
Libs: -L${libdir} -lpng16
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
VERMAJ = 1
|
||||
VERMIN = 6
|
||||
VERMIC = 0
|
||||
VERMIC = 3
|
||||
VER = $(VERMAJ).$(VERMIN).$(VERMIC)
|
||||
NAME = libpng
|
||||
PACKAGE = $(NAME)-$(VER)
|
||||
|
||||
@@ -26,19 +26,24 @@ SYMLINKS= libpng/png.h ${INCSDIR}/../png.h \
|
||||
libpng/pngconf.h ${INCSDIR}/../pngconf.h \
|
||||
libpng/pnglibconf.h ${INCSDIR}/../pnglibconf.h
|
||||
|
||||
LDADD+= -lm -lz
|
||||
#LDADD+= -lm -lz -lssp_nonshared # for OSVERSION < 800000 ?
|
||||
# where make install finds libz.a and zlib.h
|
||||
ZLIBLIB= /usr/lib
|
||||
ZLIBINC= /usr/include
|
||||
|
||||
LDADD+= -lm -lz
|
||||
#LDADD+= -lm -lz -lssp_nonshared # for OSVERSION < 800000 ?
|
||||
|
||||
DPADD+= ${LIBM} ${LIBZ}
|
||||
|
||||
CFLAGS+= -I.
|
||||
CFLAGS+= -I. -I${ZLIBINC}
|
||||
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
pngtest: pngtest.o libpng.a
|
||||
${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -lpng -lz -lm
|
||||
${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -L${ZLIBLIB} \
|
||||
-lpng ${LDADD}
|
||||
|
||||
CLEANFILES= pngtest pngtest.o pngout.png
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
RELEASE = 0
|
||||
RELEASE = 3
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@@ -236,4 +236,4 @@ pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.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
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
|
||||
204
scripts/makefile.msys
Normal file
204
scripts/makefile.msys
Normal file
@@ -0,0 +1,204 @@
|
||||
# makefile for libpng using MSYS/gcc (shared, static library)
|
||||
# Copyright (C) 2012 Glenn Randers-Pehrson and Christopher M. Wheeler
|
||||
#
|
||||
# Portions taken from makefile.linux:
|
||||
# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs and
|
||||
# Glenn Randers-Pehrson
|
||||
# Copyright (C) 2000 Cosmin Truta
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
# # # # # # # # # # # # # # # # #
|
||||
prefix=/usr/local
|
||||
exec_prefix=$(prefix)
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
RELEASE = 3
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).dll
|
||||
LIBSOMAJ=$(LIBNAME).dll.$(PNGMAJ)
|
||||
LIBSOREL=$(PNGMAJ).$(RELEASE)
|
||||
OLDSO=libpng.dll
|
||||
|
||||
# Where the zlib library and include files are located.
|
||||
#ZLIBLIB=../zlib
|
||||
#ZLIBINC=../zlib
|
||||
ZLIBLIB=/usr/local/lib
|
||||
ZLIBINC=/usr/local/include
|
||||
|
||||
# Compiler, linker, lib and other tools
|
||||
CC = gcc
|
||||
LD = $(CC)
|
||||
AR_RC = ar rcs
|
||||
RANLIB = ranlib
|
||||
RM_F = rm -rf
|
||||
MKDIR_P=mkdir -p
|
||||
LN_SF=ln -sf
|
||||
|
||||
#ARCH = -march=pentium3
|
||||
#ARCH = -march=i686
|
||||
ARCH =
|
||||
CDEBUG = -g -DPNG_DEBUG=5
|
||||
LDDEBUG =
|
||||
CRELEASE = -O2
|
||||
LDRELEASE = -s
|
||||
#CFLAGS = -W -Wall $(CDEBUG)
|
||||
CFLAGS = -W -Wall $(CRELEASE) $(ARCH)
|
||||
#LDFLAGS = $(LDDEBUG)
|
||||
LDFLAGS = $(LDRELEASE)
|
||||
LIBS = -lz -lm
|
||||
|
||||
# File extensions
|
||||
O=.o
|
||||
A=.a
|
||||
EXE=.exe
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(exec_prefix)/lib
|
||||
MANPATH=$(prefix)/man
|
||||
BINPATH=$(exec_prefix)/bin
|
||||
|
||||
# override DESTDIR= on the make install command line to easily support
|
||||
# installing into a temporary location. Example:
|
||||
#
|
||||
# make install DESTDIR=/tmp/build/libpng
|
||||
#
|
||||
# If you're going to install into a temporary location
|
||||
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
|
||||
# you execute make install.
|
||||
|
||||
DESTDIR=
|
||||
|
||||
DB=$(DESTDIR)$(BINPATH)
|
||||
DI=$(DESTDIR)$(INCPATH)
|
||||
DL=$(DESTDIR)$(LIBPATH)
|
||||
DM=$(DESTDIR)$(MANPATH)
|
||||
|
||||
# Variables
|
||||
OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
|
||||
pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \
|
||||
pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
|
||||
|
||||
# Targets
|
||||
all: static shared
|
||||
|
||||
# see scripts/pnglibconf.mak for more options
|
||||
pnglibconf.h: scripts/pnglibconf.h.prebuilt
|
||||
cp scripts/pnglibconf.h.prebuilt $@
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) -I$(ZLIBINC) $<
|
||||
|
||||
static: libpng$(A) pngtest$(EXE)
|
||||
|
||||
shared: $(LIBSOMAJ)
|
||||
$(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSO)
|
||||
|
||||
$(LIBSO): $(LIBSOMAJ)
|
||||
$(LN_SF) $(LIBSOMAJ) $(LIBSO)
|
||||
|
||||
$(LIBSOMAJ):
|
||||
$(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ)
|
||||
|
||||
libpng$(A): $(OBJS)
|
||||
$(AR_RC) $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
install-headers: png.h pngconf.h pnglibconf.h
|
||||
-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
|
||||
-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
|
||||
cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
|
||||
-@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
|
||||
-@$(RM_F) $(DI)/libpng
|
||||
(cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
|
||||
|
||||
install-static: install-headers libpng.a
|
||||
-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
|
||||
cp libpng.a $(DL)/$(LIBNAME).a
|
||||
-@$(RM_F) $(DL)/libpng.a
|
||||
(cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
|
||||
|
||||
libpng.pc:
|
||||
cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
echo prefix=\"$(prefix)\"; \
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
|
||||
install-shared: install-headers $(LIBSOMAJ) libpng.pc
|
||||
-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
|
||||
-@$(RM_F) $(DL)/$(LIBSO)
|
||||
-@$(RM_F) $(DL)/$(OLDSO)
|
||||
cp $(LIBSO) $(DL)/$(LIBSOREL)
|
||||
(cd $(DL); \
|
||||
$(LN_SF) $(LIBSOREL) $(LIBSO); \
|
||||
$(LN_SF) $(LIBSO) $(OLDSO))
|
||||
|
||||
-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
|
||||
-@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
|
||||
-@$(RM_F) $(DL)/pkgconfig/libpng.pc
|
||||
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
|
||||
(cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
|
||||
|
||||
install-man: libpng.3 libpngpf.3 png.5
|
||||
-@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
|
||||
-@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
|
||||
-@$(RM_F) $(DM)/man3/libpng.3
|
||||
-@$(RM_F) $(DM)/man3/libpngpf.3
|
||||
cp libpng.3 $(DM)/man3
|
||||
cp libpngpf.3 $(DM)/man3
|
||||
-@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
|
||||
-@$(RM_F) $(DM)/man5/png.5
|
||||
cp png.5 $(DM)/man5
|
||||
|
||||
install-config: libpng-config
|
||||
-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
|
||||
-@$(RM_F) $(DB)/libpng-config
|
||||
-@$(RM_F) $(DB)/$(LIBNAME)-config
|
||||
cp libpng-config $(DB)/$(LIBNAME)-config
|
||||
(cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
|
||||
|
||||
install: install-static install-shared install-man install-config
|
||||
|
||||
test: pngtest$(EXE)
|
||||
./pngtest$(EXE)
|
||||
|
||||
pngtest$(EXE): pngtest$(O) libpng$(A)
|
||||
$(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest$(O) libpng$(A) $(LIBS)
|
||||
|
||||
clean:
|
||||
$(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png pnglibconf.h $(LIBSO) \
|
||||
$(LIBSOMAJ) libpng-config
|
||||
|
||||
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
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng16
|
||||
|
||||
LIB= png16
|
||||
SHLIB_MAJOR= 0
|
||||
SHLIB_MINOR= 1.6.0beta28
|
||||
SHLIB_MINOR= 1.6.3
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include
|
||||
|
||||
LIB= png
|
||||
SHLIB_MAJOR= 16
|
||||
SHLIB_MINOR= 1.6.0beta28
|
||||
SHLIB_MINOR= 1.6.3
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -11,7 +11,7 @@ LIBDIR= ${PREFIX}/lib
|
||||
MANDIR= ${PREFIX}/man/cat
|
||||
|
||||
SHLIB_MAJOR= 16
|
||||
SHLIB_MINOR= 1.6.0beta28
|
||||
SHLIB_MINOR= 1.6.3
|
||||
|
||||
LIB= png
|
||||
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \
|
||||
|
||||
@@ -39,6 +39,7 @@ CPP = $(CC) -E
|
||||
ECHO = echo
|
||||
|
||||
DFNFLAGS = # DFNFLAGS contains -D options to use in the libpng build
|
||||
DFA_EXTRA = # extra files that can be used to control configuration
|
||||
CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||
|
||||
@@ -50,23 +51,23 @@ all: libpng.a pngtest
|
||||
|
||||
# The standard pnglibconf.h exists as scripts/pnglibconf.h.prebuilt,
|
||||
# copy this if the following doesn't work.
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||
$(RM_F) $@ dfn?.out
|
||||
$(AWK) -f scripts/options.awk out=dfn1.out version=search pngconf.h\
|
||||
scripts/pnglibconf.dfa $(DFA_XTRA) 1>&2
|
||||
$(AWK) -f scripts/options.awk out=dfn2.out dfn1.out 1>&2
|
||||
cp dfn2.out $@
|
||||
$(RM_F) dfn?.out
|
||||
|
||||
pnglibconf.h: pnglibconf.dfn
|
||||
$(RM_F) $@ dfn.c dfn?.out
|
||||
$(ECHO) '#include "pnglibconf.dfn"' >dfn.c
|
||||
$(CPP) $(DFNFLAGS) dfn.c >dfn1.out
|
||||
$(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\
|
||||
dfn1.out >dfn2.out
|
||||
$(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' dfn2.out >dfn3.out
|
||||
cp dfn3.out $@
|
||||
$(RM_F) dfn.c dfn?.out
|
||||
$(RM_F) $@ pnglibconf.c pnglibconf.out pnglibconf.tmp
|
||||
$(ECHO) '#include "pnglibconf.dfn"' >pnglibconf.c
|
||||
$(ECHO) "If '$(CC) -E' crashes try /lib/cpp (e.g. CPP='/lib/cpp')" >&2
|
||||
$(CPP) $(DFNFLAGS) pnglibconf.c >pnglibconf.out
|
||||
$(AWK) -f "scripts/dfn.awk" out="pnglibconf.tmp" pnglibconf.out 1>&2
|
||||
mv pnglibconf.tmp $@
|
||||
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
||||
$(RM_F) $@ pnglibconf.pre pnglibconf.tmp
|
||||
$(ECHO) "Calling $(AWK) from scripts/pnglibconf.mak" >&2
|
||||
$(ECHO) "If 'awk' crashes try a better awk (e.g. AWK='nawk')" >&2
|
||||
$(AWK) -f scripts/options.awk out="pnglibconf.pre"\
|
||||
version=search pngconf.h scripts/pnglibconf.dfa\
|
||||
pngusr.dfa $(DFA_XTRA) 1>&2
|
||||
$(AWK) -f scripts/options.awk out="pnglibconf.tmp" pnglibconf.pre 1>&2
|
||||
mv pnglibconf.tmp $@
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
$(AR_RC) $@ $(OBJS)
|
||||
@@ -96,7 +97,7 @@ install: libpng.a pnglibconf.h
|
||||
chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
|
||||
|
||||
clean:
|
||||
$(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.* dfn.c dfn?.out
|
||||
$(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.*
|
||||
|
||||
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
||||
writelock:
|
||||
|
||||
@@ -30,22 +30,33 @@
|
||||
# are copied to the preprocessed file).
|
||||
|
||||
BEGIN{
|
||||
out="/dev/null" # intermediate, preprocessed, file
|
||||
out="" # intermediate, preprocessed, file
|
||||
pre=-1 # preprocess (first line)
|
||||
version="libpng version unknown" # version information
|
||||
version_file="" # where to find the version
|
||||
err=0 # in-line exit sets this
|
||||
start="PNG_DEFN_MAGIC-" # Arbitrary start
|
||||
end="-PNG_DEFN_END" # Arbitrary end
|
||||
ct="PNG_JOIN" # Join two tokens
|
||||
cx= "/" ct "*" # Open C comment for output file
|
||||
comment=start cx # Comment start
|
||||
# The following definitions prevent the C preprocessor noticing the lines
|
||||
# that will be in the final output file. Some C preprocessors tokenise
|
||||
# the lines, for example by inserting spaces around operators, and all
|
||||
# C preprocessors notice lines that start with '#', most remove comments.
|
||||
# The technique adopted here is to make the final output lines into
|
||||
# C strings (enclosed in double quotes), preceeded by PNG_DFN. As a
|
||||
# consequence the output cannot contain a 'raw' double quote - instead put
|
||||
# @' in, this will be replaced by a single " afterward. See the parser
|
||||
# script dfn.awk for more capabilities (not required here). Note that if
|
||||
# you need a " in a 'setting' in pnglibconf.dfa it must also be @'!
|
||||
dq="@'" # For a single double quote
|
||||
start=" PNG_DFN \"" # Start stuff to output (can't contain a "!)
|
||||
end="\" " # End stuff to output
|
||||
subs="@\" " # Substitute start (substitute a C macro)
|
||||
sube=" \"@" # Substitute end
|
||||
comment=start "/*" # Comment start
|
||||
cend="*/" end # Comment end
|
||||
def=start "#define PNG_" ct # Arbitrary define
|
||||
sup=ct "_SUPPORTED" end # end supported option
|
||||
und=comment "#undef PNG_" ct # Unsupported option
|
||||
une=ct "_SUPPORTED" cend # end unsupported option
|
||||
error=start "ERROR:" # error message
|
||||
def=start "#define PNG_" # Arbitrary define
|
||||
sup="_SUPPORTED" end # end supported option
|
||||
und=comment "#undef PNG_" # Unsupported option
|
||||
une="_SUPPORTED" cend # end unsupported option
|
||||
error=start "ERROR:" # error message, terminate with 'end'
|
||||
|
||||
# Variables
|
||||
deb=0 # debug - set on command line
|
||||
@@ -53,11 +64,15 @@ BEGIN{
|
||||
logunsupported=0 # write unsupported options too
|
||||
|
||||
# Precreate arrays
|
||||
# for each option:
|
||||
option[""] = "" # list of all options: default enabled/disabled
|
||||
done[""] = 1 # marks option as having been output
|
||||
requires[""] = "" # requires by option
|
||||
iffs[""] = "" # if by option
|
||||
enabledby[""] = "" # options that enable it by option
|
||||
sets[""] = "" # settings set by each option
|
||||
setval[""] = "" # value to set (indexed: 'option sets[option]')
|
||||
# for each setting:
|
||||
setting[""] = "" # requires by setting
|
||||
defaults[""] = "" # used for a defaulted value
|
||||
doneset[""] = 1 # marks setting as having been output
|
||||
@@ -68,7 +83,7 @@ BEGIN{
|
||||
}
|
||||
|
||||
# The output file must be specified before any input:
|
||||
out == "/dev/null" {
|
||||
out == "" {
|
||||
print "out=output.file must be given on the command line"
|
||||
err = 1
|
||||
exit 1
|
||||
@@ -189,7 +204,7 @@ $1 == "com"{
|
||||
if (NF > 1) {
|
||||
# sub(/^[ ]*com[ ]*/, "")
|
||||
$1 = ""
|
||||
print comment, $0, cend >out
|
||||
print comment $0, cend >out
|
||||
} else
|
||||
print start end >out
|
||||
next
|
||||
@@ -226,7 +241,9 @@ $1 == "file" && NF >= 2{
|
||||
next
|
||||
}
|
||||
|
||||
# option NAME ( (requires|enables|if) NAME* | on | off | disabled )*
|
||||
# option NAME ( (requires|enables|if) NAME* | on | off | disabled |
|
||||
# sets SETTING VALUE+ )*
|
||||
#
|
||||
# Declares an option 'NAME' and describes its default setting (disabled)
|
||||
# and its relationship to other options. The option is disabled
|
||||
# unless *all* the options listed after 'requires' are set and at
|
||||
@@ -241,46 +258,77 @@ $1 == "file" && NF >= 2{
|
||||
# be later) entry may turn an option on or off explicitly.
|
||||
|
||||
$1 == "option" && NF >= 2{
|
||||
onoff = option[$2] # records current (and the default is "", enabled)
|
||||
opt = $2
|
||||
sub(/,$/,"",opt)
|
||||
onoff = option[opt] # records current (and the default is "", enabled)
|
||||
key = ""
|
||||
for (i=3; i<=NF; ++i) {
|
||||
if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") {
|
||||
key = ""
|
||||
if (onoff != $(i)) {
|
||||
# on or off can zap disabled or enabled:
|
||||
if (onoff == "" || (onoff == "disabled" || onoff == "enabled") && ($(i) == "on" || $(i) == "off")) {
|
||||
# It's easy to mis-spell the option when turning it
|
||||
# on or off, so warn about it here:
|
||||
if (onoff == "" && ($(i) == "on" || $(i) == "off")) {
|
||||
print $2 ": ERROR: turning unrecognized option", $(i)
|
||||
# For the moment error out - it is safer
|
||||
err = 1 # prevent END{} running
|
||||
exit 1
|
||||
}
|
||||
onoff = $(i)
|
||||
} else {
|
||||
# Print a message, otherwise the error
|
||||
# below is incomprehensible
|
||||
print $2 ": currently", onoff ": attempt to turn", $(i)
|
||||
break
|
||||
}
|
||||
istart = 3
|
||||
do {
|
||||
if (istart == 1) { # continuation line
|
||||
val = getline
|
||||
|
||||
if (val != 1) { # error reading it
|
||||
if (val == 0)
|
||||
print "option", opt ": ERROR: missing contination line"
|
||||
else
|
||||
print "option", opt ": ERROR: error reading continuation line"
|
||||
|
||||
# This is a hard error
|
||||
err = 1 # prevent END{} running
|
||||
exit 1
|
||||
}
|
||||
} else if ($(i) == "requires" || $(i) == "if" || $(i) == "enables") {
|
||||
key = $(i)
|
||||
} else if (key == "requires") {
|
||||
requires[$2] = requires[$2] " " $(i)
|
||||
} else if (key == "if") {
|
||||
iffs[$2] = iffs[$2] " " $(i)
|
||||
} else if (key == "enables") {
|
||||
enabledby[$(i)] = enabledby[$(i)] " " $2
|
||||
} else
|
||||
break # bad line format
|
||||
}
|
||||
}
|
||||
|
||||
for (i=istart; i<=NF; ++i) {
|
||||
val=$(i)
|
||||
sub(/,$/,"",val)
|
||||
if (val == "on" || val == "off" || val == "disabled") {
|
||||
key = ""
|
||||
if (onoff != val) {
|
||||
# on or off can zap disabled or enabled:
|
||||
if (onoff == "" || (onoff == "disabled" || onoff == "enabled") &&
|
||||
(val == "on" || val == "off")) {
|
||||
# It's easy to mis-spell the option when turning it
|
||||
# on or off, so warn about it here:
|
||||
if (onoff == "" && (val == "on" || val == "off")) {
|
||||
print "option", opt ": ERROR: turning unrecognized option", val
|
||||
# For the moment error out - it is safer
|
||||
err = 1 # prevent END{} running
|
||||
exit 1
|
||||
}
|
||||
onoff = val
|
||||
} else {
|
||||
# Print a message, otherwise the error
|
||||
# below is incomprehensible
|
||||
print "option", opt ": currently", onoff ": attempt to turn", val
|
||||
break
|
||||
}
|
||||
}
|
||||
} else if (val == "requires" || val == "if" || val == "enables" || val =="sets") {
|
||||
key = val
|
||||
} else if (key == "requires") {
|
||||
requires[opt] = requires[opt] " " val
|
||||
} else if (key == "if") {
|
||||
iffs[opt] = iffs[opt] " " val
|
||||
} else if (key == "enables") {
|
||||
enabledby[val] = enabledby[val] " " opt
|
||||
} else if (key == "sets") {
|
||||
sets[opt] = sets[opt] " " val
|
||||
key = "setval"
|
||||
set = val
|
||||
} else if (key == "setval") {
|
||||
setval[opt " " set] = setval[opt " " set] " " val
|
||||
} else
|
||||
break # bad line format
|
||||
}
|
||||
|
||||
istart = 1
|
||||
} while (i > NF && $0 ~ /,$/)
|
||||
|
||||
if (i > NF) {
|
||||
# Set the option, defaulting to 'enabled'
|
||||
if (onoff == "") onoff = "enabled"
|
||||
option[$2] = onoff
|
||||
option[opt] = onoff
|
||||
next
|
||||
}
|
||||
# Else fall through to the error handler
|
||||
@@ -300,41 +348,62 @@ $1 == "option" && NF >= 2{
|
||||
pre != 0 && $1 == "chunk" && NF >= 2{
|
||||
# 'chunk' is handled on the first pass by writing appropriate
|
||||
# 'option' lines into the intermediate file.
|
||||
opt = $2
|
||||
sub(/,$/,"",opt)
|
||||
onoff = ""
|
||||
reqread = ""
|
||||
reqwrite = ""
|
||||
enables = ""
|
||||
i = 3 # indicates format error
|
||||
if (NF > 2) {
|
||||
req = 0
|
||||
istart = 3
|
||||
do {
|
||||
if (istart == 1) { # continuation line
|
||||
val = getline
|
||||
|
||||
if (val != 1) { # error reading it
|
||||
if (val == 0)
|
||||
print "chunk", opt ": ERROR: missing contination line"
|
||||
else
|
||||
print "chunk", opt ": ERROR: error reading continuation line"
|
||||
|
||||
# This is a hard error
|
||||
err = 1 # prevent END{} running
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# read the keywords/additional OPTS
|
||||
req = 0
|
||||
for (i=3; i<=NF; ++i) {
|
||||
if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") {
|
||||
if (onoff != $(i)) {
|
||||
for (i=istart; i<=NF; ++i) {
|
||||
val = $(i)
|
||||
sub(/,$/,"",val)
|
||||
if (val == "on" || val == "off" || val == "disabled") {
|
||||
if (onoff != val) {
|
||||
if (onoff == "")
|
||||
onoff = $(i)
|
||||
onoff = val
|
||||
else
|
||||
break # on/off conflict
|
||||
}
|
||||
req = 0
|
||||
} else if ($(i) == "requires")
|
||||
} else if (val == "requires")
|
||||
req = 1
|
||||
else if ($(i) == "enables")
|
||||
else if (val == "enables")
|
||||
req = 2
|
||||
else if (req == 1){
|
||||
reqread = reqread " READ_" $(i)
|
||||
reqwrite = reqwrite " WRITE_" $(i)
|
||||
reqread = reqread " READ_" val
|
||||
reqwrite = reqwrite " WRITE_" val
|
||||
} else if (req == 2)
|
||||
enables = enables " " $(i)
|
||||
enables = enables " " val
|
||||
else
|
||||
break # bad line: handled below
|
||||
}
|
||||
}
|
||||
|
||||
istart = 1
|
||||
} while (i > NF && $0 ~ /,$/)
|
||||
|
||||
if (i > NF) {
|
||||
# Output new 'option' lines to the intermediate file (out)
|
||||
print "option READ_" $2, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", $2 enables , onoff >out
|
||||
print "option WRITE_" $2, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", $2 enables, onoff >out
|
||||
print "option READ_" opt, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", opt enables , onoff >out
|
||||
print "option WRITE_" opt, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", opt enables, onoff >out
|
||||
next
|
||||
}
|
||||
# Else hit the error handler below - bad line format!
|
||||
@@ -465,72 +534,7 @@ END{
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Do the 'setting' values first, the algorithm the standard
|
||||
# tree walk (O(1)) done in an O(2) while/for loop; interations
|
||||
# settings x depth, outputing the deepest required macros
|
||||
# first.
|
||||
print "" >out
|
||||
print "/* SETTINGS */" >out
|
||||
print comment, "settings", cend >out
|
||||
finished = 0
|
||||
while (!finished) {
|
||||
finished = 1
|
||||
movement = 0 # done nothing
|
||||
for (i in setting) if (!doneset[i]) {
|
||||
nreqs = split(setting[i], r)
|
||||
if (nreqs > 0) {
|
||||
for (j=1; j<=nreqs; ++j) if (!doneset[r[j]]) {
|
||||
break
|
||||
}
|
||||
if (j<=nreqs) {
|
||||
finished = 0
|
||||
continue # try a different setting
|
||||
}
|
||||
}
|
||||
|
||||
# All the requirements have been processed, output
|
||||
# this setting.
|
||||
if (deb) print "setting", i
|
||||
print "" >out
|
||||
print "/* setting: ", i >out
|
||||
print " * requires:" setting[i] >out
|
||||
print " * default: ", defaults[i], "*/" >out
|
||||
if (defaults[i] == "") { # no default, only check if defined
|
||||
print "#ifdef PNG_" i >out
|
||||
}
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
print "# ifndef PNG_" r[j] >out
|
||||
print error, i, "requires", r[j] end >out
|
||||
print "# endif" >out
|
||||
}
|
||||
if (defaults[i] != "") { # default handling
|
||||
print "#ifdef PNG_" i >out
|
||||
}
|
||||
print def i, "PNG_" i end >out
|
||||
if (defaults[i] != "") {
|
||||
print "#else /*default*/" >out
|
||||
# And add the default definition for the benefit
|
||||
# of later settings an options test:
|
||||
print "# define PNG_" i defaults[i] >out
|
||||
print def i defaults[i] end >out
|
||||
}
|
||||
print "#endif" >out
|
||||
|
||||
doneset[i] = 1
|
||||
++movement
|
||||
}
|
||||
|
||||
if (!finished && !movement) {
|
||||
print "setting: loop or missing setting in 'requires', cannot process:"
|
||||
for (i in setting) if (!doneset[i]) {
|
||||
print " setting", i, "requires" setting[i]
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
print comment, "end of settings", cend >out
|
||||
|
||||
# Now do the options - somewhat more complex. The dependency
|
||||
# Do the options first (allowing options to set settings). The dependency
|
||||
# tree is thus:
|
||||
#
|
||||
# name > name
|
||||
@@ -622,6 +626,9 @@ END{
|
||||
}
|
||||
if (err) exit 1
|
||||
|
||||
# Sort options:
|
||||
print "PNG_DFN_START_SORT 2" >out
|
||||
|
||||
# option[i] is now the complete list of all the tokens we may
|
||||
# need to output, go through it as above, depth first.
|
||||
finished = 0
|
||||
@@ -659,8 +666,9 @@ END{
|
||||
print "" >out
|
||||
print "/* option:", i, option[i] >out
|
||||
print " * requires: " requires[i] >out
|
||||
print " * if: " iffs[i] >out
|
||||
print " * enabled-by:" enabledby[i], "*/" >out
|
||||
print " * if: " iffs[i] >out
|
||||
print " * enabled-by:" enabledby[i] >out
|
||||
print " * sets: " sets[i], "*/" >out
|
||||
print "#undef PNG_on" >out
|
||||
print "#define PNG_on 1" >out
|
||||
|
||||
@@ -743,6 +751,21 @@ END{
|
||||
print error, i, "is on: enabled by:" iffs[i] enabledby[i] ", requires" requires[i] end >out
|
||||
} else if (i !~ /^ok_/) {
|
||||
print def i sup >out
|
||||
# Supported option, set required settings
|
||||
nreqs = split(sets[i], r)
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
print "# ifdef PNG_set_" r[j] >out
|
||||
# Some other option has already set a value:
|
||||
print error, i, "sets", r[j] ": duplicate setting" end >out
|
||||
print error, " previous value: " end "PNG_set_" r[j] >out
|
||||
print "# else" >out
|
||||
# Else set the default: note that this won't accept arbitrary
|
||||
# values, the setval string must be acceptable to all the C
|
||||
# compilers we use. That means it must be VERY simple; a number,
|
||||
# a name or a string.
|
||||
print "# define PNG_set_" r[j], setval[i " " r[j]] >out
|
||||
print "# endif" >out
|
||||
}
|
||||
}
|
||||
print "# endif /* definition */" >out
|
||||
print "#endif /*requires, if*/" >out
|
||||
@@ -773,10 +796,98 @@ END{
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
print "PNG_DFN_END_SORT" >out
|
||||
print comment, "end of options", cend >out
|
||||
|
||||
# Do the 'setting' values second, the algorithm the standard
|
||||
# tree walk (O(1)) done in an O(2) while/for loop; interations
|
||||
# settings x depth, outputing the deepest required macros
|
||||
# first.
|
||||
print "" >out
|
||||
print "/* SETTINGS */" >out
|
||||
print comment, "settings", cend >out
|
||||
# Sort (in dfn.awk) on field 2, the setting name
|
||||
print "PNG_DFN_START_SORT 2" >out
|
||||
finished = 0
|
||||
while (!finished) {
|
||||
finished = 1
|
||||
movement = 0 # done nothing
|
||||
for (i in setting) if (!doneset[i]) {
|
||||
nreqs = split(setting[i], r)
|
||||
if (nreqs > 0) {
|
||||
# By default assume the requires values are options, but if there
|
||||
# is no option with that name check for a setting
|
||||
for (j=1; j<=nreqs; ++j) if (option[r[j]] == "" && !doneset[r[j]]) {
|
||||
break
|
||||
}
|
||||
if (j<=nreqs) {
|
||||
finished = 0
|
||||
continue # try a different setting
|
||||
}
|
||||
}
|
||||
|
||||
# All the requirements have been processed, output
|
||||
# this setting.
|
||||
if (deb) print "setting", i
|
||||
deflt = defaults[i]
|
||||
# Remove any spurious trailing spaces
|
||||
sub(/ *$/,"",deflt)
|
||||
# A leading @ means leave it unquoted so the preprocessor
|
||||
# can substitute the build time value
|
||||
if (deflt ~ /^ @/)
|
||||
deflt = " " subs substr(deflt, 3) sube
|
||||
print "" >out
|
||||
print "/* setting: ", i >out
|
||||
print " * requires:" setting[i] >out
|
||||
print " * default: ", defaults[i] deflt, "*/" >out
|
||||
for (j=1; j<=nreqs; ++j) {
|
||||
if (option[r[j]] != "")
|
||||
print "#ifndef PNG_" r[j] "_SUPPORTED" >out
|
||||
else
|
||||
print "#ifndef PNG_" r[j] >out
|
||||
print error, i, "requires", r[j] end >out
|
||||
print "# endif" >out
|
||||
}
|
||||
# The precedence is:
|
||||
#
|
||||
# 1) External definition; trumps:
|
||||
# 2) Option 'sets' value; trumps:
|
||||
# 3) Setting 'default'
|
||||
#
|
||||
print "#ifdef PNG_" i >out
|
||||
# PNG_<i> is defined, so substitute the value:
|
||||
print def i, subs "PNG_" i sube end >out
|
||||
print "#else /* use default */" >out
|
||||
print "# ifdef PNG_set_" i >out
|
||||
# Value from an option 'sets' argument
|
||||
print def i, subs "PNG_set_" i sube end >out
|
||||
# This is so that subsequent tests on the setting work:
|
||||
print "# define PNG_" i, "1" >out
|
||||
if (defaults[i] != "") {
|
||||
print "# else /*default*/" >out
|
||||
print def i deflt end >out
|
||||
print "# define PNG_" i, "1" >out
|
||||
}
|
||||
print "# endif /* defaults */" >out
|
||||
print "#endif /* setting", i, "*/" >out
|
||||
|
||||
doneset[i] = 1
|
||||
++movement
|
||||
}
|
||||
|
||||
if (!finished && !movement) {
|
||||
print "setting: loop or missing setting in 'requires', cannot process:"
|
||||
for (i in setting) if (!doneset[i]) {
|
||||
print " setting", i, "requires" setting[i]
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
print "PNG_DFN_END_SORT" >out
|
||||
print comment, "end of settings", cend >out
|
||||
|
||||
# Regular end - everything looks ok
|
||||
if (protect != "") {
|
||||
print start "#endif", cx, protect, "*/" end >out
|
||||
print start "#endif", "/*", protect, "*/" end >out
|
||||
}
|
||||
}
|
||||
|
||||
200
scripts/pnglibconf.dfa
Normal file → Executable file
200
scripts/pnglibconf.dfa
Normal file → Executable file
@@ -8,7 +8,7 @@ com pnglibconf.h - library build configuration
|
||||
com
|
||||
version
|
||||
com
|
||||
com Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
com Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
com
|
||||
com This code is released under the libpng license.
|
||||
com For conditions of distribution and use, see the disclaimer
|
||||
@@ -27,7 +27,7 @@ file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H
|
||||
# The syntax is detailed in scripts/options.awk; this is a summary
|
||||
# only:
|
||||
#
|
||||
# setting <name> [default]
|
||||
# setting <name> [requires ...] [default]
|
||||
# #define PNG_<name> <value> /* value comes from current setting */
|
||||
# option <name> [requires ...] [if ...] [enables ...] [disabled]
|
||||
# #define PNG_<name>_SUPPORTED if the requirements are met and
|
||||
@@ -39,6 +39,11 @@ file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H
|
||||
# used as given (e.g. enables GAMMA just expands to that on the
|
||||
# correspond READ_name and WRITE_name lines.)
|
||||
#
|
||||
# "," may be used to separate options on an 'option' line and is ignored; it
|
||||
# doesn't change the meaning of the line. (NOT setting, where "," becomes
|
||||
# part of the setting!) A comma at the end of an option line causes a
|
||||
# continuation (the next line is included in the option too.)
|
||||
#
|
||||
# Note that the 'on' and 'off' keywords, while valid on both option
|
||||
# and chunk, should not be used in this file because they force the
|
||||
# relevant options on or off.
|
||||
@@ -114,7 +119,7 @@ logunsupported = 1
|
||||
#
|
||||
# If you create a private DLL you need to define the following
|
||||
# macros in the file 'pngusr.h' and set -DPNG_USER_CONFIG for
|
||||
# compilation (i.e. in CFLAGS.)
|
||||
# compilation (i.e. in CPPFLAGS.)
|
||||
# #define PNG_USER_PRIVATEBUILD \
|
||||
# <Describes by whom and why this version of the DLL was built>
|
||||
# e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
|
||||
@@ -131,6 +136,12 @@ logunsupported = 1
|
||||
# - PNG_USER_VERSIONINFO_COMPANYNAME
|
||||
# - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
|
||||
|
||||
# It is necessary to include configures definitions here so that AC_DEFINE
|
||||
# in configure.ac works in a comprehensible way
|
||||
@#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
@# include "config.h"
|
||||
@#endif
|
||||
|
||||
@#ifdef PNG_USER_CONFIG
|
||||
@# include "pngusr.h"
|
||||
@#endif
|
||||
@@ -147,6 +158,12 @@ logunsupported = 1
|
||||
@# endif
|
||||
@#endif
|
||||
|
||||
# IN DEVELOPMENT
|
||||
# These are currently experimental features; define them if you want (NOTE:
|
||||
# experimental options must be disabled before they are defined in this file!)
|
||||
|
||||
# NONE
|
||||
|
||||
# Note that PNG_USR_CONFIG only has an effect when building
|
||||
# pnglibconf.h
|
||||
|
||||
@@ -176,6 +193,60 @@ setting PREFIX
|
||||
|
||||
setting DEFAULT_READ_MACROS default 1
|
||||
|
||||
# Implementation specific control of the optimizations, enabled by those
|
||||
# hardware or software options that need it (typically when run-time choices
|
||||
# must be made by the user)
|
||||
option SET_OPTION disabled
|
||||
|
||||
# These options are specific to the ARM NEON hardware optimizations. At present
|
||||
# these optimizations depend on GCC specific pre-processing of an assembler (.S)
|
||||
# file so they probably won't work with other compilers.
|
||||
#
|
||||
# ARM_NEON_OPT: unset: check at compile time (__ARM_NEON__ must be defined by
|
||||
# the compiler, typically as a result of specifying
|
||||
# CC="gcc -mfpu=neon".)
|
||||
# 0: disable (even if the CPU has a NEON FPU.)
|
||||
# 1: check at run time (via ARM_NEON_{API,CHECK})
|
||||
# 2: switch on unconditionally (inadvisable - instead pass
|
||||
# -mfpu=neon to GCC in CC)
|
||||
# When building libpng avoid using any setting other than '0'; '1' is
|
||||
# set automatically when either 'API' or 'CHECK' are configured in,
|
||||
# '2' should not be necessary as -mfpu=neon will achieve the same
|
||||
# effect as well as applying NEON optimizations to the rest of the
|
||||
# libpng code.
|
||||
# NOTE: any setting other than '0' requires ALIGNED_MEMORY
|
||||
# ARM_NEON_API: (PNG_ARM_NEON == 1) allow the optimization to be switched on
|
||||
# with png_set_option
|
||||
# ARM_NEON_CHECK: (PNG_ARM_NEON == 1) compile a run-time check to see if Neon
|
||||
# extensions are supported, this is poorly supported and
|
||||
# deprectated - use the png_set_option API.
|
||||
setting ARM_NEON_OPT
|
||||
option ARM_NEON_API disabled requires ALIGNED_MEMORY enables SET_OPTION,
|
||||
sets ARM_NEON_OPT 1
|
||||
option ARM_NEON_CHECK disabled requires ALIGNED_MEMORY,
|
||||
sets ARM_NEON_OPT 1
|
||||
|
||||
# These settings configure the default compression level (0-9) and 'strategy';
|
||||
# strategy is as defined by the implementors of zlib, it describes the input
|
||||
# data and modifies the zlib parameters in an attempt to optimize the balance
|
||||
# between search and huffman encoding in the zlib algorithms. The defaults are
|
||||
# the zlib.h defaults - the apparently recursive definition does not arise
|
||||
# because the name of the setting is prefixed by PNG_
|
||||
#
|
||||
# The TEXT values are the defaults when writing compressed text (all forms)
|
||||
#
|
||||
# Include the zlib header too, so that the defaults below are known
|
||||
@# include <zlib.h>
|
||||
|
||||
# The '@' here means to substitute the value when pnglibconf.h is built
|
||||
setting Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION
|
||||
setting Z_DEFAULT_STRATEGY default @Z_FILTERED
|
||||
setting Z_DEFAULT_NOFILTER_STRATEGY default @Z_DEFAULT_STRATEGY
|
||||
setting ZLIB_VERNUM default @ZLIB_VERNUM
|
||||
|
||||
setting TEXT_Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION
|
||||
setting TEXT_Z_DEFAULT_STRATEGY default @Z_DEFAULT_STRATEGY
|
||||
|
||||
# The alternative is to call functions to read PNG values, if
|
||||
# the functions are turned *off* the read macros must always
|
||||
# be enabled, so turning this off will actually force the
|
||||
@@ -319,8 +390,21 @@ option SAFE_LIMITS enables USER_LIMITS disabled
|
||||
# See the comments above about how to change options and settings.
|
||||
|
||||
# READ options
|
||||
#
|
||||
# WARNING: in libpng 1.5 maintained configuration compatibility with earlier
|
||||
# versions. In some cases turning off an option turned off other options, in
|
||||
# others it was ineffective unless dependent options were also turned off.
|
||||
# Libpng 1.6 changes this: in general if you turn off an option that affects
|
||||
# APIs it stays off and simply disables APIs that depend on it.
|
||||
#
|
||||
# As a result if you simply port the libpng 1.5 configuration to libpng 1.6 you
|
||||
# will probably see build failures due to missing APIs. Fixing these failures
|
||||
# requires some, perhaps considerable, knowledge of what your libpng using
|
||||
# applications are doing, fortunately there is no great reason for you to move
|
||||
# to libpng 1.6; the new interfaces in 1.6 will take several years to become
|
||||
# popular.
|
||||
|
||||
option READ enables READ_INTERLACING
|
||||
option READ enables READ_INTERLACING SET_OPTION
|
||||
|
||||
# Disabling READ_16BIT does not disable reading 16-bit PNG files, but it
|
||||
# forces them to be chopped down to 8-bit, and disables any 16-bit
|
||||
@@ -336,27 +420,42 @@ option READ_QUANTIZE requires READ
|
||||
option READ_TRANSFORMS requires READ
|
||||
= NO_READ_TRANSFORMS READ_TRANSFORMS_NOT_SUPPORTED
|
||||
|
||||
option READ_EXPAND requires READ_TRANSFORMS
|
||||
option READ_EXPAND_16 requires READ_TRANSFORMS READ_16BIT enables READ_EXPAND
|
||||
option READ_SHIFT requires READ_TRANSFORMS
|
||||
option READ_PACK requires READ_TRANSFORMS
|
||||
option READ_BGR requires READ_TRANSFORMS
|
||||
option READ_SWAP requires READ_TRANSFORMS READ_16BIT
|
||||
option READ_PACKSWAP requires READ_TRANSFORMS
|
||||
option READ_INVERT requires READ_TRANSFORMS
|
||||
option READ_BACKGROUND requires READ_TRANSFORMS enables READ_STRIP_ALPHA
|
||||
option READ_STRIP_16_TO_8 requires READ_TRANSFORMS
|
||||
option READ_SCALE_16_TO_8 requires READ_TRANSFORMS
|
||||
option READ_FILLER requires READ_TRANSFORMS
|
||||
option READ_GAMMA requires READ_TRANSFORMS enables READ_gAMA
|
||||
option READ_GRAY_TO_RGB requires READ_TRANSFORMS
|
||||
# Read gamma handling. Gamma processing is a core part of libpng and many of
|
||||
# the capabilities are dependent on libpng performing gamma correction.
|
||||
#
|
||||
# In libpng 1.6 disabling gamma processing (setting PNG_NO_READ_GAMMA)
|
||||
# consistently disables those parts of the API that depend on it. Prior to
|
||||
# 1.6.0 this was not true; the results were unpredictable and varied between
|
||||
# releases.
|
||||
#
|
||||
# If you disable gamma processing and your program no longer compiles you need
|
||||
# to ask whether you really need the APIs that are missing. If you do then you
|
||||
# almost certainly need the gamma processing.
|
||||
#
|
||||
# If you handle gamma issues outside libpng then you do not need the libpng
|
||||
# gamma processing; and it is an enormous waste of space. You just need to
|
||||
# remove the use of libpng APIs that depend on it.
|
||||
option READ_GAMMA requires READ_TRANSFORMS, READ_gAMA
|
||||
|
||||
option READ_ALPHA_MODE requires READ_TRANSFORMS enables READ_GAMMA
|
||||
option READ_SWAP_ALPHA requires READ_TRANSFORMS
|
||||
option READ_ALPHA_MODE requires READ_TRANSFORMS, READ_GAMMA
|
||||
option READ_BACKGROUND requires READ_TRANSFORMS, READ_STRIP_ALPHA, READ_GAMMA
|
||||
option READ_BGR requires READ_TRANSFORMS
|
||||
option READ_EXPAND_16 requires READ_TRANSFORMS, READ_16BIT, READ_EXPAND
|
||||
option READ_EXPAND requires READ_TRANSFORMS
|
||||
option READ_FILLER requires READ_TRANSFORMS
|
||||
option READ_GRAY_TO_RGB requires READ_TRANSFORMS
|
||||
option READ_INVERT_ALPHA requires READ_TRANSFORMS
|
||||
option READ_INVERT requires READ_TRANSFORMS
|
||||
option READ_PACK requires READ_TRANSFORMS
|
||||
option READ_PACKSWAP requires READ_TRANSFORMS
|
||||
option READ_RGB_TO_GRAY requires READ_TRANSFORMS, READ_GAMMA
|
||||
option READ_SCALE_16_TO_8 requires READ_TRANSFORMS
|
||||
option READ_SHIFT requires READ_TRANSFORMS
|
||||
option READ_STRIP_16_TO_8 requires READ_TRANSFORMS
|
||||
option READ_STRIP_ALPHA requires READ_TRANSFORMS
|
||||
option READ_SWAP_ALPHA requires READ_TRANSFORMS
|
||||
option READ_SWAP requires READ_TRANSFORMS, READ_16BIT
|
||||
option READ_USER_TRANSFORM requires READ_TRANSFORMS
|
||||
option READ_RGB_TO_GRAY requires READ_TRANSFORMS
|
||||
|
||||
option PROGRESSIVE_READ requires READ
|
||||
option SEQUENTIAL_READ requires READ
|
||||
@@ -380,11 +479,6 @@ option INCH_CONVERSIONS
|
||||
|
||||
option BUILD_GRAYSCALE_PALETTE
|
||||
|
||||
# IN DEVELOPMENT
|
||||
# These are currently experimental features; define them if you want
|
||||
|
||||
# NOTHING HERE
|
||||
|
||||
# WRITE options
|
||||
|
||||
option WRITE
|
||||
@@ -399,7 +493,7 @@ option WRITE_TRANSFORMS requires WRITE
|
||||
option WRITE_SHIFT requires WRITE_TRANSFORMS
|
||||
option WRITE_PACK requires WRITE_TRANSFORMS
|
||||
option WRITE_BGR requires WRITE_TRANSFORMS
|
||||
option WRITE_SWAP requires WRITE_TRANSFORMS WRITE_16BIT
|
||||
option WRITE_SWAP requires WRITE_TRANSFORMS, WRITE_16BIT
|
||||
option WRITE_PACKSWAP requires WRITE_TRANSFORMS
|
||||
option WRITE_INVERT requires WRITE_TRANSFORMS
|
||||
option WRITE_FILLER requires WRITE_TRANSFORMS
|
||||
@@ -421,8 +515,8 @@ option WRITE_FLUSH requires WRITE
|
||||
|
||||
# Note: these can be turned off explicitly if not required by the
|
||||
# apps implementing the user transforms
|
||||
option USER_TRANSFORM_PTR if READ_USER_TRANSFORM WRITE_USER_TRANSFORM
|
||||
option USER_TRANSFORM_INFO if READ_USER_TRANSFORM WRITE_USER_TRANSFORM
|
||||
option USER_TRANSFORM_PTR if READ_USER_TRANSFORM, WRITE_USER_TRANSFORM
|
||||
option USER_TRANSFORM_INFO if READ_USER_TRANSFORM, WRITE_USER_TRANSFORM
|
||||
|
||||
# This enables API to set compression parameters for compressing
|
||||
# non-IDAT chunks (zTXt, iTXt, iCCP, and unknown chunks). This feature
|
||||
@@ -523,7 +617,7 @@ setting sRGB_PROFILE_CHECKS default 2
|
||||
# but can help (in theory) on some architectures. Only affects
|
||||
# internal structures. Added at libpng 1.4.0
|
||||
|
||||
option ALIGN_MEMORY
|
||||
option ALIGNED_MEMORY
|
||||
|
||||
# Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING
|
||||
# See png[wr]util.c, normally this should always be *on*
|
||||
@@ -615,7 +709,7 @@ chunk bKGD
|
||||
chunk cHRM enables COLORSPACE
|
||||
chunk gAMA enables GAMMA
|
||||
chunk hIST
|
||||
chunk iCCP enables COLORSPACE GAMMA
|
||||
chunk iCCP enables COLORSPACE, GAMMA
|
||||
chunk iTXt
|
||||
chunk oFFs
|
||||
chunk pCAL
|
||||
@@ -623,7 +717,7 @@ chunk pHYs
|
||||
chunk sBIT
|
||||
chunk sCAL
|
||||
chunk sPLT
|
||||
chunk sRGB enables COLORSPACE GAMMA
|
||||
chunk sRGB enables COLORSPACE, GAMMA
|
||||
chunk tEXt requires TEXT
|
||||
chunk tIME
|
||||
chunk tRNS
|
||||
@@ -653,7 +747,7 @@ option WRITE_UNKNOWN_CHUNKS enables STORE_UNKNOWN_CHUNKS
|
||||
# to png_get_unknown_chunks, the application must call
|
||||
# png_set_keep_unknown_chunks to cause this to actually happen (see png.h)
|
||||
option SAVE_UNKNOWN_CHUNKS requires READ requires SET_UNKNOWN_CHUNKS
|
||||
option SAVE_UNKNOWN_CHUNKS enables READ_UNKNOWN_CHUNKS STORE_UNKNOWN_CHUNKS
|
||||
option SAVE_UNKNOWN_CHUNKS enables READ_UNKNOWN_CHUNKS, STORE_UNKNOWN_CHUNKS
|
||||
|
||||
# The second approach is to use an application provided callback to process the
|
||||
# chunks, the callback can either handle the chunk entirely itself or request
|
||||
@@ -661,8 +755,8 @@ option SAVE_UNKNOWN_CHUNKS enables READ_UNKNOWN_CHUNKS STORE_UNKNOWN_CHUNKS
|
||||
#
|
||||
# Note that there is no 'WRITE_USER_CHUNKS' so the USER_CHUNKS option is always
|
||||
# the same as READ_USER_CHUNKS at present
|
||||
option READ_USER_CHUNKS requires READ requires UNKNOWN_CHUNKS
|
||||
option READ_USER_CHUNKS enables READ_UNKNOWN_CHUNKS USER_CHUNKS
|
||||
option READ_USER_CHUNKS requires READ, UNKNOWN_CHUNKS
|
||||
option READ_USER_CHUNKS enables READ_UNKNOWN_CHUNKS, USER_CHUNKS
|
||||
|
||||
# Two further options are provided to allow detailed control of the handling.
|
||||
# The first enables png_set_keep_unknown_chunks; this allows the default to be
|
||||
@@ -694,9 +788,10 @@ option CONVERT_tIME requires WRITE_ANCILLARY_CHUNKS
|
||||
|
||||
option WRITE_FILTER requires WRITE
|
||||
|
||||
option SAVE_INT_32 requires WRITE
|
||||
|
||||
# png_save_int_32 is required by the ancillary chunks oFFs and pCAL
|
||||
option SAVE_INT_32 disabled
|
||||
# png_save_int_32 is required internally for writing the ancillary chunks oFFs
|
||||
# and pCAL and for both reading and writing iCCP (for the generation/checking of
|
||||
# the corresponding cHRM/gAMA chunks) if full ICC is supported.
|
||||
|
||||
# added at libpng-1.5.4
|
||||
|
||||
@@ -728,17 +823,21 @@ option INFO_IMAGE
|
||||
|
||||
option CHECK_FOR_INVALID_INDEX enables READ_CHECK_FOR_INVALID_INDEX
|
||||
option CHECK_FOR_INVALID_INDEX enables WRITE_CHECK_FOR_INVALID_INDEX
|
||||
option READ_CHECK_FOR_INVALID_INDEX requires READ CHECK_FOR_INVALID_INDEX
|
||||
option WRITE_CHECK_FOR_INVALID_INDEX requires WRITE CHECK_FOR_INVALID_INDEX
|
||||
option READ_CHECK_FOR_INVALID_INDEX requires READ, CHECK_FOR_INVALID_INDEX
|
||||
option WRITE_CHECK_FOR_INVALID_INDEX requires WRITE, CHECK_FOR_INVALID_INDEX
|
||||
|
||||
# added at libpng-1.5.15
|
||||
option GET_PALETTE_MAX enables READ_GET_PALETTE_MAX WRITE_GET_PALETTE_MAX
|
||||
option READ_GET_PALETTE_MAX requires READ_CHECK_FOR_INVALID_INDEX disabled
|
||||
option WRITE_GET_PALETTE_MAX requires WRITE_CHECK_FOR_INVALID_INDEX disabled
|
||||
|
||||
# Simplified API options (added at libpng-1.6.0)
|
||||
# Read:
|
||||
option SIMPLIFIED_READ requires SEQUENTIAL_READ READ_TRANSFORMS SETJMP
|
||||
option SIMPLIFIED_READ requires BENIGN_ERRORS
|
||||
option SIMPLIFIED_READ enables READ_EXPAND READ_16BIT READ_EXPAND_16
|
||||
option SIMPLIFIED_READ enables READ_SCALE_16_TO_8 READ_RGB_TO_GRAY
|
||||
option SIMPLIFIED_READ enables READ_ALPHA_MODE READ_BACKGROUND READ_STRIP_ALPHA
|
||||
option SIMPLIFIED_READ enables READ_FILLER READ_SWAP
|
||||
option SIMPLIFIED_READ,
|
||||
requires SEQUENTIAL_READ READ_TRANSFORMS, SETJMP, BENIGN_ERRORS READ_GAMMA,
|
||||
enables READ_EXPAND, READ_16BIT READ_EXPAND_16, READ_SCALE_16_TO_8,
|
||||
READ_RGB_TO_GRAY, READ_ALPHA_MODE READ_BACKGROUND READ_STRIP_ALPHA,
|
||||
READ_FILLER, READ_SWAP
|
||||
|
||||
option SIMPLIFIED_READ_AFIRST requires SIMPLIFIED_READ disabled
|
||||
option READ_SWAP_ALPHA enables SIMPLIFIED_READ_AFIRST
|
||||
@@ -747,8 +846,9 @@ option SIMPLIFIED_READ_BGR requires SIMPLIFIED_READ disabled
|
||||
option READ_BGR enables SIMPLIFIED_READ_BGR
|
||||
|
||||
# Write:
|
||||
option SIMPLIFIED_WRITE requires WRITE STDIO SETJMP
|
||||
option SIMPLIFIED_WRITE enables WRITE_SWAP WRITE_gAMA WRITE_sRGB WRITE_cHRM
|
||||
option SIMPLIFIED_WRITE,
|
||||
requires WRITE STDIO, SETJMP,
|
||||
enables WRITE_SWAP WRITE_gAMA, WRITE_sRGB WRITE_cHRM
|
||||
|
||||
option SIMPLIFIED_WRITE_AFIRST requires SIMPLIFIED_WRITE disabled
|
||||
option WRITE_SWAP_ALPHA enables SIMPLIFIED_WRITE_AFIRST
|
||||
@@ -757,5 +857,5 @@ option SIMPLIFIED_WRITE_BGR requires SIMPLIFIED_WRITE disabled
|
||||
option WRITE_BGR enables SIMPLIFIED_WRITE_BGR
|
||||
|
||||
# Formats:
|
||||
option FORMAT_AFIRST if SIMPLIFIED_READ_AFIRST SIMPLIFIED_WRITE_AFIRST
|
||||
option FORMAT_BGR if SIMPLIFIED_READ_BGR SIMPLIFIED_WRITE_BGR
|
||||
option FORMAT_AFIRST if SIMPLIFIED_READ_AFIRST, SIMPLIFIED_WRITE_AFIRST
|
||||
option FORMAT_BGR if SIMPLIFIED_READ_BGR, SIMPLIFIED_WRITE_BGR
|
||||
|
||||
@@ -1,25 +1,190 @@
|
||||
|
||||
/* libpng STANDARD API DEFINITION */
|
||||
/* libpng 1.6.3 STANDARD API DEFINITION */
|
||||
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* Libpng 1.6.0beta28 - August 29, 2012 */
|
||||
/* Libpng version 1.6.3 - July 18, 2013 */
|
||||
|
||||
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
|
||||
/* Copyright (c) 1998-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 */
|
||||
|
||||
/* pnglibconf.h */
|
||||
/* Machine generated file: DO NOT EDIT */
|
||||
/* Derived from: scripts/pnglibconf.dfa */
|
||||
/* If you edit this file by hand you must obey the rules expressed in */
|
||||
/* pnglibconf.dfa with respect to the dependencies between the following */
|
||||
/* symbols. It is much better to generate a new file using */
|
||||
/* scripts/libpngconf.mak */
|
||||
|
||||
#ifndef PNGLCONF_H
|
||||
#define PNGLCONF_H
|
||||
/* options */
|
||||
#define PNG_16BIT_SUPPORTED
|
||||
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
|
||||
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_COLORSPACE_SUPPORTED
|
||||
#define PNG_CONSOLE_IO_SUPPORTED
|
||||
#define PNG_CONVERT_tIME_SUPPORTED
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||
#define PNG_ERROR_TEXT_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_FORMAT_AFIRST_SUPPORTED
|
||||
#define PNG_FORMAT_BGR_SUPPORTED
|
||||
#define PNG_GAMMA_SUPPORTED
|
||||
#define PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
#define PNG_INCH_CONVERSIONS_SUPPORTED
|
||||
#define PNG_INFO_IMAGE_SUPPORTED
|
||||
#define PNG_IO_STATE_SUPPORTED
|
||||
#define PNG_MNG_FEATURES_SUPPORTED
|
||||
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_READ_16BIT_SUPPORTED
|
||||
#define PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||
#define PNG_READ_BGR_SUPPORTED
|
||||
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_READ_EXPAND_16_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_FILLER_SUPPORTED
|
||||
#define PNG_READ_GAMMA_SUPPORTED
|
||||
#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#define PNG_READ_INTERLACING_SUPPORTED
|
||||
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_READ_INVERT_SUPPORTED
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED
|
||||
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
#define PNG_READ_QUANTIZE_SUPPORTED
|
||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_SUPPORTED
|
||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_SWAP_SUPPORTED
|
||||
#define PNG_READ_TEXT_SUPPORTED
|
||||
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
#define PNG_READ_hIST_SUPPORTED
|
||||
#define PNG_READ_iCCP_SUPPORTED
|
||||
#define PNG_READ_iTXt_SUPPORTED
|
||||
#define PNG_READ_oFFs_SUPPORTED
|
||||
#define PNG_READ_pCAL_SUPPORTED
|
||||
#define PNG_READ_pHYs_SUPPORTED
|
||||
#define PNG_READ_sBIT_SUPPORTED
|
||||
#define PNG_READ_sCAL_SUPPORTED
|
||||
#define PNG_READ_sPLT_SUPPORTED
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#define PNG_READ_tEXt_SUPPORTED
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
|
||||
#define PNG_SAVE_INT_32_SUPPORTED
|
||||
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
|
||||
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
#define PNG_SET_OPTION_SUPPORTED
|
||||
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SET_USER_LIMITS_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#define PNG_STDIO_SUPPORTED
|
||||
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_TEXT_SUPPORTED
|
||||
#define PNG_TIME_RFC1123_SUPPORTED
|
||||
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_LIMITS_SUPPORTED
|
||||
#define PNG_USER_MEM_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#define PNG_WARNINGS_SUPPORTED
|
||||
#define PNG_WRITE_16BIT_SUPPORTED
|
||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_FILLER_SUPPORTED
|
||||
#define PNG_WRITE_FILTER_SUPPORTED
|
||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||
#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED
|
||||
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_SUPPORTED
|
||||
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
#define PNG_WRITE_PACK_SUPPORTED
|
||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||
#define PNG_WRITE_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_SUPPORTED
|
||||
#define PNG_WRITE_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#define PNG_WRITE_bKGD_SUPPORTED
|
||||
#define PNG_WRITE_cHRM_SUPPORTED
|
||||
#define PNG_WRITE_gAMA_SUPPORTED
|
||||
#define PNG_WRITE_hIST_SUPPORTED
|
||||
#define PNG_WRITE_iCCP_SUPPORTED
|
||||
#define PNG_WRITE_iTXt_SUPPORTED
|
||||
#define PNG_WRITE_oFFs_SUPPORTED
|
||||
#define PNG_WRITE_pCAL_SUPPORTED
|
||||
#define PNG_WRITE_pHYs_SUPPORTED
|
||||
#define PNG_WRITE_sBIT_SUPPORTED
|
||||
#define PNG_WRITE_sCAL_SUPPORTED
|
||||
#define PNG_WRITE_sPLT_SUPPORTED
|
||||
#define PNG_WRITE_sRGB_SUPPORTED
|
||||
#define PNG_WRITE_tEXt_SUPPORTED
|
||||
#define PNG_WRITE_tIME_SUPPORTED
|
||||
#define PNG_WRITE_tRNS_SUPPORTED
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#define PNG_bKGD_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#define PNG_gAMA_SUPPORTED
|
||||
#define PNG_hIST_SUPPORTED
|
||||
#define PNG_iCCP_SUPPORTED
|
||||
#define PNG_iTXt_SUPPORTED
|
||||
#define PNG_oFFs_SUPPORTED
|
||||
#define PNG_pCAL_SUPPORTED
|
||||
#define PNG_pHYs_SUPPORTED
|
||||
#define PNG_sBIT_SUPPORTED
|
||||
#define PNG_sCAL_SUPPORTED
|
||||
#define PNG_sPLT_SUPPORTED
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
#define PNG_tEXt_SUPPORTED
|
||||
#define PNG_tIME_SUPPORTED
|
||||
#define PNG_tRNS_SUPPORTED
|
||||
#define PNG_zTXt_SUPPORTED
|
||||
/* end of options */
|
||||
/* settings */
|
||||
#define PNG_API_RULE 0
|
||||
#define PNG_CALLOC_SUPPORTED
|
||||
@@ -32,173 +197,15 @@
|
||||
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||
#define PNG_QUANTIZE_RED_BITS 5
|
||||
#define PNG_sCAL_PRECISION 5
|
||||
#define PNG_sRGB_PROFILE_CHECKS 2
|
||||
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
|
||||
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
|
||||
#define PNG_WEIGHT_SHIFT 8
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
#define PNG_ZLIB_VERNUM 0 /* unknown */
|
||||
#define PNG_Z_DEFAULT_COMPRESSION (-1)
|
||||
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
|
||||
#define PNG_Z_DEFAULT_STRATEGY 1
|
||||
#define PNG_sCAL_PRECISION 5
|
||||
#define PNG_sRGB_PROFILE_CHECKS 2
|
||||
/* end of settings */
|
||||
/* options */
|
||||
#define PNG_16BIT_SUPPORTED
|
||||
#define PNG_ALIGN_MEMORY_SUPPORTED
|
||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||
#define PNG_bKGD_SUPPORTED
|
||||
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
|
||||
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#define PNG_COLORSPACE_SUPPORTED
|
||||
#define PNG_CONSOLE_IO_SUPPORTED
|
||||
#define PNG_CONVERT_tIME_SUPPORTED
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||
#define PNG_ERROR_TEXT_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_FORMAT_AFIRST_SUPPORTED
|
||||
#define PNG_FORMAT_BGR_SUPPORTED
|
||||
#define PNG_gAMA_SUPPORTED
|
||||
#define PNG_GAMMA_SUPPORTED
|
||||
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
#define PNG_hIST_SUPPORTED
|
||||
#define PNG_iCCP_SUPPORTED
|
||||
#define PNG_INCH_CONVERSIONS_SUPPORTED
|
||||
#define PNG_INFO_IMAGE_SUPPORTED
|
||||
#define PNG_IO_STATE_SUPPORTED
|
||||
#define PNG_iTXt_SUPPORTED
|
||||
#define PNG_MNG_FEATURES_SUPPORTED
|
||||
#define PNG_oFFs_SUPPORTED
|
||||
#define PNG_pCAL_SUPPORTED
|
||||
#define PNG_pHYs_SUPPORTED
|
||||
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_READ_16BIT_SUPPORTED
|
||||
#define PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||
#define PNG_READ_BGR_SUPPORTED
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_READ_EXPAND_16_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_FILLER_SUPPORTED
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
#define PNG_READ_GAMMA_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#define PNG_READ_hIST_SUPPORTED
|
||||
#define PNG_READ_iCCP_SUPPORTED
|
||||
#define PNG_READ_INTERLACING_SUPPORTED
|
||||
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_READ_INVERT_SUPPORTED
|
||||
#define PNG_READ_iTXt_SUPPORTED
|
||||
#define PNG_READ_oFFs_SUPPORTED
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||
#define PNG_READ_pCAL_SUPPORTED
|
||||
#define PNG_READ_pHYs_SUPPORTED
|
||||
#define PNG_READ_QUANTIZE_SUPPORTED
|
||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
#define PNG_READ_sBIT_SUPPORTED
|
||||
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_sCAL_SUPPORTED
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
#define PNG_READ_sPLT_SUPPORTED
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_SUPPORTED
|
||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_SWAP_SUPPORTED
|
||||
#define PNG_READ_tEXt_SUPPORTED
|
||||
#define PNG_READ_TEXT_SUPPORTED
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
|
||||
#define PNG_SAVE_INT_32_SUPPORTED
|
||||
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_sBIT_SUPPORTED
|
||||
#define PNG_sCAL_SUPPORTED
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
|
||||
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SET_USER_LIMITS_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#define PNG_sPLT_SUPPORTED
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
#define PNG_STDIO_SUPPORTED
|
||||
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_tEXt_SUPPORTED
|
||||
#define PNG_TEXT_SUPPORTED
|
||||
#define PNG_TIME_RFC1123_SUPPORTED
|
||||
#define PNG_tIME_SUPPORTED
|
||||
#define PNG_tRNS_SUPPORTED
|
||||
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_USER_LIMITS_SUPPORTED
|
||||
#define PNG_USER_MEM_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#define PNG_WARNINGS_SUPPORTED
|
||||
#define PNG_WRITE_16BIT_SUPPORTED
|
||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
#define PNG_WRITE_bKGD_SUPPORTED
|
||||
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_WRITE_cHRM_SUPPORTED
|
||||
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_FILLER_SUPPORTED
|
||||
#define PNG_WRITE_FILTER_SUPPORTED
|
||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||
#define PNG_WRITE_gAMA_SUPPORTED
|
||||
#define PNG_WRITE_hIST_SUPPORTED
|
||||
#define PNG_WRITE_iCCP_SUPPORTED
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED
|
||||
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_SUPPORTED
|
||||
#define PNG_WRITE_iTXt_SUPPORTED
|
||||
#define PNG_WRITE_oFFs_SUPPORTED
|
||||
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
#define PNG_WRITE_PACK_SUPPORTED
|
||||
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
#define PNG_WRITE_pCAL_SUPPORTED
|
||||
#define PNG_WRITE_pHYs_SUPPORTED
|
||||
#define PNG_WRITE_sBIT_SUPPORTED
|
||||
#define PNG_WRITE_sCAL_SUPPORTED
|
||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||
#define PNG_WRITE_sPLT_SUPPORTED
|
||||
#define PNG_WRITE_sRGB_SUPPORTED
|
||||
#define PNG_WRITE_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_SUPPORTED
|
||||
#define PNG_WRITE_tEXt_SUPPORTED
|
||||
#define PNG_WRITE_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_tIME_SUPPORTED
|
||||
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
#define PNG_WRITE_tRNS_SUPPORTED
|
||||
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#define PNG_zTXt_SUPPORTED
|
||||
/* end of options */
|
||||
#endif /* PNGLCONF_H */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user