mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
391 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 | ||
|
|
cc02f89eb2 | ||
|
|
14d0ca620e | ||
|
|
8010217201 | ||
|
|
702053d110 | ||
|
|
74a9c07fdd | ||
|
|
d0eef28ee1 | ||
|
|
3c1f6983c5 | ||
|
|
4a6c6df6c7 | ||
|
|
025d415838 | ||
|
|
810c99583b | ||
|
|
e9567514dd | ||
|
|
b593b3f035 | ||
|
|
0f08665bfb | ||
|
|
3744f94fd1 | ||
|
|
aa9dea57d7 | ||
|
|
ece07cfe9c | ||
|
|
dbb7e19fda | ||
|
|
e2098ba085 | ||
|
|
26849f4693 | ||
|
|
ad5a993954 | ||
|
|
6954141484 | ||
|
|
ba2dd33d9c | ||
|
|
134c5761fa | ||
|
|
865e14fd32 | ||
|
|
5d1df4fdf4 | ||
|
|
8d3453a22d | ||
|
|
4430b91363 | ||
|
|
dff6f4c4f0 | ||
|
|
432c174b64 | ||
|
|
5f5977e708 | ||
|
|
0a9f8eb272 | ||
|
|
cad0150d12 | ||
|
|
ee427ad39a | ||
|
|
01b813000a | ||
|
|
449db5a9c1 | ||
|
|
80b67e47e8 | ||
|
|
0a9f26e219 | ||
|
|
05ed18e7d1 | ||
|
|
edb3523a9b | ||
|
|
46cb5109bd | ||
|
|
5845d3eabd | ||
|
|
4a37149f66 | ||
|
|
fc58b17772 | ||
|
|
96b917056d | ||
|
|
0546e4e579 | ||
|
|
05af5cd8fb | ||
|
|
d630301d99 | ||
|
|
2ec8409046 | ||
|
|
905cc94e3d | ||
|
|
8f424b8270 | ||
|
|
cc46157421 | ||
|
|
14ca47b453 | ||
|
|
b1e7771d5e | ||
|
|
ff7b7ba060 | ||
|
|
1935d0738f | ||
|
|
04c1c078b9 | ||
|
|
8f4d67218e | ||
|
|
15f6fd3492 | ||
|
|
b45416921b | ||
|
|
040575c80b | ||
|
|
43309056ac | ||
|
|
bc2a57f657 | ||
|
|
56f22f4320 | ||
|
|
cd39adb561 | ||
|
|
b4f5c42092 | ||
|
|
e243a1fbd8 | ||
|
|
747b554a86 | ||
|
|
f229d4df3a | ||
|
|
96027d919f | ||
|
|
58f277c18e | ||
|
|
921648a997 | ||
|
|
23a30f8583 | ||
|
|
48015617d3 | ||
|
|
13a87d9682 | ||
|
|
c1217ee280 | ||
|
|
51d1e2be1b | ||
|
|
f7677a348e | ||
|
|
8fbd60ded2 | ||
|
|
b11b31aea2 | ||
|
|
51624965e2 | ||
|
|
ce9d8a3f48 | ||
|
|
eda53e5770 | ||
|
|
2bc76ffaf1 | ||
|
|
66efa24241 | ||
|
|
0c11b5f8e7 | ||
|
|
f5dcba6b9b | ||
|
|
c26d6e9aac | ||
|
|
42ed02ed9a | ||
|
|
31d66245ea | ||
|
|
d9d7a7e8f0 | ||
|
|
d15d124d6d | ||
|
|
dd6ecbe688 | ||
|
|
aa816c4444 | ||
|
|
209b3e4b79 | ||
|
|
f2715a558a | ||
|
|
845ee6af72 | ||
|
|
9ff37ea94f | ||
|
|
35f2e1768b | ||
|
|
945cb1f9be | ||
|
|
71db131882 | ||
|
|
bf7661f01b | ||
|
|
9066919600 | ||
|
|
1ffbe8c7c1 | ||
|
|
8d0215928d | ||
|
|
b5d0051dcb | ||
|
|
6038b80277 | ||
|
|
b57c1c9e6e | ||
|
|
0c98cc7023 | ||
|
|
6225b0e61e | ||
|
|
d072048925 | ||
|
|
7d4fbb2fbb | ||
|
|
42a2b556e9 | ||
|
|
e2ae0f2f2b | ||
|
|
d6cf3a3791 | ||
|
|
e741cd592e | ||
|
|
0ae4f7b705 | ||
|
|
29a6ba01a7 | ||
|
|
434801a39c | ||
|
|
79a141876a | ||
|
|
eeb1bb678d | ||
|
|
8e92cd51c6 | ||
|
|
363387c9c0 | ||
|
|
6f237b6bf0 | ||
|
|
a0ddf0b5f2 | ||
|
|
5541ea8aaf | ||
|
|
cf49919686 | ||
|
|
363ae65e2b | ||
|
|
cb129a6234 | ||
|
|
dee7577330 | ||
|
|
1c25b9b06b | ||
|
|
0a92b23c4b | ||
|
|
5408b613f8 | ||
|
|
b7e32059d3 | ||
|
|
faf38eea03 | ||
|
|
9eb125e927 | ||
|
|
203e6dd7cf | ||
|
|
16bb03b8b4 |
306
ANNOUNCE
306
ANNOUNCE
@@ -1,233 +1,113 @@
|
||||
|
||||
Libpng 1.6.0beta13 - February 24, 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.0beta13.tar.xz (LZMA-compressed, recommended)
|
||||
1.6.0beta13.tar.gz
|
||||
1.6.0beta13.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
|
||||
|
||||
lp160b13.7z (LZMA-compressed, recommended)
|
||||
lp160b13.zip
|
||||
lpng163.7z (LZMA-compressed, recommended)
|
||||
lpng163.zip
|
||||
|
||||
Other information:
|
||||
|
||||
1.6.0beta13-README.txt
|
||||
1.6.0beta13-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.
|
||||
|
||||
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 on the configure command
|
||||
or put #define PNG_SAFE_LIMITS_SUPPORTED in pnglibconf.h.prebuilt.
|
||||
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
|
||||
|
||||
651
CHANGES
651
CHANGES
@@ -3672,7 +3672,8 @@ Version 1.5.6 [November 3, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.7beta01 [November 4, 2011]
|
||||
Added support for ARM processor (Mans Rullgard)
|
||||
Added support for ARM processor, when decoding all PNG up-filtered rows
|
||||
and any other-filtered rows with 3 or 4 bytes per pixel (Mans Rullgard).
|
||||
Fixed bug in pngvalid on early allocation failure; fixed type cast in
|
||||
pngmem.c; pngvalid would attempt to call png_error() if the allocation
|
||||
of a png_struct or png_info failed. This would probably have led to a
|
||||
@@ -3779,7 +3780,8 @@ Version 1.5.7 [December 15, 2011]
|
||||
|
||||
Version 1.6.0beta01 [December 15, 2011]
|
||||
Removed machine-generated configure files from the GIT repository (they will
|
||||
continue to appear in the tarball distributions).
|
||||
continue to appear in the tarball distributions and in the libpng15 and
|
||||
earlier GIT branches).
|
||||
Restored the new 'simplified' API, which was started in libpng-1.5.7beta02
|
||||
but later deleted from libpng-1.5.7beta05.
|
||||
Added example programs for the new 'simplified' API.
|
||||
@@ -3827,6 +3829,8 @@ Version 1.6.0beta03 [December 22, 2011]
|
||||
so is particularly valuable. Overall on a 64-bit system the libpng DLL
|
||||
decreases in code size by 1733 bytes. pngerror.o increases in size by
|
||||
about 465 bytes because of the new functionality.
|
||||
Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123()
|
||||
to avoid including a spurious buffer in the png_struct.
|
||||
|
||||
Version 1.6.0beta04 [December 30, 2011]
|
||||
Regenerated configure scripts with automake-1.11.2
|
||||
@@ -3889,7 +3893,7 @@ Version 1.6.0beta07 [January 28, 2012]
|
||||
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
|
||||
directory extracted from a tar distribution anymore. You must run it in
|
||||
a GIT clone instead.
|
||||
Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale),
|
||||
and renamed three whose names were inconsistent with those in
|
||||
@@ -3976,10 +3980,643 @@ Version 1.6.0beta13 [February 24, 2012]
|
||||
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 on the configure command
|
||||
or put #define PNG_SAFE_LIMITS_SUPPORTED in pnglibconf.h.prebuilt.
|
||||
Added PNG_SAFE_LIMITS feature to pnglibconf.dfa, pngpriv.h, and new
|
||||
pngusr.dfa to reset the user limits to safe ones if PNG_SAFE_LIMITS is
|
||||
defined. To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED=1" on the
|
||||
configure command or put #define PNG_SAFE_LIMITS_SUPPORTED in
|
||||
pnglibconf.h.prebuilt and pnglibconf.h.
|
||||
|
||||
Version 1.6.0beta14 [February 27, 2012]
|
||||
Added information about the new limits in the manual.
|
||||
Updated Makefile.in
|
||||
|
||||
Version 1.6.0beta15 [March 2, 2012]
|
||||
Removed unused "current_text" members of png_struct and the png_free()
|
||||
of png_ptr->current_text from pngread.c
|
||||
Rewrote pngstest.c for substantial speed improvement.
|
||||
Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a
|
||||
spurious check in pngwrite.c
|
||||
Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store
|
||||
intermediate files, or intermediate in-memory data, while processing
|
||||
image data with the simplified API. The option makes the files larger
|
||||
but faster to write and read. pngstest now uses this by default; this
|
||||
can be disabled with the --slow option.
|
||||
Improved pngstest fine tuning of error numbers, new test file generator.
|
||||
The generator generates images that test the full range of sample values,
|
||||
allow the error numbers in pngstest to be tuned and checked. makepng
|
||||
also allows generation of images with extra chunks, although this is
|
||||
still work-in-progress.
|
||||
Added check for invalid palette index while reading.
|
||||
Fixed some bugs in ICC profile writing. The code should now accept
|
||||
all potentially valid ICC profiles and reject obviously invalid ones.
|
||||
It now uses png_error() to do so rather than casually writing a PNG
|
||||
without the necessary color data.
|
||||
Removed whitespace from the end of lines in all source files and scripts.
|
||||
|
||||
Version 1.6.0beta16 [March 6, 2012]
|
||||
Relocated palette-index checking function from pngrutil.c to pngtrans.c
|
||||
Added palette-index checking while writing.
|
||||
Changed png_inflate() and calling routines to avoid overflow problems.
|
||||
This is an intermediate check-in that solves the immediate problems and
|
||||
introduces one performance improvement (avoiding a copy via png_ptr->zbuf.)
|
||||
Further changes will be made to make ICC profile handling more secure.
|
||||
Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options
|
||||
declares 'index' as a global, causing a warning if it is used as a local
|
||||
variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit)
|
||||
to an (int) (signed 32-bit). MSVC, however, warns about using the
|
||||
unary '-' operator on an unsigned value (even though it is well defined
|
||||
by ANSI-C to be ~x+1). The padding calculation was changed to use a
|
||||
different method. Removed the tests on png_ptr->pass.
|
||||
Added contrib/libtests/tarith.c to test internal arithmetic functions from
|
||||
png.c. This is a libpng maintainer program used to validate changes to the
|
||||
internal arithmetic functions.
|
||||
Made read 'inflate' handling like write 'deflate' handling. The read
|
||||
code now claims and releases png_ptr->zstream, like the write code.
|
||||
The bug whereby the progressive reader failed to release the zstream
|
||||
is now fixed, all initialization is delayed, and the code checks for
|
||||
changed parameters on deflate rather than always calling
|
||||
deflatedEnd/deflateInit.
|
||||
Validate the zTXt strings in pngvalid.
|
||||
Added code to validate the windowBits value passed to deflateInit2().
|
||||
If the call to deflateInit2() is wrong a png_warning will be issued
|
||||
(in fact this is harmless, but the PNG data produced may be sub-optimal).
|
||||
|
||||
Version 1.6.0beta17 [March 10, 2012]
|
||||
Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
|
||||
Reject all iCCP chunks after the first, even if the first one is invalid.
|
||||
Deflate/inflate was reworked to move common zlib calls into single
|
||||
functions [rw]util.c. A new shared keyword check routine was also added
|
||||
and the 'zbuf' is no longer allocated on progressive read. It is now
|
||||
possible to call png_inflate() incrementally. 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
|
||||
header.
|
||||
|
||||
Version 1.6.0beta18 [March 16, 2012]
|
||||
Issue a png_benign_error() instead of png_warning() about bad palette index.
|
||||
In pngtest, treat benign errors as errors if "-strict" is present.
|
||||
Fixed an off-by-one error in the palette index checking function.
|
||||
Fixed a compiler warning under Cygwin (Windows-7, 32-bit system)
|
||||
Revised example.c to put text strings in a temporary character array
|
||||
instead of directly assigning string constants to png_textp members.
|
||||
This avoids compiler warnings when -Wwrite-strings is enabled.
|
||||
Added output flushing to aid debugging under Visual Studio. Unfortunately
|
||||
this is necessary because the VS2010 output window otherwise simply loses
|
||||
the error messages on error (they weren't flushed to the window before
|
||||
the process exited, apparently!)
|
||||
Added configuration support for benign errors and changed the read
|
||||
default. Also changed some warnings in the iCCP and sRGB handling
|
||||
from to benign errors. Configuration now makes read benign
|
||||
errors warnings and write benign errors to errors by default (thus
|
||||
changing the behavior on read). The simplified API always forces
|
||||
read benign errors to warnings (regardless of the system default, unless
|
||||
this is disabled in which case the simplified API can't be built.)
|
||||
|
||||
Version 1.6.0beta19 [March 18, 2012]
|
||||
Work around for duplicate row start calls; added warning messages.
|
||||
This turns on PNG_FLAG_DETECT_UNINITIALIZED to detect app code that
|
||||
fails to call one of the 'start' routines (not enabled in libpng-1.5
|
||||
because it is technically an API change, since it did normally work
|
||||
before.) It also makes duplicate calls to png_read_start_row (an
|
||||
internal function called at the start of the image read) benign, as
|
||||
they were before changes to use png_inflate_claim. Somehow webkit is
|
||||
causing this to happen; this is probably a mis-feature in the zlib
|
||||
changes so this commit is only a work-round.
|
||||
Removed erroneous setting of DETECT_UNINITIALIZED and added more
|
||||
checks. The code now does a png_error if an attempt is made to do the
|
||||
row initialization twice; this is an application error and it has
|
||||
serious consequences because the transform data in png_struct is
|
||||
changed by each call.
|
||||
Added application error reporting and added chunk names to read
|
||||
benign errors; also added --strict to pngstest - not enabled
|
||||
yet because a warning is produced.
|
||||
Avoid the double gamma correction warning in the simplified API.
|
||||
This allows the --strict option to pass in the pngstest checks
|
||||
|
||||
Version 1.6.0beta20 [March 29, 2012]
|
||||
Changed chunk handler warnings into benign errors, incrementally load iCCP
|
||||
Added checksum-icc.c to contrib/tools
|
||||
Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice.
|
||||
Recognize known sRGB ICC profiles while reading; prefer writing the
|
||||
iCCP profile over writing the sRGB chunk, controlled by the
|
||||
PNG_sRGB_PROFILE_CHECKS option.
|
||||
Revised png_set_text_2() to avoid potential memory corruption (fixes
|
||||
CVE-2011-3048, also known as CVE-2012-3425).
|
||||
|
||||
Version 1.6.0beta21 [April 27, 2012]
|
||||
Revised scripts/makefile.darwin: use system zlib; remove quotes around
|
||||
architecture list; add missing ppc architecture; add architecture options
|
||||
to shared library link; don't try to create a shared lib based on missing
|
||||
RELEASE variable.
|
||||
Enable png_set_check_for_invalid_index() for both read and write.
|
||||
Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpriv.h around
|
||||
declaration of png_handle_unknown().
|
||||
Added -lssp_nonshared in a comment in scripts/makefile.freebsd
|
||||
and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE.
|
||||
|
||||
Version 1.6.0beta22 [May 23, 2012]
|
||||
Removed need for -Wno-cast-align with clang. clang correctly warns on
|
||||
alignment increasing pointer casts when -Wcast-align is passed. This
|
||||
fixes the cases that clang warns about either by eliminating the
|
||||
casts from png_bytep to png_uint_16p (pngread.c), or, for pngrutil.c
|
||||
where the cast is previously verified or pngstest.c where it is OK, by
|
||||
introducing new png_aligncast macros to do the cast in a way that clang
|
||||
accepts.
|
||||
|
||||
Version 1.6.0beta23 [June 6, 2012]
|
||||
Revised CMakeLists.txt to not attempt to make a symlink under mingw.
|
||||
Made fixes for new optimization warnings from gcc 4.7.0. The compiler
|
||||
performs an optimization which is safe; however it then warns about it.
|
||||
Changing the type of 'palette_number' in pngvalid.c removes the warning.
|
||||
Do not depend upon a GCC feature macro being available for use in generating
|
||||
the linker mapfile symbol prefix.
|
||||
Improved performance of new do_check_palette_indexes() function (only
|
||||
update the value when it actually increases, move test for whether
|
||||
the check is wanted out of the function.
|
||||
|
||||
Version 1.6.0beta24 [June 7, 2012]
|
||||
Don't check palette indexes if num_palette is 0 (as it can be in MNG files).
|
||||
|
||||
Version 1.6.0beta25 [June 16, 2012]
|
||||
Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all
|
||||
unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT,
|
||||
and IEND. Previously it only meant ignore all unknown chunks, the
|
||||
same as num_chunks == 0. Revised png_image_skip_unused_chunks() to
|
||||
provide a list of chunks to be processed instead of a list of chunks to
|
||||
ignore. Revised contrib/gregbook/readpng2.c accordingly.
|
||||
|
||||
Version 1.6.0beta26 [July 10, 2012]
|
||||
Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it
|
||||
depends on configure, which is not included in those archives.
|
||||
Moved scripts/chkfmt to contrib/tools.
|
||||
Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386.
|
||||
|
||||
Version 1.6.0beta27 [August 11, 2012]
|
||||
Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3.
|
||||
Do not use __restrict when GNUC is <= 3.1
|
||||
Removed references to png_zalloc() and png_zfree() from the manual.
|
||||
Fixed configurations where floating point is completely disabled. Because
|
||||
of the changes to support symbol prefixing PNG_INTERNAL_FUNCTION declares
|
||||
floating point APIs during libpng builds even if they are completely
|
||||
disabled. This requires the png floating point types (png_double*) to be
|
||||
declared even though the functions are never actually defined. This
|
||||
change provides a dummy definition so that the declarations work, yet any
|
||||
implementation will fail to compile because of an incomplete type.
|
||||
Re-eliminated the use of strcpy() in pngtest.c. An unncessary use of
|
||||
strcpy() was accidentally re-introduced in libpng16; this change replaces
|
||||
it with strncpy().
|
||||
Eliminated use of png_sizeof(); use sizeof() instead.
|
||||
Use a consistent style for (sizeof type) and (sizeof (array))
|
||||
Cleanup of png_set_filler(). This function does very different things on
|
||||
read and write. In libpng 1.6 the two cases can be distinguished and
|
||||
considerable code cleanup, and extra error checking, is possible. This
|
||||
makes calls on the write side that have no effect be ignored with a
|
||||
png_app_error(), which can be disabled in the app using
|
||||
png_set_benign_errors(), and removes the spurious use of usr_channels
|
||||
on the read side.
|
||||
Insist on autotools 1.12.1 for git builds because there are security issues
|
||||
with 1.12 and insisting on anything less would allow 1.12 to be used.
|
||||
Removed info_ptr->signature[8] from WRITE-only builds.
|
||||
Add some conditions for compiling png_fixed(). This is a small function
|
||||
but it requires "-lm" on some platforms.
|
||||
Cause pngtest --strict to fail on any warning from libpng (not just errors)
|
||||
and cause it not to fail at the comparison step if libpng lacks support
|
||||
for writing chunks that it reads from the input (currently only implemented
|
||||
for compressed text chunks).
|
||||
Make all three "make check" test programs work without READ or WRITE support.
|
||||
Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ
|
||||
or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading
|
||||
and writing of a PNG file is always tested by one or more of the tests.
|
||||
Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the
|
||||
png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros.
|
||||
Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and
|
||||
png_memcmp() macros.
|
||||
Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object
|
||||
to the split initialization of num_chunks.
|
||||
|
||||
Version 1.6.0beta28 [August 29, 2012]
|
||||
Unknown handling fixes and clean up. This adds more correct option
|
||||
control of the unknown handling, corrects the pre-existing bug where
|
||||
the per-chunk 'keep' setting is ignored and makes it possible to skip
|
||||
IDAT chunks in the sequential reader (broken in earlier 1.6 versions).
|
||||
There is a new test program, test-unknown.c, which is a work in progress
|
||||
(not currently part of the test suite). Comments in the header files now
|
||||
explain how the unknown handling works.
|
||||
Allow fine grain control of unknown chunk APIs. This change allows
|
||||
png_set_keep_unknown_chunks() to be turned off if not required and causes
|
||||
both read and write to behave appropriately (on read this is only possible
|
||||
if the user callback is used to handle unknown chunks). The change
|
||||
also removes the support for storing unknown chunks in the info_struct
|
||||
if the only unknown handling enabled is via the callback, allowing libpng
|
||||
to be configured with callback reading and none of the unnecessary code.
|
||||
Corrected fix for unknown handling in pngtest. This reinstates the
|
||||
libpng handling of unknown chunks other than vpAg and sTER (including
|
||||
unsafe-to-copy chunks which were dropped before) and eliminates the
|
||||
repositioning of vpAg and sTER in pngtest.png by changing pngtest.png
|
||||
(so the chunks are where libpng would put them).
|
||||
Added "tunknown" test and corrected a logic error in png_handle_unknown()
|
||||
when SAVE support is absent. Moved the shell test scripts for
|
||||
contrib/libtests from the libpng top directory to contrib/libtests.
|
||||
png_handle_unknown() must always read or skip the chunk, if
|
||||
SAVE_UNKNOWN_CHUNKS is turned off *and* the application does not set
|
||||
a user callback an unknown chunk will not be read, leading to a read
|
||||
error, which was revealed by the "tunknown" test.
|
||||
Cleaned up and corrected ICC profile handling.
|
||||
contrib/libtests/makepng: corrected 'rgb' and 'gray' cases. profile_error
|
||||
messages could be truncated; made a correct buffer size calculation and
|
||||
adjusted pngerror.c appropriately. png_icc_check_* checking improved;
|
||||
changed the functions to receive the correct color type of the PNG on read
|
||||
or write and check that it matches the color space of the profile (despite
|
||||
what the comments said before, there is danger in assuming the app will
|
||||
cope correctly with an RGB profile on a grayscale image and, since it
|
||||
violates the PNG spec, allowing it is certain to produce inconsistent
|
||||
app behavior and might even cause app crashes.) Check that profiles
|
||||
contain the tags needed to process the PNG (tags all required by the ICC
|
||||
spec). Removed unused PNG_STATIC from pngpriv.h.
|
||||
|
||||
Version 1.6.0beta29 [September 4, 2012]
|
||||
Fixed the simplified API example programs to add the *colormap parameter
|
||||
to several of he API and improved the error message if the version field
|
||||
is not set.
|
||||
Added contrib/examples/* to the *.zip and *.7z distributions.
|
||||
Updated simplified API synopses and description of the png_image structure
|
||||
in the manual.
|
||||
Made makepng and pngtest produce identical PNGs, add "--relaxed" option
|
||||
to pngtest. The "--relaxed" option turns off the benign errors that are
|
||||
enabled by default in pre-RC builds. makepng can now write ICC profiles
|
||||
where the length has not been extended to a multiple of 4, and pngtest
|
||||
now intercepts all libpng errors, allowing the previously-introduced
|
||||
"--strict test" on no warnings to actually work.
|
||||
Improved ICC profile handling including cHRM chunk generation and fixed
|
||||
Cygwin+MSVC build errors. The ICC profile handling now includes more
|
||||
checking. Several errors that caused rejection of the profile are now
|
||||
handled with a warning in such a way that the invalid profiles will be
|
||||
read by default in release (but not pre-RC) builds but will not be
|
||||
written by default. The easy part of handling the cHRM chunk is written,
|
||||
where the ICC profile contains the required data. The more difficult
|
||||
part plus guessing a gAMA value requires code to pass selected RGB values
|
||||
through the profile.
|
||||
|
||||
Version 1.6.0beta30 [October 24, 2012]
|
||||
Changed ICC profile matrix/vector types to not depend on array type rules.
|
||||
By the ANSI-C standard the new types should be identical to the previous
|
||||
versions, and all known versions of gcc tested with the previous versions
|
||||
except for GCC-4.2.1 work with this version. The change makes the ANSI-C
|
||||
rule that const applied to an array of elements applies instead to the
|
||||
elements in the array moot by explicitly applying const to the base
|
||||
elements of the png_icc_matrix and png_icc_vector types. The accidental
|
||||
(harmless) 'const' previously applied to the parameters of two of the
|
||||
functions have also been removed.
|
||||
Added a work around for GCC 4.2 optimization bug.
|
||||
Marked the broken (bad white point) original HP sRGB profiles correctly and
|
||||
correct comments.
|
||||
Added -DZ_SOLO to contrib/pngminim/*/makefile to work with zlib-1.2.7
|
||||
Use /MDd for vstudio debug builds. Also added pngunkown to the vstudio
|
||||
builds, fixed build errors and corrected a minor exit code error in
|
||||
pngvalid if the 'touch' file name is invalid.
|
||||
Add updated WARNING file to projects/vstudio from libpng 1.5/vstudio
|
||||
Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in
|
||||
pngrtran.c (Domani Hannes).
|
||||
|
||||
Version 1.6.0beta31 [November 1, 2012]
|
||||
Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30.
|
||||
Made pngvalid so that it will build outside the libpng source tree.
|
||||
Made builds -DPNG_NO_READ_GAMMA compile (the unit tests still fail).
|
||||
Made PNG_NO_READ_GAMMA switch off interfaces that depend on READ_GAMMA.
|
||||
Prior to 1.6.0 switching off READ_GAMMA did unpredictable things to the
|
||||
interfaces that use it (specifically, png_do_background in 1.4 would
|
||||
simply display composite for grayscale images but do composition
|
||||
with the incorrect arithmetic for color ones). In 1.6 the semantic
|
||||
of -DPNG_NO_READ_GAMMA is changed to simply disable any interface that
|
||||
depends on it; this obliges people who set it to consider whether they
|
||||
really want it off if they happen to use any of the interfaces in
|
||||
question (typically most users who disable it won't).
|
||||
Fixed GUIDs in projects/vstudio. Some were duplicated or missing,
|
||||
resulting in VS2010 having to update the files.
|
||||
Removed non-working ICC profile support code that was mostly added to
|
||||
libpng-1.6.0beta29 and beta30. There was too much code for too little
|
||||
gain; implementing full ICC color correction may be desireable but is left
|
||||
up to applications.
|
||||
|
||||
Version 1.6.0beta32 [November 25, 2012]
|
||||
Fixed an intermittent SEGV in pngstest due to an uninitialized array element.
|
||||
Added the ability for contrib/libtests/makepng.c to make a PNG with just one
|
||||
color. This is useful for debugging pngstest color inaccuracy reports.
|
||||
Fixed error checking in the simplified write API (Olaf van der Spek)
|
||||
Made png_user_version_check() ok to use with libpng version 1.10.x and later.
|
||||
|
||||
Version 1.6.0beta33 [December 15, 2012]
|
||||
Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX)
|
||||
that causes the MALLOC_MAX limit not to work (John Bowler)
|
||||
Change png_warning() to png_app_error() in pngwrite.c and comment the
|
||||
fall-through condition.
|
||||
Change png_warning() to png_app_warning() in png_write_tRNS().
|
||||
Rearranged the ARM-NEON optimizations: Isolated the machine specific code
|
||||
to the hardware subdirectory and added comments to pngrutil.c so that
|
||||
implementors of other optimizations know what to do.
|
||||
Fixed cases of unquoted DESTDIR in Makefile.am
|
||||
Rebuilt Makefile.in, etc., with autoconf-2.69 and automake-1.12.5.
|
||||
|
||||
Version 1.6.0beta34 [December 19, 2012]
|
||||
Cleaned up whitespace in the synopsis portion of the manpage "libpng.3"
|
||||
Disassembled the version number in scripts/options.awk (necessary for
|
||||
building on SunOs).
|
||||
|
||||
Version 1.6.0beta35 [December 23, 2012]
|
||||
Made default Zlib compression settings be configurable. This adds #defines to
|
||||
pnglibconf.h to control the defaults.
|
||||
Fixed Windows build issues, enabled ARM compilation. Various warnings issued
|
||||
by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old
|
||||
GCCs.) ARM support is enabled by default in zlib.props (unsupported by
|
||||
Microsoft) and ARM compilation is made possible by deleting the check for
|
||||
x86. The test programs cannot be run because they are not signed.
|
||||
|
||||
Version 1.6.0beta36 [January 2, 2013]
|
||||
Discontinued distributing libpng-1.x.x.tar.bz2.
|
||||
Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar.
|
||||
Rebuilt configure with autoconf-2.69 (inadvertently not done in beta33)
|
||||
Fixed 'make distcheck' on SUN OS - libpng.so was not being removed
|
||||
|
||||
Version 1.6.0beta37 [January 10, 2013]
|
||||
Fixed conceivable but difficult to repro overflow. Also added two test
|
||||
programs to generate and test a PNG which should have the problem.
|
||||
|
||||
Version 1.6.0beta39 [January 19, 2013]
|
||||
Again corrected attempt at overflow detection in png_set_unknown_chunks().
|
||||
Added overflow detection in png_set_sPLT() and png_set_text_2().
|
||||
|
||||
Version 1.6.0beta40 [January 20, 2013]
|
||||
Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs
|
||||
|
||||
Version 1.6.0rc01 [January 26, 2013]
|
||||
No changes.
|
||||
|
||||
Version 1.6.0rc02 [February 4, 2013]
|
||||
Added png_get_palette_max() function.
|
||||
|
||||
Version 1.6.0rc03 [February 5, 2013]
|
||||
Fixed the png_get_palette_max API.
|
||||
|
||||
Version 1.6.0rc04 [February 7, 2013]
|
||||
Turn serial tests back on (recently turned off by autotools upgrade).
|
||||
|
||||
Version 1.6.0rc05 [February 8, 2013]
|
||||
Update manual about png_get_palette_max().
|
||||
|
||||
Version 1.6.0rc06 [February 9, 2013]
|
||||
Fixed missing dependency in --prefix builds The intermediate
|
||||
internal 'prefix.h' file can only be generated correctly after
|
||||
pnglibconf.h, however the dependency was not in Makefile.am. The
|
||||
symptoms are unpredictable depending on the order make chooses to
|
||||
build pngprefix.h and pnglibconf.h, often the error goes unnoticed
|
||||
because there is a system pnglibconf.h to use instead.
|
||||
|
||||
Version 1.6.0rc07 [February 10, 2013]
|
||||
Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly.
|
||||
|
||||
Version 1.6.0rc08 [February 10, 2013]
|
||||
Fix typo in png.h #ifdef
|
||||
|
||||
Version 1.6.0 [February 14, 2013]
|
||||
No changes.
|
||||
|
||||
Version 1.6.1beta01 [February 16, 2013]
|
||||
Made symbol prefixing work with the ARM neon optimizations. Also allow
|
||||
pngpriv.h to be included for preprocessor definitions only, so it can
|
||||
be used in non-C/C++ files. Back ported from libpng 1.7.
|
||||
Made sRGB check numbers consistent.
|
||||
Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug.
|
||||
Removed cc -E workround, corrected png_get_palette_max API Tested on
|
||||
SUN OS cc 5.9, which demonstrates the tokenization problem previously
|
||||
avoided by using /lib/cpp. Since all .dfn output is now protected in
|
||||
double quotes unless it is to be macro substituted the fix should
|
||||
work everywhere.
|
||||
Enabled parallel tests - back ported from libpng-1.7.
|
||||
scripts/pnglibconf.dfa formatting improvements back ported from libpng17.
|
||||
Fixed a race condition in the creation of the build 'scripts' directory
|
||||
while building with a parallel make.
|
||||
Use approved/supported Android method to check for NEON, use Linux/POSIX
|
||||
1003.1 API to check /proc/self/auxv avoiding buffer allocation and other
|
||||
library calls (ported from libpng15).
|
||||
|
||||
Version 1.6.1beta02 [February 19, 2013]
|
||||
Use parentheses more consistently in "#if defined(MACRO)" tests.
|
||||
Folded long lines.
|
||||
Reenabled code to allow zero length PLTE chunks for MNG.
|
||||
|
||||
Version 1.6.1beta03 [February 22, 2013]
|
||||
Fixed ALIGNED_MEMORY support.
|
||||
Allow run-time ARM NEON checking to be disabled. A new configure option:
|
||||
--enable-arm-neon=always will stop the run-time checks. New checks
|
||||
within arm/arm_init.c will cause the code not to be compiled unless
|
||||
__ARM_NEON__ is set. This should make it fail safe (if someone asks
|
||||
for it on then the build will fail if it can't be done.)
|
||||
Updated the INSTALL document.
|
||||
|
||||
Version 1.6.1beta04 [February 27, 2013]
|
||||
Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
|
||||
Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC.
|
||||
Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
|
||||
with CRLF line endings.
|
||||
|
||||
Version 1.6.1beta05 [March 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
|
||||
|
||||
@@ -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()
|
||||
@@ -219,18 +210,19 @@ ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
# copies if different.
|
||||
macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||
FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
if(WIN32 AND NOT CYGWIN AND NOT MINGW)
|
||||
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||
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 MINGW)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif(WIN32 AND NOT CYGWIN AND NOT MINGW)
|
||||
else(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
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()
|
||||
|
||||
# libpng is a library so default to 'lib'
|
||||
@@ -242,7 +234,7 @@ endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
# we use the same files like ./configure, so we have to set its vars
|
||||
# Only do this on Windows for Cygwin - the files don't make much sense outside
|
||||
# a UNIX look alike
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
||||
@@ -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.0beta13
|
||||
# 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.0beta13, February 24, 2012, are
|
||||
Copyright (c) 2004, 2006-2011 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
|
||||
February 24, 2012
|
||||
July 18, 2013
|
||||
|
||||
119
Makefile.am
119
Makefile.am
@@ -7,19 +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
|
||||
pngvalid_SOURCES = contrib/libtests/pngvalid.c
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
TESTS += test-pngvalid-simple.sh test-pngvalid-full.sh test-pngstest.sh
|
||||
|
||||
pngunknown_SOURCES = contrib/libtests/pngunknown.c
|
||||
pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
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
|
||||
@@ -35,10 +68,11 @@ lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||
pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\
|
||||
pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\
|
||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa
|
||||
|
||||
if PNG_ARM_NEON
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/filter_neon.S
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
||||
arm/filter_neon.S
|
||||
endif
|
||||
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
@@ -71,12 +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
|
||||
@@ -113,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 $@
|
||||
@@ -151,13 +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
|
||||
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
|
||||
@@ -172,23 +211,21 @@ SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
||||
endif
|
||||
|
||||
.dfn.out:
|
||||
rm -f $@ $*.c $*.tf[123]
|
||||
test -d scripts || mkdir scripts
|
||||
rm -f $@ $*.c $*.tf[12]
|
||||
test -d scripts || mkdir scripts || test -d scripts
|
||||
echo '#include "$<"' >$*.c
|
||||
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) $*.c > $*.tf1
|
||||
$(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\
|
||||
$*.tf1 >$*.tf2
|
||||
$(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' $*.tf2 >$*.tf3
|
||||
rm -f $*.c $*.tf[12]
|
||||
mv $*.tf3 $@
|
||||
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
|
||||
rm -f $*.c $*.tf1
|
||||
mv $*.tf2 $@
|
||||
|
||||
# The .dfn file for pnglibconf.h is machine generated
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h $(DFA_XTRA)
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
||||
rm -f $@ $*.tf[45]
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\
|
||||
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||
$(DFA_XTRA) 1>&2
|
||||
${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2
|
||||
rm $*.tf4
|
||||
mv $*.tf5 $@
|
||||
@@ -230,22 +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;\
|
||||
@@ -253,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'
|
||||
|
||||
38
README
38
README
@@ -1,11 +1,11 @@
|
||||
README for libpng version 1.6.0beta13 - February 24, 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,
|
||||
@@ -105,7 +103,7 @@ based in a large way on Guy's and Andreas' earlier work), and the PNG
|
||||
development group.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at
|
||||
lists.sourceforge.net (subscription required; visit
|
||||
lists.sourceforge.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe) or to glennrp at users.sourceforge.net
|
||||
|
||||
@@ -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\
|
||||
@@ -134,7 +134,7 @@ do
|
||||
libpng_autotools_file_missing=1
|
||||
fi
|
||||
done
|
||||
#
|
||||
#
|
||||
# The cache directory doesn't matter - it will be regenerated and does not exist
|
||||
# anyway in a tarball.
|
||||
#
|
||||
@@ -213,7 +213,7 @@ case "$mode" in
|
||||
exec >&2
|
||||
echo "Your system has a partial set of autotools generated files."
|
||||
echo "autogen.sh is unable to proceed. The full set of files is"
|
||||
echo "contained in the distribution archive and you do not need to run"
|
||||
echo "autogen.sh if you use it."
|
||||
echo "contained in the libpng 'tar' distribution archive and you do"
|
||||
echo "not need to run autogen.sh if you use it."
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
117
configure.ac
117
configure.ac
@@ -18,17 +18,19 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.6.0beta13],[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')
|
||||
# color-tests requires automake 1.11 or later
|
||||
# silent-rules requires automake 1.11 or later
|
||||
# dist-xz requires automake 1.11 or later
|
||||
# 1.11.1 fixes a security issue in 1.11
|
||||
AM_INIT_AUTOMAKE([1.11.1 foreign dist-xz dist-bzip2 color-tests silent-rules])
|
||||
# was:
|
||||
# AM_INIT_AUTOMAKE
|
||||
# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
|
||||
# 1.13 is required for parallel tests
|
||||
AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules])
|
||||
# The following line causes --disable-maintainer-mode to be the default to
|
||||
# configure, this is necessary because libpng distributions cannot rely on the
|
||||
# time stamps of the autotools generated files being correct
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
|
||||
@@ -37,10 +39,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
|
||||
dnl AM_PREREQ([1.11.2])
|
||||
dnl stop configure from automagically running automake
|
||||
|
||||
PNGLIB_VERSION=1.6.0beta13
|
||||
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
|
||||
@@ -185,9 +178,9 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
|
||||
if test "$have_ld_version_script" = "yes"; then
|
||||
AC_MSG_CHECKING([for symbol prefix])
|
||||
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
|
||||
| ${CPP-${CC-gcc} -E} - 2>&1 \
|
||||
| ${EGREP-grep} "^PREFIX=" \
|
||||
| ${SED-sed} "s:^PREFIX=::"`
|
||||
| ${CPP-${CC-gcc} -E} - 2>&1 \
|
||||
| ${EGREP-grep} "^PREFIX=" \
|
||||
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
|
||||
AC_SUBST(SYMBOL_PREFIX)
|
||||
AC_MSG_RESULT($SYMBOL_PREFIX)
|
||||
fi
|
||||
@@ -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);
|
||||
@@ -103,7 +103,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
index < num_trans ? trans_alpha[index] : 255);
|
||||
|
||||
else /* no transparency */
|
||||
printf("INDEXED %u = %d %d %d\n", index,
|
||||
printf("INDEXED %u = %d %d %d\n", index,
|
||||
palette[index].red, palette[index].green,
|
||||
palette[index].blue);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ int main(int argc, const char **argv)
|
||||
ystep = xstep = 1;
|
||||
}
|
||||
|
||||
/* To find the pixel loop over 'py' for each pass
|
||||
/* To find the pixel, loop over 'py' for each pass
|
||||
* reading a row and then checking to see if it
|
||||
* contains the pixel.
|
||||
*/
|
||||
@@ -283,12 +283,13 @@ int main(int argc, const char **argv)
|
||||
|
||||
/* png_read_row takes two pointers. When libpng
|
||||
* handles the interlace the first is filled in
|
||||
* pixel-by-pixel, the second receives the same
|
||||
* pixel-by-pixel, and the second receives the same
|
||||
* pixels but they are replicated across the
|
||||
* unwritten pixels so far for each pass. When we
|
||||
* do the interlace, however, they just contain
|
||||
* the pixels from the interlace pass - giving
|
||||
* both is wasteful and pointless.
|
||||
* both is wasteful and pointless, so we pass a
|
||||
* NULL pointer.
|
||||
*/
|
||||
png_read_row(png_ptr, row_tmp, NULL);
|
||||
|
||||
@@ -326,7 +327,7 @@ int main(int argc, const char **argv)
|
||||
else
|
||||
{
|
||||
/* Else libpng has raised an error. An error message has
|
||||
* already been output, it is only necessary to clean up
|
||||
* already been output, so it is only necessary to clean up
|
||||
* locally allocated data:
|
||||
*/
|
||||
if (row != NULL)
|
||||
|
||||
@@ -29,13 +29,17 @@ int main(int argc, const char **argv)
|
||||
{
|
||||
png_image image;
|
||||
|
||||
/* Only the image structure version number needs to be set. */
|
||||
memset(&image, 0, sizeof image);
|
||||
image.version = PNG_IMAGE_VERSION;
|
||||
|
||||
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||
{
|
||||
png_bytep buffer;
|
||||
|
||||
/* Change this to try different formats! */
|
||||
|
||||
/* Change this to try different formats! If you set a colormap format
|
||||
* then you must also supply a colormap below.
|
||||
*/
|
||||
image.format = PNG_FORMAT_RGBA;
|
||||
|
||||
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||
@@ -43,10 +47,11 @@ int main(int argc, const char **argv)
|
||||
if (buffer != NULL)
|
||||
{
|
||||
if (png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/))
|
||||
0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */))
|
||||
{
|
||||
if (png_image_write_to_file(&image, argv[2],
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/))
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||
NULL/*colormap*/))
|
||||
result = 0;
|
||||
|
||||
else
|
||||
|
||||
@@ -215,6 +215,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
* libpng function */
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||
free(image_data);
|
||||
image_data = NULL;
|
||||
free(row_pointers);
|
||||
row_pointers = NULL;
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -136,29 +136,23 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
|
||||
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
|
||||
{
|
||||
/* These byte strings were copied from png.h. If a future libpng
|
||||
* version recognizes more chunks, add them to this list. If a
|
||||
* future version of readpng2.c recognizes more chunks, delete them
|
||||
* from this list. */
|
||||
static /* const */ png_byte chunks_to_ignore[] = {
|
||||
99, 72, 82, 77, '\0', /* cHRM */
|
||||
104, 73, 83, 84, '\0', /* hIST */
|
||||
105, 67, 67, 80, '\0', /* iCCP */
|
||||
105, 84, 88, 116, '\0', /* iTXt */
|
||||
111, 70, 70, 115, '\0', /* oFFs */
|
||||
112, 67, 65, 76, '\0', /* pCAL */
|
||||
112, 72, 89, 115, '\0', /* pHYs */
|
||||
115, 66, 73, 84, '\0', /* sBIT */
|
||||
115, 67, 65, 76, '\0', /* sCAL */
|
||||
115, 80, 76, 84, '\0', /* sPLT */
|
||||
115, 84, 69, 82, '\0', /* sTER */
|
||||
116, 69, 88, 116, '\0', /* tEXt */
|
||||
116, 73, 77, 69, '\0', /* tIME */
|
||||
122, 84, 88, 116, '\0' /* zTXt */
|
||||
};
|
||||
/* These byte strings were copied from png.h. If a future version
|
||||
* of readpng2.c recognizes more chunks, add them to this list.
|
||||
*/
|
||||
static PNG_CONST png_byte chunks_to_process[] = {
|
||||
98, 75, 71, 68, '\0', /* bKGD */
|
||||
103, 65, 77, 65, '\0', /* gAMA */
|
||||
115, 82, 71, 66, '\0', /* sRGB */
|
||||
};
|
||||
|
||||
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
|
||||
chunks_to_ignore, sizeof(chunks_to_ignore)/5);
|
||||
/* Ignore all chunks except for IHDR, PLTE, tRNS, IDAT, and IEND */
|
||||
png_set_keep_unknown_chunks(png_ptr, -1 /* PNG_HANDLE_CHUNK_NEVER */,
|
||||
NULL, -1);
|
||||
|
||||
/* But do not ignore chunks in the "chunks_to_process" list */
|
||||
png_set_keep_unknown_chunks(png_ptr,
|
||||
0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */, chunks_to_process,
|
||||
sizeof(chunks_to_process)/5);
|
||||
}
|
||||
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
|
||||
|
||||
|
||||
57
contrib/libtests/fakepng.c
Normal file
57
contrib/libtests/fakepng.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Fake a PNG - just write it out directly. */
|
||||
#include <stdio.h>
|
||||
#include <zlib.h> /* for crc32 */
|
||||
|
||||
void
|
||||
put_uLong(uLong val)
|
||||
{
|
||||
putchar(val >> 24);
|
||||
putchar(val >> 16);
|
||||
putchar(val >> 8);
|
||||
putchar(val >> 0);
|
||||
}
|
||||
|
||||
void
|
||||
put_chunk(const unsigned char *chunk, uInt length)
|
||||
{
|
||||
uLong crc;
|
||||
|
||||
put_uLong(length-4); /* Exclude the tag */
|
||||
|
||||
fwrite(chunk, length, 1, stdout);
|
||||
|
||||
crc = crc32(0, Z_NULL, 0);
|
||||
put_uLong(crc32(crc, chunk, length));
|
||||
}
|
||||
|
||||
const unsigned char signature[] =
|
||||
{
|
||||
137, 80, 78, 71, 13, 10, 26, 10
|
||||
};
|
||||
|
||||
const unsigned char IHDR[] =
|
||||
{
|
||||
73, 72, 68, 82, /* IHDR */
|
||||
0, 0, 0, 1, /* width */
|
||||
0, 0, 0, 1, /* height */
|
||||
1, /* bit depth */
|
||||
0, /* color type: greyscale */
|
||||
0, /* compression method */
|
||||
0, /* filter method */
|
||||
0 /* interlace method: none */
|
||||
};
|
||||
|
||||
const unsigned char unknown[] =
|
||||
{
|
||||
'u', 'n', 'K', 'n' /* "unKn" - private safe to copy */
|
||||
};
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fwrite(signature, sizeof signature, 1, stdout);
|
||||
put_chunk(IHDR, sizeof IHDR);
|
||||
|
||||
for(;;)
|
||||
put_chunk(unknown, sizeof unknown);
|
||||
}
|
||||
102
contrib/libtests/gentests.sh
Executable file
102
contrib/libtests/gentests.sh
Executable file
@@ -0,0 +1,102 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2013 John Cunningham Bowler
|
||||
#
|
||||
# Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
#
|
||||
# Generate a set of PNG test images. The images are generated in a
|
||||
# sub-directory called 'tests' by default, however a command line argument will
|
||||
# change that name. The generation requires a built version of makepng in the
|
||||
# current directory.
|
||||
#
|
||||
usage(){
|
||||
exec >&2
|
||||
echo "$0 [<directory>]"
|
||||
echo ' Generate a set of PNG test files in "directory" ("tests" by default)'
|
||||
exit 1
|
||||
}
|
||||
|
||||
mp="$PWD/makepng"
|
||||
test -x "$mp" || {
|
||||
exec >&2
|
||||
echo "$0: the 'makepng' program must exist"
|
||||
echo " in the directory within which this program:"
|
||||
echo " $mp"
|
||||
echo " is executed"
|
||||
usage
|
||||
}
|
||||
|
||||
# Just one argument: the directory
|
||||
testdir="tests"
|
||||
test $# -gt 1 && {
|
||||
testdir="$1"
|
||||
shift
|
||||
}
|
||||
test $# -eq 0 || usage
|
||||
|
||||
# Take care not to clobber something
|
||||
if test -e "$testdir"
|
||||
then
|
||||
test -d "$testdir" || usage
|
||||
else
|
||||
# mkdir -p isn't portable, so do the following
|
||||
mkdir "$testdir" 2>/dev/null || mkdir -p "$testdir" || usage
|
||||
fi
|
||||
|
||||
# This fails in a very satisfactory way if it's not accessible
|
||||
cd "$testdir"
|
||||
:>"test$$.png" || {
|
||||
exec >&2
|
||||
echo "$testdir: directory not writable"
|
||||
usage
|
||||
}
|
||||
rm "test$$.png" || {
|
||||
exec >&2
|
||||
echo "$testdir: you have create but not write privileges here."
|
||||
echo " This is unexpected. You have a spurion; "'"'"test$$.png"'"'"."
|
||||
echo " You need to remove this yourself. Try a different directory."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Now call makepng ($mp) to create every file we can think of with a
|
||||
# reasonable name
|
||||
doit(){
|
||||
for gamma in "" --sRGB --linear --1.8
|
||||
do
|
||||
case "$gamma" in
|
||||
"")
|
||||
gname=;;
|
||||
--sRGB)
|
||||
gname="-srgb";;
|
||||
--linear)
|
||||
gname="-lin";;
|
||||
--1.8)
|
||||
gname="-18";;
|
||||
*)
|
||||
gname="-$gamma";;
|
||||
esac
|
||||
"$mp" $gamma "$1" "$2" "test-$1-$2$gname.png"
|
||||
done
|
||||
}
|
||||
#
|
||||
for ct in gray palette
|
||||
do
|
||||
for bd in 1 2 4 8
|
||||
do
|
||||
doit "$ct" "$bd"
|
||||
done
|
||||
done
|
||||
#
|
||||
doit "gray" "16"
|
||||
#
|
||||
for ct in gray-alpha rgb rgb-alpha
|
||||
do
|
||||
for bd in 8 16
|
||||
do
|
||||
doit "$ct" "$bd"
|
||||
done
|
||||
done
|
||||
1486
contrib/libtests/makepng.c
Normal file
1486
contrib/libtests/makepng.c
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1066
contrib/libtests/pngunknown.c
Normal file
1066
contrib/libtests/pngunknown.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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.
|
||||
@@ -24,8 +24,9 @@
|
||||
#define _GNU_SOURCE 1 /* For the floating point exception extension */
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -42,6 +43,8 @@
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED /* else pngvalid can do nothing */
|
||||
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
/* This deliberately lacks the PNG_CONST. */
|
||||
typedef png_byte *png_const_bytep;
|
||||
@@ -82,10 +85,10 @@ typedef png_byte *png_const_bytep;
|
||||
/* 1.6.0 constifies many APIs, the following exists to allow pngvalid to be
|
||||
* compiled against earlier versions.
|
||||
*/
|
||||
# define png_const_strutp png_structp
|
||||
# define png_const_structp png_structp
|
||||
#endif
|
||||
|
||||
#include "zlib.h" /* For crc32 */
|
||||
#include <zlib.h> /* For crc32 */
|
||||
|
||||
#include <float.h> /* For floating point constants */
|
||||
#include <stdlib.h> /* For malloc */
|
||||
@@ -104,7 +107,11 @@ typedef png_byte *png_const_bytep;
|
||||
#endif
|
||||
|
||||
/***************************** EXCEPTION HANDLING *****************************/
|
||||
#include "../visupng/cexcept.h"
|
||||
#ifdef PNG_FREESTANDING_TESTS
|
||||
# include <cexcept.h>
|
||||
#else
|
||||
# include "../visupng/cexcept.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define this not_the_cpp_this
|
||||
@@ -170,6 +177,7 @@ static PNG_CONST char *colour_types[8] =
|
||||
"grayscale with alpha", invalid, "truecolour with alpha", invalid
|
||||
};
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Convert a double precision value to fixed point. */
|
||||
static png_fixed_point
|
||||
fix(double d)
|
||||
@@ -177,12 +185,14 @@ fix(double d)
|
||||
d = floor(d * PNG_FP_1 + .5);
|
||||
return (png_fixed_point)d;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Generate random bytes. This uses a boring repeatable algorithm and it
|
||||
* is implemented here so that it gives the same set of numbers on every
|
||||
* architecture. It's a linear congruential generator (Knuth or Sedgewick
|
||||
* "Algorithms") but it comes from the 'feedback taps' table in Horowitz and
|
||||
* Hill, "The Art of Electronics".
|
||||
* Hill, "The Art of Electronics" (Pseudo-Random Bit Sequences and Noise
|
||||
* Generation.)
|
||||
*/
|
||||
static void
|
||||
make_random_bytes(png_uint_32* seed, void* pv, size_t size)
|
||||
@@ -215,6 +225,7 @@ make_four_random_bytes(png_uint_32* seed, png_bytep bytes)
|
||||
make_random_bytes(seed, bytes, 4);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static void
|
||||
randomize(void *pv, size_t size)
|
||||
{
|
||||
@@ -234,6 +245,7 @@ random_mod(unsigned int max)
|
||||
return x % max; /* 0 .. max-1 */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
static int
|
||||
random_choice(void)
|
||||
{
|
||||
@@ -243,6 +255,8 @@ random_choice(void)
|
||||
|
||||
return x & 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* A numeric ID based on PNG file characteristics. The 'do_interlace' field
|
||||
* simply records whether pngvalid did the interlace itself or whether it
|
||||
@@ -255,7 +269,7 @@ random_choice(void)
|
||||
|
||||
#define COL_FROM_ID(id) ((png_byte)((id)& 0x7U))
|
||||
#define DEPTH_FROM_ID(id) ((png_byte)(((id) >> 3) & 0x1fU))
|
||||
#define PALETTE_FROM_ID(id) ((int)(((id) >> 8) & 0x1f))
|
||||
#define PALETTE_FROM_ID(id) (((id) >> 8) & 0x1f)
|
||||
#define INTERLACE_FROM_ID(id) ((int)(((id) >> 13) & 0x3))
|
||||
#define DO_INTERLACE_FROM_ID(id) ((int)(((id)>>15) & 1))
|
||||
#define WIDTH_FROM_ID(id) (((id)>>16) & 0xff)
|
||||
@@ -264,7 +278,7 @@ random_choice(void)
|
||||
/* Utility to construct a standard name for a standard image. */
|
||||
static size_t
|
||||
standard_name(char *buffer, size_t bufsize, size_t pos, png_byte colour_type,
|
||||
int bit_depth, int npalette, int interlace_type,
|
||||
int bit_depth, unsigned int npalette, int interlace_type,
|
||||
png_uint_32 w, png_uint_32 h, int do_interlace)
|
||||
{
|
||||
pos = safecat(buffer, bufsize, pos, colour_types[colour_type]);
|
||||
@@ -326,10 +340,11 @@ standard_name_from_id(char *buffer, size_t bufsize, size_t pos, png_uint_32 id)
|
||||
/* The following defines the number of different palettes to generate for
|
||||
* each log bit depth of a colour type 3 standard image.
|
||||
*/
|
||||
#define PALETTE_COUNT(bit_depth) ((bit_depth) > 4 ? 1 : 16)
|
||||
#define PALETTE_COUNT(bit_depth) ((bit_depth) > 4 ? 1U : 16U)
|
||||
|
||||
static int
|
||||
next_format(png_bytep colour_type, png_bytep bit_depth, int* palette_number)
|
||||
next_format(png_bytep colour_type, png_bytep bit_depth,
|
||||
unsigned int* palette_number)
|
||||
{
|
||||
if (*bit_depth == 0)
|
||||
{
|
||||
@@ -460,6 +475,7 @@ pixel_copy(png_bytep toBuffer, png_uint_32 toIndex,
|
||||
memmove(toBuffer+(toIndex>>3), fromBuffer+(fromIndex>>3), pixelSize>>3);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Copy a complete row of pixels, taking into account potential partial
|
||||
* bytes at the end.
|
||||
*/
|
||||
@@ -525,6 +541,7 @@ pixel_cmp(png_const_bytep pa, png_const_bytep pb, png_uint_32 bit_width)
|
||||
return 1+where;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/*************************** BASIC PNG FILE WRITING ***************************/
|
||||
/* A png_store takes data from the sequential writer or provides data
|
||||
@@ -635,6 +652,7 @@ store_pool_mark(png_bytep mark)
|
||||
make_four_random_bytes(store_seed, mark);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Use this for random 32 bit values; this function makes sure the result is
|
||||
* non-zero.
|
||||
*/
|
||||
@@ -654,6 +672,7 @@ random_32(void)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
static void
|
||||
store_pool_init(png_store *ps, store_pool *pool)
|
||||
@@ -859,6 +878,7 @@ store_log(png_store* ps, png_const_structp pp, png_const_charp message,
|
||||
store_verbose(ps, pp, is_error ? "error: " : "warning: ", message);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Internal error function, called with a png_store but no libpng stuff. */
|
||||
static void
|
||||
internal_error(png_store *ps, png_const_charp message)
|
||||
@@ -871,6 +891,7 @@ internal_error(png_store *ps, png_const_charp message)
|
||||
Throw ps;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Functions to use as PNG callbacks. */
|
||||
static void
|
||||
@@ -1008,6 +1029,7 @@ store_ensure_image(png_store *ps, png_const_structp pp, int nImages,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static void
|
||||
store_image_check(PNG_CONST png_store* ps, png_const_structp pp, int iImage)
|
||||
{
|
||||
@@ -1037,6 +1059,7 @@ store_image_check(PNG_CONST png_store* ps, png_const_structp pp, int iImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
static void
|
||||
store_write(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
@@ -1072,6 +1095,7 @@ store_flush(png_structp ppIn)
|
||||
UNUSED(ppIn) /*DOES NOTHING*/
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static size_t
|
||||
store_read_buffer_size(png_store *ps)
|
||||
{
|
||||
@@ -1189,6 +1213,7 @@ store_progressive_read(png_store *ps, png_structp pp, png_infop pi)
|
||||
}
|
||||
while (store_read_buffer_next(ps));
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* The caller must fill this in: */
|
||||
static store_palette_entry *
|
||||
@@ -1215,6 +1240,7 @@ store_write_palette(png_store *ps, int npalette)
|
||||
return ps->palette;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static store_palette_entry *
|
||||
store_current_palette(png_store *ps, int *npalette)
|
||||
{
|
||||
@@ -1228,6 +1254,7 @@ store_current_palette(png_store *ps, int *npalette)
|
||||
*npalette = ps->current->npalette;
|
||||
return ps->current->palette;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/***************************** MEMORY MANAGEMENT*** ***************************/
|
||||
/* A store_memory is simply the header for an allocated block of memory. The
|
||||
@@ -1502,25 +1529,29 @@ set_store_for_write(png_store *ps, png_infopp ppi,
|
||||
}
|
||||
|
||||
/* Cleanup when finished reading (either due to error or in the success case).
|
||||
* This routine exists even when there is no read support to make the code
|
||||
* tidier (avoid a mass of ifdefs) and so easier to maintain.
|
||||
*/
|
||||
static void
|
||||
store_read_reset(png_store *ps)
|
||||
{
|
||||
if (ps->pread != NULL)
|
||||
{
|
||||
anon_context(ps);
|
||||
|
||||
Try
|
||||
png_destroy_read_struct(&ps->pread, &ps->piread, NULL);
|
||||
|
||||
Catch_anonymous
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if (ps->pread != NULL)
|
||||
{
|
||||
/* error already output: continue */
|
||||
}
|
||||
anon_context(ps);
|
||||
|
||||
ps->pread = NULL;
|
||||
ps->piread = NULL;
|
||||
}
|
||||
Try
|
||||
png_destroy_read_struct(&ps->pread, &ps->piread, NULL);
|
||||
|
||||
Catch_anonymous
|
||||
{
|
||||
/* error already output: continue */
|
||||
}
|
||||
|
||||
ps->pread = NULL;
|
||||
ps->piread = NULL;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Always do this to be safe. */
|
||||
store_pool_delete(ps, &ps->read_memory_pool);
|
||||
@@ -1531,6 +1562,7 @@ store_read_reset(png_store *ps)
|
||||
ps->validated = 0;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static void
|
||||
store_read_set(png_store *ps, png_uint_32 id)
|
||||
{
|
||||
@@ -1608,6 +1640,7 @@ set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id,
|
||||
|
||||
return ps->pread;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* The overall cleanup of a store simply calls the above then removes all the
|
||||
* saved files. This does not delete the store itself.
|
||||
@@ -1647,18 +1680,6 @@ typedef struct CIE_color
|
||||
double X, Y, Z;
|
||||
} CIE_color;
|
||||
|
||||
static double
|
||||
chromaticity_x(CIE_color c)
|
||||
{
|
||||
return c.X / (c.X + c.Y + c.Z);
|
||||
}
|
||||
|
||||
static double
|
||||
chromaticity_y(CIE_color c)
|
||||
{
|
||||
return c.Y / (c.X + c.Y + c.Z);
|
||||
}
|
||||
|
||||
typedef struct color_encoding
|
||||
{
|
||||
/* A description of an (R,G,B) encoding of color (as defined above); this
|
||||
@@ -1671,11 +1692,24 @@ typedef struct color_encoding
|
||||
CIE_color red, green, blue; /* End points */
|
||||
} color_encoding;
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static double
|
||||
chromaticity_x(CIE_color c)
|
||||
{
|
||||
return c.X / (c.X + c.Y + c.Z);
|
||||
}
|
||||
|
||||
static double
|
||||
chromaticity_y(CIE_color c)
|
||||
{
|
||||
return c.Y / (c.X + c.Y + c.Z);
|
||||
}
|
||||
|
||||
static CIE_color
|
||||
white_point(PNG_CONST color_encoding *encoding)
|
||||
{
|
||||
CIE_color white;
|
||||
|
||||
|
||||
white.X = encoding->red.X + encoding->green.X + encoding->blue.X;
|
||||
white.Y = encoding->red.Y + encoding->green.Y + encoding->blue.Y;
|
||||
white.Z = encoding->red.Z + encoding->green.Z + encoding->blue.Z;
|
||||
@@ -1683,6 +1717,7 @@ white_point(PNG_CONST color_encoding *encoding)
|
||||
return white;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
static void
|
||||
normalize_color_encoding(color_encoding *encoding)
|
||||
{
|
||||
@@ -1702,6 +1737,7 @@ normalize_color_encoding(color_encoding *encoding)
|
||||
encoding->blue.Z /= whiteY;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static size_t
|
||||
safecat_color_encoding(char *buffer, size_t bufsize, size_t pos,
|
||||
@@ -1742,6 +1778,7 @@ safecat_color_encoding(char *buffer, size_t bufsize, size_t pos,
|
||||
|
||||
return pos;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
typedef struct png_modifier
|
||||
{
|
||||
@@ -1935,6 +1972,7 @@ modifier_init(png_modifier *pm)
|
||||
* to a calculation - not a digitization operation - unless the following API is
|
||||
* called directly.
|
||||
*/
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
static double digitize(PNG_CONST png_modifier *pm, double value,
|
||||
int sample_depth, int do_round)
|
||||
{
|
||||
@@ -1959,7 +1997,10 @@ static double digitize(PNG_CONST png_modifier *pm, double value,
|
||||
if (do_round) value += .5;
|
||||
return floor(value)/digitization_factor;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) ||\
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
{
|
||||
/* Absolute error permitted in linear values - affected by the bit depth of
|
||||
@@ -1971,7 +2012,9 @@ static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
else
|
||||
return pm->maxabs8;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
static double calcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
{
|
||||
/* Error in the linear composition arithmetic - only relevant when
|
||||
@@ -2088,6 +2131,7 @@ static int output_quantization_factor(PNG_CONST png_modifier *pm, int in_depth,
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
|
||||
/* One modification structure must be provided for each chunk to be modified (in
|
||||
* fact more than one can be provided if multiple separate changes are desired
|
||||
@@ -2140,6 +2184,7 @@ modification_init(png_modification *pmm)
|
||||
modification_reset(pmm);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
static void
|
||||
modifier_current_encoding(PNG_CONST png_modifier *pm, color_encoding *ce)
|
||||
{
|
||||
@@ -2151,6 +2196,7 @@ modifier_current_encoding(PNG_CONST png_modifier *pm, color_encoding *ce)
|
||||
|
||||
ce->gamma = pm->current_gamma;
|
||||
}
|
||||
#endif
|
||||
|
||||
static size_t
|
||||
safecat_current_encoding(char *buffer, size_t bufsize, size_t pos,
|
||||
@@ -2776,6 +2822,7 @@ srgb_modification_init(srgb_modification *me, png_modifier *pm, png_byte intent)
|
||||
pm->modifications = &me->this;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
typedef struct sbit_modification
|
||||
{
|
||||
png_modification this;
|
||||
@@ -2842,6 +2889,7 @@ sbit_modification_init(sbit_modification *me, png_modifier *pm, png_byte sbit)
|
||||
me->this.next = pm->modifications;
|
||||
pm->modifications = &me->this;
|
||||
}
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||
|
||||
/***************************** STANDARD PNG FILES *****************************/
|
||||
@@ -3120,6 +3168,7 @@ transform_height(png_const_structp pp, png_byte colour_type, png_byte bit_depth)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* The following can only be defined here, now we have the definitions
|
||||
* of the transform image sizes.
|
||||
*/
|
||||
@@ -3155,6 +3204,7 @@ standard_rowsize(png_const_structp pp, png_uint_32 id)
|
||||
width *= bit_size(pp, COL_FROM_ID(id), DEPTH_FROM_ID(id));
|
||||
return (width + 7) / 8;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
static void
|
||||
transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
@@ -3282,8 +3332,8 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
*/
|
||||
static void
|
||||
make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
png_byte PNG_CONST bit_depth, int palette_number, int interlace_type,
|
||||
png_const_charp name)
|
||||
png_byte PNG_CONST bit_depth, unsigned int palette_number,
|
||||
int interlace_type, png_const_charp name)
|
||||
{
|
||||
context(ps, fault);
|
||||
|
||||
@@ -3307,6 +3357,11 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
# if defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
# define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_zTXt
|
||||
# else
|
||||
# define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_NONE
|
||||
# endif
|
||||
{
|
||||
static char key[] = "image name"; /* must be writeable */
|
||||
size_t pos;
|
||||
@@ -3316,7 +3371,7 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
/* Use a compressed text string to test the correct interaction of text
|
||||
* compression and IDAT compression.
|
||||
*/
|
||||
text.compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text.compression = TEXT_COMPRESSION;
|
||||
text.key = key;
|
||||
/* Yuck: the text must be writable! */
|
||||
pos = safecat(copy, sizeof copy, 0, ps->wname);
|
||||
@@ -3374,7 +3429,7 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
/* Use a compressed text string to test the correct interaction of text
|
||||
* compression and IDAT compression.
|
||||
*/
|
||||
text.compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text.compression = TEXT_COMPRESSION;
|
||||
text.key = key;
|
||||
text.text = comment;
|
||||
text.text_length = (sizeof comment)-1;
|
||||
@@ -3410,7 +3465,7 @@ make_transform_images(png_store *ps)
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
/* This is in case of errors. */
|
||||
safecat(ps->test, sizeof ps->test, 0, "make standard images");
|
||||
@@ -3458,6 +3513,7 @@ interlace_row(png_bytep buffer, png_const_bytep imageRow,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
static void
|
||||
deinterlace_row(png_bytep buffer, png_const_bytep row,
|
||||
unsigned int pixel_size, png_uint_32 w, int pass)
|
||||
@@ -3478,6 +3534,7 @@ deinterlace_row(png_bytep buffer, png_const_bytep row,
|
||||
++xin;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Build a single row for the 'size' test images; this fills in only the
|
||||
* first bit_width bits of the sample row.
|
||||
@@ -3535,6 +3592,30 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
png_set_IHDR(pp, pi, w, h, bit_depth, colour_type, interlace_type,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
{
|
||||
static char key[] = "image name"; /* must be writeable */
|
||||
size_t pos;
|
||||
png_text text;
|
||||
char copy[FILE_NAME_SIZE];
|
||||
|
||||
/* Use a compressed text string to test the correct interaction of text
|
||||
* compression and IDAT compression.
|
||||
*/
|
||||
text.compression = TEXT_COMPRESSION;
|
||||
text.key = key;
|
||||
/* Yuck: the text must be writable! */
|
||||
pos = safecat(copy, sizeof copy, 0, ps->wname);
|
||||
text.text = copy;
|
||||
text.text_length = pos;
|
||||
text.itxt_length = 0;
|
||||
text.lang = 0;
|
||||
text.lang_key = 0;
|
||||
|
||||
png_set_text(pp, pi, &text, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (colour_type == 3) /* palette */
|
||||
init_standard_palette(ps, pp, pi, 1U << bit_depth, 0/*do tRNS*/);
|
||||
|
||||
@@ -3612,6 +3693,27 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
{
|
||||
static char key[] = "end marker";
|
||||
static char comment[] = "end";
|
||||
png_text text;
|
||||
|
||||
/* Use a compressed text string to test the correct interaction of text
|
||||
* compression and IDAT compression.
|
||||
*/
|
||||
text.compression = TEXT_COMPRESSION;
|
||||
text.key = key;
|
||||
text.text = comment;
|
||||
text.text_length = (sizeof comment)-1;
|
||||
text.itxt_length = 0;
|
||||
text.lang = 0;
|
||||
text.lang_key = 0;
|
||||
|
||||
png_set_text(pp, pi, &text, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_write_end(pp, pi);
|
||||
|
||||
/* And store this under the appropriate id, then clean up. */
|
||||
@@ -3676,6 +3778,7 @@ make_size_images(png_store *ps)
|
||||
make_size(ps, 6, 3, WRITE_BDHI);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Return a row based on image id and 'y' for checking: */
|
||||
static void
|
||||
standard_row(png_const_structp pp, png_byte std[STANDARD_ROWMAX],
|
||||
@@ -3687,6 +3790,7 @@ standard_row(png_const_structp pp, png_byte std[STANDARD_ROWMAX],
|
||||
size_row(std, WIDTH_FROM_ID(id) * bit_size(pp, COL_FROM_ID(id),
|
||||
DEPTH_FROM_ID(id)), y);
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Tests - individual test cases */
|
||||
/* Like 'make_standard' but errors are deliberately introduced into the calls
|
||||
@@ -3971,6 +4075,7 @@ perform_formatting_test(png_store *volatile ps)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Because we want to use the same code in both the progressive reader and the
|
||||
* sequential reader it is necessary to deal with the fact that the progressive
|
||||
* reader callbacks only have one parameter (png_get_progressive_ptr()), so this
|
||||
@@ -4494,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 */
|
||||
}
|
||||
@@ -4565,6 +4674,114 @@ sequential_row(standard_display *dp, png_structp pp, png_infop pi,
|
||||
png_read_end(pp, pi);
|
||||
}
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
static void
|
||||
standard_check_text(png_const_structp pp, png_const_textp tp,
|
||||
png_const_charp keyword, png_const_charp text)
|
||||
{
|
||||
char msg[1024];
|
||||
size_t pos = safecat(msg, sizeof msg, 0, "text: ");
|
||||
size_t ok;
|
||||
|
||||
pos = safecat(msg, sizeof msg, pos, keyword);
|
||||
pos = safecat(msg, sizeof msg, pos, ": ");
|
||||
ok = pos;
|
||||
|
||||
if (tp->compression != TEXT_COMPRESSION)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
sprintf(buf, "compression [%d->%d], ", TEXT_COMPRESSION,
|
||||
tp->compression);
|
||||
pos = safecat(msg, sizeof msg, pos, buf);
|
||||
}
|
||||
|
||||
if (tp->key == NULL || strcmp(tp->key, keyword) != 0)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, "keyword \"");
|
||||
if (tp->key != NULL)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, tp->key);
|
||||
pos = safecat(msg, sizeof msg, pos, "\", ");
|
||||
}
|
||||
|
||||
else
|
||||
pos = safecat(msg, sizeof msg, pos, "null, ");
|
||||
}
|
||||
|
||||
if (tp->text == NULL)
|
||||
pos = safecat(msg, sizeof msg, pos, "text lost, ");
|
||||
|
||||
else
|
||||
{
|
||||
if (tp->text_length != strlen(text))
|
||||
{
|
||||
char buf[64];
|
||||
sprintf(buf, "text length changed[%lu->%lu], ",
|
||||
(unsigned long)strlen(text), (unsigned long)tp->text_length);
|
||||
pos = safecat(msg, sizeof msg, pos, buf);
|
||||
}
|
||||
|
||||
if (strcmp(tp->text, text) != 0)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, "text becomes \"");
|
||||
pos = safecat(msg, sizeof msg, pos, tp->text);
|
||||
pos = safecat(msg, sizeof msg, pos, "\" (was \"");
|
||||
pos = safecat(msg, sizeof msg, pos, text);
|
||||
pos = safecat(msg, sizeof msg, pos, "\"), ");
|
||||
}
|
||||
}
|
||||
|
||||
if (tp->itxt_length != 0)
|
||||
pos = safecat(msg, sizeof msg, pos, "iTXt length set, ");
|
||||
|
||||
if (tp->lang != NULL)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, "iTXt language \"");
|
||||
pos = safecat(msg, sizeof msg, pos, tp->lang);
|
||||
pos = safecat(msg, sizeof msg, pos, "\", ");
|
||||
}
|
||||
|
||||
if (tp->lang_key != NULL)
|
||||
{
|
||||
pos = safecat(msg, sizeof msg, pos, "iTXt keyword \"");
|
||||
pos = safecat(msg, sizeof msg, pos, tp->lang_key);
|
||||
pos = safecat(msg, sizeof msg, pos, "\", ");
|
||||
}
|
||||
|
||||
if (pos > ok)
|
||||
{
|
||||
msg[pos-2] = '\0'; /* Remove the ", " at the end */
|
||||
png_error(pp, msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
standard_text_validate(standard_display *dp, png_const_structp pp,
|
||||
png_infop pi)
|
||||
{
|
||||
png_textp tp = NULL;
|
||||
png_uint_32 num_text = png_get_text(pp, pi, &tp, NULL);
|
||||
|
||||
if (num_text == 2 && tp != NULL)
|
||||
{
|
||||
standard_check_text(pp, tp, "image name", dp->ps->current->name);
|
||||
standard_check_text(pp, tp+1, "end marker", "end");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
char msg[64];
|
||||
|
||||
sprintf(msg, "expected two text items, got %lu",
|
||||
(unsigned long)num_text);
|
||||
png_error(pp, msg);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define standard_text_validate(dp,pp,pi) ((void)0)
|
||||
#endif
|
||||
|
||||
static void
|
||||
standard_row_validate(standard_display *dp, png_const_structp pp,
|
||||
int iImage, int iDisplay, png_uint_32 y)
|
||||
@@ -4652,6 +4869,7 @@ standard_end(png_structp ppIn, png_infop pi)
|
||||
/* Validate the image - progressive reading only produces one variant for
|
||||
* interlaced images.
|
||||
*/
|
||||
standard_text_validate(dp, pp, pi);
|
||||
standard_image_validate(dp, pp, 0, -1);
|
||||
}
|
||||
|
||||
@@ -4721,7 +4939,10 @@ standard_test(png_store* PNG_CONST psIn, png_uint_32 PNG_CONST id,
|
||||
* image is correct.
|
||||
*/
|
||||
if (!d.speed)
|
||||
{
|
||||
standard_text_validate(&d, pp, pi);
|
||||
standard_image_validate(&d, pp, 0, 1);
|
||||
}
|
||||
else
|
||||
d.ps->validated = 1;
|
||||
}
|
||||
@@ -5799,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)
|
||||
@@ -5811,6 +6033,7 @@ image_transform_default_add(image_transform *this,
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
/* png_set_palette_to_rgb */
|
||||
@@ -7126,7 +7349,7 @@ perform_transform_test(png_modifier *pm)
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number))
|
||||
{
|
||||
@@ -7489,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:
|
||||
@@ -7506,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:
|
||||
@@ -7538,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;
|
||||
}
|
||||
|
||||
@@ -7937,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:
|
||||
@@ -8488,7 +8718,7 @@ perform_gamma_threshold_tests(png_modifier *pm)
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
/* Don't test more than one instance of each palette - it's pointless, in
|
||||
* fact this test is somewhat excessive since libpng doesn't make this
|
||||
@@ -8553,7 +8783,7 @@ static void perform_gamma_transform_tests(png_modifier *pm)
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number))
|
||||
{
|
||||
@@ -8582,11 +8812,8 @@ static void perform_gamma_sbit_tests(png_modifier *pm)
|
||||
*/
|
||||
for (sbit=pm->sbitlow; sbit<(1<<READ_BDHI); ++sbit)
|
||||
{
|
||||
png_byte colour_type, bit_depth;
|
||||
int npalette;
|
||||
|
||||
colour_type = bit_depth = 0;
|
||||
npalette = 0;
|
||||
png_byte colour_type = 0, bit_depth = 0;
|
||||
unsigned int npalette = 0;
|
||||
|
||||
while (next_format(&colour_type, &bit_depth, &npalette))
|
||||
if ((colour_type & PNG_COLOR_MASK_ALPHA) == 0 &&
|
||||
@@ -8672,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,
|
||||
@@ -8802,7 +9029,7 @@ perform_gamma_composition_tests(png_modifier *pm, int do_background,
|
||||
{
|
||||
png_byte colour_type = 0;
|
||||
png_byte bit_depth = 0;
|
||||
int palette_number = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
/* Skip the non-alpha cases - there is no setting of a transparency colour at
|
||||
* present.
|
||||
@@ -8863,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)
|
||||
@@ -8982,6 +9211,7 @@ perform_gamma_test(png_modifier *pm, int summary)
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* INTERLACE MACRO VALIDATION */
|
||||
/* This is copied verbatim from the specification, it is simply the pass
|
||||
@@ -9790,7 +10020,9 @@ int main(int argc, char **argv)
|
||||
{
|
||||
perform_interlace_macro_validation();
|
||||
perform_formatting_test(&pm.this);
|
||||
perform_standard_test(&pm);
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
perform_standard_test(&pm);
|
||||
# endif
|
||||
perform_error_test(&pm);
|
||||
}
|
||||
|
||||
@@ -9798,7 +10030,9 @@ int main(int argc, char **argv)
|
||||
if (pm.test_size)
|
||||
{
|
||||
make_size_images(&pm.this);
|
||||
perform_size_test(&pm);
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
perform_size_test(&pm);
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
@@ -9891,7 +10125,21 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: open failed\n", touch);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else /* write not supported */
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "pngvalid: no write support in libpng, all tests skipped\n");
|
||||
/* 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);
|
||||
}
|
||||
999
contrib/libtests/tarith.c
Normal file
999
contrib/libtests/tarith.c
Normal file
@@ -0,0 +1,999 @@
|
||||
|
||||
/* tarith.c
|
||||
*
|
||||
* Copyright (c) 2011-2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Test internal arithmetic functions of libpng.
|
||||
*
|
||||
* This code must be linked against a math library (-lm), but does not require
|
||||
* libpng or zlib to work. Because it includes the complete source of 'png.c'
|
||||
* it tests the code with whatever compiler options are used to build it.
|
||||
* Changing these options can substantially change the errors in the
|
||||
* calculations that the compiler chooses!
|
||||
*/
|
||||
#define _POSIX_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
|
||||
/* Obtain a copy of the code to be tested (plus other things), disabling
|
||||
* stuff that is not required.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../../pngpriv.h"
|
||||
|
||||
#define png_error png_warning
|
||||
|
||||
void png_warning(png_const_structrp png_ptr, png_const_charp msg)
|
||||
{
|
||||
fprintf(stderr, "validation: %s\n", msg);
|
||||
}
|
||||
|
||||
#define png_fixed_error png_fixed_warning
|
||||
|
||||
void png_fixed_warning(png_const_structrp png_ptr, png_const_charp msg)
|
||||
{
|
||||
fprintf(stderr, "overflow in: %s\n", msg);
|
||||
}
|
||||
|
||||
#define png_set_error_fn(pp, ep, efp, wfp) ((void)0)
|
||||
#define png_malloc(pp, s) malloc(s)
|
||||
#define png_malloc_warn(pp, s) malloc(s)
|
||||
#define png_malloc_base(pp, s) malloc(s)
|
||||
#define png_calloc(pp, s) calloc(1, (s))
|
||||
#define png_free(pp, s) free(s)
|
||||
|
||||
#define png_safecat(b, sb, pos, str) (pos)
|
||||
#define png_format_number(start, end, format, number) (start)
|
||||
|
||||
#define crc32(crc, pp, s) (crc)
|
||||
#define inflateReset(zs) Z_OK
|
||||
|
||||
#define png_create_struct(type) (0)
|
||||
#define png_destroy_struct(pp) ((void)0)
|
||||
#define png_create_struct_2(type, m, mm) (0)
|
||||
#define png_destroy_struct_2(pp, f, mm) ((void)0)
|
||||
|
||||
#undef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
#undef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#undef PNG_USER_MEM_SUPPORTED
|
||||
|
||||
#include "../../png.c"
|
||||
|
||||
/* Validate ASCII to fp routines. */
|
||||
static int verbose = 0;
|
||||
|
||||
int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
{
|
||||
int showall = 0;
|
||||
double max_error=2; /* As a percentage error-in-last-digit/.5 */
|
||||
double max_error_abs=17; /* Used when precision is DBL_DIG */
|
||||
double max = 0;
|
||||
double max_abs = 0;
|
||||
double test = 0; /* Important to test this. */
|
||||
int precision = 5;
|
||||
int nonfinite = 0;
|
||||
int finite = 0;
|
||||
int ok = 0;
|
||||
int failcount = 0;
|
||||
int minorarith = 0;
|
||||
|
||||
while (--argc > 0)
|
||||
if (strcmp(*++argv, "-a") == 0)
|
||||
showall = 1;
|
||||
else if (strcmp(*argv, "-e") == 0 && argc > 0)
|
||||
{
|
||||
--argc;
|
||||
max_error = atof(*++argv);
|
||||
}
|
||||
else if (strcmp(*argv, "-E") == 0 && argc > 0)
|
||||
{
|
||||
--argc;
|
||||
max_error_abs = atof(*++argv);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
png_size_t index;
|
||||
int state, failed = 0;
|
||||
char buffer[64];
|
||||
|
||||
if (isfinite(test))
|
||||
++finite;
|
||||
else
|
||||
++nonfinite;
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "%.*g %d\n", DBL_DIG, test, precision);
|
||||
|
||||
/* Check for overflow in the buffer by setting a marker. */
|
||||
memset(buffer, 71, sizeof buffer);
|
||||
|
||||
png_ascii_from_fp(0, buffer, precision+10, test, precision);
|
||||
|
||||
/* Allow for a three digit exponent, this stuff will fail if
|
||||
* the exponent is bigger than this!
|
||||
*/
|
||||
if (buffer[precision+7] != 71)
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s'[%lu] buffer overflow\n", test,
|
||||
precision, buffer, (unsigned long)strlen(buffer));
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
/* Following are used for the number parser below and must be
|
||||
* initialized to zero.
|
||||
*/
|
||||
state = 0;
|
||||
index = 0;
|
||||
if (!isfinite(test))
|
||||
{
|
||||
/* Expect 'inf' */
|
||||
if (test >= 0 && strcmp(buffer, "inf") ||
|
||||
test < 0 && strcmp(buffer, "-inf"))
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but expected 'inf'\n", test,
|
||||
precision, buffer);
|
||||
failed = 1;
|
||||
}
|
||||
}
|
||||
else if (!png_check_fp_number(buffer, precision+10, &state, &index) ||
|
||||
buffer[index] != 0)
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but has bad format ('%c')\n", test,
|
||||
precision, buffer, buffer[index]);
|
||||
failed = 1;
|
||||
}
|
||||
else if (PNG_FP_IS_NEGATIVE(state) && !(test < 0))
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but negative value not so reported\n",
|
||||
test, precision, buffer);
|
||||
failed = 1;
|
||||
assert(!PNG_FP_IS_ZERO(state));
|
||||
assert(!PNG_FP_IS_POSITIVE(state));
|
||||
}
|
||||
else if (PNG_FP_IS_ZERO(state) && !(test == 0))
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but zero value not so reported\n",
|
||||
test, precision, buffer);
|
||||
failed = 1;
|
||||
assert(!PNG_FP_IS_NEGATIVE(state));
|
||||
assert(!PNG_FP_IS_POSITIVE(state));
|
||||
}
|
||||
else if (PNG_FP_IS_POSITIVE(state) && !(test > 0))
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but postive value not so reported\n",
|
||||
test, precision, buffer);
|
||||
failed = 1;
|
||||
assert(!PNG_FP_IS_NEGATIVE(state));
|
||||
assert(!PNG_FP_IS_ZERO(state));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check the result against the original. */
|
||||
double out = atof(buffer);
|
||||
double change = fabs((out - test)/test);
|
||||
double allow = .5/pow(10,
|
||||
(precision >= DBL_DIG) ? DBL_DIG-1 : precision-1);
|
||||
|
||||
/* NOTE: if you hit this error case are you compiling with gcc
|
||||
* and -O0? Try -O2 - the errors can accumulate if the FP
|
||||
* code above is not optimized and may drift outside the .5 in
|
||||
* DBL_DIG allowed. In any case a small number of errors may
|
||||
* occur (very small ones - 1 or 2%) because of rounding in the
|
||||
* calculations, either in the conversion API or in atof.
|
||||
*/
|
||||
if (change >= allow && (isfinite(out) ||
|
||||
fabs(test/DBL_MAX) <= 1-allow))
|
||||
{
|
||||
double percent = (precision >= DBL_DIG) ? max_error_abs : max_error;
|
||||
double allowp = (change-allow)*100/allow;
|
||||
|
||||
if (precision >= DBL_DIG)
|
||||
{
|
||||
if (max_abs < allowp) max_abs = allowp;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (max < allowp) max = allowp;
|
||||
}
|
||||
|
||||
if (showall || allowp >= percent)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%.*g[%d] -> '%s' -> %.*g number changed (%g > %g (%d%%))\n",
|
||||
DBL_DIG, test, precision, buffer, DBL_DIG, out, change, allow,
|
||||
(int)round(allowp));
|
||||
failed = 1;
|
||||
}
|
||||
else
|
||||
++minorarith;
|
||||
}
|
||||
}
|
||||
|
||||
if (failed)
|
||||
++failcount;
|
||||
else
|
||||
++ok;
|
||||
|
||||
skip:
|
||||
/* Generate a new number and precision. */
|
||||
precision = rand();
|
||||
if (precision & 1) test = -test;
|
||||
precision >>= 1;
|
||||
|
||||
/* Generate random numbers. */
|
||||
if (test == 0 || !isfinite(test))
|
||||
test = precision+1;
|
||||
else
|
||||
{
|
||||
/* Derive the exponent from the previous rand() value. */
|
||||
int exponent = precision % (DBL_MAX_EXP - DBL_MIN_EXP) + DBL_MIN_EXP;
|
||||
int tmp;
|
||||
test = frexp(test * rand(), &tmp);
|
||||
test = ldexp(test, exponent);
|
||||
precision >>= 8; /* arbitrary */
|
||||
}
|
||||
|
||||
/* This limits the precision to 32 digits, enough for standard
|
||||
* IEEE implementations which have at most 15 digits.
|
||||
*/
|
||||
precision = (precision & 0x1f) + 1;
|
||||
}
|
||||
while (--count);
|
||||
|
||||
printf("Tested %d finite values, %d non-finite, %d OK (%d failed) %d minor "
|
||||
"arithmetic errors\n", finite, nonfinite, ok, failcount, minorarith);
|
||||
printf(" Error with >=%d digit precision %.2f%%\n", DBL_DIG, max_abs);
|
||||
printf(" Error with < %d digit precision %.2f%%\n", DBL_DIG, max);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Observe that valid FP numbers have the forms listed in the PNG extensions
|
||||
* specification:
|
||||
*
|
||||
* [+,-]{integer,integer.fraction,.fraction}[{e,E}[+,-]integer]
|
||||
*
|
||||
* Test each of these in turn, including invalid cases.
|
||||
*/
|
||||
typedef enum checkfp_state
|
||||
{
|
||||
start, fraction, exponent, states
|
||||
} checkfp_state;
|
||||
|
||||
/* The characters (other than digits) that characterize the states: */
|
||||
static const char none[] = "";
|
||||
static const char hexdigits[16] = "0123456789ABCDEF";
|
||||
|
||||
static const struct
|
||||
{
|
||||
const char *start; /* Characters valid at the start */
|
||||
const char *end; /* Valid characters that end the state */
|
||||
const char *tests; /* Characters to test after 2 digits seen */
|
||||
}
|
||||
state_characters[states] =
|
||||
{
|
||||
/* start: */ { "+-.", ".eE", "+-.e*0369" },
|
||||
/* fraction: */ { none, "eE", "+-.E#0147" },
|
||||
/* exponent: */ { "+-", none, "+-.eE^0258" }
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char number[1024]; /* Buffer for number being tested */
|
||||
int limit; /* Command line limit */
|
||||
int verbose; /* Shadows global variable */
|
||||
int ctimes; /* Number of numbers tested */
|
||||
int cmillions; /* Count of millions of numbers */
|
||||
int cinvalid; /* Invalid strings checked */
|
||||
int cnoaccept; /* Characters not accepted */
|
||||
}
|
||||
checkfp_command;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int cnumber; /* Index into number string */
|
||||
checkfp_state check_state; /* Current number state */
|
||||
int at_start; /* At start (first character) of state */
|
||||
int cdigits_in_state; /* Digits seen in that state */
|
||||
int limit; /* Limit on same for checking all chars */
|
||||
int state; /* Current parser state */
|
||||
int is_negative; /* Number is negative */
|
||||
int is_zero; /* Number is (still) zero */
|
||||
int number_was_valid; /* Previous character validity */
|
||||
}
|
||||
checkfp_control;
|
||||
|
||||
static int check_all_characters(checkfp_command *co, checkfp_control c);
|
||||
|
||||
static int check_some_characters(checkfp_command *co, checkfp_control c,
|
||||
const char *tests);
|
||||
|
||||
static int check_one_character(checkfp_command *co, checkfp_control c, int ch)
|
||||
{
|
||||
/* Test this character (ch) to ensure the parser does the correct thing.
|
||||
*/
|
||||
png_size_t index = 0;
|
||||
const char test = (char)ch;
|
||||
const int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||
const int character_accepted = (index == 1);
|
||||
|
||||
if (c.check_state != exponent && isdigit(ch) && ch != '0')
|
||||
c.is_zero = 0;
|
||||
|
||||
if (c.check_state == start && c.at_start && ch == '-')
|
||||
c.is_negative = 1;
|
||||
|
||||
if (isprint(ch))
|
||||
co->number[c.cnumber++] = (char)ch;
|
||||
else
|
||||
{
|
||||
co->number[c.cnumber++] = '<';
|
||||
co->number[c.cnumber++] = hexdigits[(ch >> 4) & 0xf];
|
||||
co->number[c.cnumber++] = hexdigits[ch & 0xf];
|
||||
co->number[c.cnumber++] = '>';
|
||||
}
|
||||
co->number[c.cnumber] = 0;
|
||||
|
||||
if (co->verbose > 1)
|
||||
fprintf(stderr, "%s\n", co->number);
|
||||
|
||||
if (++(co->ctimes) == 1000000)
|
||||
{
|
||||
if (co->verbose == 1)
|
||||
fputc('.', stderr);
|
||||
co->ctimes = 0;
|
||||
++(co->cmillions);
|
||||
}
|
||||
|
||||
if (!number_is_valid)
|
||||
++(co->cinvalid);
|
||||
|
||||
if (!character_accepted)
|
||||
++(co->cnoaccept);
|
||||
|
||||
/* This should never fail (it's a serious bug if it does): */
|
||||
if (index != 0 && index != 1)
|
||||
{
|
||||
fprintf(stderr, "%s: read beyond end of string (%lu)\n", co->number,
|
||||
(unsigned long)index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Validate the new state, note that the PNG_FP_IS_ macros all return
|
||||
* false unless the number is valid.
|
||||
*/
|
||||
if (PNG_FP_IS_NEGATIVE(c.state) !=
|
||||
(number_is_valid && !c.is_zero && c.is_negative))
|
||||
{
|
||||
fprintf(stderr, "%s: negative when it is not\n", co->number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PNG_FP_IS_ZERO(c.state) != (number_is_valid && c.is_zero))
|
||||
{
|
||||
fprintf(stderr, "%s: zero when it is not\n", co->number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PNG_FP_IS_POSITIVE(c.state) !=
|
||||
(number_is_valid && !c.is_zero && !c.is_negative))
|
||||
{
|
||||
fprintf(stderr, "%s: positive when it is not\n", co->number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Testing a digit */
|
||||
if (isdigit(ch))
|
||||
{
|
||||
if (!character_accepted)
|
||||
{
|
||||
fprintf(stderr, "%s: digit '%c' not accepted\n", co->number, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!number_is_valid)
|
||||
{
|
||||
fprintf(stderr, "%s: saw a digit (%c) but number not valid\n",
|
||||
co->number, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
++c.cdigits_in_state;
|
||||
c.at_start = 0;
|
||||
c.number_was_valid = 1;
|
||||
|
||||
/* Continue testing characters in this state. Either test all of
|
||||
* them or, if we have already seen one digit in this state, just test a
|
||||
* limited set.
|
||||
*/
|
||||
if (c.cdigits_in_state < 1)
|
||||
return check_all_characters(co, c);
|
||||
|
||||
else
|
||||
return check_some_characters(co, c,
|
||||
state_characters[c.check_state].tests);
|
||||
}
|
||||
|
||||
/* A non-digit; is it allowed here? */
|
||||
else if (((ch == '+' || ch == '-') && c.check_state != fraction &&
|
||||
c.at_start) ||
|
||||
(ch == '.' && c.check_state == start) ||
|
||||
((ch == 'e' || ch == 'E') && c.number_was_valid &&
|
||||
c.check_state != exponent))
|
||||
{
|
||||
if (!character_accepted)
|
||||
{
|
||||
fprintf(stderr, "%s: character '%c' not accepted\n", co->number, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The number remains valid after start of fraction but nowhere else. */
|
||||
if (number_is_valid && (c.check_state != start || ch != '.'))
|
||||
{
|
||||
fprintf(stderr, "%s: saw a non-digit (%c) but number valid\n",
|
||||
co->number, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
c.number_was_valid = number_is_valid;
|
||||
|
||||
/* Check for a state change. When changing to 'fraction' if the number
|
||||
* is valid at this point set the at_start to false to allow an exponent
|
||||
* 'e' to come next.
|
||||
*/
|
||||
if (c.check_state == start && ch == '.')
|
||||
{
|
||||
c.check_state = fraction;
|
||||
c.at_start = !number_is_valid;
|
||||
c.cdigits_in_state = 0;
|
||||
c.limit = co->limit;
|
||||
return check_all_characters(co, c);
|
||||
}
|
||||
|
||||
else if (c.check_state < exponent && (ch == 'e' || ch == 'E'))
|
||||
{
|
||||
c.check_state = exponent;
|
||||
c.at_start = 1;
|
||||
c.cdigits_in_state = 0;
|
||||
c.limit = co->limit;
|
||||
return check_all_characters(co, c);
|
||||
}
|
||||
|
||||
/* Else it was a sign, and the state doesn't change. */
|
||||
else
|
||||
{
|
||||
if (ch != '-' && ch != '+')
|
||||
{
|
||||
fprintf(stderr, "checkfp: internal error (1)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
c.at_start = 0;
|
||||
return check_all_characters(co, c);
|
||||
}
|
||||
}
|
||||
|
||||
/* Testing an invalid character */
|
||||
else
|
||||
{
|
||||
if (character_accepted)
|
||||
{
|
||||
fprintf(stderr, "%s: character '%c' [0x%.2x] accepted\n", co->number,
|
||||
ch, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (number_is_valid != c.number_was_valid)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: character '%c' [0x%.2x] changed number validity\n", co->number,
|
||||
ch, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Do nothing - the parser has stuck; return success and keep going with
|
||||
* the next character.
|
||||
*/
|
||||
}
|
||||
|
||||
/* Successful return (the caller will try the next character.) */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int check_all_characters(checkfp_command *co, checkfp_control c)
|
||||
{
|
||||
int ch;
|
||||
|
||||
if (c.cnumber+4 < sizeof co->number) for (ch=0; ch<256; ++ch)
|
||||
{
|
||||
if (!check_one_character(co, c, ch))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int check_some_characters(checkfp_command *co, checkfp_control c,
|
||||
const char *tests)
|
||||
{
|
||||
int i;
|
||||
|
||||
--(c.limit);
|
||||
|
||||
if (c.cnumber+4 < sizeof co->number && c.limit >= 0)
|
||||
{
|
||||
if (c.limit > 0) for (i=0; tests[i]; ++i)
|
||||
{
|
||||
if (!check_one_character(co, c, tests[i]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* At the end check all the characters. */
|
||||
else
|
||||
return check_all_characters(co, c);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int validation_checkfp(int count, int argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
checkfp_command command;
|
||||
checkfp_control control;
|
||||
|
||||
command.number[0] = 0;
|
||||
command.limit = 3;
|
||||
command.verbose = verbose;
|
||||
command.ctimes = 0;
|
||||
command.cmillions = 0;
|
||||
command.cinvalid = 0;
|
||||
command.cnoaccept = 0;
|
||||
|
||||
while (--argc > 0)
|
||||
{
|
||||
++argv;
|
||||
if (argc > 1 && strcmp(*argv, "-l") == 0)
|
||||
{
|
||||
--argc;
|
||||
command.limit = atoi(*++argv);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
control.cnumber = 0;
|
||||
control.check_state = start;
|
||||
control.at_start = 1;
|
||||
control.cdigits_in_state = 0;
|
||||
control.limit = command.limit;
|
||||
control.state = 0;
|
||||
control.is_negative = 0;
|
||||
control.is_zero = 1;
|
||||
control.number_was_valid = 0;
|
||||
|
||||
result = check_all_characters(&command, control);
|
||||
|
||||
printf("checkfp: %s: checked %d,%.3d,%.3d,%.3d strings (%d invalid)\n",
|
||||
result ? "pass" : "FAIL", command.cmillions / 1000,
|
||||
command.cmillions % 1000, command.ctimes / 1000, command.ctimes % 1000,
|
||||
command.cinvalid);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int validation_muldiv(int count, int argc, char **argv)
|
||||
{
|
||||
int tested = 0;
|
||||
int overflow = 0;
|
||||
int error = 0;
|
||||
int error64 = 0;
|
||||
int passed = 0;
|
||||
int randbits = 0;
|
||||
png_uint_32 randbuffer;
|
||||
png_fixed_point a;
|
||||
png_int_32 times, div;
|
||||
|
||||
while (--argc > 0)
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *++argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Find out about the random number generator. */
|
||||
randbuffer = RAND_MAX;
|
||||
while (randbuffer != 0) ++randbits, randbuffer >>= 1;
|
||||
printf("Using random number generator that makes %d bits\n", randbits);
|
||||
for (div=0; div<32; div += randbits)
|
||||
randbuffer = (randbuffer << randbits) ^ rand();
|
||||
|
||||
a = 0;
|
||||
times = div = 0;
|
||||
do
|
||||
{
|
||||
png_fixed_point result;
|
||||
/* NOTE: your mileage may vary, a type is required below that can
|
||||
* hold 64 bits or more, if floating point is used a 64 bit or
|
||||
* better mantissa is required.
|
||||
*/
|
||||
long long int fp, fpround;
|
||||
unsigned long hi, lo;
|
||||
int ok;
|
||||
|
||||
/* Check the values, png_64bit_product can only handle positive
|
||||
* numbers, so correct for that here.
|
||||
*/
|
||||
{
|
||||
long u1, u2;
|
||||
int n = 0;
|
||||
if (a < 0) u1 = -a, n = 1; else u1 = a;
|
||||
if (times < 0) u2 = -times, n = !n; else u2 = times;
|
||||
png_64bit_product(u1, u2, &hi, &lo);
|
||||
if (n)
|
||||
{
|
||||
/* -x = ~x+1 */
|
||||
lo = ((~lo) + 1) & 0xffffffff;
|
||||
hi = ~hi;
|
||||
if (lo == 0) ++hi;
|
||||
}
|
||||
}
|
||||
|
||||
fp = a;
|
||||
fp *= times;
|
||||
if ((fp & 0xffffffff) != lo || ((fp >> 32) & 0xffffffff) != hi)
|
||||
{
|
||||
fprintf(stderr, "png_64bit_product %d * %d -> %lx|%.8lx not %llx\n",
|
||||
a, times, hi, lo, fp);
|
||||
++error64;
|
||||
}
|
||||
|
||||
if (div != 0)
|
||||
{
|
||||
/* Round - this is C round to zero. */
|
||||
if ((fp < 0) != (div < 0))
|
||||
fp -= div/2;
|
||||
else
|
||||
fp += div/2;
|
||||
|
||||
fp /= div;
|
||||
fpround = fp;
|
||||
/* Assume 2's complement here: */
|
||||
ok = fpround <= PNG_UINT_31_MAX &&
|
||||
fpround >= -1-(long long int)PNG_UINT_31_MAX;
|
||||
if (!ok) ++overflow;
|
||||
}
|
||||
else
|
||||
ok = 0, ++overflow, fpround = fp/*misleading*/;
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "TEST %d * %d / %d -> %lld (%s)\n", a, times, div,
|
||||
fp, ok ? "ok" : "overflow");
|
||||
|
||||
++tested;
|
||||
if (png_muldiv(&result, a, times, div) != ok)
|
||||
{
|
||||
++error;
|
||||
if (ok)
|
||||
fprintf(stderr, "%d * %d / %d -> overflow (expected %lld)\n", a,
|
||||
times, div, fp);
|
||||
else
|
||||
fprintf(stderr, "%d * %d / %d -> %d (expected overflow %lld)\n", a,
|
||||
times, div, result, fp);
|
||||
}
|
||||
else if (ok && result != fpround)
|
||||
{
|
||||
++error;
|
||||
fprintf(stderr, "%d * %d / %d -> %d not %lld\n", a, times, div, result,
|
||||
fp);
|
||||
}
|
||||
else
|
||||
++passed;
|
||||
|
||||
/* Generate three new values, this uses rand() and rand() only returns
|
||||
* up to RAND_MAX.
|
||||
*/
|
||||
/* CRUDE */
|
||||
a += times;
|
||||
times += div;
|
||||
div = randbuffer;
|
||||
randbuffer = (randbuffer << randbits) ^ rand();
|
||||
}
|
||||
while (--count > 0);
|
||||
|
||||
printf("%d tests including %d overflows, %d passed, %d failed (%d 64 bit "
|
||||
"errors)\n", tested, overflow, passed, error, error64);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* When FP is on this just becomes a speed test - compile without FP to get real
|
||||
* validation.
|
||||
*/
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
#define LN2 .000010576586617430806112933839 /* log(2)/65536 */
|
||||
#define L2INV 94548.46219969910586572651 /* 65536/log(2) */
|
||||
|
||||
/* For speed testing, need the internal functions too: */
|
||||
static png_uint_32 png_log8bit(unsigned x)
|
||||
{
|
||||
if (x > 0)
|
||||
return (png_uint_32)floor(.5-log(x/255.)*L2INV);
|
||||
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
static png_uint_32 png_log16bit(png_uint_32 x)
|
||||
{
|
||||
if (x > 0)
|
||||
return (png_uint_32)floor(.5-log(x/65535.)*L2INV);
|
||||
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
static png_uint_32 png_exp(png_uint_32 x)
|
||||
{
|
||||
return (png_uint_32)floor(.5 + exp(x * -LN2) * 0xffffffffU);
|
||||
}
|
||||
|
||||
static png_byte png_exp8bit(png_uint_32 log)
|
||||
{
|
||||
return (png_byte)floor(.5 + exp(log * -LN2) * 255);
|
||||
}
|
||||
|
||||
static png_uint_16 png_exp16bit(png_uint_32 log)
|
||||
{
|
||||
return (png_uint_16)floor(.5 + exp(log * -LN2) * 65535);
|
||||
}
|
||||
#endif /* FLOATING_ARITHMETIC */
|
||||
|
||||
int validation_gamma(int argc, char **argv)
|
||||
{
|
||||
double gamma[9] = { 2.2, 1.8, 1.52, 1.45, 1., 1/1.45, 1/1.52, 1/1.8, 1/2.2 };
|
||||
double maxerr;
|
||||
int i, silent=0, onlygamma=0;
|
||||
|
||||
/* Silence the output with -s, just test the gamma functions with -g: */
|
||||
while (--argc > 0)
|
||||
if (strcmp(*++argv, "-s") == 0)
|
||||
silent = 1;
|
||||
else if (strcmp(*argv, "-g") == 0)
|
||||
onlygamma = 1;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!onlygamma)
|
||||
{
|
||||
/* First validate the log functions: */
|
||||
maxerr = 0;
|
||||
for (i=0; i<256; ++i)
|
||||
{
|
||||
double correct = -log(i/255.)/log(2.)*65536;
|
||||
double error = png_log8bit(i) - correct;
|
||||
|
||||
if (i != 0 && fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
|
||||
if (i == 0 && png_log8bit(i) != 0xffffffff ||
|
||||
i != 0 && png_log8bit(i) != floor(correct+.5))
|
||||
{
|
||||
fprintf(stderr, "8 bit log error: %d: got %u, expected %f\n",
|
||||
i, png_log8bit(i), correct);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 8 bit log error = %f\n", maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (i=0; i<65536; ++i)
|
||||
{
|
||||
double correct = -log(i/65535.)/log(2.)*65536;
|
||||
double error = png_log16bit(i) - correct;
|
||||
|
||||
if (i != 0 && fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
|
||||
if (i == 0 && png_log16bit(i) != 0xffffffff ||
|
||||
i != 0 && png_log16bit(i) != floor(correct+.5))
|
||||
{
|
||||
if (error > .68) /* By experiment error is less than .68 */
|
||||
{
|
||||
fprintf(stderr, "16 bit log error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_log16bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 16 bit log error = %f\n", maxerr);
|
||||
|
||||
/* Now exponentiations. */
|
||||
maxerr = 0;
|
||||
for (i=0; i<=0xfffff; ++i)
|
||||
{
|
||||
double correct = exp(-i/65536. * log(2.)) * (65536. * 65536);
|
||||
double error = png_exp(i) - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > 1883) /* By experiment. */
|
||||
{
|
||||
fprintf(stderr, "32 bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 32 bit exp error = %f\n", maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (i=0; i<=0xfffff; ++i)
|
||||
{
|
||||
double correct = exp(-i/65536. * log(2.)) * 255;
|
||||
double error = png_exp8bit(i) - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > .50002) /* By experiment */
|
||||
{
|
||||
fprintf(stderr, "8 bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp8bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 8 bit exp error = %f\n", maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (i=0; i<=0xfffff; ++i)
|
||||
{
|
||||
double correct = exp(-i/65536. * log(2.)) * 65535;
|
||||
double error = png_exp16bit(i) - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > .524) /* By experiment */
|
||||
{
|
||||
fprintf(stderr, "16 bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp16bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("maximum 16 bit exp error = %f\n", maxerr);
|
||||
} /* !onlygamma */
|
||||
|
||||
/* Test the overall gamma correction. */
|
||||
for (i=0; i<9; ++i)
|
||||
{
|
||||
unsigned j;
|
||||
double g = gamma[i];
|
||||
png_fixed_point gfp = floor(g * PNG_FP_1 + .5);
|
||||
|
||||
if (!silent)
|
||||
printf("Test gamma %f\n", g);
|
||||
|
||||
maxerr = 0;
|
||||
for (j=0; j<256; ++j)
|
||||
{
|
||||
double correct = pow(j/255., g) * 255;
|
||||
png_byte out = png_gamma_8bit_correct(j, gfp);
|
||||
double error = out - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (out != floor(correct+.5))
|
||||
{
|
||||
fprintf(stderr, "8bit %d ^ %f: got %d expected %f error %f\n",
|
||||
j, g, out, correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("gamma %f: maximum 8 bit error %f\n", g, maxerr);
|
||||
|
||||
maxerr = 0;
|
||||
for (j=0; j<65536; ++j)
|
||||
{
|
||||
double correct = pow(j/65535., g) * 65535;
|
||||
png_uint_16 out = png_gamma_16bit_correct(j, gfp);
|
||||
double error = out - correct;
|
||||
|
||||
if (fabs(error) > maxerr)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > 1.62)
|
||||
{
|
||||
fprintf(stderr, "16bit %d ^ %f: got %d expected %f error %f\n",
|
||||
j, g, out, correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
printf("gamma %f: maximum 16 bit error %f\n", g, maxerr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************** VALIDATION TESTS ********************************/
|
||||
/* Various validation routines are included herein, they require some
|
||||
* definition for png_warning and png_error, seetings of VALIDATION:
|
||||
*
|
||||
* 1: validates the ASCII to floating point conversions
|
||||
* 2: validates png_muldiv
|
||||
* 3: accuracy test of fixed point gamma tables
|
||||
*/
|
||||
|
||||
/* The following COUNT (10^8) takes about 1 hour on a 1GHz Pentium IV
|
||||
* processor.
|
||||
*/
|
||||
#define COUNT 1000000000
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int count = COUNT;
|
||||
|
||||
while (argc > 1)
|
||||
{
|
||||
if (argc > 2 && strcmp(argv[1], "-c") == 0)
|
||||
{
|
||||
count = atoi(argv[2]);
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[1], "-v") == 0)
|
||||
{
|
||||
++verbose;
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (count > 0 && argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1], "ascii") == 0)
|
||||
return validation_ascii_to_fp(count, argc-1, argv+1);
|
||||
else if (strcmp(argv[1], "checkfp") == 0)
|
||||
return validation_checkfp(count, argc-1, argv+1);
|
||||
else if (strcmp(argv[1], "muldiv") == 0)
|
||||
return validation_muldiv(count, argc-1, argv+1);
|
||||
else if (strcmp(argv[1], "gamma") == 0)
|
||||
return validation_gamma(argc-1, argv+1);
|
||||
}
|
||||
|
||||
/* Bad argument: */
|
||||
fprintf(stderr,
|
||||
"usage: tarith [-v] [-c count] {ascii,muldiv,gamma} [args]\n");
|
||||
fprintf(stderr, " arguments: ascii [-a (all results)] [-e error%%]\n");
|
||||
fprintf(stderr, " checkfp [-l max-number-chars]\n");
|
||||
fprintf(stderr, " muldiv\n");
|
||||
fprintf(stderr, " gamma -s (silent) -g (only gamma; no log)\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/* timepng.c
|
||||
*
|
||||
* Copyright (c) 2012 John Cunningham Bowler
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.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
|
||||
@@ -38,4 +38,3 @@ option STDIO on
|
||||
option READ_EXPAND on
|
||||
option READ_STRIP_16_TO_8 on
|
||||
option USER_LIMITS on
|
||||
@#define PNG_SECURE
|
||||
|
||||
@@ -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'))
|
||||
{
|
||||
@@ -239,7 +254,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
get_token(pnm_file, maxval_token);
|
||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
||||
maxval = (png_uint_32) ul_maxval;
|
||||
|
||||
|
||||
if (maxval <= 1)
|
||||
bit_depth = 1;
|
||||
else if (maxval <= 3)
|
||||
@@ -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] != ' '));
|
||||
|
||||
|
||||
102
contrib/tools/checksum-icc.c
Normal file
102
contrib/tools/checksum-icc.c
Normal file
@@ -0,0 +1,102 @@
|
||||
/* checksum-icc.c
|
||||
*
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Generate crc32 and adler32 checksums of the given input files, used to
|
||||
* generate check-codes for use when matching ICC profiles within libpng.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
static int
|
||||
read_one_file(FILE *ip, const char *name)
|
||||
{
|
||||
uLong length = 0;
|
||||
uLong a32 = adler32(0, NULL, 0);
|
||||
uLong c32 = crc32(0, NULL, 0);
|
||||
Byte header[132];
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int ch = getc(ip);
|
||||
Byte b;
|
||||
|
||||
if (ch == EOF) break;
|
||||
|
||||
b = (Byte)ch;
|
||||
|
||||
if (length < sizeof header)
|
||||
header[length] = b;
|
||||
|
||||
++length;
|
||||
a32 = adler32(a32, &b, 1);
|
||||
c32 = crc32(c32, &b, 1);
|
||||
}
|
||||
|
||||
if (ferror(ip))
|
||||
return 0;
|
||||
|
||||
/* Success */
|
||||
printf("PNG_ICC_CHECKSUM(0x%8.8lx, 0x%8.8lx,\n PNG_MD5("
|
||||
"0x%2.2x%2.2x%2.2x%2.2x, 0x%2.2x%2.2x%2.2x%2.2x, 0x%2.2x%2.2x%2.2x%2.2x,"
|
||||
" 0x%2.2x%2.2x%2.2x%2.2x), %d,\n"
|
||||
" \"%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d\", %lu, \"%s\")\n",
|
||||
(unsigned long)a32, (unsigned long)c32,
|
||||
header[84], header[85], header[86], header[87],
|
||||
header[88], header[89], header[90], header[91],
|
||||
header[92], header[93], header[94], header[95],
|
||||
header[96], header[97], header[98], header[99],
|
||||
# define u16(x) (header[x] * 256 + header[x+1])
|
||||
# define u32(x) (u16(x) * 65536 + u16(x+2))
|
||||
u32(64), u16(24), u16(26), u16(28), u16(30), u16(32), u16(34),
|
||||
(unsigned long)length, name);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
printf("/* adler32, crc32, MD5[16], intent, date, length, file-name */\n");
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=1; i<argc; ++i)
|
||||
{
|
||||
FILE *ip = fopen(argv[i], "rb");
|
||||
|
||||
if (ip == NULL || !read_one_file(ip, argv[i]))
|
||||
{
|
||||
err = 1;
|
||||
perror(argv[i]);
|
||||
fprintf(stderr, "%s: read error\n", argv[i]);
|
||||
printf("/* ERROR: %s */\n", argv[i]);
|
||||
}
|
||||
|
||||
(void)fclose(ip);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (!read_one_file(stdin, "-"))
|
||||
{
|
||||
err = 1;
|
||||
perror("stdin");
|
||||
fprintf(stderr, "stdin: read error\n");
|
||||
printf("/* ERROR: stdin */\n");
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/*-
|
||||
* convert.c
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2013.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#
|
||||
# intgamma.sh
|
||||
#
|
||||
# Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
# Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
#
|
||||
# COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
# COPYRIGHT: Written by John Cunningham Bowler, 2013.
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* makesRGB.c -- build sRGB-to-linear and linear-to-sRGB conversion tables
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2012.
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2013.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
|
||||
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.
|
||||
|
||||
@@ -17,7 +17,7 @@ void PngFileInitialize (HWND hwnd) ;
|
||||
BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
|
||||
BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
|
||||
|
||||
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor);
|
||||
BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
|
||||
int iWidth, int iHeight, png_color BkgColor);
|
||||
|
||||
94
example.c
94
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
|
||||
@@ -48,7 +48,8 @@ int main(int argc, const char **argv)
|
||||
png_image image; /* The control structure used by libpng */
|
||||
|
||||
/* Initialize the 'png_image' structure. */
|
||||
memset(&image, 0, sizeof image);
|
||||
memset(&image, 0, (sizeof image));
|
||||
image.version = PNG_IMAGE_VERSION;
|
||||
|
||||
/* The first argument is the file to read: */
|
||||
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||
@@ -75,16 +76,28 @@ int main(int argc, const char **argv)
|
||||
* be supplied or the output buffer would have to be initialized to the
|
||||
* actual background of the image.
|
||||
*
|
||||
* The final argument to png_image_finish_read is the 'row_stride' -
|
||||
* The fourth argument to png_image_finish_read is the 'row_stride' -
|
||||
* this is the number of components allocated for the image in each
|
||||
* row. It has to be at least as big as the value returned by
|
||||
* PNG_IMAGE_ROW_STRIDE, but if you just allocate space for the
|
||||
* default, minimum, size using PNG_IMAGE_SIZE as above you can pass
|
||||
* zero.
|
||||
*
|
||||
* The final argument is a pointer to a buffer for the colormap;
|
||||
* colormaps have exactly the same format as a row of image pixels (so
|
||||
* you choose what format to make the colormap by setting
|
||||
* image.format). A colormap is only returned if
|
||||
* PNG_FORMAT_FLAG_COLORMAP is also set in image.format, so in this
|
||||
* case NULL is passed as the final argument. If you do want to force
|
||||
* all images into an index/color-mapped format then you can use:
|
||||
*
|
||||
* PNG_IMAGE_COLORMAP_SIZE(image)
|
||||
*
|
||||
* to find the maximum size of the colormap in bytes.
|
||||
*/
|
||||
if (buffer != NULL &&
|
||||
png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/))
|
||||
0/*row_stride*/, NULL/*colormap*/))
|
||||
{
|
||||
/* Now write the image out to the second argument. In the write
|
||||
* call 'convert_to_8bit' allows 16-bit data to be squashed down to
|
||||
@@ -92,7 +105,7 @@ int main(int argc, const char **argv)
|
||||
* to the 8-bit format.
|
||||
*/
|
||||
if (png_image_write_to_file(&image, argv[2], 0/*convert_to_8bit*/,
|
||||
buffer, 0/*row_stride*/))
|
||||
buffer, 0/*row_stride*/, NULL/*colormap*/))
|
||||
{
|
||||
/* The image has been written successfully. */
|
||||
exit(0);
|
||||
@@ -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;
|
||||
@@ -833,7 +846,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
|
||||
/* Set the palette if there is one. REQUIRED for indexed-color images */
|
||||
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
|
||||
* png_sizeof(png_color));
|
||||
* (sizeof (png_color)));
|
||||
/* ... Set palette colors ... */
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
|
||||
/* You must not free palette here, because png_set_PLTE only makes a link to
|
||||
@@ -864,25 +877,38 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
png_set_gAMA(png_ptr, info_ptr, gamma);
|
||||
|
||||
/* Optionally write comments into the image */
|
||||
text_ptr[0].key = "Title";
|
||||
text_ptr[0].text = "Mona Lisa";
|
||||
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[0].itxt_length = 0;
|
||||
text_ptr[0].lang = NULL;
|
||||
text_ptr[0].lang_key = NULL;
|
||||
text_ptr[1].key = "Author";
|
||||
text_ptr[1].text = "Leonardo DaVinci";
|
||||
text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[1].itxt_length = 0;
|
||||
text_ptr[1].lang = NULL;
|
||||
text_ptr[1].lang_key = NULL;
|
||||
text_ptr[2].key = "Description";
|
||||
text_ptr[2].text = "<long text>";
|
||||
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text_ptr[2].itxt_length = 0;
|
||||
text_ptr[2].lang = NULL;
|
||||
text_ptr[2].lang_key = NULL;
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, 3);
|
||||
{
|
||||
png_text text_ptr[3];
|
||||
|
||||
char key0[]="Title";
|
||||
char text0[]="Mona Lisa";
|
||||
text_ptr[0].key = key0;
|
||||
text_ptr[0].text = text0;
|
||||
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[0].itxt_length = 0;
|
||||
text_ptr[0].lang = NULL;
|
||||
text_ptr[0].lang_key = NULL;
|
||||
|
||||
char key1[]="Author";
|
||||
char text1[]="Leonardo DaVinci";
|
||||
text_ptr[1].key = key1;
|
||||
text_ptr[1].text = text1;
|
||||
text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[1].itxt_length = 0;
|
||||
text_ptr[1].lang = NULL;
|
||||
text_ptr[1].lang_key = NULL;
|
||||
|
||||
char key2[]="Description";
|
||||
char text2[]="<long text>";
|
||||
text_ptr[2].key = key2;
|
||||
text_ptr[2].text = text2;
|
||||
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text_ptr[2].itxt_length = 0;
|
||||
text_ptr[2].lang = NULL;
|
||||
text_ptr[2].lang_key = NULL;
|
||||
|
||||
png_set_text(write_ptr, write_info_ptr, text_ptr, 3);
|
||||
}
|
||||
|
||||
/* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */
|
||||
|
||||
@@ -955,12 +981,16 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* use the first method if you aren't handling interlacing yourself.
|
||||
*/
|
||||
png_uint_32 k, height, width;
|
||||
png_byte image[height][width*bytes_per_pixel];
|
||||
|
||||
/* In this example, "image" is a one-dimensional array of bytes */
|
||||
png_byte image[height*width*bytes_per_pixel];
|
||||
|
||||
png_bytep row_pointers[height];
|
||||
|
||||
if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
|
||||
if (height > PNG_UINT_32_MAX/(sizeof (png_bytep)))
|
||||
png_error (png_ptr, "Image is too tall to process in memory");
|
||||
|
||||
/* Set up pointers into your "image" byte array */
|
||||
for (k = 0; k < height; k++)
|
||||
row_pointers[k] = image + k*width*bytes_per_pixel;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.6.0beta13 - February 24, 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.0beta13 - February 24, 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.
|
||||
|
||||
@@ -160,8 +158,8 @@ APIs. Most of these are fairly obvious; for example types corresponding
|
||||
to integers of particular sizes and types for passing color values.
|
||||
|
||||
One exception is how non-integral numbers are handled. For application
|
||||
convenience most APIs that take such numbers have C (double) arguments,
|
||||
however internally PNG, and libpng, use 32 bit signed integers and encode
|
||||
convenience most APIs that take such numbers have C (double) arguments;
|
||||
however, internally PNG, and libpng, use 32 bit signed integers and encode
|
||||
the value by multiplying by 100,000. As of libpng 1.5.0 a convenience
|
||||
macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point)
|
||||
which is simply (png_int_32).
|
||||
@@ -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
|
||||
@@ -572,6 +575,7 @@ chunk types. To change this, you can call:
|
||||
|
||||
png_set_keep_unknown_chunks(png_ptr, keep,
|
||||
chunk_list, num_chunks);
|
||||
|
||||
keep - 0: default unknown chunk handling
|
||||
1: ignore; do not keep
|
||||
2: keep only if safe-to-copy
|
||||
@@ -585,11 +589,16 @@ chunk types. To change this, you can call:
|
||||
|
||||
chunk_list - list of chunks affected (a byte string,
|
||||
five bytes per chunk, NULL or '\0' if
|
||||
num_chunks is 0)
|
||||
num_chunks is positive; ignored if
|
||||
numchunks <= 0).
|
||||
|
||||
num_chunks - number of chunks affected; if 0, all
|
||||
unknown chunks are affected. If nonzero,
|
||||
only the chunks in the list are affected
|
||||
unknown chunks are affected. If positive,
|
||||
only the chunks in the list are affected,
|
||||
and if negative all unknown chunks and
|
||||
all known chunks except for the IHDR,
|
||||
PLTE, tRNS, IDAT, and IEND chunks are
|
||||
affected.
|
||||
|
||||
Unknown chunks declared in this way will be saved as raw data onto a
|
||||
list of png_unknown_chunk structures. If a chunk that is normally
|
||||
@@ -622,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
|
||||
@@ -669,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
|
||||
|
||||
@@ -822,7 +830,7 @@ the screen_gamma value. Pixels with alpha less than 1.0
|
||||
will still have linear components.
|
||||
|
||||
Use this format if you have control over your
|
||||
compositing software and do don't do other arithmetic
|
||||
compositing software and so don't do other arithmetic
|
||||
(such as scaling) on the data you get from libpng. Your
|
||||
compositing software can simply copy opaque pixels to
|
||||
the output but still has linear values for the
|
||||
@@ -985,7 +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");
|
||||
|
||||
@@ -994,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 */
|
||||
@@ -1153,6 +1161,15 @@ data has been read, or zero if it is missing. The parameters to the
|
||||
png_get_<chunk> are set directly if they are simple data types, or a
|
||||
pointer into the info_ptr is returned for any complex types.
|
||||
|
||||
The colorspace data from gAMA, cHRM, sRGB, iCCP, and sBIT chunks
|
||||
is simply returned to give the application information about how the
|
||||
image was encoded. Libpng itself only does transformations using the file
|
||||
gamma when combining semitransparent pixels with the background color, and,
|
||||
since libpng-1.6.0, when converting between 8-bit sRGB and 16-bit linear pixels
|
||||
within the simplified API. Libpng also uses the file gamma when converting
|
||||
RGB to gray, beginning with libpng-1.0.5, if the application calls
|
||||
png_set_rgb_to_gray()).
|
||||
|
||||
png_get_PLTE(png_ptr, info_ptr, &palette,
|
||||
&num_palette);
|
||||
|
||||
@@ -1764,7 +1781,7 @@ the current display (e.g., the background color from a web page). You
|
||||
need to tell libpng how the color is represented, both the format of the
|
||||
component values in the color (the number of bits) and the gamma encoding of the
|
||||
color. The function takes two arguments, background_gamma_mode and need_expand
|
||||
to convey this information, however only two combinations are likely to be
|
||||
to convey this information; however, only two combinations are likely to be
|
||||
useful:
|
||||
|
||||
png_color_16 my_background;
|
||||
@@ -2058,7 +2075,7 @@ the second parameter NULL.
|
||||
|
||||
If you don't want libpng to handle the interlacing details, just call
|
||||
png_read_rows() PNG_INTERLACE_ADAM7_PASSES times to read in all the images.
|
||||
Each of the images is a valid image by itself, however you will almost
|
||||
Each of the images is a valid image by itself; however, you will almost
|
||||
certainly need to distribute the pixels from each sub-image to the
|
||||
correct place. This is where everything gets very tricky.
|
||||
|
||||
@@ -2215,7 +2232,7 @@ sPLT, only the n'th item in the structure is freed, where n is "seq".
|
||||
The default behavior is only to free data that was allocated internally
|
||||
by libpng. This can be changed, so that libpng will not free the data,
|
||||
or so that it will free data that was allocated by the user with png_malloc()
|
||||
or png_zalloc() and passed in via a png_set_*() function, with
|
||||
or png_calloc() and passed in via a png_set_*() function, with
|
||||
|
||||
png_data_freer(png_ptr, info_ptr, freer, mask)
|
||||
|
||||
@@ -2236,7 +2253,7 @@ or png_destroy_*() is supposed to free the data. When the user assumes
|
||||
responsibility for libpng-allocated data, the application must use
|
||||
png_free() to free it, and when the user transfers responsibility to libpng
|
||||
for data that the user has allocated, the user must have used png_malloc()
|
||||
or png_zalloc() to allocate it.
|
||||
or png_calloc() to allocate it.
|
||||
|
||||
If you allocated your row_pointers in a single block, as suggested above in
|
||||
the description of the high level read interface, you must not transfer
|
||||
@@ -2272,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
|
||||
@@ -2552,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
|
||||
@@ -3054,18 +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(png_timep) is provided to convert from PNG
|
||||
time to an RFC 1123 format string.
|
||||
png_convert_to_rfc1123_buffer(png_ptr, buffer, png_timep) is provided to
|
||||
convert from PNG time to an RFC 1123 format string. The caller must provide
|
||||
a writeable buffer of at least 29 bytes.
|
||||
|
||||
Writing unknown chunks
|
||||
|
||||
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
|
||||
|
||||
@@ -3417,7 +3483,7 @@ png_destroy_write_struct().
|
||||
The default behavior is only to free data that was allocated internally
|
||||
by libpng. This can be changed, so that libpng will not free the data,
|
||||
or so that it will free data that was allocated by the user with png_malloc()
|
||||
or png_zalloc() and passed in via a png_set_*() function, with
|
||||
or png_calloc() and passed in via a png_set_*() function, with
|
||||
|
||||
png_data_freer(png_ptr, info_ptr, freer, mask)
|
||||
|
||||
@@ -3453,7 +3519,7 @@ When the user assumes responsibility for libpng-allocated data, the
|
||||
application must use
|
||||
png_free() to free it, and when the user transfers responsibility to libpng
|
||||
for data that the user has allocated, the user must have used png_malloc()
|
||||
or png_zalloc() to allocate it.
|
||||
or png_calloc() to allocate it.
|
||||
|
||||
If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
|
||||
separately, do not transfer responsibility for freeing text_ptr to libpng,
|
||||
@@ -3508,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
|
||||
@@ -3526,7 +3593,7 @@ are multiple warnings, only the first one is recorded.
|
||||
The upper 30 bits of this value are reserved; the low two bits contain
|
||||
a two bit code such that a value more than 1 indicates a failure in the API
|
||||
just called:
|
||||
|
||||
|
||||
0 - no warning or error
|
||||
1 - warning
|
||||
2 - error
|
||||
@@ -3534,7 +3601,7 @@ just called:
|
||||
|
||||
The pixels (samples) of the image have one to four channels whose components
|
||||
have original values in the range 0 to 1.0:
|
||||
|
||||
|
||||
1: A single gray or luminance channel (G).
|
||||
2: A gray/luminance channel and an alpha channel (GA).
|
||||
3: Three red, green, blue color channels (RGB).
|
||||
@@ -3673,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)
|
||||
@@ -3684,7 +3767,7 @@ Corresponding information about the pixels
|
||||
PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\
|
||||
The size, in bytes, of each component in a pixel; 1 for a color-mapped
|
||||
image.
|
||||
|
||||
|
||||
PNG_IMAGE_PIXEL_SIZE(fmt)
|
||||
The size, in bytes, of a complete pixel; 1 for a color-mapped image.
|
||||
|
||||
@@ -3703,7 +3786,7 @@ Information about the whole row, or whole image
|
||||
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
|
||||
This indicates the the RGB values of the in-memory bitmap do not
|
||||
correspond to the red, green and blue end-points defined by sRGB.
|
||||
|
||||
|
||||
PNG_IMAGE_FLAG_COLORMAP == 0x02
|
||||
The PNG is color-mapped. If this flag is set png_image_read_colormap
|
||||
can be used without further loss of image information. If it is not set
|
||||
@@ -3731,24 +3814,25 @@ READ APIs
|
||||
The PNG header is read from the given memory buffer.
|
||||
|
||||
int png_image_finish_read(png_imagep image,
|
||||
png_colorp background, void *buffer, png_int_32 row_stride));
|
||||
png_colorp background, void *buffer,
|
||||
png_int_32 row_stride, void *colormap));
|
||||
|
||||
Finish reading the image into the supplied buffer and
|
||||
clean up the png_image structure.
|
||||
|
||||
|
||||
row_stride is the step, in png_byte or png_uint_16 units
|
||||
as appropriate, between adjacent rows. A positive stride
|
||||
indicates that the top-most row is first in the buffer -
|
||||
the normal top-down arrangement. A negative stride
|
||||
indicates that the bottom-most row is first in the buffer.
|
||||
|
||||
|
||||
background need only be supplied if an alpha channel must
|
||||
be removed from a png_byte format and the removal is to be
|
||||
done by compositing on a solid color; otherwise it may be
|
||||
NULL and any composition will be done directly onto the
|
||||
buffer. The value is an sRGB color to use for the
|
||||
background, for grayscale output the green channel is used.
|
||||
|
||||
|
||||
For linear output removing the alpha channel is always done
|
||||
by compositing on black.
|
||||
|
||||
@@ -3768,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
|
||||
@@ -3775,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*).
|
||||
|
||||
@@ -3817,12 +3904,13 @@ in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change
|
||||
these functions, call the appropriate png_set_*_fn() function.
|
||||
|
||||
Memory allocation is done through the functions png_malloc(), png_calloc(),
|
||||
and png_free(). These currently just call the standard C functions.
|
||||
png_calloc() calls png_malloc() and then clears the newly
|
||||
allocated memory to zero. There is limited support for certain systems
|
||||
with segmented memory architectures and the types of pointers declared by
|
||||
png.h match this; you will have to use appropriate pointers in your
|
||||
application. Since it is
|
||||
and png_free(). The png_malloc() and png_free() functions currently just
|
||||
call the standard C functions and png_calloc() calls png_malloc() and then
|
||||
clears the newly allocated memory to zero; note that png_calloc(png_ptr, size)
|
||||
is not the same as the calloc(number, size) function provided by stdlib.h.
|
||||
There is limited support for certain systems with segmented memory
|
||||
architectures and the types of pointers declared by png.h match this; you
|
||||
will have to use appropriate pointers in your application. Since it is
|
||||
unlikely that the method of handling memory allocation on a platform
|
||||
will change between applications, these functions must be modified in
|
||||
the library at compile time. If you prefer to use a different method
|
||||
@@ -3932,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
|
||||
@@ -4052,7 +4152,7 @@ available to set these separately for non-IDAT
|
||||
compressed chunks such as zTXt, iTXt, and iCCP:
|
||||
|
||||
#include zlib.h
|
||||
#if PNG_LIBPNG_VER <= 10504
|
||||
#if PNG_LIBPNG_VER >= 10504
|
||||
png_set_text_compression_level(png_ptr, level);
|
||||
|
||||
png_set_text_compression_mem_level(png_ptr, level);
|
||||
@@ -4202,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
|
||||
|
||||
@@ -4500,7 +4600,9 @@ png_set_strip_error_numbers() was removed from the library by default.
|
||||
|
||||
The png_zalloc() and png_zfree() functions are no longer exported.
|
||||
The png_zalloc() function no longer zeroes out the memory that it
|
||||
allocates.
|
||||
allocates. Applications that called png_zalloc(png_ptr, number, size)
|
||||
can call png_calloc(png_ptr, number*size) instead, and can call
|
||||
png_free() instead of png_zfree().
|
||||
|
||||
Support for dithering was disabled by default in libpng-1.4.0, because
|
||||
it has not been well tested and doesn't actually "dither".
|
||||
@@ -4520,10 +4622,41 @@ XI. Changes to Libpng from version 1.4.x to 1.5.x
|
||||
From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
|
||||
function) incorrectly returned a value of type png_uint_32.
|
||||
|
||||
Checking for invalid palette index on read or write was added at libpng
|
||||
1.5.10. When an invalid index is found, libpng issues a benign error.
|
||||
This is enabled by default because this condition is an error according
|
||||
to the PNG specification, Clause 11.3.2, but the error can be ignored in
|
||||
each png_ptr with
|
||||
|
||||
png_set_check_for_invalid_index(png_ptr, allowed);
|
||||
|
||||
allowed - one of
|
||||
0: disable benign error (accept the
|
||||
invalid data without warning).
|
||||
1: enable benign error (treat the
|
||||
invalid data as an error or a
|
||||
warning).
|
||||
|
||||
If the error is ignored, or if png_benign_error() treats it as a warning,
|
||||
any invalid pixels are decoded as opaque black by the decoder and written
|
||||
as-is by the encoder.
|
||||
|
||||
Retrieving the maximum palette index found was added at libpng-1.5.15.
|
||||
This statement must appear after png_read_png() or png_read_image() while
|
||||
reading, and after png_write_png() or png_write_image() while writing.
|
||||
|
||||
int max_palette = png_get_palette_max(png_ptr, info_ptr);
|
||||
|
||||
This will return the maximum palette index found in the image, or "-1" if
|
||||
the palette was not checked, or "0" if no palette was found. Note that this
|
||||
does not account for any palette index used by ancillary chunks such as the
|
||||
bKGD chunk; you must check those separately to determine the maximum
|
||||
palette index actually used.
|
||||
|
||||
A. Changes that affect users of libpng
|
||||
|
||||
There are no substantial API changes between the non-deprecated parts of
|
||||
the 1.4.5 API and the 1.5.0 API; however the ability to directly access
|
||||
the 1.4.5 API and the 1.5.0 API; however, the ability to directly access
|
||||
members of the main libpng control structures, png_struct and png_info,
|
||||
deprecated in earlier versions of libpng, has been completely removed from
|
||||
libpng 1.5.
|
||||
@@ -4534,9 +4667,12 @@ need access to information in zlib.h will need to add the '#include "zlib.h"'
|
||||
directive. It does not matter whether this is placed prior to or after
|
||||
the '"#include png.h"' directive.
|
||||
|
||||
We moved the png_strcpy(), png_strncpy(), png_strlen(), png_memcpy(),
|
||||
png_memcmp(), png_sprintf, and png_memcpy() macros into a private
|
||||
header file (pngpriv.h) that is not accessible by applications.
|
||||
The png_sprintf(), png_strcpy(), and png_strncpy() macros are no longer used
|
||||
and were removed.
|
||||
|
||||
We moved the png_strlen(), png_memcpy(), png_memset(), and png_memcmp()
|
||||
macros into a private header file (pngpriv.h) that is not accessible to
|
||||
applications.
|
||||
|
||||
In png_get_iCCP, the type of "profile" was changed from png_charpp
|
||||
to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep.
|
||||
@@ -4639,16 +4775,30 @@ PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said
|
||||
that it could be used to override them. Now this function will reduce or
|
||||
increase the limits.
|
||||
|
||||
Starting in libpng-1.5.10, the user limits can be set en masse with the
|
||||
configuration option PNG_SAFE_LIMITS_SUPPORTED. If this option is enabled,
|
||||
a set of "safe" limits is applied in pngpriv.h. These can be overridden by
|
||||
application calls to png_set_user_limits(), png_set_user_chunk_cache_max(),
|
||||
and/or png_set_user_malloc_max() that increase or decrease the limits. Also,
|
||||
in libpng-1.5.10 the default width and height limits were increased
|
||||
from 1,000,000 to 0x7ffffff (i.e., made unlimited). Therefore, the
|
||||
limits are now
|
||||
default safe
|
||||
png_user_width_max 0x7fffffff 1,000,000
|
||||
png_user_height_max 0x7fffffff 1,000,000
|
||||
png_user_chunk_cache_max 0 (unlimited) 128
|
||||
png_user_chunk_malloc_max 0 (unlimited) 8,000,000
|
||||
|
||||
B. Changes to the build and configuration of libpng
|
||||
|
||||
Details of internal changes to the library code can be found in the CHANGES
|
||||
file and in the GIT repository logs. These will be of no concern to the vast
|
||||
majority of library users or builders, however the few who configure libpng
|
||||
majority of library users or builders; however, the few who configure libpng
|
||||
to a non-default feature set may need to change how this is done.
|
||||
|
||||
There should be no need for library builders to alter build scripts if
|
||||
these use the distributed build support - configure or the makefiles -
|
||||
however users of the makefiles may care to update their build scripts
|
||||
however, users of the makefiles may care to update their build scripts
|
||||
to build pnglibconf.h where the corresponding makefile does not do so.
|
||||
|
||||
Building libpng with a non-default configuration has changed completely.
|
||||
@@ -4754,7 +4904,7 @@ merely stops the function from being exported.
|
||||
PNG_FLOATING_ARITHMETIC_SUPPORTED chooses between the internal floating
|
||||
point implementation or the fixed point one. Typically the fixed point
|
||||
implementation is larger and slower than the floating point implementation
|
||||
on a system that supports floating point, however it may be faster on a
|
||||
on a system that supports floating point; however, it may be faster on a
|
||||
system which lacks floating point hardware and therefore uses a software
|
||||
emulation.
|
||||
|
||||
@@ -4783,7 +4933,7 @@ pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the
|
||||
build of pnglibconf.h and it is never included in an application build.
|
||||
|
||||
The rarely used alternative of adding a list of feature macros to the
|
||||
CFLAGS setting in the build also still works, however the macros will be
|
||||
CFLAGS setting in the build also still works; however, the macros will be
|
||||
copied to pnglibconf.h and this may produce macro redefinition warnings
|
||||
when the individual C files are compiled.
|
||||
|
||||
@@ -4808,29 +4958,107 @@ 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
|
||||
a string.
|
||||
The png_sizeof(), png_strlen(), png_memcpy(), png_memcmp(), and
|
||||
png_memset() macros are no longer used in the libpng sources and
|
||||
have been removed. These had already been made invisible to applications
|
||||
(i.e., defined in the private pngpriv.h header file) since libpng-1.5.0.
|
||||
|
||||
The signatures of many exported functions were changed, such that
|
||||
png_structp became png_structrp or png_const_structrp
|
||||
png_infop became png_inforp or png_const_inforp
|
||||
where "rp" indicates a "restricted pointer".
|
||||
|
||||
Error detection in some chunks has improved; in particular the iCCP chunk
|
||||
reader now does pretty complete validation of the basic format. Some bad
|
||||
profiles that were previously accepted are now rejected, in particular the
|
||||
very old broken Microsoft/HP sRGB profile. The 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
|
||||
|
||||
@@ -4848,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
|
||||
@@ -4948,11 +5176,22 @@ pngtest) appear in
|
||||
pngpriv.h
|
||||
above the comment that says
|
||||
|
||||
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
|
||||
/* Maintainer: Put new private prototypes here ^ */
|
||||
|
||||
We put a space after the "sizeof" operator and we omit the
|
||||
optional parentheses around its argument when the argument
|
||||
is an expression, not a type name, and we always enclose the
|
||||
sizeof operator, with its argument, in parentheses:
|
||||
|
||||
(sizeof (png_uint_32))
|
||||
(sizeof array)
|
||||
|
||||
Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as
|
||||
though it were a function.
|
||||
|
||||
To avoid polluting the global namespace, the names of all exported
|
||||
functions and variables begin with "png_", and all publicly visible C
|
||||
preprocessor macros begin with "PNG_". We request that applications that
|
||||
functions and variables begin with "png_", and all publicly visible C
|
||||
preprocessor macros begin with "PNG". We request that applications that
|
||||
use libpng *not* begin any of their own symbols with either of these strings.
|
||||
|
||||
We put a space after each comma and after each semicolon
|
||||
@@ -4965,12 +5204,16 @@ left parenthesis that follows it:
|
||||
for (i = 2; i > 0; --i)
|
||||
y[i] = a(x) + (int)b;
|
||||
|
||||
We prefer #ifdef and #ifndef to #if defined() and if !defined()
|
||||
when there is only one macro being tested.
|
||||
We prefer #ifdef and #ifndef to #if defined() and #if !defined()
|
||||
when there is only one macro being tested. We always use parentheses
|
||||
with "defined".
|
||||
|
||||
We prefer to express integers that are used as bit masks in hex format,
|
||||
with an even number of lower-case hex digits (e.g., 0x00, 0xff, 0x0100).
|
||||
|
||||
We prefer to use underscores in variable names rather than camelCase, except
|
||||
for a few type names that we inherit from zlib.h.
|
||||
|
||||
We do not use the TAB character for indentation in the C sources.
|
||||
|
||||
Lines do not exceed 80 characters.
|
||||
@@ -4979,25 +5222,25 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
XVI. Y2K Compliance in libpng
|
||||
|
||||
February 24, 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.0beta13 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 three year fields. One is a 2-byte unsigned integer that
|
||||
will hold years up to 65535. The other two hold the date in text
|
||||
format, and will hold years up to 9999.
|
||||
Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
that will hold years up to 65535. The other, which is deprecated,
|
||||
holds the date in text format, and will hold years up to 9999.
|
||||
|
||||
The integer is
|
||||
"png_uint_16 year" in png_time_struct.
|
||||
|
||||
The strings are
|
||||
"png_charp time_buffer" in png_struct and
|
||||
"near_time_buffer", which is a local character string in png.c.
|
||||
The string is
|
||||
"char time_buffer[29]" in png_struct. This is no longer used
|
||||
in libpng-1.6.x and will be removed from libpng-1.7.0.
|
||||
|
||||
There are seven time-related functions:
|
||||
|
||||
|
||||
16
libpngpf.3
16
libpngpf.3
@@ -1,21 +1,11 @@
|
||||
.TH LIBPNGPF 3 "February 24, 2012"
|
||||
.TH LIBPNGPF 3 "July 18, 2013"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.0beta13
|
||||
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 "February 24, 2012"
|
||||
.TH PNG 5 "July 18, 2013"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
||||
406
png.h
406
png.h
@@ -1,8 +1,8 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.0beta13 - February 24, 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.0beta13 - February 24, 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-13 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
|
||||
@@ -176,7 +187,7 @@
|
||||
* to the source version x.y.z (leading zeros in y and z). Beta versions
|
||||
* were given the previous public release number plus a letter, until
|
||||
* version 1.0.6j; from then on they were given the upcoming public
|
||||
* release number plus "betaNN" or "rcN".
|
||||
* release number plus "betaNN" or "rcNN".
|
||||
*
|
||||
* Binary incompatibility exists only when applications make direct access
|
||||
* to the info_ptr or png_ptr members through png.h, and the compiled
|
||||
@@ -198,8 +209,8 @@
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.0beta13, February 24, 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,28 +321,30 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* February 24, 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.0beta13 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
|
||||
* that will hold years up to 65535. The other holds the date in text
|
||||
* format, and will hold years up to 9999.
|
||||
* that will hold years up to 65535. The other, which is deprecated,
|
||||
* holds the date in text format, and will hold years up to 9999.
|
||||
*
|
||||
* The integer is
|
||||
* "png_uint_16 year" in png_time_struct.
|
||||
*
|
||||
* The string is
|
||||
* "png_char time_buffer" in png_struct
|
||||
* "char time_buffer[29]" in png_struct. This is no longer used
|
||||
* in libpng-1.6.x and will be removed from libpng-1.7.0.
|
||||
*
|
||||
* There are seven time-related functions:
|
||||
* png.c: png_convert_to_rfc_1123() in png.c
|
||||
* (formerly png_convert_to_rfc_1152() in error)
|
||||
* png.c: png_convert_to_rfc_1123_buffer() in png.c
|
||||
* (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
|
||||
* png_convert_to_rfc_1152() in error prior to libpng-0.98)
|
||||
* png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
|
||||
* png_convert_from_time_t() in pngwrite.c
|
||||
* png_get_tIME() in pngget.c
|
||||
@@ -342,8 +355,8 @@
|
||||
* All handle dates properly in a Y2K environment. The
|
||||
* png_convert_from_time_t() function calls gmtime() to convert from system
|
||||
* clock time, which returns (year - 1900), which we properly convert to
|
||||
* the full 4-digit year. There is a possibility that applications using
|
||||
* libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
|
||||
* the full 4-digit year. There is a possibility that libpng applications
|
||||
* are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()
|
||||
* function, or that they are incorrectly passing only a 2-digit year
|
||||
* instead of "year - 1900" into the png_convert_from_struct_tm() function,
|
||||
* but this is not under our control. The libpng documentation has always
|
||||
@@ -374,9 +387,9 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.0beta13"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.3"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.6.0beta13 - February 24, 2012\n"
|
||||
" libpng version 1.6.3 - July 18, 2013\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
@@ -384,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 13
|
||||
#define PNG_LIBPNG_VER_BUILD 0
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@@ -407,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.
|
||||
@@ -415,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.
|
||||
@@ -520,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_0beta13;
|
||||
typedef char* png_libpng_version_1_6_3;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
@@ -702,20 +715,26 @@ typedef png_time * png_timep;
|
||||
typedef const png_time * png_const_timep;
|
||||
typedef png_time * * png_timepp;
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* png_unknown_chunk is a structure to hold queued chunks for which there is
|
||||
* no specific support. The idea is that we can use this to queue
|
||||
* up private chunks for output even though the library doesn't actually
|
||||
* know about their semantics.
|
||||
*
|
||||
* The data in the structure is set by libpng on read and used on write.
|
||||
*/
|
||||
typedef struct png_unknown_chunk_t
|
||||
{
|
||||
png_byte name[5];
|
||||
png_byte *data;
|
||||
png_byte name[5]; /* Textual chunk name with '\0' terminator */
|
||||
png_byte *data; /* Data, should not be modified on read! */
|
||||
png_size_t size;
|
||||
|
||||
/* libpng-using applications should NOT directly modify this byte. */
|
||||
/* On write 'location' must be set using the flag values listed below.
|
||||
* Notice that on read it is set by libpng however the values stored have
|
||||
* more bits set than are listed below. Always treat the value as a
|
||||
* bitmask. On write set only one bit - setting multiple bits may cause the
|
||||
* chunk to be written in multiple places.
|
||||
*/
|
||||
png_byte location; /* mode of operation at read time */
|
||||
}
|
||||
png_unknown_chunk;
|
||||
@@ -725,8 +744,7 @@ typedef const png_unknown_chunk * png_const_unknown_chunkp;
|
||||
typedef png_unknown_chunk * * png_unknown_chunkpp;
|
||||
#endif
|
||||
|
||||
/* Values for the unknown chunk location byte */
|
||||
|
||||
/* Flag values for the unknown chunk location byte. */
|
||||
#define PNG_HAVE_IHDR 0x01
|
||||
#define PNG_HAVE_PLTE 0x02
|
||||
#define PNG_AFTER_IDAT 0x08
|
||||
@@ -894,7 +912,8 @@ typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,
|
||||
png_unknown_chunkp));
|
||||
#endif
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp));
|
||||
/* not used anywhere */
|
||||
/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
@@ -1032,7 +1051,7 @@ PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,
|
||||
PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,
|
||||
png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));
|
||||
# define png_jmpbuf(png_ptr) \
|
||||
(*png_set_longjmp_fn((png_ptr), longjmp, sizeof (jmp_buf)))
|
||||
(*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))
|
||||
#else
|
||||
# define png_jmpbuf(png_ptr) \
|
||||
(LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
|
||||
@@ -1047,7 +1066,7 @@ PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Reset the compression stream */
|
||||
PNG_EXPORT(10, int, png_reset_zstream, (png_structrp png_ptr));
|
||||
PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);
|
||||
#endif
|
||||
|
||||
/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
|
||||
@@ -1095,9 +1114,9 @@ PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,
|
||||
|
||||
/* Writes all the PNG information before the image. */
|
||||
PNG_EXPORT(20, void, png_write_info_before_PLTE,
|
||||
(png_structrp png_ptr, png_inforp info_ptr));
|
||||
(png_structrp png_ptr, png_const_inforp info_ptr));
|
||||
PNG_EXPORT(21, void, png_write_info,
|
||||
(png_structrp png_ptr, png_inforp info_ptr));
|
||||
(png_structrp png_ptr, png_const_inforp info_ptr));
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
/* Read the information before the actual image data. */
|
||||
@@ -1111,6 +1130,7 @@ PNG_EXPORT(22, void, png_read_info,
|
||||
* png_struct, this will be removed in future versions.
|
||||
*/
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */
|
||||
PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
|
||||
png_const_timep ptime),PNG_DEPRECATED);
|
||||
#endif
|
||||
@@ -1235,7 +1255,7 @@ PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,
|
||||
int mode, png_fixed_point output_gamma))
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
/* The output_gamma value is a screen gamma in libpng terminology: it expresses
|
||||
* how to decode the output values, not how they are encoded. The values used
|
||||
* correspond to the normal numbers used to describe the overall gamma of a
|
||||
@@ -1541,7 +1561,8 @@ PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image));
|
||||
#endif
|
||||
|
||||
/* Write a row of image data */
|
||||
PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, png_const_bytep row));
|
||||
PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr,
|
||||
png_const_bytep row));
|
||||
|
||||
/* Write a few rows of image data: (*row) is not written; however, the type
|
||||
* is declared as writeable to maintain compatibility with previous versions
|
||||
@@ -1555,7 +1576,8 @@ PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row,
|
||||
PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image));
|
||||
|
||||
/* Write the end of the PNG file. */
|
||||
PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, png_inforp info_ptr));
|
||||
PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr,
|
||||
png_inforp info_ptr));
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
/* Read the end of the PNG file. */
|
||||
@@ -1823,9 +1845,31 @@ PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp));
|
||||
PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* 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
|
||||
* png_set_ APIs.)
|
||||
*
|
||||
* There is no write support - on write, by default, all the chunks in the
|
||||
* 'unknown' list are written in the specified position.
|
||||
*
|
||||
* 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 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));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr));
|
||||
#endif
|
||||
|
||||
@@ -1838,11 +1882,12 @@ PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr,
|
||||
png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));
|
||||
|
||||
/* Returns the user pointer associated with the push read functions */
|
||||
PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structrp png_ptr));
|
||||
PNG_EXPORT(91, png_voidp, png_get_progressive_ptr,
|
||||
(png_const_structrp png_ptr));
|
||||
|
||||
/* Function to be called when data becomes available */
|
||||
PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep buffer, png_size_t buffer_size));
|
||||
PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size));
|
||||
|
||||
/* A function which may be called *only* within png_process_data to stop the
|
||||
* processing of any more data. The function returns the number of bytes
|
||||
@@ -1892,9 +1937,12 @@ PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
|
||||
/* Reassign responsibility for freeing existing data, whether allocated
|
||||
* by libpng or by the application; this works on the png_info structure passed
|
||||
* in, it does not change the state for other png_info structures.
|
||||
*
|
||||
* It is unlikely that this function works correctly as of 1.6.0 and using it
|
||||
* may result either in memory leaks or double free of allocated data.
|
||||
*/
|
||||
PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int freer, png_uint_32 mask));
|
||||
PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED);
|
||||
|
||||
/* Assignments for png_data_freer */
|
||||
#define PNG_DESTROY_WILL_FREE_DATA 1
|
||||
@@ -1907,8 +1955,10 @@ PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
|
||||
#define PNG_FREE_ROWS 0x0040
|
||||
#define PNG_FREE_PCAL 0x0080
|
||||
#define PNG_FREE_SCAL 0x0100
|
||||
#define PNG_FREE_UNKN 0x0200
|
||||
#define PNG_FREE_LIST 0x0400
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# define PNG_FREE_UNKN 0x0200
|
||||
#endif
|
||||
/* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */
|
||||
#define PNG_FREE_PLTE 0x1000
|
||||
#define PNG_FREE_TRNS 0x2000
|
||||
#define PNG_FREE_TEXT 0x4000
|
||||
@@ -1952,9 +2002,11 @@ PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,
|
||||
PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
|
||||
/* Same, chunk name is prepended to message. */
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Same, chunk name is prepended to message (only during read) */
|
||||
PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#endif
|
||||
|
||||
PNG_EXPORT(109, void, png_set_benign_errors,
|
||||
(png_structrp png_ptr, int allowed));
|
||||
@@ -2061,9 +2113,11 @@ PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Returns pointer to signature string read from PNG header */
|
||||
PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr,
|
||||
@@ -2084,14 +2138,12 @@ PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z,
|
||||
double *green_X, double *green_Y, double *green_Z, double *blue_X,
|
||||
double *blue_Y, double *blue_Z))
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */
|
||||
PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
|
||||
(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_white_x, png_fixed_point *int_white_y,
|
||||
png_fixed_point *int_red_x, png_fixed_point *int_red_y,
|
||||
png_fixed_point *int_green_x, png_fixed_point *int_green_y,
|
||||
png_fixed_point *int_blue_x, png_fixed_point *int_blue_y))
|
||||
#endif
|
||||
PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,
|
||||
(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
||||
@@ -2141,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
|
||||
@@ -2173,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
|
||||
@@ -2196,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));
|
||||
@@ -2225,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
|
||||
|
||||
@@ -2236,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
|
||||
@@ -2247,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,
|
||||
@@ -2288,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
|
||||
@@ -2313,35 +2365,134 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
|
||||
png_const_charp swidth, png_const_charp sheight));
|
||||
#endif /* PNG_sCAL_SUPPORTED */
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
/* Provide a list of chunks and how they are to be handled, if the built-in
|
||||
handling or default unknown chunk handling is not desired. Any chunks not
|
||||
listed will be handled in the default manner. The IHDR and IEND chunks
|
||||
must not be listed. Because this turns off the default handling for chunks
|
||||
that would otherwise be recognized the behavior of libpng transformations may
|
||||
well become incorrect!
|
||||
keep = 0: PNG_HANDLE_CHUNK_AS_DEFAULT: follow default behavior
|
||||
= 1: PNG_HANDLE_CHUNK_NEVER: do not keep
|
||||
= 2: PNG_HANDLE_CHUNK_IF_SAFE: keep only if safe-to-copy
|
||||
= 3: PNG_HANDLE_CHUNK_ALWAYS: keep even if unsafe-to-copy
|
||||
*/
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Provide the default handling for all unknown chunks or, optionally, for
|
||||
* specific unknown chunks.
|
||||
*
|
||||
* NOTE: prior to 1.6.0 the handling specified for particular chunks on read was
|
||||
* ignored and the default was used, the per-chunk setting only had an effect on
|
||||
* write. If you wish to have chunk-specific handling on read in code that must
|
||||
* work on earlier versions you must use a user chunk callback to specify the
|
||||
* desired handling (keep or discard.)
|
||||
*
|
||||
* The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The
|
||||
* parameter is interpreted as follows:
|
||||
*
|
||||
* READ:
|
||||
* PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
* Known chunks: do normal libpng processing, do not keep the chunk (but
|
||||
* 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:
|
||||
* Discard the chunk data.
|
||||
* PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
* Keep the chunk data if the chunk is not critical else raise a chunk
|
||||
* error.
|
||||
* PNG_HANDLE_CHUNK_ALWAYS:
|
||||
* Keep the chunk data.
|
||||
*
|
||||
* If the chunk data is saved it can be retrieved using png_get_unknown_chunks,
|
||||
* below. Notice that specifying "AS_DEFAULT" as a global default is equivalent
|
||||
* 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
|
||||
* png_set_keep_unknown_chunks will have no effect. If it is set then known
|
||||
* chunks listed with a keep other than AS_DEFAULT will *never* be processed
|
||||
* by libpng, in addition critical chunks must either be processed by the
|
||||
* callback or saved.
|
||||
*
|
||||
* The IHDR and IEND chunks must not be listed. Because this turns off the
|
||||
* default handling for chunks that would otherwise be recognized the
|
||||
* behavior of libpng transformations may well become incorrect!
|
||||
*
|
||||
* WRITE:
|
||||
* When writing chunks the options only apply to the chunks specified by
|
||||
* png_set_unknown_chunks (below), libpng will *always* write known chunks
|
||||
* required by png_set_ calls and will always write the core critical chunks
|
||||
* (as required for PLTE).
|
||||
*
|
||||
* Each chunk in the png_set_unknown_chunks list is looked up in the
|
||||
* png_set_keep_unknown_chunks list to find the keep setting, this is then
|
||||
* interpreted as follows:
|
||||
*
|
||||
* PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
* Write safe-to-copy chunks and write other chunks if the global
|
||||
* default is set to _ALWAYS, otherwise don't write this chunk.
|
||||
* PNG_HANDLE_CHUNK_NEVER:
|
||||
* Do not write the chunk.
|
||||
* PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
* Write the chunk if it is safe-to-copy, otherwise do not write it.
|
||||
* PNG_HANDLE_CHUNK_ALWAYS:
|
||||
* Write the chunk.
|
||||
*
|
||||
* Note that the default behavior is effectively the opposite of the read case -
|
||||
* in read unknown chunks are not stored by default, in write they are written
|
||||
* by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different
|
||||
* - on write the safe-to-copy bit is checked, on read the critical bit is
|
||||
* checked and on read if the chunk is critical an error will be raised.
|
||||
*
|
||||
* num_chunks:
|
||||
* ===========
|
||||
* If num_chunks is positive, then the "keep" parameter specifies the manner
|
||||
* for handling only those chunks appearing in the chunk_list array,
|
||||
* otherwise the chunk list array is ignored.
|
||||
*
|
||||
* If num_chunks is 0 the "keep" parameter specifies the default behavior for
|
||||
* unknown chunks, as described above.
|
||||
*
|
||||
* If num_chunks is negative, then the "keep" parameter specifies the manner
|
||||
* for handling all unknown chunks plus all chunks recognized by libpng
|
||||
* except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
|
||||
* be processed by libpng.
|
||||
*/
|
||||
PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
|
||||
int keep, png_const_bytep chunk_list, int num_chunks));
|
||||
|
||||
/* The handling code is returned; the result is therefore true (non-zero) if
|
||||
* special handling is required, false for the default handling.
|
||||
/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
|
||||
* the result is therefore true (non-zero) if special handling is required,
|
||||
* false for the default handling.
|
||||
*/
|
||||
PNG_EXPORT(173, int, png_handle_as_unknown, (png_structrp png_ptr,
|
||||
PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
|
||||
png_const_bytep chunk_name));
|
||||
#endif
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_unknown_chunkp unknowns,
|
||||
int num_unknowns));
|
||||
/* NOTE: prior to 1.6.0 this routine set the 'location' field of the added
|
||||
* unknowns to the location currently stored in the png_struct. This is
|
||||
* invariably the wrong value on write. To fix this call the following API
|
||||
* for each chunk in the list with the correct location. If you know your
|
||||
* code won't be compiled on earlier versions you can rely on
|
||||
* png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing
|
||||
* the correct thing.
|
||||
*/
|
||||
|
||||
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.
|
||||
@@ -2350,7 +2501,7 @@ PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,
|
||||
*/
|
||||
PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int mask));
|
||||
|
||||
|
||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||
/* The "params" pointer is currently not used and is for future expansion. */
|
||||
PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,
|
||||
@@ -2378,6 +2529,7 @@ PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,
|
||||
#define PNG_HANDLE_CHUNK_NEVER 1
|
||||
#define PNG_HANDLE_CHUNK_IF_SAFE 2
|
||||
#define PNG_HANDLE_CHUNK_ALWAYS 3
|
||||
#define PNG_HANDLE_CHUNK_LAST 4
|
||||
|
||||
/* Strip the prepended error numbers ("#nnn ") from error and warning
|
||||
* messages before passing them to the error or warning handler.
|
||||
@@ -2503,10 +2655,10 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
|
||||
* necessary to find the row in the output image given a row in an interlaced
|
||||
* image, so two more macros:
|
||||
*/
|
||||
#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \
|
||||
(((yIn)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
|
||||
#define PNG_COL_FROM_PASS_COL(xIn, pass) \
|
||||
(((xIn)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
|
||||
#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \
|
||||
(((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
|
||||
#define PNG_COL_FROM_PASS_COL(x_in, pass) \
|
||||
(((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
|
||||
|
||||
/* Two macros which return a boolean (0 or 1) saying whether the given row
|
||||
* or column is in a particular pass. These use a common utility macro that
|
||||
@@ -2646,7 +2798,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
||||
* formats do not accomodate your needs then you can, and should, use the more
|
||||
* sophisticated APIs above - these support a wide variety of in-memory formats
|
||||
* and a wide variety of sophisticated transformations to those formats as well
|
||||
* as a wide variety of APIs to manipulate ancilliary information.
|
||||
* as a wide variety of APIs to manipulate ancillary information.
|
||||
*
|
||||
* To read a PNG file using the simplified API:
|
||||
*
|
||||
@@ -2929,7 +3081,7 @@ typedef struct
|
||||
(PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
|
||||
/* Return the size, in bytes, of the color-map of this image. If the image
|
||||
* format is not a color-map format this will return a size sufficient for
|
||||
* 256 entries in the given format; check PNG_IMAGE_FORMAT_FLAG_COLORMAP if
|
||||
* 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if
|
||||
* you don't want to allocate a color-map in this case.
|
||||
*/
|
||||
|
||||
@@ -2943,6 +3095,35 @@ typedef struct
|
||||
* correspond to the red, green and blue end-points defined by sRGB.
|
||||
*/
|
||||
|
||||
#define PNG_IMAGE_FLAG_FAST 0x02
|
||||
/* On write emphasise speed over compression; the resultant PNG file will be
|
||||
* larger but will be produced significantly faster, particular for large
|
||||
* images. Do not use this option for images which will be distributed, only
|
||||
* used it when producing intermediate files that will be read back in
|
||||
* repeatedly. For a typical 24-bit image the option will double the read
|
||||
* speed at the cost of increasing the image size by 25%, however for many
|
||||
* more compressible images the PNG file can be 10 times larger with only a
|
||||
* 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
|
||||
* ---------
|
||||
@@ -2993,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.
|
||||
@@ -3008,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
|
||||
@@ -3050,13 +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
|
||||
******************************************************************************/
|
||||
|
||||
#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
|
||||
@@ -3064,7 +3298,7 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
||||
* scripts/symbols.def as well.
|
||||
*/
|
||||
#ifdef PNG_EXPORT_LAST_ORDINAL
|
||||
PNG_EXPORT_LAST_ORDINAL(241);
|
||||
PNG_EXPORT_LAST_ORDINAL(244);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
85
pngconf.h
85
pngconf.h
@@ -1,9 +1,9 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.0beta13 - February 24, 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.)
|
||||
*
|
||||
@@ -87,8 +87,8 @@
|
||||
|
||||
/* This controls optimization of the reading of 16 and 32 bit values
|
||||
* from PNG files. It can be set on a per-app-file basis - it
|
||||
* just changes whether a macro is used to the function is called.
|
||||
* The library builder sets the default, if read functions are not
|
||||
* just changes whether a macro is used when the function is called.
|
||||
* The library builder sets the default; if read functions are not
|
||||
* built into the library the macro implementation is forced on.
|
||||
*/
|
||||
#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
@@ -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 */
|
||||
@@ -366,24 +368,28 @@
|
||||
# ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((warning("This function is not exported by libpng.")))
|
||||
# else
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# if __GNUC__ >= 3
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# endif
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((warning("This function is not exported by libpng.")))
|
||||
# else
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# endif
|
||||
# endif
|
||||
# if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif /* __GNUC__ == 3.0 */
|
||||
# endif /* __GNUC__ >= 3 */
|
||||
|
||||
# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# ifndef PNG_USE_RESULT
|
||||
@@ -431,6 +437,9 @@
|
||||
#ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE /* This is a private libpng function */
|
||||
#endif
|
||||
#ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT /* The C99 "restrict" feature */
|
||||
#endif
|
||||
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||
@@ -485,9 +494,9 @@
|
||||
# error "libpng requires an unsigned 16 bit type"
|
||||
#endif
|
||||
|
||||
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||
typedef int png_int_32;
|
||||
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||
typedef long int png_int_32;
|
||||
#else
|
||||
# error "libpng requires a signed 32 bit (or more) type"
|
||||
@@ -533,7 +542,7 @@ typedef ptrdiff_t png_ptrdiff_t;
|
||||
* png_uint_32) should be explicitly applied; however, we do not expect to
|
||||
* encounter practical situations that require such conversions.
|
||||
*
|
||||
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||
* 4294967295 - i.e. less than the maximum value of png_uint_32.
|
||||
*/
|
||||
#ifdef PNG_SMALL_SIZE_T
|
||||
@@ -542,12 +551,6 @@ typedef ptrdiff_t png_ptrdiff_t;
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
#endif
|
||||
|
||||
/* This macro makes the sizeof operator look and behave like a function, except
|
||||
* that it can take a type without the enclosing () as an argument so long as
|
||||
* the type contains no "," characters.
|
||||
*/
|
||||
#define png_sizeof(x) (sizeof (x))
|
||||
|
||||
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
|
||||
* implementations of Intel CPU specific support of user-mode segmented address
|
||||
* spaces, where 16-bit pointers address more than 65536 bytes of memory using
|
||||
|
||||
113
pngerror.c
113
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.)
|
||||
*
|
||||
@@ -80,7 +80,8 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
}
|
||||
#endif
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), error_message);
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
|
||||
error_message);
|
||||
|
||||
/* If the custom handler doesn't exist, or if it returns,
|
||||
use the default handler, which will not return. */
|
||||
@@ -162,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02u:
|
||||
/* Expects at least 2 digits. */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_u:
|
||||
*--end = digits[number % 10];
|
||||
@@ -172,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02x:
|
||||
/* This format expects at least two digits */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_x:
|
||||
*--end = digits[number & 0xf];
|
||||
@@ -360,12 +361,47 @@ png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||
void PNGAPI
|
||||
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
png_ptr->chunk_name != 0)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
else
|
||||
# endif
|
||||
png_warning(png_ptr, error_message);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
png_ptr->chunk_name != 0)
|
||||
png_chunk_error(png_ptr, error_message);
|
||||
else
|
||||
# endif
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
#endif
|
||||
|
||||
void /* PRIVATE */
|
||||
png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
#endif /* BENIGN_ERRORS */
|
||||
|
||||
/* These utilities are used internally to build an error message that relates
|
||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||
@@ -379,7 +415,7 @@ static PNG_CONST char png_digit[16] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
#define PNG_MAX_ERROR_TEXT 64
|
||||
#define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
@@ -462,7 +498,8 @@ png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
@@ -473,6 +510,41 @@ png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp error_message
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
{
|
||||
/* This is always supported, but for just read or just write it
|
||||
* unconditionally does the right thing.
|
||||
*/
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
{
|
||||
if (error < PNG_CHUNK_ERROR)
|
||||
png_chunk_warning(png_ptr, message);
|
||||
|
||||
else
|
||||
png_chunk_benign_error(png_ptr, message);
|
||||
}
|
||||
# endif
|
||||
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
else if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
{
|
||||
if (error < PNG_CHUNK_WRITE_ERROR)
|
||||
png_app_warning(png_ptr, message);
|
||||
|
||||
else
|
||||
png_app_error(png_ptr, message);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
PNG_FUNCTION(void,
|
||||
@@ -482,7 +554,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||
int iin;
|
||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
png_memcpy(msg, fixed_message, fixed_message_ln);
|
||||
memcpy(msg, fixed_message, fixed_message_ln);
|
||||
iin = 0;
|
||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
@@ -520,7 +592,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
{
|
||||
png_ptr->jmp_buf_size = 0; /* not allocated */
|
||||
|
||||
if (jmp_buf_size <= sizeof png_ptr->jmp_buf_local)
|
||||
if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))
|
||||
png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
|
||||
|
||||
else
|
||||
@@ -541,7 +613,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
size = sizeof png_ptr->jmp_buf_local;
|
||||
size = (sizeof png_ptr->jmp_buf_local);
|
||||
if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
|
||||
{
|
||||
/* This is an internal error in libpng: somehow we have been left
|
||||
@@ -772,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:
|
||||
@@ -790,7 +862,7 @@ png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
*/
|
||||
if (image != NULL)
|
||||
{
|
||||
png_safecat(image->message, sizeof image->message, 0, error_message);
|
||||
png_safecat(image->message, (sizeof image->message), 0, error_message);
|
||||
image->warning_or_error |= PNG_IMAGE_ERROR;
|
||||
|
||||
/* Retrieve the jmp_buf from within the png_control, making this work for
|
||||
@@ -802,9 +874,10 @@ png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
|
||||
/* Missing longjmp buffer, the following is to help debugging: */
|
||||
{
|
||||
size_t pos = png_safecat(image->message, sizeof image->message, 0,
|
||||
size_t pos = png_safecat(image->message, (sizeof image->message), 0,
|
||||
"bad longjmp: ");
|
||||
png_safecat(image->message, sizeof image->message, pos, error_message);
|
||||
png_safecat(image->message, (sizeof image->message), pos,
|
||||
error_message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -822,16 +895,16 @@ png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
/* A warning is only logged if there is no prior warning or error. */
|
||||
if (image->warning_or_error == 0)
|
||||
{
|
||||
png_safecat(image->message, sizeof image->message, 0, warning_message);
|
||||
png_safecat(image->message, (sizeof image->message), 0, warning_message);
|
||||
image->warning_or_error |= PNG_IMAGE_WARNING;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int /* PRIVATE */
|
||||
png_safe_execute(png_imagep imageIn, int (*function)(png_voidp), png_voidp arg)
|
||||
png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||
{
|
||||
volatile png_imagep image = imageIn;
|
||||
volatile png_imagep image = image_in;
|
||||
volatile int result;
|
||||
volatile png_voidp saved_error_buf;
|
||||
jmp_buf safe_jmpbuf;
|
||||
|
||||
309
pngget.c
309
pngget.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.1 [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.)
|
||||
*
|
||||
@@ -112,7 +112,8 @@ png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@@ -129,7 +130,8 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@@ -164,7 +166,8 @@ png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float PNGAPI
|
||||
png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
|
||||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
@@ -175,6 +178,9 @@ png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp info_ptr
|
||||
return ((float)((float)info_ptr->y_pixels_per_unit
|
||||
/(float)info_ptr->x_pixels_per_unit));
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return ((float)0.0);
|
||||
@@ -203,6 +209,9 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
|
||||
(png_int_32)info_ptr->x_pixels_per_unit))
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -422,6 +431,7 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
@@ -431,6 +441,7 @@ png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
png_const_bytep PNGAPI
|
||||
png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
@@ -439,6 +450,7 @@ png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
@@ -463,87 +475,47 @@ png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
* same time to correct the rgb grayscale coefficient defaults obtained from the
|
||||
* cHRM chunk in 1.5.4
|
||||
*/
|
||||
png_uint_32 PNGFAPI
|
||||
png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
||||
png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
|
||||
png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
|
||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
{
|
||||
png_xy xy;
|
||||
png_XYZ XYZ;
|
||||
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
xy.whitex = info_ptr->x_white;
|
||||
xy.whitey = info_ptr->y_white;
|
||||
xy.redx = info_ptr->x_red;
|
||||
xy.redy = info_ptr->y_red;
|
||||
xy.greenx = info_ptr->x_green;
|
||||
xy.greeny = info_ptr->y_green;
|
||||
xy.bluex = info_ptr->x_blue;
|
||||
xy.bluey = info_ptr->y_blue;
|
||||
|
||||
/* The *_checked function handles error reporting, so just return 0 if
|
||||
* there is a failure here.
|
||||
*/
|
||||
if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
|
||||
{
|
||||
if (int_red_X != NULL)
|
||||
*int_red_X = XYZ.redX;
|
||||
if (int_red_Y != NULL)
|
||||
*int_red_Y = XYZ.redY;
|
||||
if (int_red_Z != NULL)
|
||||
*int_red_Z = XYZ.redZ;
|
||||
if (int_green_X != NULL)
|
||||
*int_green_X = XYZ.greenX;
|
||||
if (int_green_Y != NULL)
|
||||
*int_green_Y = XYZ.greenY;
|
||||
if (int_green_Z != NULL)
|
||||
*int_green_Z = XYZ.greenZ;
|
||||
if (int_blue_X != NULL)
|
||||
*int_blue_X = XYZ.blueX;
|
||||
if (int_blue_Y != NULL)
|
||||
*int_blue_Y = XYZ.blueY;
|
||||
if (int_blue_Z != NULL)
|
||||
*int_blue_Z = XYZ.blueZ;
|
||||
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
/* Quiet API change: this code used to only return the end points if a cHRM
|
||||
* chunk was present, but the end points can also come from iCCP or sRGB
|
||||
* chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
|
||||
* the png_set_ APIs merely check that set end points are mutually
|
||||
* consistent.
|
||||
*/
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
if (white_x != NULL)
|
||||
*white_x = png_float(png_ptr, info_ptr->x_white, "cHRM white X");
|
||||
*white_x = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
|
||||
if (white_y != NULL)
|
||||
*white_y = png_float(png_ptr, info_ptr->y_white, "cHRM white Y");
|
||||
*white_y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
|
||||
if (red_x != NULL)
|
||||
*red_x = png_float(png_ptr, info_ptr->x_red, "cHRM red X");
|
||||
*red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
|
||||
"cHRM red X");
|
||||
if (red_y != NULL)
|
||||
*red_y = png_float(png_ptr, info_ptr->y_red, "cHRM red Y");
|
||||
*red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
|
||||
"cHRM red Y");
|
||||
if (green_x != NULL)
|
||||
*green_x = png_float(png_ptr, info_ptr->x_green, "cHRM green X");
|
||||
*green_x = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
|
||||
if (green_y != NULL)
|
||||
*green_y = png_float(png_ptr, info_ptr->y_green, "cHRM green Y");
|
||||
*green_y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
|
||||
if (blue_x != NULL)
|
||||
*blue_x = png_float(png_ptr, info_ptr->x_blue, "cHRM blue X");
|
||||
*blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
|
||||
"cHRM blue X");
|
||||
if (blue_y != NULL)
|
||||
*blue_y = png_float(png_ptr, info_ptr->y_blue, "cHRM blue Y");
|
||||
*blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
|
||||
"cHRM blue Y");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@@ -556,30 +528,38 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
||||
double *blue_Z)
|
||||
{
|
||||
png_XYZ XYZ;
|
||||
|
||||
if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,
|
||||
&XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,
|
||||
&XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
|
||||
|
||||
if (red_X != NULL)
|
||||
*red_X = png_float(png_ptr, XYZ.redX, "cHRM red X");
|
||||
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
|
||||
"cHRM red X");
|
||||
if (red_Y != NULL)
|
||||
*red_Y = png_float(png_ptr, XYZ.redY, "cHRM red Y");
|
||||
*red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
|
||||
"cHRM red Y");
|
||||
if (red_Z != NULL)
|
||||
*red_Z = png_float(png_ptr, XYZ.redZ, "cHRM red Z");
|
||||
*red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
|
||||
"cHRM red Z");
|
||||
if (green_X != NULL)
|
||||
*green_X = png_float(png_ptr, XYZ.greenX, "cHRM green X");
|
||||
*green_X = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
|
||||
if (green_Y != NULL)
|
||||
*green_Y = png_float(png_ptr, XYZ.greenY, "cHRM green Y");
|
||||
*green_Y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
|
||||
if (green_Z != NULL)
|
||||
*green_Z = png_float(png_ptr, XYZ.greenZ, "cHRM green Z");
|
||||
*green_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
|
||||
if (blue_X != NULL)
|
||||
*blue_X = png_float(png_ptr, XYZ.blueX, "cHRM blue X");
|
||||
*blue_X = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
|
||||
if (blue_Y != NULL)
|
||||
*blue_Y = png_float(png_ptr, XYZ.blueY, "cHRM blue Y");
|
||||
*blue_Y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
|
||||
if (blue_Z != NULL)
|
||||
*blue_Z = png_float(png_ptr, XYZ.blueZ, "cHRM blue Z");
|
||||
*blue_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@@ -588,6 +568,43 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
||||
png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
|
||||
png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
|
||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
if (int_red_X != NULL)
|
||||
*int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
|
||||
if (int_red_Y != NULL)
|
||||
*int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
|
||||
if (int_red_Z != NULL)
|
||||
*int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
|
||||
if (int_green_X != NULL)
|
||||
*int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
|
||||
if (int_green_Y != NULL)
|
||||
*int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
|
||||
if (int_green_Z != NULL)
|
||||
*int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
|
||||
if (int_blue_X != NULL)
|
||||
*int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
|
||||
if (int_blue_Y != NULL)
|
||||
*int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
|
||||
if (int_blue_Z != NULL)
|
||||
*int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
|
||||
@@ -596,24 +613,25 @@ png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
if (white_x != NULL)
|
||||
*white_x = info_ptr->x_white;
|
||||
*white_x = info_ptr->colorspace.end_points_xy.whitex;
|
||||
if (white_y != NULL)
|
||||
*white_y = info_ptr->y_white;
|
||||
*white_y = info_ptr->colorspace.end_points_xy.whitey;
|
||||
if (red_x != NULL)
|
||||
*red_x = info_ptr->x_red;
|
||||
*red_x = info_ptr->colorspace.end_points_xy.redx;
|
||||
if (red_y != NULL)
|
||||
*red_y = info_ptr->y_red;
|
||||
*red_y = info_ptr->colorspace.end_points_xy.redy;
|
||||
if (green_x != NULL)
|
||||
*green_x = info_ptr->x_green;
|
||||
*green_x = info_ptr->colorspace.end_points_xy.greenx;
|
||||
if (green_y != NULL)
|
||||
*green_y = info_ptr->y_green;
|
||||
*green_y = info_ptr->colorspace.end_points_xy.greeny;
|
||||
if (blue_x != NULL)
|
||||
*blue_x = info_ptr->x_blue;
|
||||
*blue_x = info_ptr->colorspace.end_points_xy.bluex;
|
||||
if (blue_y != NULL)
|
||||
*blue_y = info_ptr->y_blue;
|
||||
*blue_y = info_ptr->colorspace.end_points_xy.bluey;
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@@ -623,35 +641,43 @@ png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
png_uint_32 PNGFAPI
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *file_gamma)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "gAMA");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||
&& file_gamma != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = info_ptr->gamma;
|
||||
*file_gamma = info_ptr->colorspace.gamma;
|
||||
return (PNG_INFO_gAMA);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *file_gamma)
|
||||
{
|
||||
png_fixed_point igamma;
|
||||
png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);
|
||||
png_debug1(1, "in %s retrieval function", "gAMA(float)");
|
||||
|
||||
if (ok)
|
||||
*file_gamma = png_float(png_ptr, igamma, "png_get_gAMA");
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
|
||||
"png_get_gAMA");
|
||||
return (PNG_INFO_gAMA);
|
||||
}
|
||||
|
||||
return ok;
|
||||
return (0);
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -665,7 +691,7 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||
&& file_srgb_intent != NULL)
|
||||
{
|
||||
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
||||
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
|
||||
return (PNG_INFO_sRGB);
|
||||
}
|
||||
|
||||
@@ -675,7 +701,7 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_charpp name, int *compression_type,
|
||||
png_bytepp profile, png_uint_32 *proflen)
|
||||
{
|
||||
@@ -687,11 +713,11 @@ png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
*name = info_ptr->iccp_name;
|
||||
*profile = info_ptr->iccp_profile;
|
||||
/* Compression_type is a dummy so the API won't have to change
|
||||
* if we introduce multiple compression types later.
|
||||
*proflen = png_get_uint_32(info_ptr->iccp_profile);
|
||||
/* This is somewhat irrelevant since the profile data returned has
|
||||
* actually been uncompressed.
|
||||
*/
|
||||
*proflen = info_ptr->iccp_proflen;
|
||||
*compression_type = info_ptr->iccp_compression;
|
||||
*compression_type = PNG_COMPRESSION_TYPE_BASE;
|
||||
return (PNG_INFO_iCCP);
|
||||
}
|
||||
|
||||
@@ -700,14 +726,14 @@ png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sPLT(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int PNGAPI
|
||||
png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_sPLT_tpp spalettes)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||
{
|
||||
*spalettes = info_ptr->splt_palettes;
|
||||
return ((png_uint_32)info_ptr->splt_palettes_num);
|
||||
return info_ptr->splt_palettes_num;
|
||||
}
|
||||
|
||||
return (0);
|
||||
@@ -716,7 +742,7 @@ png_get_sPLT(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_hIST(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_uint_16p *hist)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "hIST");
|
||||
@@ -792,7 +818,7 @@ png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||
png_charp *units, png_charpp *params)
|
||||
{
|
||||
@@ -818,8 +844,8 @@ png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
# if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||
(defined PNG_FLOATING_POINT_SUPPORTED)
|
||||
# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_fixed_point *width, png_fixed_point *height)
|
||||
@@ -912,7 +938,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
#endif /* pHYs */
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_PLTE(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_colorp *palette, int *num_palette)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "PLTE");
|
||||
@@ -948,8 +974,8 @@ png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int PNGAPI
|
||||
png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_textp *text_ptr, int *num_text)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
||||
@@ -963,7 +989,7 @@ png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
if (num_text != NULL)
|
||||
*num_text = info_ptr->num_text;
|
||||
|
||||
return ((png_uint_32)info_ptr->num_text);
|
||||
return info_ptr->num_text;
|
||||
}
|
||||
|
||||
if (num_text != NULL)
|
||||
@@ -1036,9 +1062,9 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int PNGAPI
|
||||
png_get_unknown_chunks(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_unknown_chunkpp unknowns)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
||||
@@ -1070,7 +1096,24 @@ png_get_user_chunk_ptr(png_const_structrp png_ptr)
|
||||
png_size_t PNGAPI
|
||||
png_get_compression_buffer_size(png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->zbuf_size : 0);
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
# endif
|
||||
{
|
||||
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
return png_ptr->IDAT_read_size;
|
||||
# else
|
||||
return PNG_IDAT_READ_SIZE;
|
||||
# endif
|
||||
}
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
else
|
||||
return png_ptr->zbuffer_size;
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
@@ -1116,15 +1159,19 @@ png_get_io_chunk_type (png_const_structrp png_ptr)
|
||||
{
|
||||
return png_ptr->chunk_name;
|
||||
}
|
||||
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
png_const_bytep PNGAPI
|
||||
png_get_io_chunk_name (png_structrp png_ptr)
|
||||
{
|
||||
PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);
|
||||
return png_ptr->io_chunk_string;
|
||||
}
|
||||
#endif
|
||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
int PNGAPI
|
||||
png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return png_ptr->num_palette_max;
|
||||
|
||||
return (-1);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
||||
73
pnginfo.h
73
pnginfo.h
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pnginfo.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
struct png_info_def
|
||||
{
|
||||
/* the following are necessary for every PNG file */
|
||||
/* The following are necessary for every PNG file */
|
||||
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
||||
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
||||
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
||||
@@ -70,11 +70,17 @@ struct png_info_def
|
||||
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
||||
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
|
||||
/* The following is informational only on read, and not used on writes. */
|
||||
/* The following are set by png_set_IHDR, called from the application on
|
||||
* write, but the are never actually used by the write code.
|
||||
*/
|
||||
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte spare_byte; /* to align the data, and for future use */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* This is never set during write */
|
||||
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
||||
#endif
|
||||
|
||||
/* The rest of the data is optional. If you are reading, check the
|
||||
* valid field to see if the information in these are valid. If you
|
||||
@@ -82,18 +88,25 @@ struct png_info_def
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
/* The gAMA chunk describes the gamma characteristics of the system
|
||||
* on which the image was created, normally in the range [1.0, 2.5].
|
||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||
* defined. When COLORSPACE is switched on all the colorspace-defining
|
||||
* chunks should be enabled, when GAMMA is switched on all the gamma-defining
|
||||
* chunks should be enabled. If this is not done it becomes possible to read
|
||||
* inconsistent PNG files and assign a probably incorrect interpretation to
|
||||
* the information. (In other words, by carefully choosing which chunks to
|
||||
* recognize the system configuration can select an interpretation for PNG
|
||||
* files containing ambiguous data and this will result in inconsistent
|
||||
* behavior between different libpng builds!)
|
||||
*/
|
||||
png_fixed_point gamma;
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
/* GR-P, 0.96a */
|
||||
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
|
||||
png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
@@ -183,23 +196,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_uint_16p hist;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* The cHRM chunk describes the CIE color characteristics of the monitor
|
||||
* on which the PNG was created. This data allows the viewer to do gamut
|
||||
* mapping of the input image to ensure that the viewer sees the same
|
||||
* colors in the image as the creator. Values are in the range
|
||||
* [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
|
||||
*/
|
||||
png_fixed_point x_white;
|
||||
png_fixed_point y_white;
|
||||
png_fixed_point x_red;
|
||||
png_fixed_point y_red;
|
||||
png_fixed_point x_green;
|
||||
png_fixed_point y_green;
|
||||
png_fixed_point x_blue;
|
||||
png_fixed_point y_blue;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
/* The pCAL chunk describes a transformation between the stored pixel
|
||||
* values and original physical data values used to create the image.
|
||||
@@ -224,25 +220,20 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* New members added in libpng-1.0.6 */
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||
png_byte iccp_compression; /* Always zero */
|
||||
/* The type of this field is limited by the type of
|
||||
* png_struct::user_chunk_cache_max, else overflow can occur.
|
||||
*/
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
/* Data on sPLT chunks (there may be more than one). */
|
||||
png_sPLT_tp splt_palettes;
|
||||
png_uint_32 splt_palettes_num;
|
||||
int splt_palettes_num; /* Match type returned by png_get API */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
|
||||
72
pngmem.c
72
pngmem.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -30,7 +30,7 @@ png_destroy_png_struct(png_structrp png_ptr)
|
||||
* png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||
*/
|
||||
png_struct dummy_struct = *png_ptr;
|
||||
memset(png_ptr, 0, sizeof *png_ptr);
|
||||
memset(png_ptr, 0, (sizeof *png_ptr));
|
||||
png_free(&dummy_struct, png_ptr);
|
||||
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
@@ -54,7 +54,7 @@ png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
ret = png_malloc(png_ptr, size);
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret, 0, size);
|
||||
memset(ret, 0, size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
if (size > 0 && size <= ~(size_t)0
|
||||
if (size > 0 && size <= PNG_SIZE_MAX
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
&& size <= 65536U
|
||||
# endif
|
||||
@@ -95,6 +95,68 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
|
||||
* that arises because of the checks in png_realloc_array that are repeated in
|
||||
* png_malloc_array.
|
||||
*/
|
||||
static png_voidp
|
||||
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size)
|
||||
{
|
||||
png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||
|
||||
if (req <= PNG_SIZE_MAX/element_size)
|
||||
return png_malloc_base(png_ptr, req * element_size);
|
||||
|
||||
/* The failure case when the request is too large */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
if (nelements <= 0 || element_size == 0)
|
||||
png_error(png_ptr, "internal error: array alloc");
|
||||
|
||||
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
|
||||
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
/* These are internal errors: */
|
||||
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||
(old_array == NULL && old_elements > 0))
|
||||
png_error(png_ptr, "internal error: array realloc");
|
||||
|
||||
/* Check for overflow on the elements count (so the caller does not have to
|
||||
* check.)
|
||||
*/
|
||||
if (add_elements <= INT_MAX - old_elements)
|
||||
{
|
||||
png_voidp new_array = png_malloc_array_checked(png_ptr,
|
||||
old_elements+add_elements, element_size);
|
||||
|
||||
if (new_array != NULL)
|
||||
{
|
||||
/* Because png_malloc_array worked the size calculations below cannot
|
||||
* overflow.
|
||||
*/
|
||||
if (old_elements > 0)
|
||||
memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||
|
||||
memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||
element_size*(unsigned)add_elements);
|
||||
|
||||
return new_array;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL; /* error */
|
||||
}
|
||||
|
||||
/* Various functions that have different error handling are derived from this.
|
||||
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
|
||||
* function png_malloc_default is also provided.
|
||||
|
||||
110
pngpread.c
110
pngpread.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -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)
|
||||
@@ -185,6 +185,9 @@ void /* PRIVATE */
|
||||
png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
png_uint_32 chunk_name;
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int keep; /* unknown handling method */
|
||||
#endif
|
||||
|
||||
/* First we make sure we have enough data for the 4 byte chunk name
|
||||
* and the 4 byte chunk length before proceeding with decoding the
|
||||
@@ -216,14 +219,28 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
/* This is here above the if/else case statement below because if the
|
||||
* unknown handling marks 'IDAT' as unknown then the IDAT handling case is
|
||||
* completely skipped.
|
||||
*
|
||||
* TODO: there must be a better way of doing this.
|
||||
*/
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||
|
||||
/* If we reach an IDAT chunk, this means we have read all of the
|
||||
* header chunks, and we can start reading the image (or if this
|
||||
* is called after the image has been read - we have an error).
|
||||
*/
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
if (png_ptr->push_length == 0)
|
||||
return;
|
||||
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
}
|
||||
|
||||
if (chunk_name == png_IHDR)
|
||||
@@ -255,7 +272,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if (png_chunk_unknown_handling(png_ptr, chunk_name))
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
@@ -263,23 +280,10 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (chunk_name == png_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);
|
||||
|
||||
if (chunk_name == png_PLTE)
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -295,30 +299,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
/* If we reach an IDAT chunk, this means we have read all of the
|
||||
* header chunks, and we can start reading the image (or if this
|
||||
* is called after the image has been read - we have an error).
|
||||
*/
|
||||
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
if (png_ptr->mode & PNG_HAVE_IDAT)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
if (png_ptr->push_length == 0)
|
||||
return;
|
||||
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
}
|
||||
|
||||
png_ptr->idat_size = png_ptr->push_length;
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
||||
png_push_have_info(png_ptr, info_ptr);
|
||||
png_ptr->zstream.avail_out =
|
||||
@@ -556,7 +537,8 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
}
|
||||
|
||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
@@ -649,7 +631,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
else
|
||||
save_size = png_ptr->save_buffer_size;
|
||||
|
||||
png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
|
||||
memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
|
||||
length -= save_size;
|
||||
ptr += save_size;
|
||||
png_ptr->buffer_size -= save_size;
|
||||
@@ -666,7 +648,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
else
|
||||
save_size = png_ptr->current_buffer_size;
|
||||
|
||||
png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
|
||||
memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
|
||||
png_ptr->buffer_size -= save_size;
|
||||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
@@ -715,13 +697,13 @@ png_push_save_buffer(png_structrp png_ptr)
|
||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||
}
|
||||
|
||||
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
png_free(png_ptr, old_buffer);
|
||||
png_ptr->save_buffer_max = new_max;
|
||||
}
|
||||
if (png_ptr->current_buffer_size)
|
||||
{
|
||||
png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
|
||||
memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
|
||||
png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);
|
||||
png_ptr->save_buffer_size += png_ptr->current_buffer_size;
|
||||
png_ptr->current_buffer_size = 0;
|
||||
@@ -766,7 +748,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
{
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
|
||||
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
||||
if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
png_error(png_ptr, "Not enough compressed data");
|
||||
|
||||
return;
|
||||
@@ -838,6 +820,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_ptr->zowner = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -854,13 +837,14 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
* handle the uncompressed results.
|
||||
*/
|
||||
png_ptr->zstream.next_in = buffer;
|
||||
/* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */
|
||||
png_ptr->zstream.avail_in = (uInt)buffer_length;
|
||||
|
||||
/* Keep going until the decompressed data is all processed
|
||||
* or the stream marked as finished.
|
||||
*/
|
||||
while (png_ptr->zstream.avail_in > 0 &&
|
||||
!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
||||
!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -871,9 +855,9 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
*/
|
||||
if (!(png_ptr->zstream.avail_out > 0))
|
||||
{
|
||||
png_ptr->zstream.avail_out =
|
||||
(uInt) PNG_ROWBYTES(png_ptr->pixel_depth,
|
||||
png_ptr->iwidth) + 1;
|
||||
/* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */
|
||||
png_ptr->zstream.avail_out = (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth,
|
||||
png_ptr->iwidth) + 1);
|
||||
|
||||
png_ptr->zstream.next_out = png_ptr->row_buf;
|
||||
}
|
||||
@@ -891,7 +875,8 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
if (ret != Z_OK && ret != Z_STREAM_END)
|
||||
{
|
||||
/* Terminate the decompression. */
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
png_ptr->zowner = 0;
|
||||
|
||||
/* This may be a truncated stream (missing or
|
||||
* damaged end code). Treat that as a warning.
|
||||
@@ -919,7 +904,8 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
{
|
||||
/* Extra data. */
|
||||
png_warning(png_ptr, "Extra compressed data in IDAT");
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
png_ptr->zowner = 0;
|
||||
|
||||
/* Do no more processing; skip the unprocessed
|
||||
* input check below.
|
||||
@@ -934,7 +920,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
|
||||
/* And check for the end of the stream. */
|
||||
if (ret == Z_STREAM_END)
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
}
|
||||
|
||||
/* All the data should have been processed, if anything
|
||||
@@ -972,7 +958,7 @@ png_push_process_row(png_structrp png_ptr)
|
||||
* it may not be in the future, so this was changed just to copy the
|
||||
* interlaced row count:
|
||||
*/
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
if (png_ptr->transformations)
|
||||
@@ -1206,7 +1192,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
541
pngread.c
541
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
|
||||
|
||||
@@ -48,61 +48,34 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
int ok = 0;
|
||||
png_ptr->mode = PNG_IS_READ_STRUCT;
|
||||
|
||||
/* TODO: why does this happen here on read, but in png_write_IHDR on
|
||||
* write? If it happened there then there would be no error handling case
|
||||
* here and png_ptr could be a png_structrp.
|
||||
/* Added in libpng-1.6.0; this can be used to detect a read structure if
|
||||
* required (it will be zero in a write structure.)
|
||||
*/
|
||||
png_ptr->zstream.zalloc = png_zalloc;
|
||||
png_ptr->zstream.zfree = png_zfree;
|
||||
png_ptr->zstream.opaque = png_ptr;
|
||||
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
png_ptr->IDAT_read_size = PNG_IDAT_READ_SIZE;
|
||||
# endif
|
||||
|
||||
switch (inflateInit(&png_ptr->zstream))
|
||||
{
|
||||
case Z_OK:
|
||||
ok = 1;
|
||||
break;
|
||||
# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||
png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
|
||||
|
||||
case Z_MEM_ERROR:
|
||||
png_warning(png_ptr, "zlib memory error");
|
||||
break;
|
||||
|
||||
case Z_STREAM_ERROR:
|
||||
png_warning(png_ptr, "zlib stream error");
|
||||
break;
|
||||
|
||||
case Z_VERSION_ERROR:
|
||||
png_warning(png_ptr, "zlib version error");
|
||||
break;
|
||||
|
||||
default:
|
||||
png_warning(png_ptr, "Unknown zlib error");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
|
||||
|
||||
/* 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.
|
||||
/* In stable builds only warn if an application error can be completely
|
||||
* handled.
|
||||
*/
|
||||
png_set_read_fn(png_ptr, NULL, NULL);
|
||||
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||
# endif
|
||||
# endif
|
||||
|
||||
return png_ptr;
|
||||
}
|
||||
|
||||
/* Else something went wrong in the zlib initialization above; it would
|
||||
* much simplify this code if the creation of the zlib stuff was to be
|
||||
* delayed until it is needed.
|
||||
/* 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.
|
||||
*/
|
||||
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||
png_set_read_fn(png_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return png_ptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +91,10 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
void PNGAPI
|
||||
png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int keep;
|
||||
#endif
|
||||
|
||||
png_debug(1, "in png_read_info");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
@@ -131,13 +108,30 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_uint_32 length = png_read_chunk_header(png_ptr);
|
||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||
|
||||
/* IDAT logic needs to happen here to simplify getting the two flags
|
||||
* right.
|
||||
*/
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_chunk_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_chunk_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
else if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_chunk_benign_error(png_ptr, "Too many IDATs found");
|
||||
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
}
|
||||
|
||||
else if (png_ptr->mode & PNG_HAVE_IDAT)
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
|
||||
/* This should be a binary subdivision search or a hash for
|
||||
* matching the chunk name rather than a linear search.
|
||||
*/
|
||||
if (chunk_name == png_IDAT)
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||
|
||||
if (chunk_name == png_IHDR)
|
||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||
|
||||
@@ -145,26 +139,16 @@ 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 (png_chunk_unknown_handling(png_ptr, chunk_name) !=
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||
{
|
||||
if (chunk_name == png_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
png_handle_unknown(png_ptr, info_ptr, length, keep);
|
||||
|
||||
if (chunk_name == png_PLTE)
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
png_ptr->idat_size = 0; /* It has been consumed */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -174,15 +158,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
png_ptr->idat_size = length;
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -272,7 +248,8 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#endif
|
||||
|
||||
else
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
png_handle_unknown(png_ptr, info_ptr, length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
@@ -283,16 +260,24 @@ png_read_update_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_update_info");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
|
||||
{
|
||||
png_read_start_row(png_ptr);
|
||||
|
||||
png_read_start_row(png_ptr);
|
||||
# ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
png_read_transform_info(png_ptr, info_ptr);
|
||||
# else
|
||||
PNG_UNUSED(info_ptr)
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
png_read_transform_info(png_ptr, info_ptr);
|
||||
#else
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
/* New in 1.6.0 this avoids the bug of doing the initializations twice */
|
||||
else
|
||||
png_app_error(png_ptr,
|
||||
"png_read_update_info/png_start_read_image: duplicate call");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
@@ -307,7 +292,15 @@ png_start_read_image(png_structrp png_ptr)
|
||||
png_debug(1, "in png_start_read_image");
|
||||
|
||||
if (png_ptr != NULL)
|
||||
png_read_start_row(png_ptr);
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
|
||||
png_read_start_row(png_ptr);
|
||||
|
||||
/* New in 1.6.0 this avoids the bug of doing the initializations twice */
|
||||
else
|
||||
png_app_error(png_ptr,
|
||||
"png_start_read_image/png_read_update_info: duplicate call");
|
||||
}
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
@@ -315,8 +308,6 @@ png_start_read_image(png_structrp png_ptr)
|
||||
void PNGAPI
|
||||
png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
{
|
||||
int ret;
|
||||
|
||||
png_row_info row_info;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
@@ -470,49 +461,8 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
png_error(png_ptr, "Invalid attempt to read row data");
|
||||
|
||||
png_ptr->zstream.next_out = png_ptr->row_buf;
|
||||
png_ptr->zstream.avail_out =
|
||||
(uInt)(PNG_ROWBYTES(png_ptr->pixel_depth,
|
||||
png_ptr->iwidth) + 1);
|
||||
|
||||
do
|
||||
{
|
||||
if (!(png_ptr->zstream.avail_in))
|
||||
{
|
||||
while (!png_ptr->idat_size)
|
||||
{
|
||||
png_crc_finish(png_ptr, 0);
|
||||
|
||||
png_ptr->idat_size = png_read_chunk_header(png_ptr);
|
||||
if (png_ptr->chunk_name != png_IDAT)
|
||||
png_error(png_ptr, "Not enough image data");
|
||||
}
|
||||
png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
|
||||
png_ptr->zstream.next_in = png_ptr->zbuf;
|
||||
if (png_ptr->zbuf_size > png_ptr->idat_size)
|
||||
png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size;
|
||||
png_crc_read(png_ptr, png_ptr->zbuf,
|
||||
(png_size_t)png_ptr->zstream.avail_in);
|
||||
png_ptr->idat_size -= png_ptr->zstream.avail_in;
|
||||
}
|
||||
|
||||
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
||||
|
||||
if (ret == Z_STREAM_END)
|
||||
{
|
||||
if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in ||
|
||||
png_ptr->idat_size)
|
||||
png_benign_error(png_ptr, "Extra compressed data");
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret != Z_OK)
|
||||
png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
|
||||
"Decompression error");
|
||||
|
||||
} while (png_ptr->zstream.avail_out);
|
||||
/* Fill the row with IDAT data: */
|
||||
png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
|
||||
{
|
||||
@@ -528,7 +478,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
* it may not be in the future, so this was changed just to copy the
|
||||
* interlaced count:
|
||||
*/
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
@@ -737,12 +687,29 @@ png_read_image(png_structrp png_ptr, png_bytepp image)
|
||||
void PNGAPI
|
||||
png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int keep;
|
||||
#endif
|
||||
|
||||
png_debug(1, "in png_read_end");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
|
||||
/* If png_read_end is called in the middle of reading the rows there may
|
||||
* still be pending IDAT data and an owned zstream. Deal with this here.
|
||||
*/
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
if (!png_chunk_unknown_handling(png_ptr, png_IDAT))
|
||||
#endif
|
||||
png_read_finish_IDAT(png_ptr);
|
||||
|
||||
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Report invalid palette index; added at libng-1.5.10 */
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
png_ptr->num_palette_max > png_ptr->num_palette)
|
||||
png_benign_error(png_ptr, "Read palette index exceeding num_palette");
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
@@ -756,15 +723,14 @@ 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 (png_chunk_unknown_handling(png_ptr, chunk_name) !=
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||
{
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
}
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
png_handle_unknown(png_ptr, info_ptr, length, keep);
|
||||
if (chunk_name == png_PLTE)
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
}
|
||||
@@ -869,7 +835,8 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#endif
|
||||
|
||||
else
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
png_handle_unknown(png_ptr, info_ptr, length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
} while (!(png_ptr->mode & PNG_HAVE_IEND));
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
@@ -884,10 +851,9 @@ png_read_destroy(png_structrp png_ptr)
|
||||
png_destroy_gamma_table(png_ptr);
|
||||
#endif
|
||||
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_free(png_ptr, png_ptr->big_row_buf);
|
||||
png_free(png_ptr, png_ptr->big_prev_row);
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_free(png_ptr, png_ptr->read_buffer);
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->palette_lookup);
|
||||
@@ -911,17 +877,12 @@ png_read_destroy(png_structrp png_ptr)
|
||||
png_free(png_ptr, png_ptr->save_buffer);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->current_text);
|
||||
#endif /* PNG_TEXT_SUPPORTED */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_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
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
#endif
|
||||
|
||||
@@ -984,7 +945,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||
* PNG file before the first IDAT (image data chunk).
|
||||
*/
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
|
||||
if (info_ptr->height > PNG_UINT_32_MAX/(sizeof (png_bytep)))
|
||||
png_error(png_ptr, "Image is too high to process with png_read_png()");
|
||||
|
||||
/* -------------- image transformations start here ------------------- */
|
||||
@@ -1131,7 +1092,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_uint_32 iptr;
|
||||
|
||||
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
|
||||
info_ptr->height * png_sizeof(png_bytep));
|
||||
info_ptr->height * (sizeof (png_bytep)));
|
||||
for (iptr=0; iptr<info_ptr->height; iptr++)
|
||||
info_ptr->row_pointers[iptr] = NULL;
|
||||
|
||||
@@ -1164,6 +1125,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||
/* Arguments to png_image_finish_read: */
|
||||
|
||||
/* Encoding of PNG data (used by the color-map code) */
|
||||
/* TODO: change these, dang, ANSI-C reserves the 'E' namespace. */
|
||||
# define E_NOTSET 0 /* File encoding not yet known */
|
||||
# define E_sRGB 1 /* 8-bit encoded to sRGB gamma */
|
||||
# define E_LINEAR 2 /* 16-bit linear: not encoded, NOT pre-multiplied! */
|
||||
@@ -1195,8 +1157,8 @@ typedef struct
|
||||
png_voidp colormap;
|
||||
png_const_colorp background;
|
||||
/* Local variables: */
|
||||
png_bytep local_row;
|
||||
png_bytep first_row;
|
||||
png_voidp local_row;
|
||||
png_voidp first_row;
|
||||
ptrdiff_t row_bytes; /* step between rows */
|
||||
int file_encoding; /* E_ values above */
|
||||
png_fixed_point gamma_to_linear; /* For E_FILE, reciprocal of gamma */
|
||||
@@ -1219,7 +1181,7 @@ png_image_read_init(png_imagep image)
|
||||
/* And set the rest of the structure to NULL to ensure that the various
|
||||
* fields are consistent.
|
||||
*/
|
||||
memset(image, 0, sizeof *image);
|
||||
memset(image, 0, (sizeof *image));
|
||||
image->version = PNG_IMAGE_VERSION;
|
||||
|
||||
if (png_ptr != NULL)
|
||||
@@ -1229,11 +1191,11 @@ png_image_read_init(png_imagep image)
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
png_controlp control = png_voidcast(png_controlp,
|
||||
png_malloc_warn(png_ptr, sizeof *control));
|
||||
png_malloc_warn(png_ptr, (sizeof *control)));
|
||||
|
||||
if (control != NULL)
|
||||
{
|
||||
png_memset(control, 0, sizeof *control);
|
||||
memset(control, 0, (sizeof *control));
|
||||
|
||||
control->png_ptr = png_ptr;
|
||||
control->info_ptr = info_ptr;
|
||||
@@ -1316,6 +1278,7 @@ png_image_read_header(png_voidp argument)
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
png_inforp info_ptr = image->opaque->info_ptr;
|
||||
|
||||
png_set_benign_errors(png_ptr, 1/*warn*/);
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
/* Do this the fast way; just read directly out of png_struct. */
|
||||
@@ -1327,41 +1290,17 @@ png_image_read_header(png_voidp argument)
|
||||
|
||||
image->format = format;
|
||||
|
||||
/* Now try to work out whether the color data does not match sRGB. */
|
||||
if ((format & PNG_FORMAT_FLAG_COLOR) != 0 &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB) == 0)
|
||||
{
|
||||
/* gamma is irrelevant because libpng does gamma correction, what
|
||||
* matters is if the cHRM chunk doesn't match or, in the absence of
|
||||
* cRHM, if the iCCP profile appears to have different end points.
|
||||
*/
|
||||
if (info_ptr->valid & PNG_INFO_cHRM)
|
||||
{
|
||||
/* TODO: this is a copy'n'paste from pngrutil.c, make a common
|
||||
* checking function. This checks for a 1% error.
|
||||
*/
|
||||
/* The cHRM chunk is used in preference to iCCP */
|
||||
if (PNG_OUT_OF_RANGE(info_ptr->x_white, 31270, 1000) ||
|
||||
PNG_OUT_OF_RANGE(info_ptr->y_white, 32900, 1000) ||
|
||||
PNG_OUT_OF_RANGE(info_ptr->x_red, 64000, 1000) ||
|
||||
PNG_OUT_OF_RANGE(info_ptr->y_red, 33000, 1000) ||
|
||||
PNG_OUT_OF_RANGE(info_ptr->x_green, 30000, 1000) ||
|
||||
PNG_OUT_OF_RANGE(info_ptr->y_green, 60000, 1000) ||
|
||||
PNG_OUT_OF_RANGE(info_ptr->x_blue, 15000, 1000) ||
|
||||
PNG_OUT_OF_RANGE(info_ptr->y_blue, 6000, 1000))
|
||||
image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB;
|
||||
}
|
||||
|
||||
else if (info_ptr->valid & PNG_INFO_iCCP)
|
||||
{
|
||||
# if 0
|
||||
/* TODO: IMPLEMENT THIS! */
|
||||
/* Here if we just have an iCCP chunk. */
|
||||
if (!png_iCCP_is_sRGB(png_ptr, info_ptr))
|
||||
# endif
|
||||
image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB;
|
||||
}
|
||||
}
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* Does the colorspace match sRGB? If there is no color endpoint
|
||||
* (colorant) information assume yes, otherwise require the
|
||||
* 'ENDPOINTS_MATCHE_sRGB' colorspace flag to have been set. If the
|
||||
* colorspace has been determined to be invalid ignore it.
|
||||
*/
|
||||
if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags
|
||||
& (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB|
|
||||
PNG_COLORSPACE_INVALID)) == PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We need the maximum number of entries regardless of the format the
|
||||
@@ -1418,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;
|
||||
}
|
||||
|
||||
@@ -1452,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 */
|
||||
@@ -1472,7 +1419,7 @@ png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)
|
||||
|
||||
if (memory != NULL && size >= need)
|
||||
{
|
||||
png_memcpy(out, memory, need);
|
||||
memcpy(out, memory, need);
|
||||
cp->memory = memory + need;
|
||||
cp->size = size - need;
|
||||
return;
|
||||
@@ -1513,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;
|
||||
}
|
||||
|
||||
@@ -1535,31 +1486,26 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
|
||||
*
|
||||
* This provides a small performance improvement and eliminates any
|
||||
* potential vulnerability to security problems in the unused chunks.
|
||||
*
|
||||
* TODO: make it so that this is an explicit list to process, not a list
|
||||
* to ignore?
|
||||
*/
|
||||
{
|
||||
static PNG_CONST png_byte chunks_to_ignore[] = {
|
||||
104, 73, 83, 84, '\0', /* hIST */
|
||||
105, 84, 88, 116, '\0', /* iTXt */
|
||||
111, 70, 70, 115, '\0', /* oFFs */
|
||||
112, 67, 65, 76, '\0', /* pCAL */
|
||||
112, 72, 89, 115, '\0', /* pHYs */
|
||||
115, 67, 65, 76, '\0', /* sCAL */
|
||||
115, 80, 76, 84, '\0', /* sPLT */
|
||||
116, 69, 88, 116, '\0', /* tEXt */
|
||||
116, 73, 77, 69, '\0', /* tIME */
|
||||
122, 84, 88, 116, '\0' /* zTXt */
|
||||
};
|
||||
static PNG_CONST png_byte chunks_to_process[] = {
|
||||
98, 75, 71, 68, '\0', /* bKGD */
|
||||
99, 72, 82, 77, '\0', /* cHRM */
|
||||
103, 65, 77, 65, '\0', /* gAMA */
|
||||
105, 67, 67, 80, '\0', /* iCCP */
|
||||
115, 66, 73, 84, '\0', /* sBIT */
|
||||
115, 82, 71, 66, '\0', /* sRGB */
|
||||
};
|
||||
|
||||
/* Ignore unknown chunks */
|
||||
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
|
||||
NULL, 0);
|
||||
/* Ignore unknown chunks and all other chunks except for the
|
||||
* IHDR, PLTE, tRNS, IDAT, and IEND chunks.
|
||||
*/
|
||||
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER,
|
||||
NULL, -1);
|
||||
|
||||
/* Ignore known but unused chunks */
|
||||
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
|
||||
chunks_to_ignore, (sizeof chunks_to_ignore)/5);
|
||||
/* But do not ignore image data handling chunks */
|
||||
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT,
|
||||
chunks_to_process, (sizeof chunks_to_process)/5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1578,7 +1524,7 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
|
||||
static void
|
||||
set_file_encoding(png_image_read_control *display)
|
||||
{
|
||||
png_fixed_point g = display->image->opaque->png_ptr->gamma;
|
||||
png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma;
|
||||
if (png_gamma_significant(g))
|
||||
{
|
||||
if (png_gamma_not_sRGB(g))
|
||||
@@ -1887,6 +1833,17 @@ png_create_colormap_entry(png_image_read_control *display,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
make_gray_file_colormap(png_image_read_control *display)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i=0; i<256; ++i)
|
||||
png_create_colormap_entry(display, i, i, i, i, 255, E_FILE);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int
|
||||
make_gray_colormap(png_image_read_control *display)
|
||||
{
|
||||
@@ -2047,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
|
||||
@@ -2082,7 +2061,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
|
||||
/* png_create_colormap_entry just takes an RGBA and writes the
|
||||
* corresponding color-map entry using the format from 'image',
|
||||
* including the required convertion to sRGB or linear as
|
||||
* including the required conversion to sRGB or linear as
|
||||
* appropriate. The input values are always either sRGB (if the
|
||||
* gamma correction flag is 0) or 0..255 scaled file encoded values
|
||||
* (if the function must gamma correct them).
|
||||
@@ -2417,7 +2396,24 @@ png_image_read_colormap(png_voidp argument)
|
||||
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
|
||||
png_error(png_ptr, "rgb[gray] color-map: too few entries");
|
||||
|
||||
cmap_entries = make_gray_colormap(display);
|
||||
/* Ideally this code would use libpng to do the gamma correction,
|
||||
* but if an input alpha channel is to be removed we will hit the
|
||||
* libpng bug in gamma+compose+rgb-to-gray (the double gamma
|
||||
* correction bug). Fix this by dropping the gamma correction in
|
||||
* this case and doing it in the palette; this will result in
|
||||
* duplicate palette entries, but that's better than the
|
||||
* alternative of double gamma correction.
|
||||
*/
|
||||
if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
png_ptr->num_trans > 0) &&
|
||||
png_gamma_not_sRGB(png_ptr->colorspace.gamma))
|
||||
{
|
||||
cmap_entries = make_gray_file_colormap(display);
|
||||
data_encoding = E_FILE;
|
||||
}
|
||||
|
||||
else
|
||||
cmap_entries = make_gray_colormap(display);
|
||||
|
||||
/* But if the input has alpha or transparency it must be removed
|
||||
*/
|
||||
@@ -2432,18 +2428,38 @@ png_image_read_colormap(png_voidp argument)
|
||||
* it. Achieve this simply by ensuring that the entry
|
||||
* selected for the background really is the background color.
|
||||
*/
|
||||
if (output_encoding == E_LINEAR)
|
||||
if (data_encoding == E_FILE) /* from the fixup above */
|
||||
{
|
||||
/* The app supplied a gray which is in output_encoding, we
|
||||
* need to convert it to a value of the input (E_FILE)
|
||||
* encoding then set this palette entry to the required
|
||||
* output encoding.
|
||||
*/
|
||||
if (output_encoding == E_sRGB)
|
||||
gray = png_sRGB_table[gray]; /* now E_LINEAR */
|
||||
|
||||
gray = PNG_DIV257(png_gamma_16bit_correct(gray,
|
||||
png_ptr->colorspace.gamma)); /* now E_FILE */
|
||||
|
||||
/* And make sure the corresponding palette entry contains
|
||||
* exactly the required sRGB value.
|
||||
*/
|
||||
png_create_colormap_entry(display, gray, back_g, back_g,
|
||||
back_g, 0/*unused*/, output_encoding);
|
||||
}
|
||||
|
||||
else if (output_encoding == E_LINEAR)
|
||||
{
|
||||
gray = PNG_sRGB_FROM_LINEAR(gray * 255);
|
||||
|
||||
/* And make sure the corresponding palette entry matches.
|
||||
*/
|
||||
png_create_colormap_entry(display, gray, back_g, back_g,
|
||||
back_g, 65535, E_LINEAR);
|
||||
back_g, 0/*unused*/, E_LINEAR);
|
||||
}
|
||||
|
||||
/* The background passed to libpng, however, must be the sRGB
|
||||
* value.
|
||||
/* The background passed to libpng, however, must be the
|
||||
* output (normally sRGB) value.
|
||||
*/
|
||||
c.index = 0; /*unused*/
|
||||
c.gray = c.red = c.green = c.blue = (png_uint_16)gray;
|
||||
@@ -2555,7 +2571,8 @@ png_image_read_colormap(png_voidp argument)
|
||||
|
||||
/* Compare the newly-created color-map entry with the one the
|
||||
* PNG_CMAP_RGB algorithm will use. If the two entries don't
|
||||
* match, add the new one and set this as the background index.
|
||||
* match, add the new one and set this as the background
|
||||
* index.
|
||||
*/
|
||||
if (memcmp((png_const_bytep)display->colormap +
|
||||
sample_size * cmap_entries,
|
||||
@@ -2706,13 +2723,12 @@ png_image_read_colormap(png_voidp argument)
|
||||
png_error(png_ptr, "bad data option (internal error)");
|
||||
break;
|
||||
|
||||
case E_FILE:
|
||||
/* Make no changes */
|
||||
break;
|
||||
|
||||
case E_sRGB:
|
||||
/* Change to 8-bit sRGB */
|
||||
png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB);
|
||||
/* FALL THROUGH */
|
||||
|
||||
case E_FILE:
|
||||
if (png_ptr->bit_depth > 8)
|
||||
png_set_scale_16(png_ptr);
|
||||
break;
|
||||
@@ -2797,7 +2813,7 @@ png_image_read_and_map(png_voidp argument)
|
||||
png_uint_32 height = image->height;
|
||||
png_uint_32 width = image->width;
|
||||
int proc = display->colormap_processing;
|
||||
png_bytep first_row = display->first_row;
|
||||
png_bytep first_row = png_voidcast(png_bytep, display->first_row);
|
||||
ptrdiff_t step_row = display->row_bytes;
|
||||
int pass;
|
||||
|
||||
@@ -2827,7 +2843,7 @@ png_image_read_and_map(png_voidp argument)
|
||||
|
||||
for (; y<height; y += stepy)
|
||||
{
|
||||
png_bytep inrow = display->local_row;
|
||||
png_bytep inrow = png_voidcast(png_bytep, display->local_row);
|
||||
png_bytep outrow = first_row + y * step_row;
|
||||
png_const_bytep end_row = outrow + width;
|
||||
|
||||
@@ -3037,14 +3053,18 @@ png_image_read_colormapped(png_voidp argument)
|
||||
* size libpng requires and call the relevant processing routine safely.
|
||||
*/
|
||||
{
|
||||
png_bytep first_row = png_voidcast(png_bytep, display->buffer);
|
||||
png_voidp first_row = display->buffer;
|
||||
ptrdiff_t row_bytes = display->row_stride;
|
||||
|
||||
/* The following expression is designed to work correctly whether it gives
|
||||
* a signed or an unsigned result.
|
||||
*/
|
||||
if (row_bytes < 0)
|
||||
first_row += (image->height-1) * (-row_bytes);
|
||||
{
|
||||
char *ptr = png_voidcast(char*, first_row);
|
||||
ptr += (image->height-1) * (-row_bytes);
|
||||
first_row = png_voidcast(png_voidp, ptr);
|
||||
}
|
||||
|
||||
display->first_row = first_row;
|
||||
display->row_bytes = row_bytes;
|
||||
@@ -3053,8 +3073,7 @@ png_image_read_colormapped(png_voidp argument)
|
||||
if (passes == 0)
|
||||
{
|
||||
int result;
|
||||
png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
png_get_rowbytes(png_ptr, info_ptr)));
|
||||
png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
|
||||
|
||||
display->local_row = row;
|
||||
result = png_safe_execute(image, png_image_read_and_map, display);
|
||||
@@ -3071,7 +3090,7 @@ png_image_read_colormapped(png_voidp argument)
|
||||
while (--passes >= 0)
|
||||
{
|
||||
png_uint_32 y = image->height;
|
||||
png_bytep row = display->first_row;
|
||||
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||
|
||||
while (y-- > 0)
|
||||
{
|
||||
@@ -3112,7 +3131,6 @@ png_image_read_composite(png_voidp argument)
|
||||
{
|
||||
png_uint_32 height = image->height;
|
||||
png_uint_32 width = image->width;
|
||||
png_bytep first_row = display->first_row;
|
||||
ptrdiff_t step_row = display->row_bytes;
|
||||
unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
|
||||
int pass;
|
||||
@@ -3144,13 +3162,17 @@ png_image_read_composite(png_voidp argument)
|
||||
|
||||
for (; y<height; y += stepy)
|
||||
{
|
||||
png_bytep inrow = display->local_row;
|
||||
png_bytep outrow = first_row + y * step_row;
|
||||
png_const_bytep end_row = outrow + width * channels;
|
||||
png_bytep inrow = png_voidcast(png_bytep, display->local_row);
|
||||
png_bytep outrow;
|
||||
png_const_bytep end_row;
|
||||
|
||||
/* Read the row, which is packed: */
|
||||
png_read_row(png_ptr, inrow, NULL);
|
||||
|
||||
outrow = png_voidcast(png_bytep, display->first_row);
|
||||
outrow += y * step_row;
|
||||
end_row = outrow + width * channels;
|
||||
|
||||
/* Now do the composition on each pixel in this row. */
|
||||
outrow += startx;
|
||||
for (; outrow < end_row; outrow += stepx)
|
||||
@@ -3268,12 +3290,13 @@ png_image_read_background(png_voidp argument)
|
||||
* Unlike the code above ALPHA_OPTIMIZED has *not* been done.
|
||||
*/
|
||||
{
|
||||
png_bytep first_row = display->first_row;
|
||||
png_bytep first_row = png_voidcast(png_bytep, display->first_row);
|
||||
ptrdiff_t step_row = display->row_bytes;
|
||||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_bytep row = display->first_row;
|
||||
png_bytep row = png_voidcast(png_bytep,
|
||||
display->first_row);
|
||||
unsigned int startx, stepx, stepy;
|
||||
png_uint_32 y;
|
||||
|
||||
@@ -3300,7 +3323,8 @@ png_image_read_background(png_voidp argument)
|
||||
{
|
||||
for (; y<height; y += stepy)
|
||||
{
|
||||
png_bytep inrow = display->local_row;
|
||||
png_bytep inrow = png_voidcast(png_bytep,
|
||||
display->local_row);
|
||||
png_bytep outrow = first_row + y * step_row;
|
||||
png_const_bytep end_row = outrow + width;
|
||||
|
||||
@@ -3344,7 +3368,8 @@ png_image_read_background(png_voidp argument)
|
||||
|
||||
for (; y<height; y += stepy)
|
||||
{
|
||||
png_bytep inrow = display->local_row;
|
||||
png_bytep inrow = png_voidcast(png_bytep,
|
||||
display->local_row);
|
||||
png_bytep outrow = first_row + y * step_row;
|
||||
png_const_bytep end_row = outrow + width;
|
||||
|
||||
@@ -3390,8 +3415,12 @@ png_image_read_background(png_voidp argument)
|
||||
* handles the alpha-first option.
|
||||
*/
|
||||
{
|
||||
png_bytep first_row = display->first_row;
|
||||
ptrdiff_t step_row = display->row_bytes;
|
||||
png_uint_16p first_row = png_voidcast(png_uint_16p,
|
||||
display->first_row);
|
||||
/* The division by two is safe because the caller passed in a
|
||||
* stride which was multiplied by 2 (below) to get row_bytes.
|
||||
*/
|
||||
ptrdiff_t step_row = display->row_bytes / 2;
|
||||
int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
unsigned int outchannels = 1+preserve_alpha;
|
||||
int swap_alpha = 0;
|
||||
@@ -3429,12 +3458,13 @@ png_image_read_background(png_voidp argument)
|
||||
for (; y<height; y += stepy)
|
||||
{
|
||||
png_const_uint_16p inrow;
|
||||
png_uint_16p outrow = (png_uint_16p)(first_row + y*step_row);
|
||||
png_uint_16p outrow = first_row + y*step_row;
|
||||
png_uint_16p end_row = outrow + width * outchannels;
|
||||
|
||||
/* Read the row, which is packed: */
|
||||
png_read_row(png_ptr, display->local_row, NULL);
|
||||
inrow = (png_const_uint_16p)display->local_row;
|
||||
png_read_row(png_ptr, png_voidcast(png_bytep,
|
||||
display->local_row), NULL);
|
||||
inrow = png_voidcast(png_const_uint_16p, display->local_row);
|
||||
|
||||
/* Now do the pre-multiplication on each pixel in this row.
|
||||
*/
|
||||
@@ -3539,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;
|
||||
@@ -3585,8 +3616,8 @@ png_image_read_direct(png_voidp argument)
|
||||
* yet; it's set below. png_struct::gamma, however, is set to the
|
||||
* final value.
|
||||
*/
|
||||
if (png_muldiv(>est, output_gamma, png_ptr->gamma, PNG_FP_1) &&
|
||||
!png_gamma_significant(gtest))
|
||||
if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma,
|
||||
PNG_FP_1) && !png_gamma_significant(gtest))
|
||||
do_local_background = 0;
|
||||
|
||||
else if (mode == PNG_ALPHA_STANDARD)
|
||||
@@ -3832,7 +3863,7 @@ png_image_read_direct(png_voidp argument)
|
||||
* display acts as a flag.
|
||||
*/
|
||||
{
|
||||
png_bytep first_row = png_voidcast(png_bytep, display->buffer);
|
||||
png_voidp first_row = display->buffer;
|
||||
ptrdiff_t row_bytes = display->row_stride;
|
||||
|
||||
if (linear)
|
||||
@@ -3842,7 +3873,11 @@ png_image_read_direct(png_voidp argument)
|
||||
* a signed or an unsigned result.
|
||||
*/
|
||||
if (row_bytes < 0)
|
||||
first_row += (image->height-1) * (-row_bytes);
|
||||
{
|
||||
char *ptr = png_voidcast(char*, first_row);
|
||||
ptr += (image->height-1) * (-row_bytes);
|
||||
first_row = png_voidcast(png_voidp, ptr);
|
||||
}
|
||||
|
||||
display->first_row = first_row;
|
||||
display->row_bytes = row_bytes;
|
||||
@@ -3851,8 +3886,7 @@ png_image_read_direct(png_voidp argument)
|
||||
if (do_local_compose)
|
||||
{
|
||||
int result;
|
||||
png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
png_get_rowbytes(png_ptr, info_ptr)));
|
||||
png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
|
||||
|
||||
display->local_row = row;
|
||||
result = png_safe_execute(image, png_image_read_composite, display);
|
||||
@@ -3865,8 +3899,7 @@ png_image_read_direct(png_voidp argument)
|
||||
else if (do_local_background == 2)
|
||||
{
|
||||
int result;
|
||||
png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
png_get_rowbytes(png_ptr, info_ptr)));
|
||||
png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
|
||||
|
||||
display->local_row = row;
|
||||
result = png_safe_execute(image, png_image_read_background, display);
|
||||
@@ -3883,7 +3916,7 @@ png_image_read_direct(png_voidp argument)
|
||||
while (--passes >= 0)
|
||||
{
|
||||
png_uint_32 y = image->height;
|
||||
png_bytep row = display->first_row;
|
||||
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||
|
||||
while (y-- > 0)
|
||||
{
|
||||
@@ -3922,7 +3955,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
int result;
|
||||
png_image_read_control display;
|
||||
|
||||
png_memset(&display, 0, sizeof display);
|
||||
memset(&display, 0, (sizeof display));
|
||||
display.image = image;
|
||||
display.buffer = buffer;
|
||||
display.row_stride = row_stride;
|
||||
@@ -3956,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.)
|
||||
*
|
||||
|
||||
313
pngrtran.c
313
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.)
|
||||
*
|
||||
@@ -88,6 +88,36 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
/* Is it OK to set a transformation now? Only if png_start_read_image or
|
||||
* png_read_update_info have not been called. It is not necessary for the IHDR
|
||||
* to have been read in all cases, the parameter allows for this check too.
|
||||
*/
|
||||
static int
|
||||
png_rtran_ok(png_structrp png_ptr, int need_IHDR)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_ROW_INIT)
|
||||
png_app_error(png_ptr,
|
||||
"invalid after png_start_read_image or png_read_update_info");
|
||||
|
||||
else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||
png_app_error(png_ptr, "invalid before the PNG header has been read");
|
||||
|
||||
else
|
||||
{
|
||||
/* Turn on failure to initialize correctly for all transforms. */
|
||||
png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
|
||||
|
||||
return 1; /* Ok */
|
||||
}
|
||||
}
|
||||
|
||||
return 0; /* no png_error possible! */
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
/* Handle alpha and tRNS via a background color */
|
||||
void PNGFAPI
|
||||
@@ -97,7 +127,7 @@ png_set_background_fixed(png_structrp png_ptr,
|
||||
{
|
||||
png_debug(1, "in png_set_background_fixed");
|
||||
|
||||
if (png_ptr == NULL || background_color == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0) || background_color == NULL)
|
||||
return;
|
||||
|
||||
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
||||
@@ -141,7 +171,7 @@ png_set_scale_16(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_scale_16");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_SCALE_16_TO_8;
|
||||
@@ -155,7 +185,7 @@ png_set_strip_16(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_16");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_16_TO_8;
|
||||
@@ -168,7 +198,7 @@ png_set_strip_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_alpha");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||
@@ -193,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;
|
||||
@@ -247,7 +279,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
|
||||
png_debug(1, "in png_set_alpha_mode");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
|
||||
@@ -319,8 +351,11 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
* the side effect that the gamma in a second call to png_set_alpha_mode will
|
||||
* be ignored.)
|
||||
*/
|
||||
if (png_ptr->gamma == 0)
|
||||
png_ptr->gamma = file_gamma;
|
||||
if (png_ptr->colorspace.gamma == 0)
|
||||
{
|
||||
png_ptr->colorspace.gamma = file_gamma;
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
}
|
||||
|
||||
/* But always set the output gamma: */
|
||||
png_ptr->screen_gamma = output_gamma;
|
||||
@@ -331,8 +366,8 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
if (compose)
|
||||
{
|
||||
/* And obtain alpha pre-multiplication by composing on black: */
|
||||
png_memset(&png_ptr->background, 0, sizeof png_ptr->background);
|
||||
png_ptr->background_gamma = png_ptr->gamma; /* just in case */
|
||||
memset(&png_ptr->background, 0, (sizeof png_ptr->background));
|
||||
png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */
|
||||
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
|
||||
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
|
||||
|
||||
@@ -342,9 +377,6 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
|
||||
png_ptr->transformations |= PNG_COMPOSE;
|
||||
}
|
||||
|
||||
/* New API, make sure apps call the correct initializers: */
|
||||
png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@@ -383,7 +415,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
{
|
||||
png_debug(1, "in png_set_quantize");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_QUANTIZE;
|
||||
@@ -393,7 +425,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
int i;
|
||||
|
||||
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->quantize_index[i] = (png_byte)i;
|
||||
}
|
||||
@@ -410,7 +442,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
|
||||
/* Initialize an array to sort colors */
|
||||
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
|
||||
/* Initialize the quantize_sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@@ -544,9 +576,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
|
||||
/* Initialize palette index arrays */
|
||||
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
|
||||
/* Initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@@ -556,7 +588,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
}
|
||||
|
||||
hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
|
||||
png_sizeof(png_dsortp)));
|
||||
(sizeof (png_dsortp))));
|
||||
|
||||
num_new_palette = num_palette;
|
||||
|
||||
@@ -586,7 +618,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
{
|
||||
|
||||
t = (png_dsortp)png_malloc_warn(png_ptr,
|
||||
(png_uint_32)(png_sizeof(png_dsort)));
|
||||
(png_uint_32)(sizeof (png_dsort)));
|
||||
|
||||
if (t == NULL)
|
||||
break;
|
||||
@@ -711,12 +743,12 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
||||
|
||||
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
|
||||
(png_uint_32)(num_entries * png_sizeof(png_byte)));
|
||||
(png_uint_32)(num_entries * (sizeof (png_byte))));
|
||||
|
||||
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
||||
png_sizeof(png_byte)));
|
||||
(sizeof (png_byte))));
|
||||
|
||||
png_memset(distance, 0xff, num_entries * png_sizeof(png_byte));
|
||||
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
||||
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
@@ -770,7 +802,7 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
||||
{
|
||||
png_debug(1, "in png_set_gamma_fixed");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
|
||||
@@ -798,7 +830,8 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
||||
* file if a gAMA chunk was present. png_set_alpha_mode provides a
|
||||
* different, easier, way to default the file gamma.
|
||||
*/
|
||||
png_ptr->gamma = file_gamma;
|
||||
png_ptr->colorspace.gamma = file_gamma;
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
png_ptr->screen_gamma = scrn_gamma;
|
||||
}
|
||||
|
||||
@@ -822,11 +855,10 @@ png_set_expand(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
|
||||
/* GRR 19990627: the following three functions currently are identical
|
||||
@@ -853,11 +885,10 @@ png_set_palette_to_rgb(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_palette_to_rgb");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
|
||||
/* Expand grayscale images of less than 8-bit depth to 8 bits. */
|
||||
@@ -866,23 +897,22 @@ png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_EXPAND;
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Expand tRNS chunks to alpha channels. */
|
||||
void PNGAPI
|
||||
png_set_tRNS_to_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_tRNS_to_alpha");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||
|
||||
@@ -895,14 +925,10 @@ png_set_expand_16(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand_16");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
|
||||
/* New API, make sure apps call the correct initializers: */
|
||||
png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -912,13 +938,12 @@ png_set_gray_to_rgb(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_gray_to_rgb");
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* Because rgb must be 8 bits or more: */
|
||||
png_set_expand_gray_1_2_4_to_8(png_ptr);
|
||||
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
/* Because rgb must be 8 bits or more: */
|
||||
png_set_expand_gray_1_2_4_to_8(png_ptr);
|
||||
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -929,7 +954,9 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
{
|
||||
png_debug(1, "in png_set_rgb_to_gray");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
/* Need the IHDR here because of the check on color_type below. */
|
||||
/* TODO: fix this */
|
||||
if (!png_rtran_ok(png_ptr, 1))
|
||||
return;
|
||||
|
||||
switch(error_action)
|
||||
@@ -950,15 +977,19 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
png_error(png_ptr, "invalid error action to rgb_to_gray");
|
||||
break;
|
||||
}
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
png_ptr->transformations |= PNG_EXPAND;
|
||||
#else
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
/* Make this an error in 1.6 because otherwise the application may assume
|
||||
* that it just worked and get a memory overwrite.
|
||||
*/
|
||||
png_error(png_ptr,
|
||||
"Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED");
|
||||
|
||||
png_ptr->transformations &= ~PNG_RGB_TO_GRAY;
|
||||
/* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */
|
||||
}
|
||||
#endif
|
||||
{
|
||||
@@ -982,7 +1013,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
else
|
||||
{
|
||||
if (red >= 0 && green >= 0)
|
||||
png_warning(png_ptr,
|
||||
png_app_warning(png_ptr,
|
||||
"ignoring out of range rgb_to_gray coefficients");
|
||||
|
||||
/* Use the defaults, from the cHRM chunk if set, else the historical
|
||||
@@ -1011,16 +1042,13 @@ void PNGAPI
|
||||
png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red,
|
||||
double green)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_set_rgb_to_gray_fixed(png_ptr, error_action,
|
||||
png_fixed(png_ptr, red, "rgb to gray red coefficient"),
|
||||
png_fixed(png_ptr, green, "rgb to gray green coefficient"));
|
||||
}
|
||||
#endif /* FLOATING POINT */
|
||||
|
||||
#endif
|
||||
#endif /* RGB_TO_GRAY */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
@@ -1030,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_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
||||
@@ -1219,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 */
|
||||
@@ -1265,17 +1290,17 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
*/
|
||||
int gamma_correction = 0;
|
||||
|
||||
if (png_ptr->gamma != 0) /* has been set */
|
||||
if (png_ptr->colorspace.gamma != 0) /* has been set */
|
||||
{
|
||||
if (png_ptr->screen_gamma != 0) /* screen set too */
|
||||
gamma_correction = png_gamma_threshold(png_ptr->gamma,
|
||||
gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma,
|
||||
png_ptr->screen_gamma);
|
||||
|
||||
else
|
||||
/* Assume the output matches the input; a long time default behavior
|
||||
* of libpng, although the standard has nothing to say about this.
|
||||
*/
|
||||
png_ptr->screen_gamma = png_reciprocal(png_ptr->gamma);
|
||||
png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma);
|
||||
}
|
||||
|
||||
else if (png_ptr->screen_gamma != 0)
|
||||
@@ -1284,7 +1309,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* png_set_alpha_mode (even if the alpha handling mode isn't required
|
||||
* or isn't changed from the default.)
|
||||
*/
|
||||
png_ptr->gamma = png_reciprocal(png_ptr->screen_gamma);
|
||||
png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma);
|
||||
|
||||
else /* neither are set */
|
||||
/* Just in case the following prevents any processing - file and screen
|
||||
@@ -1292,7 +1317,10 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* third gamma value other than png_set_background with 'UNIQUE', and,
|
||||
* prior to 1.5.4
|
||||
*/
|
||||
png_ptr->screen_gamma = png_ptr->gamma = PNG_FP_1;
|
||||
png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1;
|
||||
|
||||
/* We have a gamma value now. */
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
|
||||
/* Now turn the gamma transformation on or off as appropriate. Notice
|
||||
* that PNG_GAMMA just refers to the file->screen correction. Alpha
|
||||
@@ -1374,9 +1402,16 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
|
||||
defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* Make sure the coefficients for the rgb to gray conversion are set
|
||||
* appropriately.
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
png_colorspace_set_rgb_coefficients(png_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* Detect gray background and attempt to enable optimization for
|
||||
* gray --> RGB case.
|
||||
*
|
||||
@@ -1418,7 +1453,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED (etc) */
|
||||
#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
|
||||
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
|
||||
|
||||
/* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations
|
||||
* can be performed directly on the palette, and some (such as rgb to gray)
|
||||
@@ -1514,10 +1550,10 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_GAMMA)
|
||||
|| ((png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
&& (png_gamma_significant(png_ptr->gamma) ||
|
||||
&& (png_gamma_significant(png_ptr->colorspace.gamma) ||
|
||||
png_gamma_significant(png_ptr->screen_gamma)))
|
||||
|| ((png_ptr->transformations & PNG_COMPOSE)
|
||||
&& (png_gamma_significant(png_ptr->gamma)
|
||||
&& (png_gamma_significant(png_ptr->colorspace.gamma)
|
||||
|| png_gamma_significant(png_ptr->screen_gamma)
|
||||
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
|
||||
@@ -1574,8 +1610,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
break;
|
||||
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
g = png_reciprocal(png_ptr->gamma);
|
||||
gs = png_reciprocal2(png_ptr->gamma,
|
||||
g = png_reciprocal(png_ptr->colorspace.gamma);
|
||||
gs = png_reciprocal2(png_ptr->colorspace.gamma,
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
|
||||
@@ -1683,8 +1719,9 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
break;
|
||||
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
g = png_reciprocal(png_ptr->gamma);
|
||||
gs = png_reciprocal2(png_ptr->gamma, png_ptr->screen_gamma);
|
||||
g = png_reciprocal(png_ptr->colorspace.gamma);
|
||||
gs = png_reciprocal2(png_ptr->colorspace.gamma,
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
|
||||
case PNG_BACKGROUND_GAMMA_UNIQUE:
|
||||
@@ -1828,12 +1865,15 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
|
||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SHIFT) &&
|
||||
!(png_ptr->transformations & PNG_EXPAND) &&
|
||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
int i;
|
||||
int istop = png_ptr->num_palette;
|
||||
int shift = 8 - png_ptr->sig_bit.red;
|
||||
|
||||
png_ptr->transformations &= ~PNG_SHIFT;
|
||||
|
||||
/* significant bits can be in the range 1 to 7 for a meaninful result, if
|
||||
* the number of significant bits is 0 then no shift is done (this is an
|
||||
* error condition which is silently ignored.)
|
||||
@@ -1923,8 +1963,12 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
* however it seems that the code in png_init_read_transformations, which has
|
||||
* been called before this from png_read_update_info->png_read_start_row
|
||||
* sometimes does the gamma transform and cancels the flag.
|
||||
*
|
||||
* TODO: this looks wrong; the info_ptr should end up with a gamma equal to
|
||||
* the screen_gamma value. The following probably results in weirdness if
|
||||
* the info_ptr is used by the app after the rows have been read.
|
||||
*/
|
||||
info_ptr->gamma = png_ptr->gamma;
|
||||
info_ptr->colorspace.gamma = png_ptr->colorspace.gamma;
|
||||
#endif
|
||||
|
||||
if (info_ptr->bit_depth == 16)
|
||||
@@ -2087,8 +2131,9 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
|
||||
/* The following is debugging; prior to 1.5.4 the code was never compiled in;
|
||||
* in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
|
||||
* PNG_WARN_UNINITIALIZED_ROW removed. In 1.5 the new flag is set only for
|
||||
* selected new APIs to ensure that there is no API change.
|
||||
* PNG_WARN_UNINITIALIZED_ROW removed. In 1.6 the new flag is set only for
|
||||
* all transformations, however in practice the ROW_INIT always gets done on
|
||||
* demand, if necessary.
|
||||
*/
|
||||
if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&
|
||||
!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
@@ -2193,8 +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
|
||||
@@ -2205,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.)
|
||||
*/
|
||||
@@ -2294,32 +2339,11 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
png_do_unpack(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
/* Added at libpng-1.6.0 */
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* To do: Fix does not check sub-8-bit rows that have not been unpacked. */
|
||||
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Added at libpng-1.5.10 */
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
row_info->bit_depth == 8)
|
||||
if (png_ptr->num_palette < (1 << png_ptr->bit_depth))
|
||||
{
|
||||
if ((png_ptr->interlaced && png_ptr->pass == 6) ||
|
||||
(!png_ptr->interlaced && png_ptr->pass == 0))
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_bytep rp = png_ptr->row_buf+1; /* +1 to skip the filter byte */
|
||||
|
||||
for (i = 0; i <= row_info->rowbytes; i++)
|
||||
{
|
||||
if (*rp >= png_ptr->num_palette)
|
||||
{
|
||||
/* Should this be a benign error instead of a warning? */
|
||||
png_warning(png_ptr,"Found invalid palette index");
|
||||
break;
|
||||
}
|
||||
|
||||
rp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
png_ptr->num_palette_max >= 0)
|
||||
png_do_check_palette_indexes(png_ptr, row_info);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_BGR_SUPPORTED
|
||||
@@ -3259,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
|
||||
@@ -3336,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;
|
||||
@@ -3493,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.
|
||||
@@ -3510,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");
|
||||
@@ -3728,8 +3752,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
if (v == png_ptr->trans_color.gray)
|
||||
{
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray
|
||||
& 0xff);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -3752,8 +3778,10 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
if (v == png_ptr->trans_color.gray)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray
|
||||
& 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3833,9 +3861,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
}
|
||||
|
||||
@@ -3876,9 +3907,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
}
|
||||
}
|
||||
@@ -3933,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3961,7 +3995,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
else if (a == 0)
|
||||
{
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
}
|
||||
|
||||
@@ -3991,7 +4026,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
if (a == 0)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
|
||||
*sp = (png_byte)((png_ptr->background.gray >> 8)
|
||||
& 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
|
||||
}
|
||||
|
||||
@@ -4000,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);
|
||||
}
|
||||
@@ -4121,9 +4157,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
/* Background is already in screen gamma */
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
}
|
||||
|
||||
@@ -4134,14 +4173,16 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.red);
|
||||
if (!optimize)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
*sp = (png_byte)((w >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(w & 0xff);
|
||||
|
||||
v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.green);
|
||||
if (!optimize)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
|
||||
*(sp + 2) = (png_byte)((w >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(w & 0xff);
|
||||
@@ -4149,7 +4190,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.blue);
|
||||
if (!optimize)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
|
||||
*(sp + 4) = (png_byte)((w >> 8) & 0xff);
|
||||
*(sp + 5) = (png_byte)(w & 0xff);
|
||||
@@ -4170,9 +4212,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
{
|
||||
*sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
|
||||
*(sp + 2) = (png_byte)((png_ptr->background.green >> 8)
|
||||
& 0xff);
|
||||
*(sp + 3) = (png_byte)(png_ptr->background.green
|
||||
& 0xff);
|
||||
*(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)
|
||||
& 0xff);
|
||||
*(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
|
||||
}
|
||||
|
||||
|
||||
2993
pngrutil.c
2993
pngrutil.c
File diff suppressed because it is too large
Load Diff
211
pngstruct.h
211
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
|
||||
@@ -24,7 +24,122 @@
|
||||
* in this structure and is required for decompressing the LZ compressed
|
||||
* data in PNG files.
|
||||
*/
|
||||
#ifndef ZLIB_CONST
|
||||
/* We must ensure that zlib uses 'const' in declarations. */
|
||||
# define ZLIB_CONST
|
||||
#endif
|
||||
#include "zlib.h"
|
||||
#ifdef const
|
||||
/* zlib.h sometimes #defines const to nothing, undo this. */
|
||||
# undef const
|
||||
#endif
|
||||
|
||||
/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
|
||||
* with older builds.
|
||||
*/
|
||||
#if ZLIB_VERNUM < 0x1260
|
||||
# define PNGZ_MSG_CAST(s) png_constcast(char*,s)
|
||||
# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
|
||||
#else
|
||||
# define PNGZ_MSG_CAST(s) (s)
|
||||
# define PNGZ_INPUT_CAST(b) (b)
|
||||
#endif
|
||||
|
||||
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
|
||||
* can handle at once. This type need be no larger than 16 bits (so maximum of
|
||||
* 65535), this define allows us to discover how big it is, but limited by the
|
||||
* maximuum for png_size_t. The value can be overriden in a library build
|
||||
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
|
||||
* lower value (e.g. 255 works). A lower value may help memory usage (slightly)
|
||||
* and may even improve performance on some systems (and degrade it on others.)
|
||||
*/
|
||||
#ifndef ZLIB_IO_MAX
|
||||
# define ZLIB_IO_MAX ((uInt)-1)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* The type of a compression buffer list used by the write code. */
|
||||
typedef struct png_compression_buffer
|
||||
{
|
||||
struct png_compression_buffer *next;
|
||||
png_byte output[1]; /* actually zbuf_size */
|
||||
} png_compression_buffer, *png_compression_bufferp;
|
||||
|
||||
#define PNG_COMPRESSION_BUFFER_SIZE(pp)\
|
||||
(offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)
|
||||
#endif
|
||||
|
||||
/* Colorspace support; structures used in png_struct, png_info and in internal
|
||||
* functions to hold and communicate information about the color space.
|
||||
*
|
||||
* PNG_COLORSPACE_SUPPORTED is only required if the application will perform
|
||||
* colorspace corrections, otherwise all the colorspace information can be
|
||||
* skipped and the size of libpng can be reduced (significantly) by compiling
|
||||
* out the colorspace support.
|
||||
*/
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* The chromaticities of the red, green and blue colorants and the chromaticity
|
||||
* of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
|
||||
*/
|
||||
typedef struct png_xy
|
||||
{
|
||||
png_fixed_point redx, redy;
|
||||
png_fixed_point greenx, greeny;
|
||||
png_fixed_point bluex, bluey;
|
||||
png_fixed_point whitex, whitey;
|
||||
} png_xy;
|
||||
|
||||
/* The same data as above but encoded as CIE XYZ values. When this data comes
|
||||
* from chromaticities the sum of the Y values is assumed to be 1.0
|
||||
*/
|
||||
typedef struct png_XYZ
|
||||
{
|
||||
png_fixed_point red_X, red_Y, red_Z;
|
||||
png_fixed_point green_X, green_Y, green_Z;
|
||||
png_fixed_point blue_X, blue_Y, blue_Z;
|
||||
} png_XYZ;
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* A colorspace is all the above plus, potentially, profile information,
|
||||
* however at present libpng does not use the profile internally so it is only
|
||||
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||
* is retained here and is checked.
|
||||
*
|
||||
* The file gamma encoding information is also stored here and gamma correction
|
||||
* is done by libpng, whereas color correction must currently be done by the
|
||||
* application.
|
||||
*/
|
||||
typedef struct png_colorspace
|
||||
{
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
png_fixed_point gamma; /* File gamma */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
png_xy end_points_xy; /* End points as chromaticities */
|
||||
png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
|
||||
png_uint_16 rendering_intent; /* Rendering intent of a profile */
|
||||
#endif
|
||||
|
||||
/* Flags are always defined to simplify the code. */
|
||||
png_uint_16 flags; /* As defined below */
|
||||
} png_colorspace, * PNG_RESTRICT png_colorspacerp;
|
||||
|
||||
typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
|
||||
|
||||
/* General flags for the 'flags' field */
|
||||
#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
|
||||
#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
|
||||
#define PNG_COLORSPACE_HAVE_INTENT 0x0004
|
||||
#define PNG_COLORSPACE_FROM_gAMA 0x0008
|
||||
#define PNG_COLORSPACE_FROM_cHRM 0x0010
|
||||
#define PNG_COLORSPACE_FROM_sRGB 0x0020
|
||||
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
|
||||
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
|
||||
#define PNG_COLORSPACE_INVALID 0x8000
|
||||
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
|
||||
#endif /* COLORSPACE || GAMMA */
|
||||
|
||||
struct png_struct_def
|
||||
{
|
||||
@@ -65,22 +180,12 @@ struct png_struct_def
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations; /* which transformations to perform */
|
||||
|
||||
z_stream zstream; /* pointer to decompression structure (below) */
|
||||
png_bytep zbuf; /* buffer for zlib */
|
||||
uInt zbuf_size; /* size of zbuf (typically 65536) */
|
||||
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||
z_stream zstream; /* decompression structure */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Added in 1.5.4: state to keep track of whether the zstream has been
|
||||
* initialized and if so whether it is for IDAT or some other chunk.
|
||||
*/
|
||||
#define PNG_ZLIB_UNINITIALIZED 0
|
||||
#define PNG_ZLIB_FOR_IDAT 1
|
||||
#define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */
|
||||
#define PNG_ZLIB_USE_MASK 3 /* bottom two bits */
|
||||
#define PNG_ZLIB_IN_USE 4 /* a flag value */
|
||||
|
||||
png_uint_32 zlib_state; /* State of zlib initialization */
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
||||
uInt zbuffer_size; /* size of the actual buffer */
|
||||
|
||||
int zlib_level; /* holds zlib compression level */
|
||||
int zlib_method; /* holds zlib compression method */
|
||||
@@ -89,8 +194,7 @@ struct png_struct_def
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* Added at libpng 1.5.4 */
|
||||
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
int zlib_text_level; /* holds zlib compression level */
|
||||
int zlib_text_method; /* holds zlib compression method */
|
||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||
@@ -98,6 +202,14 @@ struct png_struct_def
|
||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
/* Added at libpng 1.6.0 */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
int zlib_set_level; /* Actual values set into the zstream on write */
|
||||
int zlib_set_method;
|
||||
int zlib_set_window_bits;
|
||||
int zlib_set_mem_level;
|
||||
int zlib_set_strategy;
|
||||
#endif
|
||||
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
@@ -113,16 +225,24 @@ struct png_struct_def
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||
* This is a pointer into big_row_buf
|
||||
*/
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
#endif
|
||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||
|
||||
png_uint_32 idat_size; /* current IDAT size for read */
|
||||
png_uint_32 crc; /* current chunk CRC value */
|
||||
png_colorp palette; /* palette from the input file */
|
||||
png_uint_16 num_palette; /* number of color entries in palette */
|
||||
|
||||
/* Added at libpng-1.5.10 */
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
int num_palette_max; /* maximum palette index found in IDAT */
|
||||
#endif
|
||||
|
||||
png_uint_16 num_trans; /* number of transparency values */
|
||||
png_byte compression; /* file compression type (always 0) */
|
||||
png_byte filter; /* file filter type (always 0) */
|
||||
@@ -134,17 +254,14 @@ struct png_struct_def
|
||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte channels; /* number of channels in file */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_byte usr_channels; /* channels at start of write: write only */
|
||||
#endif
|
||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||
png_byte maximum_pixel_depth;
|
||||
/* pixel depth used for the row buffers */
|
||||
png_byte transformed_pixel_depth;
|
||||
/* pixel depth after read/write transforms */
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
png_byte io_chunk_string[5];
|
||||
/* string name of chunk */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
@@ -167,7 +284,6 @@ struct png_struct_def
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
png_fixed_point gamma; /* file gamma value */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
@@ -215,13 +331,6 @@ struct png_struct_def
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
# ifdef PNG_TEXT_SUPPORTED
|
||||
png_size_t current_text_size; /* current size of text input data */
|
||||
png_size_t current_text_left; /* how much text left to read in input */
|
||||
png_charp current_text; /* current text chunk buffer */
|
||||
png_charp current_text_ptr; /* current location in current_text */
|
||||
# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
@@ -248,7 +357,13 @@ 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
|
||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||
#endif
|
||||
@@ -260,17 +375,16 @@ struct png_struct_def
|
||||
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
png_voidp user_chunk_ptr;
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
unsigned int num_chunk_list;
|
||||
png_bytep chunk_list;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
/* Added in 1.5.5 to record an sRGB chunk in the png. */
|
||||
png_byte is_sRGB;
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int unknown_default; /* As PNG_HANDLE_* */
|
||||
unsigned int num_chunk_list; /* Number of entries in the list */
|
||||
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
|
||||
* followed by a PNG_HANDLE_* byte */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.3 */
|
||||
@@ -335,20 +449,24 @@ struct png_struct_def
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Temporary storage for unknown chunk that the library doesn't recognize,
|
||||
* used while reading the chunk.
|
||||
*/
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
png_unknown_chunk unknown_chunk;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.2.26 */
|
||||
png_size_t old_big_row_buf_size;
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* New member added in libpng-1.2.30 */
|
||||
png_charp chunkdata; /* buffer for reading chunk data */
|
||||
png_bytep read_buffer; /* buffer for reading chunk data */
|
||||
png_alloc_size_t read_buffer_size; /* current size of the buffer */
|
||||
#endif
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* New member added in libpng-1.4.0 */
|
||||
@@ -358,7 +476,14 @@ struct png_struct_def
|
||||
/* New member added in libpng-1.5.6 */
|
||||
png_bytep big_prev_row;
|
||||
|
||||
/* New member added in libpng-1.5.7 */
|
||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row);
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif /* PNGSTRUCT_H */
|
||||
|
||||
673
pngtest.c
673
pngtest.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.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.)
|
||||
*
|
||||
@@ -33,16 +33,39 @@
|
||||
|
||||
#define _POSIX_SOURCE 1
|
||||
|
||||
#include "zlib.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Defined so I can write to a file on gui/windowing platforms */
|
||||
/* #define STDERR stderr */
|
||||
#define STDERR stdout /* For DOS */
|
||||
|
||||
#include "png.h"
|
||||
|
||||
/* 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
|
||||
# define PNG_ZBUF_SIZE 8192
|
||||
#endif
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# define FCLOSE(file) fclose(file)
|
||||
#define FCLOSE(file) fclose(file)
|
||||
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
typedef FILE * png_FILE_p;
|
||||
@@ -88,20 +111,31 @@ 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 */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#endif
|
||||
|
||||
/* Defined so I can write to a file on gui/windowing platforms */
|
||||
/* #define STDERR stderr */
|
||||
#define STDERR stdout /* For DOS */
|
||||
|
||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) png_ptr->jmpbuf
|
||||
#endif
|
||||
|
||||
/* Defines for unknown chunk handling if required. */
|
||||
#ifndef PNG_HANDLE_CHUNK_ALWAYS
|
||||
# define PNG_HANDLE_CHUNK_ALWAYS 3
|
||||
#endif
|
||||
#ifndef PNG_HANDLE_CHUNK_IF_SAFE
|
||||
# define PNG_HANDLE_CHUNK_IF_SAFE 2
|
||||
#endif
|
||||
|
||||
/* Utility to save typing/errors, the argument must be a name */
|
||||
#define MEMZERO(var) ((void)memset(&var, 0, sizeof var))
|
||||
|
||||
/* Example of using row callbacks to make a simple progress meter */
|
||||
static int status_pass = 1;
|
||||
static int status_dots_requested = 0;
|
||||
@@ -131,6 +165,7 @@ read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
fprintf(stdout, "r");
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
static void PNGCBAPI
|
||||
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
{
|
||||
@@ -139,6 +174,7 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
|
||||
fprintf(stdout, "w");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
@@ -269,8 +305,6 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
}
|
||||
#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
|
||||
static int wrote_question = 0;
|
||||
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
/* START of code to validate stdio-free compilation */
|
||||
/* These copies of the default read/write functions come from pngrio.c and
|
||||
@@ -378,24 +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);
|
||||
|
||||
if (test == NULL)
|
||||
fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
|
||||
++warning_count;
|
||||
|
||||
else
|
||||
fprintf(STDERR, "%s: libpng warning: %s\n", test, message);
|
||||
if (test != NULL && test->file_name != NULL)
|
||||
name = test->file_name;
|
||||
|
||||
fprintf(STDERR, "%s: libpng warning: %s\n", name, message);
|
||||
}
|
||||
|
||||
/* This is the default error handling function. Note that replacements for
|
||||
@@ -406,12 +447,14 @@ pngtest_warning(png_structp png_ptr, png_const_charp message)
|
||||
static void PNGCBAPI
|
||||
pngtest_error(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
++error_count;
|
||||
|
||||
pngtest_warning(png_ptr, message);
|
||||
/* We can return because png_error calls the default handler, which is
|
||||
* actually OK in this case.
|
||||
*/
|
||||
}
|
||||
#endif /* !PNG_STDIO_SUPPORTED */
|
||||
|
||||
/* END of code to validate stdio-free compilation */
|
||||
|
||||
/* START of code to validate memory allocation and deallocation */
|
||||
@@ -462,7 +505,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
memory_infop pinfo;
|
||||
png_set_mem_fn(png_ptr, NULL, NULL, NULL);
|
||||
pinfo = (memory_infop)png_malloc(png_ptr,
|
||||
png_sizeof(*pinfo));
|
||||
(sizeof *pinfo));
|
||||
pinfo->size = size;
|
||||
current_allocation += size;
|
||||
total_allocation += size;
|
||||
@@ -556,25 +599,73 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
/* END of code to test memory allocation/deallocation */
|
||||
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* Demonstration of user chunk support of the sTER and vpAg chunks */
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
|
||||
/* (sTER is a public chunk not yet known by libpng. vpAg is a private
|
||||
chunk used in ImageMagick to store "virtual page" size). */
|
||||
|
||||
static png_uint_32 user_chunk_data[4];
|
||||
static struct user_chunk_data
|
||||
{
|
||||
png_const_infop info_ptr;
|
||||
png_uint_32 vpAg_width, vpAg_height;
|
||||
png_byte vpAg_units;
|
||||
png_byte sTER_mode;
|
||||
int location[2];
|
||||
}
|
||||
user_chunk_data;
|
||||
|
||||
/* 0: sTER mode + 1
|
||||
* 1: vpAg width
|
||||
* 2: vpAg height
|
||||
* 3: vpAg units
|
||||
*/
|
||||
/* Used for location and order; zero means nothing. */
|
||||
#define have_sTER 0x01
|
||||
#define have_vpAg 0x02
|
||||
#define before_PLTE 0x10
|
||||
#define before_IDAT 0x20
|
||||
#define after_IDAT 0x40
|
||||
|
||||
static void
|
||||
init_callback_info(png_const_infop info_ptr)
|
||||
{
|
||||
MEMZERO(user_chunk_data);
|
||||
user_chunk_data.info_ptr = info_ptr;
|
||||
}
|
||||
|
||||
static int
|
||||
set_location(png_structp png_ptr, struct user_chunk_data *data, int what)
|
||||
{
|
||||
int location;
|
||||
|
||||
if ((data->location[0] & what) || (data->location[1] & what))
|
||||
return 0; /* already have one of these */
|
||||
|
||||
/* Find where we are (the code below zeros info_ptr to indicate that the
|
||||
* chunks before the first IDAT have been read.)
|
||||
*/
|
||||
if (data->info_ptr == NULL) /* after IDAT */
|
||||
location = what | after_IDAT;
|
||||
|
||||
else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE))
|
||||
location = what | before_IDAT;
|
||||
|
||||
else
|
||||
location = what | before_PLTE;
|
||||
|
||||
if (data->location[0] == 0)
|
||||
data->location[0] = location;
|
||||
|
||||
else
|
||||
data->location[1] = location;
|
||||
|
||||
return 1; /* handled */
|
||||
}
|
||||
|
||||
static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
png_unknown_chunkp chunk)
|
||||
{
|
||||
png_uint_32
|
||||
*my_user_chunk_data;
|
||||
struct user_chunk_data *my_user_chunk_data =
|
||||
(struct user_chunk_data*)png_get_user_chunk_ptr(png_ptr);
|
||||
|
||||
if (my_user_chunk_data == NULL)
|
||||
png_error(png_ptr, "lost user chunk pointer");
|
||||
|
||||
/* Return one of the following:
|
||||
* return (-n); chunk had an error
|
||||
@@ -599,9 +690,14 @@ static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
if (chunk->data[0] != 0 && chunk->data[0] != 1)
|
||||
return (-1); /* Invalid mode */
|
||||
|
||||
my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
|
||||
my_user_chunk_data[0]=chunk->data[0]+1;
|
||||
return (1);
|
||||
if (set_location(png_ptr, my_user_chunk_data, have_sTER))
|
||||
{
|
||||
my_user_chunk_data->sTER_mode=chunk->data[0];
|
||||
return (1);
|
||||
}
|
||||
|
||||
else
|
||||
return (0); /* duplicate sTER - give it to libpng */
|
||||
}
|
||||
|
||||
if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */
|
||||
@@ -613,24 +709,119 @@ static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
if (chunk->size != 9)
|
||||
return (-1); /* Error return */
|
||||
|
||||
my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
|
||||
if (!set_location(png_ptr, my_user_chunk_data, have_vpAg))
|
||||
return (0); /* duplicate vpAg */
|
||||
|
||||
my_user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data);
|
||||
my_user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4);
|
||||
my_user_chunk_data[3]=(png_uint_32)chunk->data[8];
|
||||
my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data);
|
||||
my_user_chunk_data->vpAg_height = png_get_uint_31(png_ptr, chunk->data + 4);
|
||||
my_user_chunk_data->vpAg_units = chunk->data[8];
|
||||
|
||||
return (1);
|
||||
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
static void
|
||||
write_sTER_chunk(png_structp write_ptr)
|
||||
{
|
||||
png_byte png_sTER[5] = {115, 84, 69, 82, '\0'};
|
||||
|
||||
if (verbose)
|
||||
fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode);
|
||||
|
||||
png_write_chunk(write_ptr, png_sTER, &user_chunk_data.sTER_mode, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
write_vpAg_chunk(png_structp write_ptr)
|
||||
{
|
||||
png_byte png_vpAg[5] = {118, 112, 65, 103, '\0'};
|
||||
|
||||
png_byte vpag_chunk_data[9];
|
||||
|
||||
if (verbose)
|
||||
fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
|
||||
(unsigned long)user_chunk_data.vpAg_width,
|
||||
(unsigned long)user_chunk_data.vpAg_height,
|
||||
user_chunk_data.vpAg_units);
|
||||
|
||||
png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);
|
||||
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);
|
||||
vpag_chunk_data[8] = user_chunk_data.vpAg_units;
|
||||
png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9);
|
||||
}
|
||||
|
||||
static void
|
||||
write_chunks(png_structp write_ptr, int location)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Notice that this preserves the original chunk order, however chunks
|
||||
* intercepted by the callback will be written *after* chunks passed to
|
||||
* libpng. This will actually reverse a pair of sTER chunks or a pair of
|
||||
* vpAg chunks, resulting in an error later. This is not worth worrying
|
||||
* about - the chunks should not be duplicated!
|
||||
*/
|
||||
for (i=0; i<2; ++i)
|
||||
{
|
||||
if (user_chunk_data.location[i] == (location | have_sTER))
|
||||
write_sTER_chunk(write_ptr);
|
||||
|
||||
else if (user_chunk_data.location[i] == (location | have_vpAg))
|
||||
write_vpAg_chunk(write_ptr);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#else /* !PNG_READ_USER_CHUNKS_SUPPORTED */
|
||||
# define write_chunks(pp,loc) ((void)0)
|
||||
#endif
|
||||
/* END of code to demonstrate user chunk support */
|
||||
|
||||
/* START of code to check that libpng has the required text support; this only
|
||||
* checks for the write support because if read support is missing the chunk
|
||||
* will simply not be reported back to pngtest.
|
||||
*/
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
static void
|
||||
pngtest_check_text_support(png_const_structp png_ptr, png_textp text_ptr,
|
||||
int num_text)
|
||||
{
|
||||
while (num_text > 0)
|
||||
{
|
||||
switch (text_ptr[--num_text].compression)
|
||||
{
|
||||
case PNG_TEXT_COMPRESSION_NONE:
|
||||
break;
|
||||
|
||||
case PNG_TEXT_COMPRESSION_zTXt:
|
||||
# ifndef PNG_WRITE_zTXt_SUPPORTED
|
||||
++unsupported_chunks;
|
||||
# endif
|
||||
break;
|
||||
|
||||
case PNG_ITXT_COMPRESSION_NONE:
|
||||
case PNG_ITXT_COMPRESSION_zTXt:
|
||||
# ifndef PNG_WRITE_iTXt_SUPPORTED
|
||||
++unsupported_chunks;
|
||||
# endif
|
||||
break;
|
||||
|
||||
default:
|
||||
/* This is an error */
|
||||
png_error(png_ptr, "invalid text chunk compression field");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* END of code to check that libpng has the required text support */
|
||||
|
||||
/* Test one file */
|
||||
static int
|
||||
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
static png_FILE_p fpin;
|
||||
static png_FILE_p fpout; /* "static" prevents setjmp corruption */
|
||||
pngtest_error_parameters error_parameters;
|
||||
png_structp read_ptr;
|
||||
png_infop read_info_ptr, end_info_ptr;
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
@@ -648,9 +839,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int num_pass, pass;
|
||||
int bit_depth, color_type;
|
||||
|
||||
char inbuf[256], outbuf[256];
|
||||
|
||||
row_buf = NULL;
|
||||
error_parameters.file_name = inname;
|
||||
|
||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||
{
|
||||
@@ -674,20 +864,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
read_ptr =
|
||||
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
#endif
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
|
||||
pngtest_warning);
|
||||
#endif
|
||||
png_set_error_fn(read_ptr, &error_parameters, pngtest_error,
|
||||
pngtest_warning);
|
||||
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
user_chunk_data[0] = 0;
|
||||
user_chunk_data[1] = 0;
|
||||
user_chunk_data[2] = 0;
|
||||
user_chunk_data[3] = 0;
|
||||
png_set_read_user_chunk_fn(read_ptr, user_chunk_data,
|
||||
read_user_chunk_callback);
|
||||
|
||||
#endif
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
write_ptr =
|
||||
@@ -697,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);
|
||||
@@ -710,6 +887,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
write_end_info_ptr = png_create_info_struct(write_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
init_callback_info(read_info_ptr);
|
||||
png_set_read_user_chunk_fn(read_ptr, &user_chunk_data,
|
||||
read_user_chunk_callback);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
pngtest_debug("Setting jmpbuf for read struct");
|
||||
if (setjmp(png_jmpbuf(read_ptr)))
|
||||
@@ -745,6 +928,32 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (strict)
|
||||
{
|
||||
/* Treat png_benign_error() as errors on read */
|
||||
png_set_benign_errors(read_ptr, 0);
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* Treat them as errors on write */
|
||||
png_set_benign_errors(write_ptr, 0);
|
||||
#endif
|
||||
|
||||
/* if strict is not set, then app warnings and errors are treated as
|
||||
* warnings in release builds, but not in unstable builds; this can be
|
||||
* changed with '--relaxed'.
|
||||
*/
|
||||
}
|
||||
|
||||
else if (relaxed)
|
||||
{
|
||||
/* Allow application (pngtest) errors and warnings to pass */
|
||||
png_set_benign_errors(read_ptr, 1);
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_set_benign_errors(write_ptr, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
pngtest_debug("Initializing input and output streams");
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
png_init_io(read_ptr, fpin);
|
||||
@@ -763,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
|
||||
@@ -802,24 +1003,37 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_set_write_user_transform_fn(write_ptr, count_zero_samples);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifndef PNG_HANDLE_CHUNK_ALWAYS
|
||||
# define PNG_HANDLE_CHUNK_ALWAYS 3
|
||||
# endif
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Preserve all the unknown chunks, if possible. If this is disabled then,
|
||||
* even if the png_{get,set}_unknown_chunks stuff is enabled, we can't use
|
||||
* libpng to *save* the unknown chunks on read (because we can't switch the
|
||||
* save option on!)
|
||||
*
|
||||
* Notice that if SET_UNKNOWN_CHUNKS is *not* supported read will discard all
|
||||
* unknown chunks and write will write them all.
|
||||
*/
|
||||
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,
|
||||
NULL, 0);
|
||||
#endif
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifndef PNG_HANDLE_CHUNK_IF_SAFE
|
||||
# define PNG_HANDLE_CHUNK_IF_SAFE 2
|
||||
# endif
|
||||
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE,
|
||||
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,
|
||||
NULL, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
pngtest_debug("Reading info struct");
|
||||
png_read_info(read_ptr, read_info_ptr);
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* This is a bit of a hack; there is no obvious way in the callback function
|
||||
* to determine that the chunks before the first IDAT have been read, so
|
||||
* remove the info_ptr (which is only used to determine position relative to
|
||||
* PLTE) here to indicate that we are after the IDAT.
|
||||
*/
|
||||
user_chunk_data.info_ptr = NULL;
|
||||
#endif
|
||||
|
||||
pngtest_debug("Transferring info struct");
|
||||
{
|
||||
int interlace_type, compression_type, filter_type;
|
||||
@@ -975,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;
|
||||
@@ -1011,8 +1226,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text);
|
||||
|
||||
pngtest_check_text_support(read_ptr, text_ptr, num_text);
|
||||
|
||||
if (verbose)
|
||||
printf("\n Text compression=%d\n", text_ptr->compression);
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("\n");
|
||||
for (i=0; i<num_text; i++)
|
||||
{
|
||||
printf(" Text compression[%d]=%d\n",
|
||||
i, text_ptr[i].compression);
|
||||
}
|
||||
}
|
||||
|
||||
png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
|
||||
}
|
||||
@@ -1027,10 +1253,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_set_tIME(write_ptr, write_info_ptr, mod_time);
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
|
||||
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
|
||||
tIME_string[(sizeof tIME_string) - 1] = '\0';
|
||||
|
||||
else
|
||||
strcpy(tIME_string, "*** invalid time ***");
|
||||
{
|
||||
strncpy(tIME_string, "*** invalid time ***", (sizeof tIME_string));
|
||||
tIME_string[(sizeof tIME_string) - 1] = '\0';
|
||||
}
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
@@ -1067,16 +1296,20 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
if (num_unknowns)
|
||||
{
|
||||
int i;
|
||||
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
/* Copy the locations from the read_info_ptr. The automatically
|
||||
* generated locations in write_info_ptr are wrong because we
|
||||
* haven't written anything yet.
|
||||
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
|
||||
* because they are reset from the write pointer (removed in 1.6.0).
|
||||
*/
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1084,47 +1317,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
pngtest_debug("Writing info struct");
|
||||
|
||||
/* If we wanted, we could write info in two steps:
|
||||
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
||||
*/
|
||||
/* Write the info in two steps so that if we write the 'unknown' chunks here
|
||||
* they go to the correct place.
|
||||
*/
|
||||
png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
||||
|
||||
write_chunks(write_ptr, before_PLTE); /* before PLTE */
|
||||
|
||||
png_write_info(write_ptr, write_info_ptr);
|
||||
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (user_chunk_data[0] != 0)
|
||||
{
|
||||
png_byte png_sTER[5] = {115, 84, 69, 82, '\0'};
|
||||
|
||||
unsigned char
|
||||
ster_chunk_data[1];
|
||||
|
||||
if (verbose)
|
||||
fprintf(STDERR, "\n stereo mode = %lu\n",
|
||||
(unsigned long)(user_chunk_data[0] - 1));
|
||||
|
||||
ster_chunk_data[0]=(unsigned char)(user_chunk_data[0] - 1);
|
||||
png_write_chunk(write_ptr, png_sTER, ster_chunk_data, 1);
|
||||
}
|
||||
|
||||
if (user_chunk_data[1] != 0 || user_chunk_data[2] != 0)
|
||||
{
|
||||
png_byte png_vpAg[5] = {118, 112, 65, 103, '\0'};
|
||||
|
||||
unsigned char
|
||||
vpag_chunk_data[9];
|
||||
|
||||
if (verbose)
|
||||
fprintf(STDERR, " vpAg = %lu x %lu, units = %lu\n",
|
||||
(unsigned long)user_chunk_data[1],
|
||||
(unsigned long)user_chunk_data[2],
|
||||
(unsigned long)user_chunk_data[3]);
|
||||
|
||||
png_save_uint_32(vpag_chunk_data, user_chunk_data[1]);
|
||||
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data[2]);
|
||||
vpag_chunk_data[8] = (unsigned char)(user_chunk_data[3] & 0xff);
|
||||
png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9);
|
||||
}
|
||||
|
||||
#endif
|
||||
write_chunks(write_ptr, before_IDAT); /* after PLTE */
|
||||
#endif
|
||||
|
||||
#ifdef SINGLE_ROWBUF_ALLOC
|
||||
@@ -1207,6 +1409,21 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
|
||||
{
|
||||
pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text);
|
||||
|
||||
pngtest_check_text_support(read_ptr, text_ptr, num_text);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("\n");
|
||||
for (i=0; i<num_text; i++)
|
||||
{
|
||||
printf(" Text compression[%d]=%d\n",
|
||||
i, text_ptr[i].compression);
|
||||
}
|
||||
}
|
||||
|
||||
png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
|
||||
}
|
||||
}
|
||||
@@ -1220,10 +1437,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
|
||||
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
|
||||
tIME_string[(sizeof tIME_string) - 1] = '\0';
|
||||
|
||||
else
|
||||
strcpy(tIME_string, "*** invalid time ***");
|
||||
{
|
||||
strncpy(tIME_string, "*** invalid time ***", sizeof tIME_string);
|
||||
tIME_string[(sizeof tIME_string)-1] = '\0';
|
||||
}
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
@@ -1238,20 +1458,41 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
if (num_unknowns)
|
||||
{
|
||||
int i;
|
||||
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
/* Copy the locations from the read_info_ptr. The automatically
|
||||
* generated locations in write_end_info_ptr are wrong because we
|
||||
* haven't written the end_info yet.
|
||||
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
|
||||
* because they are reset from the write pointer (removed in 1.6.0).
|
||||
*/
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
/* Normally one would use Z_DEFAULT_STRATEGY for text compression.
|
||||
* This is here just to make pngtest replicate the results from libpng
|
||||
* versions prior to 1.5.4, and to test this new API.
|
||||
*/
|
||||
png_set_text_compression_strategy(write_ptr, Z_FILTERED);
|
||||
#endif
|
||||
|
||||
/* When the unknown vpAg/sTER chunks are written by pngtest the only way to
|
||||
* do it is to write them *before* calling png_write_end. When unknown
|
||||
* chunks are written by libpng, however, they are written just before IEND.
|
||||
* There seems to be no way round this, however vpAg/sTER are not expected
|
||||
* after IDAT.
|
||||
*/
|
||||
write_chunks(write_ptr, after_IDAT);
|
||||
|
||||
png_write_end(write_ptr, write_end_info_ptr);
|
||||
#endif
|
||||
|
||||
@@ -1285,6 +1526,40 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
/* Summarize any warnings or errors and in 'strict' mode fail the test.
|
||||
* Unsupported chunks can result in warnings, in that case ignore the strict
|
||||
* setting, otherwise fail the test on warnings as well as errors.
|
||||
*/
|
||||
if (error_count > 0)
|
||||
{
|
||||
/* We don't really expect to get here because of the setjmp handling
|
||||
* above, but this is safe.
|
||||
*/
|
||||
fprintf(STDERR, "\n %s: %d libpng errors found (%d warnings)",
|
||||
inname, error_count, warning_count);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
}
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
/* If there we no write support nothing was written! */
|
||||
else if (unsupported_chunks > 0)
|
||||
{
|
||||
fprintf(STDERR, "\n %s: unsupported chunks (%d)%s",
|
||||
inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
|
||||
}
|
||||
# endif
|
||||
|
||||
else if (warning_count > 0)
|
||||
{
|
||||
fprintf(STDERR, "\n %s: %d libpng warnings found",
|
||||
inname, warning_count);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
}
|
||||
|
||||
pngtest_debug("Opening files for comparison");
|
||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||
{
|
||||
@@ -1299,71 +1574,85 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
return (1);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
#ifdef PNG_WRITE_SUPPORTED /* else nothing was written */
|
||||
{
|
||||
png_size_t num_in, num_out;
|
||||
int wrote_question = 0;
|
||||
|
||||
num_in = fread(inbuf, 1, 1, fpin);
|
||||
num_out = fread(outbuf, 1, 1, fpout);
|
||||
|
||||
if (num_in != num_out)
|
||||
for (;;)
|
||||
{
|
||||
fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
|
||||
inname, outname);
|
||||
png_size_t num_in, num_out;
|
||||
char inbuf[256], outbuf[256];
|
||||
|
||||
if (wrote_question == 0)
|
||||
|
||||
num_in = fread(inbuf, 1, sizeof inbuf, fpin);
|
||||
num_out = fread(outbuf, 1, sizeof outbuf, fpout);
|
||||
|
||||
if (num_in != num_out)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
inname, PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
}
|
||||
fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
|
||||
inname, outname);
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (!num_in)
|
||||
break;
|
||||
|
||||
if (memcmp(inbuf, outbuf, num_in))
|
||||
{
|
||||
fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname);
|
||||
|
||||
if (wrote_question == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
if (wrote_question == 0 && unsupported_chunks == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
inname, PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
}
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
if (strict != 0 && unsupported_chunks == 0)
|
||||
return (1);
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
if (!num_in)
|
||||
break;
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
if (memcmp(inbuf, outbuf, num_in))
|
||||
{
|
||||
fprintf(STDERR, "\nFiles %s and %s are different\n", inname,
|
||||
outname);
|
||||
|
||||
else
|
||||
return (0);
|
||||
if (wrote_question == 0 && unsupported_chunks == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
inname, PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
}
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
|
||||
/* NOTE: the unsupported_chunks escape is permitted here because
|
||||
* unsupported text chunk compression will result in the compression
|
||||
* mode being changed (to NONE) yet, in the test case, the result
|
||||
* can be exactly the same size!
|
||||
*/
|
||||
if (strict != 0 && unsupported_chunks == 0)
|
||||
return (1);
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
@@ -1449,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
|
||||
@@ -1657,6 +1956,16 @@ main(int argc, char *argv[])
|
||||
|
||||
return (int)(ierror != 0);
|
||||
}
|
||||
#else
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" test ignored because libpng was not built with read support\n");
|
||||
/* 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_0beta13 Your_png_h_is_not_version_1_6_0beta13;
|
||||
typedef png_libpng_version_1_6_3 Your_png_h_is_not_version_1_6_3;
|
||||
|
||||
BIN
pngtest.png
BIN
pngtest.png
Binary file not shown.
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
207
pngtrans.c
207
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.)
|
||||
*
|
||||
@@ -122,32 +122,79 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* In libpng 1.6 it is possible to determine whether this is a read or write
|
||||
* operation and therefore to do more checking here for a valid call.
|
||||
*/
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
{
|
||||
# ifdef PNG_READ_FILLER_SUPPORTED
|
||||
/* On read png_set_filler is always valid, regardless of the base PNG
|
||||
* format, because other transformations can give a format where the
|
||||
* filler code can execute (basically an 8 or 16-bit component RGB or G
|
||||
* format.)
|
||||
*
|
||||
* NOTE: usr_channels is not used by the read code! (This has led to
|
||||
* confusion in the past.) The filler is only used in the read code.
|
||||
*/
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
# else
|
||||
png_app_error(png_ptr, "png_set_filler not supported on read");
|
||||
PNG_UNUSED(filler) /* not used in the write case */
|
||||
return;
|
||||
# endif
|
||||
}
|
||||
|
||||
else /* write */
|
||||
{
|
||||
# ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
/* On write the usr_channels parameter must be set correctly at the
|
||||
* start to record the number of channels in the app-supplied data.
|
||||
*/
|
||||
switch (png_ptr->color_type)
|
||||
{
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
png_ptr->usr_channels = 4;
|
||||
break;
|
||||
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
if (png_ptr->bit_depth >= 8)
|
||||
{
|
||||
png_ptr->usr_channels = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* There simply isn't any code in libpng to strip out bits
|
||||
* from bytes when the components are less than a byte in
|
||||
* size!
|
||||
*/
|
||||
png_app_error(png_ptr,
|
||||
"png_set_filler is invalid for low bit depth gray output");
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
png_app_error(png_ptr,
|
||||
"png_set_filler: inappropriate color type");
|
||||
return;
|
||||
}
|
||||
# else
|
||||
png_app_error(png_ptr, "png_set_filler not supported on write");
|
||||
return;
|
||||
# endif
|
||||
}
|
||||
|
||||
/* Here on success - libpng supports the operation, set the transformation
|
||||
* and the flag to say where the filler channel is.
|
||||
*/
|
||||
png_ptr->transformations |= PNG_FILLER;
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
|
||||
if (filler_loc == PNG_FILLER_AFTER)
|
||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
/* This should probably go in the "do_read_filler" routine.
|
||||
* I attempted to do that in libpng-1.0.1a but that caused problems
|
||||
* so I restored it in libpng-1.0.2a
|
||||
*/
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
png_ptr->usr_channels = 4;
|
||||
}
|
||||
|
||||
/* Also I added this in libpng-1.0.2a (what happens when we expand
|
||||
* a less-than-8-bit grayscale to GA?) */
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
|
||||
{
|
||||
png_ptr->usr_channels = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Added to libpng-1.2.7 */
|
||||
@@ -160,7 +207,9 @@ png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
return;
|
||||
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
/* The above may fail to do anything. */
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -619,6 +668,109 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||
/* Added at libpng-1.5.10 */
|
||||
void /* PRIVATE */
|
||||
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
||||
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
|
||||
{
|
||||
/* Calculations moved outside switch in an attempt to stop different
|
||||
* compiler warnings. 'padding' is in *bits* within the last byte, it is
|
||||
* an 'int' because pixel_depth becomes an 'int' in the expression below,
|
||||
* and this calculation is used because it avoids warnings that other
|
||||
* forms produced on either GCC or MSVC.
|
||||
*/
|
||||
int padding = (-row_info->pixel_depth * row_info->width) & 7;
|
||||
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
|
||||
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
/* in this case, all bytes must be 0 so we don't need
|
||||
* to unpack the pixels except for the rightmost one.
|
||||
*/
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if (*rp >> padding != 0)
|
||||
png_ptr->num_palette_max = 1;
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
int i = ((*rp >> padding) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 2) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 4) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 6) & 0x03);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
int i = ((*rp >> padding) & 0x0f);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
i = (((*rp >> padding) >> 4) & 0x0f);
|
||||
|
||||
if (i > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = i;
|
||||
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 8:
|
||||
{
|
||||
for (; rp > png_ptr->row_buf; rp--)
|
||||
{
|
||||
if (*rp > png_ptr->num_palette_max)
|
||||
png_ptr->num_palette_max = (int) *rp;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
@@ -630,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.)
|
||||
*
|
||||
|
||||
441
pngwrite.c
441
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,12 +12,65 @@
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Write out all the unknown chunks for the current given location */
|
||||
static void
|
||||
write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
||||
unsigned int where)
|
||||
{
|
||||
if (info_ptr->unknown_chunks_num)
|
||||
{
|
||||
png_const_unknown_chunkp up;
|
||||
|
||||
png_debug(5, "writing extra chunks");
|
||||
|
||||
for (up = info_ptr->unknown_chunks;
|
||||
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
|
||||
++up)
|
||||
if (up->location & where)
|
||||
{
|
||||
/* If per-chunk unknown chunk handling is enabled use it, otherwise
|
||||
* just write the chunks the application has set.
|
||||
*/
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int keep = png_handle_as_unknown(png_ptr, up->name);
|
||||
|
||||
/* NOTE: this code is radically different from the read side in the
|
||||
* matter of handling an ancillary unknown chunk. In the read side
|
||||
* the default behavior is to discard it, in the code below the default
|
||||
* behavior is to write it. Critical chunks are, however, only
|
||||
* written if explicitly listed or if the default is set to write all
|
||||
* unknown chunks.
|
||||
*
|
||||
* The default handling is also slightly weird - it is not possible to
|
||||
* stop the writing of all unsafe-to-copy chunks!
|
||||
*
|
||||
* TODO: REVIEW: this would seem to be a bug.
|
||||
*/
|
||||
if (keep != PNG_HANDLE_CHUNK_NEVER &&
|
||||
((up->name[3] & 0x20) /* safe-to-copy overrides everything */ ||
|
||||
keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(keep == PNG_HANDLE_CHUNK_AS_DEFAULT &&
|
||||
png_ptr->unknown_default == PNG_HANDLE_CHUNK_ALWAYS)))
|
||||
#endif
|
||||
{
|
||||
/* TODO: review, what is wrong with a zero length unknown chunk? */
|
||||
if (up->size == 0)
|
||||
png_warning(png_ptr, "Writing zero-length unknown chunk");
|
||||
|
||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
|
||||
/* Writes all the PNG information. This is the suggested way to use the
|
||||
* library. If you have a new chunk to add, make a function to write it,
|
||||
* and put it in the correct location here. If you want the chunk written
|
||||
@@ -28,7 +81,7 @@
|
||||
* them in png_write_end(), and compressing them.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_write_info_before_PLTE(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_write_info_before_PLTE");
|
||||
|
||||
@@ -54,75 +107,88 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_inforp info_ptr)
|
||||
info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
|
||||
info_ptr->filter_type,
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
info_ptr->interlace_type);
|
||||
info_ptr->interlace_type
|
||||
#else
|
||||
0);
|
||||
0
|
||||
#endif
|
||||
);
|
||||
|
||||
/* The rest of these check to see if the valid field has the appropriate
|
||||
* flag set, and if it does, writes the chunk.
|
||||
*
|
||||
* 1.6.0: COLORSPACE support controls the writing of these chunks too, and
|
||||
* the chunks will be written if the WRITE routine is there and information
|
||||
* is available in the COLORSPACE. (See png_colorspace_sync_info in png.c
|
||||
* for where the valid flags get set.)
|
||||
*
|
||||
* Under certain circumstances the colorspace can be invalidated without
|
||||
* syncing the info_struct 'valid' flags; this happens if libpng detects and
|
||||
* error and calls png_error while the color space is being set, yet the
|
||||
* application continues writing the PNG. So check the 'invalid' flag here
|
||||
* too.
|
||||
*/
|
||||
#ifdef PNG_WRITE_gAMA_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_gAMA)
|
||||
png_write_gAMA_fixed(png_ptr, info_ptr->gamma);
|
||||
#endif
|
||||
#ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_sRGB)
|
||||
png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent);
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
# ifdef PNG_WRITE_gAMA_SUPPORTED
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) &&
|
||||
(info_ptr->valid & PNG_INFO_gAMA))
|
||||
png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_iCCP_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_iCCP)
|
||||
png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE,
|
||||
(png_charp)info_ptr->iccp_profile, (int)info_ptr->iccp_proflen);
|
||||
#endif
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* Write only one of sRGB or an ICC profile. If a profile was supplied
|
||||
* and it matches one of the known sRGB ones issue a warning.
|
||||
*/
|
||||
# ifdef PNG_WRITE_iCCP_SUPPORTED
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
(info_ptr->valid & PNG_INFO_iCCP))
|
||||
{
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_sRGB)
|
||||
png_app_warning(png_ptr,
|
||||
"profile matches sRGB but writing iCCP instead");
|
||||
# endif
|
||||
|
||||
png_write_iCCP(png_ptr, info_ptr->iccp_name,
|
||||
info_ptr->iccp_profile);
|
||||
}
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
else
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB))
|
||||
png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
|
||||
# endif /* WRITE_sRGB */
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#ifdef PNG_WRITE_sBIT_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_sBIT)
|
||||
png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
|
||||
#endif
|
||||
#ifdef PNG_WRITE_cHRM_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_cHRM)
|
||||
png_write_cHRM_fixed(png_ptr,
|
||||
info_ptr->x_white, info_ptr->y_white,
|
||||
info_ptr->x_red, info_ptr->y_red,
|
||||
info_ptr->x_green, info_ptr->y_green,
|
||||
info_ptr->x_blue, info_ptr->y_blue);
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
# ifdef PNG_WRITE_cHRM_SUPPORTED
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) &&
|
||||
(info_ptr->valid & PNG_INFO_cHRM))
|
||||
png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (info_ptr->unknown_chunks_num)
|
||||
{
|
||||
png_unknown_chunk *up;
|
||||
|
||||
png_debug(5, "writing extra chunks");
|
||||
|
||||
for (up = info_ptr->unknown_chunks;
|
||||
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
|
||||
up++)
|
||||
{
|
||||
int keep = png_handle_as_unknown(png_ptr, up->name);
|
||||
|
||||
if (keep != PNG_HANDLE_CHUNK_NEVER &&
|
||||
up->location &&
|
||||
!(up->location & PNG_HAVE_PLTE) &&
|
||||
!(up->location & PNG_HAVE_IDAT) &&
|
||||
!(up->location & PNG_AFTER_IDAT) &&
|
||||
((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
|
||||
{
|
||||
if (up->size == 0)
|
||||
png_warning(png_ptr, "Writing zero-length unknown chunk");
|
||||
|
||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);
|
||||
#endif
|
||||
|
||||
png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
|
||||
}
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_write_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
int i;
|
||||
@@ -266,29 +332,7 @@ png_write_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#endif /* tEXt */
|
||||
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (info_ptr->unknown_chunks_num)
|
||||
{
|
||||
png_unknown_chunk *up;
|
||||
|
||||
png_debug(5, "writing extra chunks");
|
||||
|
||||
for (up = info_ptr->unknown_chunks;
|
||||
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
|
||||
up++)
|
||||
{
|
||||
int keep = png_handle_as_unknown(png_ptr, up->name);
|
||||
if (keep != PNG_HANDLE_CHUNK_NEVER &&
|
||||
up->location &&
|
||||
(up->location & PNG_HAVE_PLTE) &&
|
||||
!(up->location & PNG_HAVE_IDAT) &&
|
||||
!(up->location & PNG_AFTER_IDAT) &&
|
||||
((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
|
||||
{
|
||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_PLTE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -308,6 +352,11 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
png_error(png_ptr, "No IDATs written into file");
|
||||
|
||||
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
if (png_ptr->num_palette_max > png_ptr->num_palette)
|
||||
png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
|
||||
#endif
|
||||
|
||||
/* See if user wants us to write information chunks */
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
@@ -375,27 +424,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (info_ptr->unknown_chunks_num)
|
||||
{
|
||||
png_unknown_chunk *up;
|
||||
|
||||
png_debug(5, "writing extra chunks");
|
||||
|
||||
for (up = info_ptr->unknown_chunks;
|
||||
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
|
||||
up++)
|
||||
{
|
||||
int keep = png_handle_as_unknown(png_ptr, up->name);
|
||||
if (keep != PNG_HANDLE_CHUNK_NEVER &&
|
||||
up->location &&
|
||||
(up->location & PNG_AFTER_IDAT) &&
|
||||
((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
|
||||
{
|
||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -418,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)
|
||||
{
|
||||
@@ -466,9 +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;
|
||||
|
||||
/* 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 = 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
|
||||
png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
|
||||
/* In stable builds only warn if an application error can be completely
|
||||
* handled.
|
||||
*/
|
||||
#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
|
||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||
#endif
|
||||
|
||||
/* 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.
|
||||
@@ -683,7 +752,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes);
|
||||
|
||||
/* Copy user's row into buffer, leaving room for filter byte. */
|
||||
png_memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
|
||||
memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* Handle interlacing */
|
||||
@@ -731,6 +800,14 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Added at libpng-1.5.10 */
|
||||
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Check for out-of-range palette index */
|
||||
if (row_info.color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
png_ptr->num_palette_max >= 0)
|
||||
png_do_check_palette_indexes(png_ptr, &row_info);
|
||||
#endif
|
||||
|
||||
/* Find a filter if necessary, filter the row and write it out. */
|
||||
png_write_find_filter(png_ptr, &row_info);
|
||||
|
||||
@@ -755,8 +832,6 @@ png_set_flush(png_structrp png_ptr, int nrows)
|
||||
void PNGAPI
|
||||
png_write_flush(png_structrp png_ptr)
|
||||
{
|
||||
int wrote_IDAT;
|
||||
|
||||
png_debug(1, "in png_write_flush");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
@@ -766,46 +841,14 @@ png_write_flush(png_structrp png_ptr)
|
||||
if (png_ptr->row_number >= png_ptr->num_rows)
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Compress the data */
|
||||
ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH);
|
||||
wrote_IDAT = 0;
|
||||
|
||||
/* Check for compression errors */
|
||||
if (ret != Z_OK)
|
||||
{
|
||||
if (png_ptr->zstream.msg != NULL)
|
||||
png_error(png_ptr, png_ptr->zstream.msg);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "zlib error");
|
||||
}
|
||||
|
||||
if (!(png_ptr->zstream.avail_out))
|
||||
{
|
||||
/* Write the IDAT and reset the zlib output buffer */
|
||||
png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
|
||||
wrote_IDAT = 1;
|
||||
}
|
||||
} while (wrote_IDAT == 1);
|
||||
|
||||
/* If there is any data left to be output, write it into a new IDAT */
|
||||
if (png_ptr->zbuf_size != png_ptr->zstream.avail_out)
|
||||
{
|
||||
/* Write the IDAT and reset the zlib output buffer */
|
||||
png_write_IDAT(png_ptr, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
||||
}
|
||||
png_compress_IDAT(png_ptr, NULL, 0, Z_SYNC_FLUSH);
|
||||
png_ptr->flush_rows = 0;
|
||||
png_flush(png_ptr);
|
||||
}
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
static void png_reset_filter_heuristics(png_structrp png_ptr); /* forward decl */
|
||||
static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */
|
||||
#endif
|
||||
|
||||
/* Free any memory used in png_ptr struct without freeing the struct itself. */
|
||||
@@ -815,11 +858,11 @@ png_write_destroy(png_structrp png_ptr)
|
||||
png_debug(1, "in png_write_destroy");
|
||||
|
||||
/* Free any memory zlib uses */
|
||||
if (png_ptr->zlib_state != PNG_ZLIB_UNINITIALIZED)
|
||||
if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
|
||||
deflateEnd(&png_ptr->zstream);
|
||||
|
||||
/* Free our memory. png_free checks NULL for us. */
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
|
||||
png_free(png_ptr, png_ptr->row_buf);
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->prev_row);
|
||||
@@ -836,7 +879,7 @@ png_write_destroy(png_structrp png_ptr)
|
||||
png_free(png_ptr, png_ptr->inv_filter_costs);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
#endif
|
||||
|
||||
@@ -895,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;
|
||||
@@ -917,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 */
|
||||
}
|
||||
|
||||
@@ -1063,7 +1107,7 @@ png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
||||
if (num_weights > 0)
|
||||
{
|
||||
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(png_sizeof(png_byte) * num_weights));
|
||||
(png_uint_32)((sizeof (png_byte)) * num_weights));
|
||||
|
||||
/* To make sure that the weighting starts out fairly */
|
||||
for (i = 0; i < num_weights; i++)
|
||||
@@ -1072,10 +1116,10 @@ png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
||||
}
|
||||
|
||||
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(png_sizeof(png_uint_16) * num_weights));
|
||||
(png_uint_32)((sizeof (png_uint_16)) * num_weights));
|
||||
|
||||
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(png_sizeof(png_uint_16) * num_weights));
|
||||
(png_uint_32)((sizeof (png_uint_16)) * num_weights));
|
||||
|
||||
for (i = 0; i < num_weights; i++)
|
||||
{
|
||||
@@ -1093,10 +1137,10 @@ png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
||||
if (png_ptr->filter_costs == NULL)
|
||||
{
|
||||
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
|
||||
(png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
|
||||
|
||||
png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
|
||||
(png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
|
||||
}
|
||||
|
||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
||||
@@ -1254,7 +1298,6 @@ png_set_compression_level(png_structrp png_ptr, int level)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL;
|
||||
png_ptr->zlib_level = level;
|
||||
}
|
||||
|
||||
@@ -1266,7 +1309,6 @@ png_set_compression_mem_level(png_structrp png_ptr, int mem_level)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL;
|
||||
png_ptr->zlib_mem_level = mem_level;
|
||||
}
|
||||
|
||||
@@ -1278,6 +1320,8 @@ png_set_compression_strategy(png_structrp png_ptr, int strategy)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* The flag setting here prevents the libpng dynamic selection of strategy.
|
||||
*/
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
|
||||
png_ptr->zlib_strategy = strategy;
|
||||
}
|
||||
@@ -1291,22 +1335,24 @@ png_set_compression_window_bits(png_structrp png_ptr, int window_bits)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Prior to 1.6.0 this would warn but then set the window_bits value, this
|
||||
* meant that negative window bits values could be selected which would cause
|
||||
* libpng to write a non-standard PNG file with raw deflate or gzip
|
||||
* compressed IDAT or ancillary chunks. Such files can be read and there is
|
||||
* no warning on read, so this seems like a very bad idea.
|
||||
*/
|
||||
if (window_bits > 15)
|
||||
{
|
||||
png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
|
||||
window_bits = 15;
|
||||
}
|
||||
|
||||
else if (window_bits < 8)
|
||||
{
|
||||
png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
|
||||
window_bits = 8;
|
||||
}
|
||||
|
||||
#ifndef WBITS_8_OK
|
||||
/* Avoid libpng bug with 256-byte windows */
|
||||
if (window_bits == 8)
|
||||
{
|
||||
png_warning(png_ptr, "Compression window is being reset to 512");
|
||||
window_bits = 9;
|
||||
}
|
||||
|
||||
#endif
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS;
|
||||
png_ptr->zlib_window_bits = window_bits;
|
||||
}
|
||||
|
||||
@@ -1318,10 +1364,12 @@ png_set_compression_method(png_structrp png_ptr, int method)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* This would produce an invalid PNG file if it worked, but it doesn't and
|
||||
* deflate will fault it, so it is harmless to just warn here.
|
||||
*/
|
||||
if (method != 8)
|
||||
png_warning(png_ptr, "Only compression method 8 is supported by PNG");
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD;
|
||||
png_ptr->zlib_method = method;
|
||||
}
|
||||
|
||||
@@ -1335,7 +1383,6 @@ png_set_text_compression_level(png_structrp png_ptr, int level)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_LEVEL;
|
||||
png_ptr->zlib_text_level = level;
|
||||
}
|
||||
|
||||
@@ -1347,7 +1394,6 @@ png_set_text_compression_mem_level(png_structrp png_ptr, int mem_level)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL;
|
||||
png_ptr->zlib_text_mem_level = mem_level;
|
||||
}
|
||||
|
||||
@@ -1359,7 +1405,6 @@ png_set_text_compression_strategy(png_structrp png_ptr, int strategy)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_STRATEGY;
|
||||
png_ptr->zlib_text_strategy = strategy;
|
||||
}
|
||||
|
||||
@@ -1373,21 +1418,17 @@ png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits)
|
||||
return;
|
||||
|
||||
if (window_bits > 15)
|
||||
{
|
||||
png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
|
||||
window_bits = 15;
|
||||
}
|
||||
|
||||
else if (window_bits < 8)
|
||||
{
|
||||
png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
|
||||
window_bits = 8;
|
||||
}
|
||||
|
||||
#ifndef WBITS_8_OK
|
||||
/* Avoid libpng bug with 256-byte windows */
|
||||
if (window_bits == 8)
|
||||
{
|
||||
png_warning(png_ptr, "Text compression window is being reset to 512");
|
||||
window_bits = 9;
|
||||
}
|
||||
|
||||
#endif
|
||||
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS;
|
||||
png_ptr->zlib_text_window_bits = window_bits;
|
||||
}
|
||||
|
||||
@@ -1402,7 +1443,6 @@ png_set_text_compression_method(png_structrp png_ptr, int method)
|
||||
if (method != 8)
|
||||
png_warning(png_ptr, "Only compression method 8 is supported by PNG");
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_METHOD;
|
||||
png_ptr->zlib_text_method = method;
|
||||
}
|
||||
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
|
||||
@@ -1537,11 +1577,11 @@ png_image_write_init(png_imagep image)
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
png_controlp control = png_voidcast(png_controlp,
|
||||
png_malloc_warn(png_ptr, sizeof *control));
|
||||
png_malloc_warn(png_ptr, (sizeof *control)));
|
||||
|
||||
if (control != NULL)
|
||||
{
|
||||
png_memset(control, 0, sizeof *control);
|
||||
memset(control, 0, (sizeof *control));
|
||||
|
||||
control->png_ptr = png_ptr;
|
||||
control->info_ptr = info_ptr;
|
||||
@@ -1558,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: */
|
||||
@@ -1592,7 +1632,7 @@ png_write_image_16bit(png_voidp argument)
|
||||
display->first_row);
|
||||
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
|
||||
png_uint_16p row_end;
|
||||
int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
|
||||
int aindex = 0;
|
||||
png_uint_32 y = image->height;
|
||||
|
||||
@@ -1625,7 +1665,7 @@ png_write_image_16bit(png_voidp argument)
|
||||
|
||||
while (out_ptr < row_end)
|
||||
{
|
||||
png_uint_16 alpha = in_ptr[aindex];
|
||||
const png_uint_16 alpha = in_ptr[aindex];
|
||||
png_uint_32 reciprocal = 0;
|
||||
int c;
|
||||
|
||||
@@ -1747,7 +1787,7 @@ png_write_image_8bit(png_voidp argument)
|
||||
display->first_row);
|
||||
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
|
||||
png_uint_32 y = image->height;
|
||||
int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
|
||||
|
||||
if (image->format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
@@ -1772,7 +1812,7 @@ png_write_image_8bit(png_voidp argument)
|
||||
png_const_uint_16p in_ptr = input_row;
|
||||
png_bytep out_ptr = output_row;
|
||||
|
||||
if (aindex != 0) while (out_ptr < row_end) /* Alpha channel case */
|
||||
while (out_ptr < row_end)
|
||||
{
|
||||
png_uint_16 alpha = in_ptr[aindex];
|
||||
png_byte alphabyte = (png_byte)PNG_DIV257(alpha);
|
||||
@@ -1858,8 +1898,8 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
png_color palette[256];
|
||||
png_byte tRNS[256];
|
||||
|
||||
memset(tRNS, 255, sizeof tRNS);
|
||||
memset(palette, 0, sizeof palette);
|
||||
memset(tRNS, 255, (sizeof tRNS));
|
||||
memset(palette, 0, (sizeof palette));
|
||||
|
||||
for (i=num_trans=0; i<entries; ++i)
|
||||
{
|
||||
@@ -1869,7 +1909,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
if (format & PNG_FORMAT_FLAG_LINEAR)
|
||||
{
|
||||
png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);
|
||||
|
||||
|
||||
entry += i * channels;
|
||||
|
||||
if (channels & 1) /* no alpha */
|
||||
@@ -1925,7 +1965,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
else /* Color-map has sRGB values */
|
||||
{
|
||||
png_const_bytep entry = png_voidcast(png_const_bytep, cmap);
|
||||
|
||||
|
||||
entry += i * channels;
|
||||
|
||||
switch (channels)
|
||||
@@ -1989,6 +2029,11 @@ png_image_write_main(png_voidp argument)
|
||||
int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
int write_16bit = linear && !colormap && !display->convert_to_8bit;
|
||||
|
||||
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
/* Make sure we error out on any bad situation */
|
||||
png_set_benign_errors(png_ptr, 0/*error*/);
|
||||
# endif
|
||||
|
||||
/* Default the 'row_stride' parameter if required. */
|
||||
if (display->row_stride == 0)
|
||||
display->row_stride = PNG_IMAGE_ROW_STRIDE(*image);
|
||||
@@ -2100,7 +2145,7 @@ png_image_write_main(png_voidp argument)
|
||||
ptrdiff_t row_bytes = display->row_stride;
|
||||
|
||||
if (linear)
|
||||
row_bytes *= sizeof (png_uint_16);
|
||||
row_bytes *= (sizeof (png_uint_16));
|
||||
|
||||
if (row_bytes < 0)
|
||||
row += (image->height-1) * (-row_bytes);
|
||||
@@ -2109,6 +2154,18 @@ png_image_write_main(png_voidp argument)
|
||||
display->row_bytes = row_bytes;
|
||||
}
|
||||
|
||||
/* Apply 'fast' options if the flag is set. */
|
||||
if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0)
|
||||
{
|
||||
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS);
|
||||
/* NOTE: determined by experiment using pngstest, this reflects some
|
||||
* balance between the time to write the image once and the time to read
|
||||
* it about 50 times. The speed-up in pngstest was about 10-20% of the
|
||||
* total (user) time on a heavily loaded system.
|
||||
*/
|
||||
png_set_compression_level(png_ptr, 3);
|
||||
}
|
||||
|
||||
/* Check for the cases that currently require a pre-transform on the row
|
||||
* before it is written. This only applies when the input is 16-bit and
|
||||
* either there is an alpha channel or it is converted to 8-bit.
|
||||
@@ -2158,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)
|
||||
{
|
||||
@@ -2173,7 +2230,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||
*/
|
||||
image->opaque->png_ptr->io_ptr = file;
|
||||
|
||||
png_memset(&display, 0, sizeof display);
|
||||
memset(&display, 0, (sizeof display));
|
||||
display.image = image;
|
||||
display.buffer = buffer;
|
||||
display.row_stride = row_stride;
|
||||
@@ -2194,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;
|
||||
}
|
||||
@@ -2204,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)
|
||||
{
|
||||
@@ -2257,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.)
|
||||
*
|
||||
|
||||
1749
pngwutil.c
1749
pngwutil.c
File diff suppressed because it is too large
Load Diff
@@ -21,8 +21,8 @@ MCommand
|
||||
0
|
||||
5
|
||||
MCommand
|
||||
1109
|
||||
pngstest --log ../../contrib/pngsuite/basn0g01.png ../../contrib/pngsuite/basn0g02.png ../../contrib/pngsuite/basn0g04.png ../../contrib/pngsuite/basn0g08.png ../../contrib/pngsuite/basn0g16.png ../../contrib/pngsuite/basn2c08.png ../../contrib/pngsuite/basn2c16.png ../../contrib/pngsuite/basn3p01.png ../../contrib/pngsuite/basn3p02.png ../../contrib/pngsuite/basn3p04.png ../../contrib/pngsuite/basn3p08.png ../../contrib/pngsuite/basn4a08.png ../../contrib/pngsuite/basn4a16.png ../../contrib/pngsuite/basn6a08.png ../../contrib/pngsuite/basn6a16.png ../../contrib/pngsuite/ftbbn0g04.png ../../contrib/pngsuite/ftbbn0g01.png ../../contrib/pngsuite/ftbbn0g02.png ../../contrib/pngsuite/ftbbn2c16.png ../../contrib/pngsuite/ftbbn3p08.png ../../contrib/pngsuite/ftbgn2c16.png ../../contrib/pngsuite/ftbgn3p08.png ../../contrib/pngsuite/ftbrn2c08.png ../../contrib/pngsuite/ftbwn0g16.png ../../contrib/pngsuite/ftbwn3p08.png ../../contrib/pngsuite/ftbyn3p08.png ../../contrib/pngsuite/ftp0n0g08.png ../../contrib/pngsuite/ftp0n2c08.png ../../contrib/pngsuite/ftp0n3p08.png ../../contrib/pngsuite/ftp1n3p08.png
|
||||
1118
|
||||
pngstest --strict --log ../../contrib/pngsuite/basn0g01.png ../../contrib/pngsuite/basn0g02.png ../../contrib/pngsuite/basn0g04.png ../../contrib/pngsuite/basn0g08.png ../../contrib/pngsuite/basn0g16.png ../../contrib/pngsuite/basn2c08.png ../../contrib/pngsuite/basn2c16.png ../../contrib/pngsuite/basn3p01.png ../../contrib/pngsuite/basn3p02.png ../../contrib/pngsuite/basn3p04.png ../../contrib/pngsuite/basn3p08.png ../../contrib/pngsuite/basn4a08.png ../../contrib/pngsuite/basn4a16.png ../../contrib/pngsuite/basn6a08.png ../../contrib/pngsuite/basn6a16.png ../../contrib/pngsuite/ftbbn0g04.png ../../contrib/pngsuite/ftbbn0g01.png ../../contrib/pngsuite/ftbbn0g02.png ../../contrib/pngsuite/ftbbn2c16.png ../../contrib/pngsuite/ftbbn3p08.png ../../contrib/pngsuite/ftbgn2c16.png ../../contrib/pngsuite/ftbgn3p08.png ../../contrib/pngsuite/ftbrn2c08.png ../../contrib/pngsuite/ftbwn0g16.png ../../contrib/pngsuite/ftbwn3p08.png ../../contrib/pngsuite/ftbyn3p08.png ../../contrib/pngsuite/ftp0n0g08.png ../../contrib/pngsuite/ftp0n2c08.png ../../contrib/pngsuite/ftp0n3p08.png ../../contrib/pngsuite/ftp1n3p08.png
|
||||
6
|
||||
MItem
|
||||
12
|
||||
|
||||
27
projects/vstudio/WARNING
Normal file
27
projects/vstudio/WARNING
Normal file
@@ -0,0 +1,27 @@
|
||||
WARNING
|
||||
=======
|
||||
Libpng 1.6 does not use the default run-time library when building static
|
||||
library builds of libpng; instead of the shared DLL runtime it uses a static
|
||||
runtime. If you need to change this make sure to change the setting on all the
|
||||
relevant projects:
|
||||
|
||||
libpng
|
||||
zlib
|
||||
all the test programs
|
||||
|
||||
The runtime library settings for each build are as follows:
|
||||
|
||||
Release Debug
|
||||
DLL /MD /MDd
|
||||
Library /MT /MTd
|
||||
|
||||
NOTICE that libpng 1.5 erroneously used /MD for Debug DLL builds; if you used
|
||||
the debug builds in your app and you changed your app to use /MD you will need
|
||||
to change it to /MDd for libpng 1.6.
|
||||
|
||||
The Visual Studio 2010 defaults for a Win32 DLL or Static Library project are
|
||||
as follows:
|
||||
|
||||
Release Debug
|
||||
DLL /MD /MDd
|
||||
Static Library /MD /MDd
|
||||
@@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>libpng</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
@@ -101,6 +101,7 @@
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}</ProjectGuid>
|
||||
<ProjectGuid>{277AC57F-313B-4D06-B119-A3CDB672D2FF}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngstest</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
@@ -91,16 +91,17 @@
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Command>"$(OutDir)pngstest.exe" --strict --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
@@ -133,7 +134,7 @@
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Command>"$(OutDir)pngstest.exe" --strict --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
@@ -162,13 +163,13 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Command>"$(OutDir)pngstest.exe" --strict --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
@@ -204,7 +205,7 @@
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
<Message>Executing libpng simplified API test program</Message>
|
||||
<Command>"$(OutDir)pngstest.exe" --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Command>"$(OutDir)pngstest.exe" --strict --log --touch "$(IntDir)pngstest.out" ../../../contrib/pngsuite/basn0g01.png ../../../contrib/pngsuite/basn0g02.png ../../../contrib/pngsuite/basn0g04.png ../../../contrib/pngsuite/basn0g08.png ../../../contrib/pngsuite/basn0g16.png ../../../contrib/pngsuite/basn2c08.png ../../../contrib/pngsuite/basn2c16.png ../../../contrib/pngsuite/basn3p01.png ../../../contrib/pngsuite/basn3p02.png ../../../contrib/pngsuite/basn3p04.png ../../../contrib/pngsuite/basn3p08.png ../../../contrib/pngsuite/basn4a08.png ../../../contrib/pngsuite/basn4a16.png ../../../contrib/pngsuite/basn6a08.png ../../../contrib/pngsuite/basn6a16.png ../../../contrib/pngsuite/ftbbn0g01.png ../../../contrib/pngsuite/ftbbn0g02.png ../../../contrib/pngsuite/ftbbn0g04.png ../../../contrib/pngsuite/ftbbn2c16.png ../../../contrib/pngsuite/ftbbn3p08.png ../../../contrib/pngsuite/ftbgn2c16.png ../../../contrib/pngsuite/ftbgn3p08.png ../../../contrib/pngsuite/ftbrn2c08.png ../../../contrib/pngsuite/ftbwn0g16.png ../../../contrib/pngsuite/ftbwn3p08.png ../../../contrib/pngsuite/ftbyn3p08.png ../../../contrib/pngsuite/ftp0n0g08.png ../../../contrib/pngsuite/ftp0n2c08.png ../../../contrib/pngsuite/ftp0n3p08.png ../../../contrib/pngsuite/ftp1n3p08.png</Command>
|
||||
<Outputs>$(IntDir)pngstest.out</Outputs>
|
||||
<Inputs>$(OutDir)pngstest.exe</Inputs>
|
||||
</CustomBuildStep>
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngtest</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
@@ -91,6 +91,7 @@
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
||||
219
projects/vstudio/pngunknown/pngunknown.vcxproj
Normal file
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.0beta13 - February 24, 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.0beta13 - February 24, 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.0beta13 - February 24, 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.0beta13)
|
||||
(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.0beta13)
|
||||
(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.0beta13)
|
||||
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.0beta13)
|
||||
creates libpng16.so.16.1.6.3)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng16.so.16.1.6.0beta13)
|
||||
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"
|
||||
|
||||
@@ -33,20 +33,20 @@ clean :
|
||||
|
||||
|
||||
# Other dependencies.
|
||||
png.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngpread.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngset.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngget.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngread.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrtran.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrutil.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngerror.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngmem.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrio.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwio.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngtrans.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwrite.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwtran.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwutil.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
png.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngpread.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngset.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngget.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngread.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrtran.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrutil.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngerror.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngmem.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngrio.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwio.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngtrans.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwrite.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwtran.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
pngwutil.obj : png.h, pngconf.h, pnglibconf.h, pngpriv.h, pngstruct.h, pnginfo.h, pngdebug.h
|
||||
|
||||
pngtest.obj : png.h, pngconf.h
|
||||
|
||||
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.0beta13
|
||||
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.0beta13
|
||||
Version: 1.6.3
|
||||
Libs: -L${libdir} -lpng16
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -222,20 +222,20 @@ writelock:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
|
||||
@@ -222,20 +222,20 @@ writelock:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
|
||||
@@ -102,20 +102,20 @@ install: $(LIBNAME)$(A)
|
||||
clean:
|
||||
$(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png pnglibconf.h
|
||||
|
||||
png$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest$(O): png.h pngconf.h pnglibconf.h
|
||||
|
||||
@@ -114,21 +114,21 @@ test: pngtest.exe
|
||||
pnglibconf.h: scripts\pnglibconf.h.prebuilt
|
||||
copy scripts\pnglibconf.h.prebuilt $@
|
||||
|
||||
png.obj: png.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.obj: pngerror.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.obj: pngget.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.obj: pngmem.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.obj: pngpread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.obj: pngread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.obj: pngrio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.obj: pngrtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.obj: pngrutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.obj: pngset.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.obj: pngtrans.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.obj: pngwio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.obj: pngwrite.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.obj: pngwtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.obj: pngwutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png.obj: png.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.obj: pngerror.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.obj: pngget.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.obj: pngmem.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.obj: pngpread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.obj: pngread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.obj: pngrio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.obj: pngrtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.obj: pngrutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.obj: pngset.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.obj: pngtrans.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.obj: pngwio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.obj: pngwrite.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.obj: pngwtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.obj: pngwutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtest.obj: pngtest.c png.h pngconf.h pnglibconf.h
|
||||
|
||||
$(LIBNAME): $(OBJS)
|
||||
|
||||
@@ -196,20 +196,20 @@ clean:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
|
||||
@@ -121,21 +121,21 @@ test: pngtest$(MODEL).exe
|
||||
|
||||
## Minor Targets
|
||||
|
||||
png.obj: png.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.obj: pngerror.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.obj: pngget.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.obj: pngmem.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.obj: pngpread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.obj: pngread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.obj: pngrio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.obj: pngrtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.obj: pngrutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.obj: pngset.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.obj: pngtrans.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.obj: pngwio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.obj: pngwrite.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.obj: pngwtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.obj: pngwutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png.obj: png.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.obj: pngerror.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.obj: pngget.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.obj: pngmem.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.obj: pngpread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.obj: pngread.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.obj: pngrio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.obj: pngrtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.obj: pngrutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.obj: pngset.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.obj: pngtrans.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.obj: pngwio.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.obj: pngwrite.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.obj: pngwtran.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.obj: pngwutil.c png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
$(LIBNAME): $(OBJS)
|
||||
-del $(LIBNAME)
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
|
||||
VERMAJ = 1
|
||||
VERMIN = 6
|
||||
VERMIC = 0
|
||||
VERMIC = 3
|
||||
VER = $(VERMAJ).$(VERMIN).$(VERMIC)
|
||||
NAME = libpng
|
||||
PACKAGE = $(NAME)-$(VER)
|
||||
|
||||
BIN = libpng16-0.dll
|
||||
LIB = libpng16.a libpng16.dll.a libpng.a libpng.dll.a
|
||||
INCLUDE = png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
INCLUDE = png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
PC = libpng16.pc libpng.pc
|
||||
|
||||
MANIFESTVERBIN = "Libpng-$(VER): Binary files"
|
||||
|
||||
@@ -15,10 +15,8 @@ prefix=/usr/local
|
||||
exec_prefix=$(prefix)
|
||||
|
||||
# Where the zlib library and include files are located
|
||||
#ZLIBLIB=/usr/local/lib
|
||||
#ZLIBINC=/usr/local/include
|
||||
ZLIBLIB=../zlib
|
||||
ZLIBINC=../zlib
|
||||
ZLIBLIB=/usr/lib
|
||||
ZLIBINC=/usr/include
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
@@ -37,7 +35,7 @@ MKDIR_P=mkdir -p
|
||||
LN_SF=ln -sf
|
||||
RANLIB=ranlib
|
||||
RM_F=/bin/rm -f
|
||||
ARCH="-arch i386 -arch x86_64"
|
||||
ARCH=-arch ppc -arch i386 -arch x86_64
|
||||
|
||||
# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops
|
||||
CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops $(ARCH)
|
||||
@@ -107,7 +105,7 @@ $(LIBSOMAJ): $(OBJSDLL)
|
||||
$(CC) -dynamiclib \
|
||||
-install_name $(LIBPATH)/$(LIBSOMAJ) \
|
||||
-current_version 16 -compatibility_version 16 \
|
||||
-o $(LIBSOMAJ) \
|
||||
$(ARCH) -o $(LIBSOMAJ) \
|
||||
$(OBJSDLL) -L$(ZLIBLIB) -lz
|
||||
|
||||
pngtest: pngtest.o $(LIBSO)
|
||||
@@ -136,10 +134,10 @@ install-static: install-headers libpng.a
|
||||
install-shared: install-headers $(LIBSOMAJ) libpng.pc
|
||||
-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
|
||||
-@$(RM_F) $(DL)/$(LIBSO)
|
||||
-@$(RM_F) $(DL)/$(LIBSOREL)
|
||||
-@$(RM_F) $(DL)/$(LIBSOMAJ)
|
||||
-@$(RM_F) $(DL)/$(OLDSO)
|
||||
cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
|
||||
chmod 755 $(DL)/$(LIBSOREL)
|
||||
cp $(LIBSOMAJ) $(DL)
|
||||
chmod 755 $(DL)/$(LIBSOMAJ)
|
||||
(cd $(DL); \
|
||||
$(LN_SF) $(LIBSOREL) $(LIBSO); \
|
||||
$(LN_SF) $(LIBSO) $(OLDSO))
|
||||
@@ -201,20 +199,20 @@ writelock:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
|
||||
@@ -183,20 +183,20 @@ clean:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user