mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
150 Commits
v1.7.0beta
...
v1.7.0beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
755f92fc41 | ||
|
|
d9d1c997d8 | ||
|
|
aeb4a22975 | ||
|
|
9c0b5ab848 | ||
|
|
05dcaffd38 | ||
|
|
cca25b182f | ||
|
|
f87df31c8c | ||
|
|
41547820e8 | ||
|
|
e5d462d829 | ||
|
|
6f46730cb7 | ||
|
|
67b88b8ee0 | ||
|
|
7a4bfbdec1 | ||
|
|
859254054a | ||
|
|
515659d638 | ||
|
|
fd409c8019 | ||
|
|
9ee6678e1f | ||
|
|
9b36280e31 | ||
|
|
eaad9f9177 | ||
|
|
70cd1a10f2 | ||
|
|
7974d60f54 | ||
|
|
c7e743d385 | ||
|
|
b2e89f1af6 | ||
|
|
ad30a1262b | ||
|
|
35f88c1341 | ||
|
|
4f8050416f | ||
|
|
776d1768aa | ||
|
|
d7078c52e2 | ||
|
|
4a67ac3f1e | ||
|
|
2799bf9a4f | ||
|
|
34e49ae1bc | ||
|
|
cea01951da | ||
|
|
1a9c06b11a | ||
|
|
f3b1eb68a6 | ||
|
|
12845bc947 | ||
|
|
3ac960f128 | ||
|
|
eb2b0248e2 | ||
|
|
e529698d38 | ||
|
|
1a9e897289 | ||
|
|
3a81956ffe | ||
|
|
0acf4f9770 | ||
|
|
b407af6503 | ||
|
|
0fb41f05df | ||
|
|
8ebdaa0700 | ||
|
|
4e61b58980 | ||
|
|
88e7d62fbc | ||
|
|
43cd0a0bb5 | ||
|
|
1345c5bff8 | ||
|
|
39c420834f | ||
|
|
f898f69f46 | ||
|
|
352f43cdc6 | ||
|
|
f99393490d | ||
|
|
deb920b4a7 | ||
|
|
148cdac18f | ||
|
|
51ecc14a8a | ||
|
|
713a20c57d | ||
|
|
4526f546ba | ||
|
|
0c5acfa19e | ||
|
|
848eeacb41 | ||
|
|
2ced844b0e | ||
|
|
e2c5ed8d1d | ||
|
|
76004ce6ed | ||
|
|
258b986917 | ||
|
|
50a09830b8 | ||
|
|
9a3f244085 | ||
|
|
fb1305faeb | ||
|
|
3d7f3bbab7 | ||
|
|
2d032e966d | ||
|
|
8dd3784f7c | ||
|
|
98b9371115 | ||
|
|
d29413a2a9 | ||
|
|
dc63b03da1 | ||
|
|
cf354c2c82 | ||
|
|
484dad1a19 | ||
|
|
1695471118 | ||
|
|
ae14dcd404 | ||
|
|
302c58b8cf | ||
|
|
39fee3cee1 | ||
|
|
b7362c6738 | ||
|
|
f2d8561fdc | ||
|
|
1bd81ffa21 | ||
|
|
6d2b1a7dbc | ||
|
|
5daa97c2eb | ||
|
|
9e441e96b9 | ||
|
|
a0d314ce84 | ||
|
|
b871b25997 | ||
|
|
d38ebc9ded | ||
|
|
995402ca6e | ||
|
|
1982968dad | ||
|
|
32cd66d619 | ||
|
|
03a53fa429 | ||
|
|
441de8f4fd | ||
|
|
4e5c80034e | ||
|
|
879d63156a | ||
|
|
eb021245d0 | ||
|
|
6607a3b905 | ||
|
|
28711dff2a | ||
|
|
4413d5dcd2 | ||
|
|
206d1eed42 | ||
|
|
114fa16ab3 | ||
|
|
eb2af04bd3 | ||
|
|
200fc68f52 | ||
|
|
4cfd01a288 | ||
|
|
e98229ceb0 | ||
|
|
ad1a4c8cc3 | ||
|
|
8df7c46e5b | ||
|
|
99078ec8bd | ||
|
|
a2c5f56e77 | ||
|
|
9e168ea2c9 | ||
|
|
06be739941 | ||
|
|
448092b8eb | ||
|
|
1faa6ff32c | ||
|
|
3adf438f39 | ||
|
|
d45a632529 | ||
|
|
5a1b8d106d | ||
|
|
05f896004f | ||
|
|
a4f1de9109 | ||
|
|
7ebb353944 | ||
|
|
b1f0c7d0e5 | ||
|
|
55df049962 | ||
|
|
219ba1370e | ||
|
|
4dc4471bb5 | ||
|
|
a199a15b28 | ||
|
|
e9446f2f95 | ||
|
|
f70f2fcf48 | ||
|
|
158c947ce2 | ||
|
|
7e2707e2af | ||
|
|
81824079b5 | ||
|
|
e8e1add0a8 | ||
|
|
a549223f91 | ||
|
|
ebe7945b96 | ||
|
|
e3e35aa980 | ||
|
|
9f2fbcf5d8 | ||
|
|
264ba68afe | ||
|
|
3ef99c9316 | ||
|
|
4b29f97f9b | ||
|
|
fe6e6cf130 | ||
|
|
547df4b9ca | ||
|
|
a0d4a0b971 | ||
|
|
72c2577302 | ||
|
|
091fab713c | ||
|
|
32aeb2cd4e | ||
|
|
c1bcdc3a86 | ||
|
|
553b8f85d3 | ||
|
|
30666a6097 | ||
|
|
0bfa63cd0d | ||
|
|
b37a7c6674 | ||
|
|
7657ac14f2 | ||
|
|
d9f60caf72 | ||
|
|
88c20ada06 | ||
|
|
f3bfc4a142 |
308
ANNOUNCE
308
ANNOUNCE
@@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.7.0beta18 - September 16, 2013
|
||||
Libpng 1.7.0beta41 - November 7, 2014
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
@@ -9,20 +9,20 @@ Files available for download:
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
1.7.0beta18.tar.xz (LZMA-compressed, recommended)
|
||||
1.7.0beta18.tar.gz
|
||||
1.7.0beta41.tar.xz (LZMA-compressed, recommended)
|
||||
1.7.0beta41.tar.gz
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
lp170b18.7z (LZMA-compressed, recommended)
|
||||
lp170b18.zip
|
||||
lp170b41.7z (LZMA-compressed, recommended)
|
||||
lp170b41.zip
|
||||
|
||||
Other information:
|
||||
|
||||
1.7.0beta18-README.txt
|
||||
1.7.0beta18-LICENSE.txt
|
||||
Gnupg/*.asc (PGP armored detached signatures)
|
||||
1.7.0beta41-README.txt
|
||||
1.7.0beta41-LICENSE.txt
|
||||
libpng-1.7.0beta41-*.asc (armored detached GPG signatures)
|
||||
|
||||
Changes since the last public release (1.6.0):
|
||||
|
||||
@@ -112,7 +112,9 @@ Version 1.7.0alpha07 [January 10, 2013]
|
||||
programs to generate and test a PNG which should have the problem.
|
||||
|
||||
Version 1.7.0alpha08 [January 17, 2013]
|
||||
Corrected previous attempt at overflow detection in png_set_unknown_chunks().
|
||||
Corrected previous attempt at overflow detection in png_set_unknown_chunks()
|
||||
(CVE-2013-7353). Added overflow detection in png_set_sPLT() and
|
||||
png_set_text_2() (CVE-2013-7354).
|
||||
|
||||
Version 1.7.0alpha09 [January 21, 2013]
|
||||
Pulled changes to multi-chunk handling from libpng-1.6.0beta40.
|
||||
@@ -357,6 +359,294 @@ Version 1.7.0beta18 [September 16, 2013]
|
||||
prototype, definition, and usage. Made it depend on
|
||||
PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere.
|
||||
|
||||
Version 1.7.0beta19 [September 30, 2013]
|
||||
Reverted the change to unknown handling #defines; the change breaks 'NOREAD'
|
||||
builds.
|
||||
Fixed default behavior of ARM_NEON_API. If the ARM NEON API option is
|
||||
compiled without the CHECK option it defaulted to on, not off.
|
||||
Catch up with recent libpng16 changes; unknown handling and spelling
|
||||
corrections
|
||||
Avoid up-cast warnings in pngvalid.c. On ARM the alignment requirements of
|
||||
png_modifier are greater than that of png_store and as a consequence
|
||||
compilation of pngvalid.c results in a warning about increased alignment
|
||||
requirements because of the bare cast to (png_modifier*). The code is
|
||||
safe, because the pointer is known to point to a stack allocated
|
||||
png_modifier, but this change avoids the warning.
|
||||
Fixed some grammatical changes and updated the png chunks list.
|
||||
|
||||
Version 1.7.0beta20 [October 13, 2013]
|
||||
Made changes for compatibility with automake 1.14:
|
||||
1) Added the 'compile' program to the list of programs that must be cleaned
|
||||
in autogen.sh
|
||||
2) Added 'subdir-objects' which causes .c files in sub-directories to be
|
||||
compiled such that the corresponding .o files are also in the
|
||||
sub-directory. This is because automake 1.14 warns that the
|
||||
current behavior of compiling to the top level directory may be removed
|
||||
in the future.
|
||||
3) Updated dependencies on pnglibconf.h to match the new .o locations and
|
||||
added all the files in contrib/libtests and contrib/tools that depend
|
||||
on pnglibconf.h
|
||||
4) Added 'BUILD_SOURCES = pnglibconf.h'; this is the automake recommended
|
||||
way of handling the dependencies of sources that are machine generated;
|
||||
unfortunately it only works if the user does 'make all' or 'make check',
|
||||
so the dependencies (3) are still required.
|
||||
Cleaned up (char*) casts of zlib messages. The latest version of the Intel C
|
||||
compiler complains about casting a string literal as (char*), so copied the
|
||||
treatment of z_const from the library code into pngfix.c
|
||||
Simplified error message code in pngunknown. The simplification has the
|
||||
useful side effect of avoiding a bogus warning generated by the latest
|
||||
version of the Intel C compiler (it objects to
|
||||
condition ? string-literal : string-literal).
|
||||
Make autogen.sh work with automake 1.13 as well as 1.14. Do this by always
|
||||
removing the 1.14 'compile' script but never checking for it.
|
||||
|
||||
Version 1.7.0beta21 [November 2, 2013]
|
||||
Added ARMv8 support (James Yu <james.yu at linaro.org>). Added file
|
||||
arm/filter_neon_intrinsics.c; enable with -mfpu=neon.
|
||||
Revised pngvalid to generate size images with as many filters as it can
|
||||
manage, limited by the number of rows.
|
||||
Cleaned up ARM NEON compilation handling. The tests are now in pngpriv.h
|
||||
and detect the broken GCC compilers.
|
||||
Allow clang derived from older GCC versions to use ARM intrinsics. This
|
||||
causes all clang builds that use -mfpu=neon to use the intrinsics code,
|
||||
not the assembler code. This has only been tested on iOS 7. It may be
|
||||
necessary to exclude some earlier clang versions but this seems unlikely.
|
||||
Changed NEON implementation selection mechanism. This allows assembler
|
||||
or intrinsics to be turned on at compile time during the build by defining
|
||||
PNG_ARM_NEON_IMPLEMENTATION to the correct value (2 or 1). This macro
|
||||
is undefined by default and the build type is selected in pngpriv.h.
|
||||
|
||||
Version 1.7.0beta22 [November 7, 2013]
|
||||
Fixed #include in filter_neon_intrinsics.c and ctype macros. The ctype char
|
||||
checking macros take an unsigned char argument, not a signed char.
|
||||
|
||||
Version 1.7.0beta23 [November 24, 2013]
|
||||
Changed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpread.c to
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED to be consistent with
|
||||
what is in pngpriv.h.
|
||||
Moved prototype for png_handle_unknown() in pngpriv.h outside of
|
||||
the #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED/#endif block.
|
||||
Added "-Wall" to CFLAGS in contrib/pngminim/*/makefile
|
||||
Conditionally compile some unused functions reported by -Wall in
|
||||
pngminim.
|
||||
Fixed 'minimal' builds. Various obviously useful minimal configurations
|
||||
don't build because of missing contrib/libtests test programs and
|
||||
overly complex dependencies in scripts/pnglibconf.dfa. This change
|
||||
adds contrib/conftest/*.dfa files that can be used in automatic build
|
||||
scripts to ensure that these configurations continue to build.
|
||||
Enabled WRITE_INVERT and WRITE_PACK in contrib/pngminim/encoder.
|
||||
Fixed pngvalid 'fail' function declaration on the Intel C Compiler.
|
||||
This reverts to the previous 'static' implementation and works round
|
||||
the 'unused static function' warning by using PNG_UNUSED().
|
||||
|
||||
Version 1.7.0beta24 [December 15, 2013]
|
||||
Removed or marked PNG_UNUSED some harmless "dead assignments" reported
|
||||
by clang scan-build.
|
||||
Changed tabs to 3 spaces in png_debug macros and changed '"%s"m'
|
||||
to '"%s" m' to improve portability among compilers.
|
||||
Changed png_free_default() to free() in pngtest.c
|
||||
Tidied up pngfix inits and fixed pngtest no-write builds.
|
||||
Bookkeeping: Moved functions around (no changes). Moved transform
|
||||
function definitions before the place where they are called so that
|
||||
they can be made static. Move the intrapixel functions and the
|
||||
grayscale palette builder out of the png?tran.c files. The latter
|
||||
isn't a transform function and is no longer used internally, and the
|
||||
former MNG specific functions are better placed in pngread/pngwrite.c
|
||||
Made transform implementation functions static. This makes the internal
|
||||
functions called by png_do_{read|write}_transformations static. On an
|
||||
x86-64 DLL build (Gentoo Linux) this reduces the size of the text
|
||||
segment of the DLL by 1208 bytes, about 0.6%. It also simplifies
|
||||
maintenance by removing the declarations from pngpriv.h and allowing
|
||||
easier changes to the internal interfaces.
|
||||
Handle zero-length PLTE chunk or NULL palette with png_error()
|
||||
instead of png_chunk_report(), which by default issues a warning
|
||||
rather than an error, leading to later reading from a NULL pointer
|
||||
(png_ptr->palette) in png_do_expand_palette(). This is CVE-2013-6954
|
||||
and VU#650142. Libpng-1.6.1 through 1.6.7 and libpng-1.7.0beta03
|
||||
through 1.7.0beta23 are vulnerable. Libpng-1.6.0 and earlier do not
|
||||
have the bug.
|
||||
|
||||
Version 1.7.0beta25 [December 26, 2013]
|
||||
Merged files with version 1.6.8 that have not changed since then.
|
||||
Rebuilt configure scripts with automake-1.14.1 and autoconf-2.69
|
||||
|
||||
Version 1.7.0beta26 [January 1, 2014]
|
||||
Added libpng 1.5 checks to pngvalid.c
|
||||
Merged with 1.5 and 1.6 changes to create a single pngvalid.c
|
||||
Added dSIG to chunk list in png.h
|
||||
Removed #error macro from contrib/tools/pngfix.c (Thomas Klausner).
|
||||
Merged pngrio.c, pngtrans.c, and pngwio.c with libpng-1.6.9
|
||||
Fixed test programs for interlace options. Made pngvalid.c and
|
||||
pngtest.c work correctly when READ_INTERLACING and/or WRITE_INTERLACING
|
||||
are switched off.
|
||||
Changed pngvalid.c to support libpng 1.5, which does not support
|
||||
the PNG_MAXIMUM_INFLATE_WINDOW option, so #define it out when
|
||||
appropriate in pngvalid.c
|
||||
Allow unversioned links created on install to be disabled in configure.
|
||||
In configure builds 'make install' changes/adds links like png.h
|
||||
and libpng.a to point to the newly installed, versioned, files (e.g.
|
||||
libpng17/png.h and libpng17.a). Three new configure options and some
|
||||
rearrangement of Makefile.am allow creation of these links to be disabled.
|
||||
|
||||
Version 1.7.0beta27 [January 10, 2014]
|
||||
Removed potentially misleading warning from png_check_IHDR().
|
||||
|
||||
Version 1.7.0beta28 [January 20, 2014]
|
||||
Updated scripts/makefile.* to use CPPFLAGS (Cosmin).
|
||||
Added clang attribute support (Cosmin).
|
||||
|
||||
Version 1.7.0beta29 [January 30, 2014]
|
||||
Quiet an uninitialized memory warning from VS2013 in png_get_png().
|
||||
|
||||
Version 1.7.0beta30 [February 2, 2014]
|
||||
Fixed a large number of instances where PNGCBAPI was omitted from
|
||||
function definitions.
|
||||
Added pngimage test program for png_read_png and png_write_png. This
|
||||
is a work-in-progress; no tests are run automatically at present and
|
||||
the program by virtue of exhaustively testing all the transforms is
|
||||
very slow.
|
||||
|
||||
Version 1.7.0beta31 [February 6, 2014]
|
||||
Make png_read_png() and png_write_png() prototypes in png.h depend
|
||||
upon PNG_READ_SUPPORTED and PNG_WRITE_SUPPORTED.
|
||||
Removed dependence on !PNG_READ_EXPAND_SUPPORTED for calling
|
||||
png_set_packing() in png_read_png().
|
||||
Completed full working pngimage test program and added two test scripts.
|
||||
Fixed combination of ~alpha with shift. On read invert alpha, processing
|
||||
occurred after shift processing, which causes the final values to be
|
||||
outside the range that should be produced by the shift. Reversing the
|
||||
order on read makes the two transforms work together correctly and mirrors
|
||||
the order used on write.
|
||||
Do not read invalid sBIT chunks. Previously libpng only checked sBIT
|
||||
values on write, so a malicious PNG writer could therefore cause
|
||||
the read code to return an invalid sBIT chunk, which might lead to
|
||||
application errors or crashes. Such chunks are now skipped (with
|
||||
chunk_benign_error).
|
||||
Restored a line, "c = b;", that was inadvertently deleted from the
|
||||
PAETH filtering code from libpng-1.7.0beta24/pngrutil.c. Deleted
|
||||
the other instance of "c = b;" which is the one that triggered a
|
||||
scan-build warning.
|
||||
Support builds with unsupported PNG_TRANSFORM_* values. All of the
|
||||
PNG_TRANSFORM_* values are always defined in png.h and, because they
|
||||
are used for both read and write in some cases, it is not reliable
|
||||
to #if out ones that are totally unsupported. This change adds error
|
||||
detection in png_read_image() and png_write_image() to do a
|
||||
png_app_error() if the app requests something that cannot be done
|
||||
and it adds corresponding code to pngimage.c to handle such options
|
||||
by not attempting to test them.
|
||||
|
||||
Version 1.7.0beta32 [February 26, 2014]
|
||||
Moved redefines of png_error(), png_warning(), png_chunk_error(),
|
||||
and png_chunk_warning() from pngpriv.h to png.h to make them visible
|
||||
to libpng-calling applications.
|
||||
Moved OS dependent code from arm/arm_init.c, to allow the included
|
||||
implementation of the ARM NEON discovery function to be set at
|
||||
build-time and provide sample implementations from the current code in the
|
||||
contrib/arm-neon subdirectory. The __linux__ code has also been changed to
|
||||
compile and link on Android by using /proc/cpuinfo, and the old linux code
|
||||
is in contrib/arm-neon/linux-auxv.c. The new code avoids POSIX and Linux
|
||||
dependencies apart from opening /proc/cpuinfo and is C90 compliant.
|
||||
Check for info_ptr == NULL early in png_read_end() so we don't need to
|
||||
run all the png_handle_*() and depend on them to return if info_ptr == NULL.
|
||||
This improves the performance of png_read_end(png_ptr, NULL) and makes
|
||||
it more robust against future programming errors.
|
||||
Check for __has_extension before using it in pngconf.h, to
|
||||
support older Clang versions (Jeremy Sequoia).
|
||||
Use a user warning handler in contrib/gregbook/readpng2.c instead of default,
|
||||
so warnings will be put on stderr even if libpng has CONSOLE_IO disabled.
|
||||
Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk
|
||||
after recognizing the IDAT chunk, which avoids an infinite loop while
|
||||
reading a datastream whose first IDAT chunk is of zero-length.
|
||||
This fixes CERT VU#684412 and CVE-2014-0333.
|
||||
Don't recognize known sRGB profiles as sRGB if they have been hacked,
|
||||
but don't reject them and don't issue a copyright violation warning.
|
||||
Minor editing of contrib/arm-neon/README and contrib/examples/*.c
|
||||
Moved some documentation from png.h to libpng.3 and libpng-manual.txt
|
||||
|
||||
Version 1.7.0beta33 [February 27, 2014]
|
||||
Fixed typos in the manual and in scripts/pnglibconf.dfa (CFLAGS -> CPPFLAGS
|
||||
and PNG_USR_CONFIG -> PNG_USER_CONFIG).
|
||||
|
||||
Version 1.7.0beta34 [March 17, 2014]
|
||||
Treat CRC error handling with png_set_crc_action(), instead of with
|
||||
png_set_benign_errors(), which has been the case since libpng-1.6.0beta18.
|
||||
Use "if (value != 0)" instead of "if (value)" consistently.
|
||||
Changed ZlibSrcDir from 1.2.5 to 1.2.8 in projects/vstudio.
|
||||
Moved configuration information from the manual to the INSTALL file.
|
||||
|
||||
Version 1.7.0beta35 [August 6, 2014]
|
||||
Removed #if/#else/#endif from inside two pow() calls in pngvalid.c because
|
||||
they were handled improperly by Portland Group's PGI-14.1 - PGI-14.3
|
||||
when using its "__builtin_pow()" function.
|
||||
Silence 'unused parameter' build warnings (Cosmin).
|
||||
$(CP) is now used alongside $(RM_F). Also, use 'copy' instead
|
||||
of 'cp' where applicable, and applied other minor makefile changes.
|
||||
Don't warn about invalid dimensions exceeding user limits.
|
||||
Allow an easy replacement of the default pre-built configuration
|
||||
header with a custom header, via the make PNGLIBCONF_H_PREBUILT
|
||||
macro.
|
||||
Fixed a typo in pngrutil.c, introduced in libpng-1.5.6, that interferes
|
||||
with "blocky" expansion of sub-8-bit interlaced PNG files (Eric Huss).
|
||||
Removed scripts/makefile.elf. It has not worked since libpng-1.5.0beta14
|
||||
due to elimination of the PNG_FUNCTION_EXPORT and PNG_DATA_EXPORT
|
||||
definitions from pngconf.h.
|
||||
Ensure that CMakeLists.txt makes the target "lib" directory before making
|
||||
symbolic link into it (SourceForge bug report #226 by Rolf Timmermans).
|
||||
Added opinion that the ECCN (Export Control Classification Number) for
|
||||
libpng is EAR99 to the README file.
|
||||
|
||||
Version 1.7.0beta36 [September 27, 2014]
|
||||
Updated scripts/makefiles from libpng-1.6.13beta04.
|
||||
Minor updates to the manual from libpng-1.6.14beta04.
|
||||
Fixed incorrect handling of the iTXt compression flag in pngrutil.c
|
||||
(bug report by Shunsaku Hirata). Bug was introduced in libpng-1.6.0.
|
||||
|
||||
Version 1.7.0beta37 [September 28, 2014]
|
||||
Merged scripts/*, pngvalid.c and pngfix.c with libpng-1.6.14beta04.
|
||||
|
||||
Version 1.7.0beta38 [October 17, 2014]
|
||||
Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
|
||||
Removed unused "text_len" parameter from private function png_write_zTXt().
|
||||
Conditionally compile some code in png_deflate_claim(), when
|
||||
PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
|
||||
Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
|
||||
Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
|
||||
to pnglibconf.dfa.
|
||||
Removed "option READ_COMPRESSED_TEXT enables READ_TEXT" from pnglibconf.dfa,
|
||||
to make it possible to configure a libpng that supports iCCP but not TEXT.
|
||||
Removed "option WRITE_COMPRESSED_TEXT enables WRITE_TEXT" from pnglibconf.dfa
|
||||
Only mark text chunks as written after successfully writing them.
|
||||
|
||||
Version 1.7.0beta39 [November 1, 2014]
|
||||
Ported cosmetic changes from libpng-1.6.15beta02.
|
||||
|
||||
Version 1.7.0beta40 [November 6, 2014]
|
||||
Made a one-line revision to configure.ac to support ARM on aarch64
|
||||
(bug report by Marcin Juszkiewicz, fix by John Bowler).
|
||||
Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
|
||||
example.c, pngtest.c, and applications in the contrib directory.
|
||||
Avoid out-of-bounds memory access in png_user_version_check().
|
||||
Simplified and future-proofed png_user_version_check().
|
||||
Fixed GCC unsigned int->float warnings. Various versions of GCC
|
||||
seem to generate warnings when an unsigned value is implicitly
|
||||
converted to double. This is probably a GCC bug but this change
|
||||
avoids the issue by explicitly converting to (int) where safe.
|
||||
Free all allocated memory in pngimage. The file buffer cache was left
|
||||
allocated at the end of the program, harmless but it causes memory
|
||||
leak reports from clang.
|
||||
Fixed array size calculations to avoid warnings. At various points
|
||||
in the code the number of elements in an array is calculated using
|
||||
sizeof. This generates a compile time constant of type (size_t) which
|
||||
is then typically assigned to an (unsigned int) or (int). Some versions
|
||||
of GCC on 64-bit systems warn about the apparent narrowing, even though
|
||||
the same compiler does apparently generate the correct, in-range,
|
||||
numeric constant. This adds appropriate, safe, casts to make the
|
||||
warnings go away.
|
||||
|
||||
Version 1.7.0beta41 [November 7, 2014]
|
||||
Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and
|
||||
png_do_swap().
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
292
CHANGES
292
CHANGES
@@ -4400,7 +4400,9 @@ Version 1.7.0alpha07 [January 10, 2013]
|
||||
programs to generate and test a PNG which should have the problem.
|
||||
|
||||
Version 1.7.0alpha08 [January 17, 2013]
|
||||
Corrected previous attempt at overflow detection in png_set_unknown_chunks().
|
||||
Corrected previous attempt at overflow detection in png_set_unknown_chunks()
|
||||
(CVE-2013-7353). Added overflow detection in png_set_sPLT() and
|
||||
png_set_text_2() (CVE-2013-7354).
|
||||
|
||||
Version 1.7.0alpha09 [January 21, 2013]
|
||||
Pulled changes to multi-chunk handling from libpng-1.6.0beta40.
|
||||
@@ -4646,6 +4648,294 @@ Version 1.7.0beta18 [September 16, 2013]
|
||||
prototype, definition, and usage. Made it depend on
|
||||
PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere.
|
||||
|
||||
Version 1.7.0beta19 [September 30, 2013]
|
||||
Reverted the change to unknown handling #defines; the change breaks 'NOREAD'
|
||||
builds.
|
||||
Fixed default behavior of ARM_NEON_API. If the ARM NEON API option is
|
||||
compiled without the CHECK option it defaulted to on, not off.
|
||||
Catch up with recent libpng16 changes; unknown handling and spelling
|
||||
corrections
|
||||
Avoid up-cast warnings in pngvalid.c. On ARM the alignment requirements of
|
||||
png_modifier are greater than that of png_store and as a consequence
|
||||
compilation of pngvalid.c results in a warning about increased alignment
|
||||
requirements because of the bare cast to (png_modifier*). The code is
|
||||
safe, because the pointer is known to point to a stack allocated
|
||||
png_modifier, but this change avoids the warning.
|
||||
Fixed some grammatical changes and updated the png chunks list.
|
||||
|
||||
Version 1.7.0beta20 [October 13, 2013]
|
||||
Made changes for compatibility with automake 1.14:
|
||||
1) Added the 'compile' program to the list of programs that must be cleaned
|
||||
in autogen.sh
|
||||
2) Added 'subdir-objects' which causes .c files in sub-directories to be
|
||||
compiled such that the corresponding .o files are also in the
|
||||
sub-directory. This is because automake 1.14 warns that the
|
||||
current behavior of compiling to the top level directory may be removed
|
||||
in the future.
|
||||
3) Updated dependencies on pnglibconf.h to match the new .o locations and
|
||||
added all the files in contrib/libtests and contrib/tools that depend
|
||||
on pnglibconf.h
|
||||
4) Added 'BUILD_SOURCES = pnglibconf.h'; this is the automake recommended
|
||||
way of handling the dependencies of sources that are machine generated;
|
||||
unfortunately it only works if the user does 'make all' or 'make check',
|
||||
so the dependencies (3) are still required.
|
||||
Cleaned up (char*) casts of zlib messages. The latest version of the Intel C
|
||||
compiler complains about casting a string literal as (char*), so copied the
|
||||
treatment of z_const from the library code into pngfix.c
|
||||
Simplified error message code in pngunknown. The simplification has the
|
||||
useful side effect of avoiding a bogus warning generated by the latest
|
||||
version of the Intel C compiler (it objects to
|
||||
condition ? string-literal : string-literal).
|
||||
Make autogen.sh work with automake 1.13 as well as 1.14. Do this by always
|
||||
removing the 1.14 'compile' script but never checking for it.
|
||||
|
||||
Version 1.7.0beta21 [November 2, 2013]
|
||||
Added ARMv8 support (James Yu <james.yu at linaro.org>). Added file
|
||||
arm/filter_neon_intrinsics.c; enable with -mfpu=neon.
|
||||
Revised pngvalid to generate size images with as many filters as it can
|
||||
manage, limited by the number of rows.
|
||||
Cleaned up ARM NEON compilation handling. The tests are now in pngpriv.h
|
||||
and detect the broken GCC compilers.
|
||||
Allow clang derived from older GCC versions to use ARM intrinsics. This
|
||||
causes all clang builds that use -mfpu=neon to use the intrinsics code,
|
||||
not the assembler code. This has only been tested on iOS 7. It may be
|
||||
necessary to exclude some earlier clang versions but this seems unlikely.
|
||||
Changed NEON implementation selection mechanism. This allows assembler
|
||||
or intrinsics to be turned on at compile time during the build by defining
|
||||
PNG_ARM_NEON_IMPLEMENTATION to the correct value (2 or 1). This macro
|
||||
is undefined by default and the build type is selected in pngpriv.h.
|
||||
|
||||
Version 1.7.0beta22 [November 7, 2013]
|
||||
Fixed #include in filter_neon_intrinsics.c and ctype macros. The ctype char
|
||||
checking macros take an unsigned char argument, not a signed char.
|
||||
|
||||
Version 1.7.0beta23 [November 24, 2013]
|
||||
Changed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpread.c to
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED to be consistent with
|
||||
what is in pngpriv.h.
|
||||
Moved prototype for png_handle_unknown() in pngpriv.h outside of
|
||||
the #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED/#endif block.
|
||||
Added "-Wall" to CFLAGS in contrib/pngminim/*/makefile
|
||||
Conditionally compile some unused functions reported by -Wall in
|
||||
pngminim.
|
||||
Fixed 'minimal' builds. Various obviously useful minimal configurations
|
||||
don't build because of missing contrib/libtests test programs and
|
||||
overly complex dependencies in scripts/pnglibconf.dfa. This change
|
||||
adds contrib/conftest/*.dfa files that can be used in automatic build
|
||||
scripts to ensure that these configurations continue to build.
|
||||
Enabled WRITE_INVERT and WRITE_PACK in contrib/pngminim/encoder.
|
||||
Fixed pngvalid 'fail' function declaration on the Intel C Compiler.
|
||||
This reverts to the previous 'static' implementation and works round
|
||||
the 'unused static function' warning by using PNG_UNUSED().
|
||||
|
||||
Version 1.7.0beta24 [December 15, 2013]
|
||||
Removed or marked PNG_UNUSED some harmless "dead assignments" reported
|
||||
by clang scan-build.
|
||||
Changed tabs to 3 spaces in png_debug macros and changed '"%s"m'
|
||||
to '"%s" m' to improve portability among compilers.
|
||||
Changed png_free_default() to free() in pngtest.c
|
||||
Tidied up pngfix inits and fixed pngtest no-write builds.
|
||||
Bookkeeping: Moved functions around (no changes). Moved transform
|
||||
function definitions before the place where they are called so that
|
||||
they can be made static. Move the intrapixel functions and the
|
||||
grayscale palette builder out of the png?tran.c files. The latter
|
||||
isn't a transform function and is no longer used internally, and the
|
||||
former MNG specific functions are better placed in pngread/pngwrite.c
|
||||
Made transform implementation functions static. This makes the internal
|
||||
functions called by png_do_{read|write}_transformations static. On an
|
||||
x86-64 DLL build (Gentoo Linux) this reduces the size of the text
|
||||
segment of the DLL by 1208 bytes, about 0.6%. It also simplifies
|
||||
maintenance by removing the declarations from pngpriv.h and allowing
|
||||
easier changes to the internal interfaces.
|
||||
Handle zero-length PLTE chunk or NULL palette with png_error()
|
||||
instead of png_chunk_report(), which by default issues a warning
|
||||
rather than an error, leading to later reading from a NULL pointer
|
||||
(png_ptr->palette) in png_do_expand_palette(). This is CVE-2013-6954
|
||||
and VU#650142. Libpng-1.6.1 through 1.6.7 and libpng-1.7.0beta03
|
||||
through 1.7.0beta23 are vulnerable. Libpng-1.6.0 and earlier do not
|
||||
have the bug.
|
||||
|
||||
Version 1.7.0beta25 [December 26, 2013]
|
||||
Merged files with version 1.6.8 that have not changed since then.
|
||||
Rebuilt configure scripts with automake-1.14.1 and autoconf-2.69
|
||||
|
||||
Version 1.7.0beta26 [January 1, 2014]
|
||||
Added libpng 1.5 checks to pngvalid.c
|
||||
Merged with 1.5 and 1.6 changes to create a single pngvalid.c
|
||||
Added dSIG to chunk list in png.h
|
||||
Removed #error macro from contrib/tools/pngfix.c (Thomas Klausner).
|
||||
Merged pngrio.c, pngtrans.c, and pngwio.c with libpng-1.6.9
|
||||
Fixed test programs for interlace options. Made pngvalid.c and
|
||||
pngtest.c work correctly when READ_INTERLACING and/or WRITE_INTERLACING
|
||||
are switched off.
|
||||
Changed pngvalid.c to support libpng 1.5, which does not support
|
||||
the PNG_MAXIMUM_INFLATE_WINDOW option, so #define it out when
|
||||
appropriate in pngvalid.c
|
||||
Allow unversioned links created on install to be disabled in configure.
|
||||
In configure builds 'make install' changes/adds links like png.h
|
||||
and libpng.a to point to the newly installed, versioned, files (e.g.
|
||||
libpng17/png.h and libpng17.a). Three new configure options and some
|
||||
rearrangement of Makefile.am allow creation of these links to be disabled.
|
||||
|
||||
Version 1.7.0beta27 [January 10, 2014]
|
||||
Removed potentially misleading warning from png_check_IHDR().
|
||||
|
||||
Version 1.7.0beta28 [January 20, 2014]
|
||||
Updated scripts/makefile.* to use CPPFLAGS (Cosmin).
|
||||
Added clang attribute support (Cosmin).
|
||||
|
||||
Version 1.7.0beta29 [January 30, 2014]
|
||||
Quiet an uninitialized memory warning from VS2013 in png_get_png().
|
||||
|
||||
Version 1.7.0beta30 [February 2, 2014]
|
||||
Fixed a large number of instances where PNGCBAPI was omitted from
|
||||
function definitions.
|
||||
Added pngimage test program for png_read_png and png_write_png. This
|
||||
is a work-in-progress; no tests are run automatically at present and
|
||||
the program by virtue of exhaustively testing all the transforms is
|
||||
very slow.
|
||||
|
||||
Version 1.7.0beta31 [February 6, 2014]
|
||||
Make png_read_png() and png_write_png() prototypes in png.h depend
|
||||
upon PNG_READ_SUPPORTED and PNG_WRITE_SUPPORTED.
|
||||
Removed dependence on !PNG_READ_EXPAND_SUPPORTED for calling
|
||||
png_set_packing() in png_read_png().
|
||||
Completed full working pngimage test program and added two test scripts.
|
||||
Fixed combination of ~alpha with shift. On read invert alpha, processing
|
||||
occurred after shift processing, which causes the final values to be
|
||||
outside the range that should be produced by the shift. Reversing the
|
||||
order on read makes the two transforms work together correctly and mirrors
|
||||
the order used on write.
|
||||
Do not read invalid sBIT chunks. Previously libpng only checked sBIT
|
||||
values on write, so a malicious PNG writer could therefore cause
|
||||
the read code to return an invalid sBIT chunk, which might lead to
|
||||
application errors or crashes. Such chunks are now skipped (with
|
||||
chunk_benign_error).
|
||||
Restored a line, "c = b;", that was inadvertently deleted from the
|
||||
PAETH filtering code from libpng-1.7.0beta24/pngrutil.c. Deleted
|
||||
the other instance of "c = b;" which is the one that triggered a
|
||||
scan-build warning.
|
||||
Support builds with unsupported PNG_TRANSFORM_* values. All of the
|
||||
PNG_TRANSFORM_* values are always defined in png.h and, because they
|
||||
are used for both read and write in some cases, it is not reliable
|
||||
to #if out ones that are totally unsupported. This change adds error
|
||||
detection in png_read_image() and png_write_image() to do a
|
||||
png_app_error() if the app requests something that cannot be done
|
||||
and it adds corresponding code to pngimage.c to handle such options
|
||||
by not attempting to test them.
|
||||
|
||||
Version 1.7.0beta32 [February 26, 2014]
|
||||
Moved redefines of png_error(), png_warning(), png_chunk_error(),
|
||||
and png_chunk_warning() from pngpriv.h to png.h to make them visible
|
||||
to libpng-calling applications.
|
||||
Moved OS dependent code from arm/arm_init.c, to allow the included
|
||||
implementation of the ARM NEON discovery function to be set at
|
||||
build-time and provide sample implementations from the current code in the
|
||||
contrib/arm-neon subdirectory. The __linux__ code has also been changed to
|
||||
compile and link on Android by using /proc/cpuinfo, and the old linux code
|
||||
is in contrib/arm-neon/linux-auxv.c. The new code avoids POSIX and Linux
|
||||
dependencies apart from opening /proc/cpuinfo and is C90 compliant.
|
||||
Check for info_ptr == NULL early in png_read_end() so we don't need to
|
||||
run all the png_handle_*() and depend on them to return if info_ptr == NULL.
|
||||
This improves the performance of png_read_end(png_ptr, NULL) and makes
|
||||
it more robust against future programming errors.
|
||||
Check for __has_extension before using it in pngconf.h, to
|
||||
support older Clang versions (Jeremy Sequoia).
|
||||
Use a user warning handler in contrib/gregbook/readpng2.c instead of default,
|
||||
so warnings will be put on stderr even if libpng has CONSOLE_IO disabled.
|
||||
Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk
|
||||
after recognizing the IDAT chunk, which avoids an infinite loop while
|
||||
reading a datastream whose first IDAT chunk is of zero-length.
|
||||
This fixes CERT VU#684412 and CVE-2014-0333.
|
||||
Don't recognize known sRGB profiles as sRGB if they have been hacked,
|
||||
but don't reject them and don't issue a copyright violation warning.
|
||||
Minor editing of contrib/arm-neon/README and contrib/examples/*.c
|
||||
Moved some documentation from png.h to libpng.3 and libpng-manual.txt
|
||||
|
||||
Version 1.7.0beta33 [February 27, 2014]
|
||||
Fixed typos in the manual and in scripts/pnglibconf.dfa (CFLAGS -> CPPFLAGS
|
||||
and PNG_USR_CONFIG -> PNG_USER_CONFIG).
|
||||
|
||||
Version 1.7.0beta34 [March 17, 2014]
|
||||
Treat CRC error handling with png_set_crc_action(), instead of with
|
||||
png_set_benign_errors(), which has been the case since libpng-1.6.0beta18.
|
||||
Use "if (value != 0)" instead of "if (value)" consistently.
|
||||
Changed ZlibSrcDir from 1.2.5 to 1.2.8 in projects/vstudio.
|
||||
Moved configuration information from the manual to the INSTALL file.
|
||||
|
||||
Version 1.7.0beta35 [August 6, 2014]
|
||||
Removed #if/#else/#endif from inside two pow() calls in pngvalid.c because
|
||||
they were handled improperly by Portland Group's PGI-14.1 - PGI-14.3
|
||||
when using its "__builtin_pow()" function.
|
||||
Silence 'unused parameter' build warnings (Cosmin).
|
||||
$(CP) is now used alongside $(RM_F). Also, use 'copy' instead
|
||||
of 'cp' where applicable, and applied other minor makefile changes.
|
||||
Don't warn about invalid dimensions exceeding user limits.
|
||||
Allow an easy replacement of the default pre-built configuration
|
||||
header with a custom header, via the make PNGLIBCONF_H_PREBUILT
|
||||
macro.
|
||||
Fixed a typo in pngrutil.c, introduced in libpng-1.5.6, that interferes
|
||||
with "blocky" expansion of sub-8-bit interlaced PNG files (Eric Huss).
|
||||
Removed scripts/makefile.elf. It has not worked since libpng-1.5.0beta14
|
||||
due to elimination of the PNG_FUNCTION_EXPORT and PNG_DATA_EXPORT
|
||||
definitions from pngconf.h.
|
||||
Ensure that CMakeLists.txt makes the target "lib" directory before making
|
||||
symbolic link into it (SourceForge bug report #226 by Rolf Timmermans).
|
||||
Added opinion that the ECCN (Export Control Classification Number) for
|
||||
libpng is EAR99 to the README file.
|
||||
|
||||
Version 1.7.0beta36 [September 27, 2014]
|
||||
Updated scripts/makefiles from libpng-1.6.13beta04.
|
||||
Minor updates to the manual from libpng-1.6.14beta04.
|
||||
Fixed incorrect handling of the iTXt compression flag in pngrutil.c
|
||||
(bug report by Shunsaku Hirata). Bug was introduced in libpng-1.6.0.
|
||||
|
||||
Version 1.7.0beta37 [September 28, 2014]
|
||||
Merged scripts/*, pngvalid.c and pngfix.c with libpng-1.6.14beta04.
|
||||
|
||||
Version 1.7.0beta38 [October 17, 2014]
|
||||
Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
|
||||
Removed unused "text_len" parameter from private function png_write_zTXt().
|
||||
Conditionally compile some code in png_deflate_claim(), when
|
||||
PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
|
||||
Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
|
||||
Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
|
||||
to pnglibconf.dfa.
|
||||
Removed "option READ_COMPRESSED_TEXT enables READ_TEXT" from pnglibconf.dfa,
|
||||
to make it possible to configure a libpng that supports iCCP but not TEXT.
|
||||
Removed "option WRITE_COMPRESSED_TEXT enables WRITE_TEXT" from pnglibconf.dfa
|
||||
Only mark text chunks as written after successfully writing them.
|
||||
|
||||
Version 1.7.0beta39 [November 1, 2014]
|
||||
Ported cosmetic changes from libpng-1.6.15beta02.
|
||||
|
||||
Version 1.7.0beta40 [November 6, 2014]
|
||||
Made a one-line revision to configure.ac to support ARM on aarch64
|
||||
(bug report by Marcin Juszkiewicz, fix by John Bowler).
|
||||
Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
|
||||
example.c, pngtest.c, and applications in the contrib directory.
|
||||
Avoid out-of-bounds memory access in png_user_version_check().
|
||||
Simplified and future-proofed png_user_version_check().
|
||||
Fixed GCC unsigned int->float warnings. Various versions of GCC
|
||||
seem to generate warnings when an unsigned value is implicitly
|
||||
converted to double. This is probably a GCC bug but this change
|
||||
avoids the issue by explicitly converting to (int) where safe.
|
||||
Free all allocated memory in pngimage. The file buffer cache was left
|
||||
allocated at the end of the program, harmless but it causes memory
|
||||
leak reports from clang.
|
||||
Fixed array size calculations to avoid warnings. At various points
|
||||
in the code the number of elements in an array is calculated using
|
||||
sizeof. This generates a compile time constant of type (size_t) which
|
||||
is then typically assigned to an (unsigned int) or (int). Some versions
|
||||
of GCC on 64-bit systems warn about the apparent narrowing, even though
|
||||
the same compiler does apparently generate the correct, in-range,
|
||||
numeric constant. This adds appropriate, safe, casts to make the
|
||||
warnings go away.
|
||||
|
||||
Version 1.7.0beta41 [November 7, 2014]
|
||||
Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and
|
||||
png_do_swap().
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
# Copyright (C) 2007-2013 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2007-2014 Glenn Randers-Pehrson
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@@ -220,6 +220,7 @@ macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
else(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
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)
|
||||
@@ -252,7 +253,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta18
|
||||
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta41
|
||||
VERSION 17.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 17
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
@@ -350,7 +351,7 @@ if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
|
||||
install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
|
||||
endif()
|
||||
|
||||
# what's with libpng-$VER%.txt and all the extra files?
|
||||
# what's with libpng-manual.txt and all the extra files?
|
||||
|
||||
# UNINSTALL
|
||||
# do we need this?
|
||||
|
||||
278
INSTALL
278
INSTALL
@@ -1,13 +1,47 @@
|
||||
|
||||
Installing libpng
|
||||
|
||||
Contents
|
||||
|
||||
I. Simple installation
|
||||
II. Rebuilding the configure scripts
|
||||
III. Using scripts/makefile*
|
||||
IV. Using cmake
|
||||
V. Directory structure
|
||||
VI. Building with project files
|
||||
VII. Building with makefiles
|
||||
VIII. Configuring libpng for 16-bit platforms
|
||||
IX. Configuring for DOS
|
||||
X. Configuring for Medium Model
|
||||
XI. Prepending a prefix to exported symbols
|
||||
XII. Configuring for compiler xxx:
|
||||
XIII. Removing unwanted object code
|
||||
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
|
||||
XV. Configuring libpng for multiprocessing
|
||||
XVI. Other sources of information about libpng
|
||||
|
||||
I. Simple installation
|
||||
|
||||
On Unix/Linux and similar systems, you can simply type
|
||||
|
||||
./configure [--prefix=/path]
|
||||
make check
|
||||
make install
|
||||
|
||||
and ignore the rest of this document.
|
||||
and ignore the rest of this document. "/path" is the path to the directory
|
||||
where you want to install the libpng "lib", "include", and "bin"
|
||||
subdirectories.
|
||||
|
||||
If you downloaded a GIT clone, you will need to run ./autogen.sh before
|
||||
running ./configure, to create "configure" and "Makefile.in" which are
|
||||
not included in the GIT repository.
|
||||
|
||||
Note that "configure" is only included in the "*.tar" distributions and not
|
||||
in the "*.zip" or "*.7z" distributions. If you downloaded one of those
|
||||
distributions, see "Building with project files" or "Building with makefiles",
|
||||
below.
|
||||
|
||||
II. Rebuilding the configure scripts
|
||||
|
||||
If configure does not work on your system, or if you have a need to
|
||||
change configure.ac or Makefile.am, and you have a reasonably
|
||||
@@ -24,9 +58,12 @@ aren't using any of the included pre-built scripts, you can do this:
|
||||
make install
|
||||
make check
|
||||
|
||||
III. Using scripts/makefile*
|
||||
|
||||
Instead, you can use one of the custom-built makefiles in the
|
||||
"scripts" directory
|
||||
|
||||
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
|
||||
cp scripts/makefile.system makefile
|
||||
make test
|
||||
make install
|
||||
@@ -38,8 +75,8 @@ Or you can use one of the "projects" in the "projects" directory.
|
||||
|
||||
Before installing libpng, you must first install zlib, if it
|
||||
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.
|
||||
wherever you got libpng; otherwise go to http://zlib.net. You can place
|
||||
zlib in in the same directory as libpng or in another directory.
|
||||
|
||||
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
|
||||
@@ -59,15 +96,23 @@ 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".
|
||||
|
||||
IV. Using cmake
|
||||
|
||||
If you want to use "cmake" (see www.cmake.org), type
|
||||
|
||||
cmake . -DCMAKE_INSTALL_PREFIX=/path
|
||||
make
|
||||
make install
|
||||
|
||||
As when using the simple configure method described above, "/path" points to
|
||||
the installation directory where you want to put the libpng "lib", "include",
|
||||
and "bin" subdirectories.
|
||||
|
||||
V. Directory structure
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
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".
|
||||
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
|
||||
or "zlib128") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
|
||||
@@ -75,8 +120,7 @@ Your directory structure should look like this:
|
||||
libpng (this directory)
|
||||
INSTALL (this file)
|
||||
README
|
||||
*.h
|
||||
*.c
|
||||
*.h, *.c => libpng source files
|
||||
CMakeLists.txt => "cmake" script
|
||||
configuration files:
|
||||
configure.ac, configure, Makefile.am, Makefile.in,
|
||||
@@ -84,15 +128,10 @@ Your directory structure should look like this:
|
||||
libpng-config.in, aclocal.m4, config.h.in, config.sub,
|
||||
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
|
||||
contrib
|
||||
gregbook
|
||||
libtests
|
||||
pngminim
|
||||
pngminus
|
||||
pngsuite
|
||||
visupng
|
||||
arm-neon, conftest, examples, gregbook, libtests, pngminim,
|
||||
pngminus, pngsuite, tools, visupng
|
||||
projects
|
||||
visualc71
|
||||
vstudio
|
||||
cbuilder5, owatcom, visualc71, vstudio, xcode
|
||||
scripts
|
||||
makefile.*
|
||||
*.def (module definition files)
|
||||
@@ -100,29 +139,31 @@ Your directory structure should look like this:
|
||||
pngtest.png
|
||||
etc.
|
||||
zlib
|
||||
README
|
||||
*.h
|
||||
*.c
|
||||
contrib
|
||||
etc.
|
||||
README, *.h, *.c contrib, etc.
|
||||
|
||||
If the line endings in the files look funny, you may wish to get the other
|
||||
distribution of libpng. It is available in both tar.gz (UNIX style line
|
||||
endings) and zip (DOS style line endings) formats.
|
||||
|
||||
VI. Building with project files
|
||||
|
||||
If you are building libpng with MSVC, you can enter the
|
||||
libpng projects\visualc6 or visualc71 directory and follow the instructions
|
||||
libpng projects\visualc71 or vstudio directory and follow the instructions
|
||||
in README.txt.
|
||||
|
||||
Otherwise enter the zlib directory and follow the instructions in zlib/README,
|
||||
then come back here and run "configure" or choose the appropriate
|
||||
makefile.sys in the scripts directory.
|
||||
|
||||
VII. Building with makefiles
|
||||
|
||||
Copy the file (or files) that you need from the
|
||||
scripts directory into this directory, for example
|
||||
|
||||
MSDOS example: copy scripts\makefile.msc makefile
|
||||
UNIX example: cp scripts/makefile.std makefile
|
||||
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
|
||||
UNIX example: cp scripts/makefile.std makefile
|
||||
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
|
||||
|
||||
Read the makefile to see if you need to change any source or
|
||||
target directories to match your preferences.
|
||||
@@ -145,6 +186,197 @@ do that, run "make install" in the zlib directory first if necessary).
|
||||
Some also allow you to run "make test-installed" after you have
|
||||
run "make install".
|
||||
|
||||
VIII. Configuring libpng for 16-bit platforms
|
||||
|
||||
You will want to look into zconf.h to tell zlib (and thus libpng) that
|
||||
it cannot allocate more then 64K at a time. Even if you can, the memory
|
||||
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
|
||||
|
||||
IX. Configuring for DOS
|
||||
|
||||
For DOS users who only have access to the lower 640K, you will
|
||||
have to limit zlib's memory usage via a png_set_compression_mem_level()
|
||||
call. See zlib.h or zconf.h in the zlib library for more information.
|
||||
|
||||
X. Configuring for Medium Model
|
||||
|
||||
Libpng's support for medium model has been tested on most of the popular
|
||||
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
|
||||
defined, and FAR gets defined to far in pngconf.h, and you should be
|
||||
all set. Everything in the library (except for zlib's structure) is
|
||||
expecting far data. You must use the typedefs with the p or pp on
|
||||
the end for pointers (or at least look at them and be careful). Make
|
||||
note that the rows of data are defined as png_bytepp, which is
|
||||
an "unsigned char far * far *".
|
||||
|
||||
XI. Prepending a prefix to exported symbols
|
||||
|
||||
Starting with libpng-1.6.0, you can configure libpng (when using the
|
||||
"configure" script) to prefix all exported symbols by means of the
|
||||
configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
|
||||
string beginning with a letter and containing only uppercase
|
||||
and lowercase letters, digits, and the underscore (i.e., a C language
|
||||
identifier). This creates a set of macros in pnglibconf.h, so this is
|
||||
transparent to applications; their function calls get transformed by
|
||||
the macros to use the modified names.
|
||||
|
||||
XII. Configuring for compiler xxx:
|
||||
|
||||
All includes for libpng are in pngconf.h. If you need to add, change
|
||||
or delete an include, this is the place to do it.
|
||||
The includes that are not needed outside libpng are placed in pngpriv.h,
|
||||
which is only used by the routines inside libpng itself.
|
||||
The files in libpng proper only include pngpriv.h and png.h, which
|
||||
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
|
||||
As of libpng-1.5.0, pngpriv.h also includes three other private header
|
||||
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
|
||||
that previously appeared in the public headers.
|
||||
|
||||
XIII. Removing unwanted object code
|
||||
|
||||
There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use a capability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space, or
|
||||
you can turn off individual capabilities with defines that begin with
|
||||
PNG_NO_.
|
||||
|
||||
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
|
||||
|
||||
You can also turn all of the transforms and ancillary chunk capabilities
|
||||
off en masse with compiler directives that define
|
||||
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
|
||||
or all four, along with directives to turn on any of the capabilities that
|
||||
you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
|
||||
extra transformations but still leave the library fully capable of reading
|
||||
and writing PNG files with all known public chunks. Use of the
|
||||
PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
|
||||
that is incapable of reading or writing ancillary chunks. If you are
|
||||
not using the progressive reading capability, you can turn that off
|
||||
with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
|
||||
capability, which you'll still have).
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
make sure, or if you are building a stand alone library, all the
|
||||
reading files start with "pngr" and all the writing files start with "pngw".
|
||||
The files that don't match either (like png.c, pngtrans.c, etc.)
|
||||
are used for both reading and writing, and always need to be included.
|
||||
The progressive reader is in pngpread.c
|
||||
|
||||
If you are creating or distributing a dynamically linked library (a .so
|
||||
or DLL file), you should not remove or disable any parts of the library,
|
||||
as this will cause applications linked with different versions of the
|
||||
library to fail if they call functions not available in your library.
|
||||
The size of the library itself should not be an issue, because only
|
||||
those sections that are actually used will be loaded into memory.
|
||||
|
||||
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
|
||||
|
||||
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
|
||||
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
|
||||
to build pnglibconf.h where the corresponding makefile does not do so.
|
||||
|
||||
Building libpng with a non-default configuration has changed completely.
|
||||
The old method using pngusr.h should still work correctly even though the
|
||||
way pngusr.h is used in the build has been changed; however, library
|
||||
builders will probably want to examine the changes to take advantage of
|
||||
new capabilities and to simplify their build system.
|
||||
|
||||
A. Specific changes to library configuration capabilities
|
||||
|
||||
The exact mechanism used to control attributes of API functions has
|
||||
changed. A single set of operating system independent macro definitions
|
||||
is used and operating system specific directives are defined in
|
||||
pnglibconf.h
|
||||
|
||||
As part of this the mechanism used to choose procedure call standards on
|
||||
those systems that allow a choice has been changed. At present this only
|
||||
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
|
||||
running on Intel processors. As before, PNGAPI is defined where required
|
||||
to control the exported API functions; however, two new macros, PNGCBAPI
|
||||
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
|
||||
(PNGCAPI) for functions that must match a C library prototype (currently
|
||||
only png_longjmp_ptr, which must match the C longjmp function.) The new
|
||||
approach is documented in pngconf.h
|
||||
|
||||
Despite these changes, libpng 1.5.0 only supports the native C function
|
||||
calling standard on those platforms tested so far (__cdecl on Microsoft
|
||||
Windows). This is because the support requirements for alternative
|
||||
calling conventions seem to no longer exist. Developers who find it
|
||||
necessary to set PNG_API_RULE to 1 should advise the mailing list
|
||||
(png-mng-implement) of this and library builders who use Openwatcom and
|
||||
therefore set PNG_API_RULE to 2 should also contact the mailing list.
|
||||
|
||||
B. Changes to the configuration mechanism
|
||||
|
||||
Prior to libpng-1.5.0 library builders who needed to configure libpng
|
||||
had either to modify the exported pngconf.h header file to add system
|
||||
specific configuration or had to write feature selection macros into
|
||||
pngusr.h and cause this to be included into pngconf.h by defining
|
||||
PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
|
||||
application built without PNG_USER_CONFIG defined would see the
|
||||
unmodified, default, libpng API and thus would probably fail to link.
|
||||
|
||||
These mechanisms still work in the configure build and in any makefile
|
||||
build that builds pnglibconf.h, although the feature selection macros
|
||||
have changed somewhat as described above. In 1.5.0, however, pngusr.h is
|
||||
processed only once, at the time the exported header file pnglibconf.h is
|
||||
built. 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 formerly used alternative of adding a list of feature macros to the
|
||||
CPPFLAGS 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.
|
||||
|
||||
All configuration now only works if pnglibconf.h is built from
|
||||
scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
|
||||
(the original author of awk) maintains C source code of that awk and this
|
||||
and all known later implementations (often called by subtly different
|
||||
names - nawk and gawk for example) are adequate to build pnglibconf.h.
|
||||
The Sun Microsystems (now Oracle) program 'awk' is an earlier version
|
||||
and does not work; this may also apply to other systems that have a
|
||||
functioning awk called 'nawk'.
|
||||
|
||||
Configuration options are now documented in scripts/pnglibconf.dfa. This
|
||||
file also includes dependency information that ensures a configuration is
|
||||
consistent; that is, if a feature is switched off, dependent features are
|
||||
also switched off. As a recommended alternative to using feature macros in
|
||||
pngusr.h a system builder may also define equivalent options in pngusr.dfa
|
||||
(or, indeed, any file) and add that to the configuration by setting
|
||||
DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
|
||||
how to do this, and also illustrate a case where pngusr.h is still required.
|
||||
|
||||
After you have built libpng, the definitions that were recorded in
|
||||
pnglibconf.h are available to your application (pnglibconf.h is included
|
||||
in png.h and gets installed alongside png.h and pngconf.h in your
|
||||
$PREFIX/include directory). Do not edit pnglibconf.h after you have built
|
||||
libpng, because than the settings would not accurately reflect the settings
|
||||
that were used to build libpng.
|
||||
|
||||
XV. Configuring libpng for multiprocessing
|
||||
|
||||
Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
|
||||
is known to be not thread-safe on some platforms and we don't know of
|
||||
any platform where it is guaranteed to be thread-safe. Therefore, if
|
||||
your application is going to be using multiple threads, you should
|
||||
configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
|
||||
-DPNG_NO_SETJMP on your compile line, or with
|
||||
|
||||
#undef PNG_SETJMP_SUPPORTED
|
||||
|
||||
in your pnglibconf.h or pngusr.h.
|
||||
|
||||
XVI. Other sources of information about libpng:
|
||||
|
||||
Further information can be found in the README and libpng-manual.txt
|
||||
files, in the individual makefiles, in png.h, and the manual pages
|
||||
libpng.3 and png.5.
|
||||
@@ -162,7 +394,7 @@ CFLAGS="-Wall -O -funroll-loops \
|
||||
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
|
||||
|
||||
You can alternatively specify --includedir=/usr/include, /usr/local/include,
|
||||
/usr/include/libpng%NN%, or whatever.
|
||||
/usr/include/libpng17, or whatever.
|
||||
|
||||
If you find that the configure script is out-of-date or is not supporting
|
||||
your platform properly, try running autogen.sh to regenerate "configure",
|
||||
|
||||
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.7.0beta18, September 16, 2013, are
|
||||
Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.7.0beta41, November 7, 2014, are
|
||||
Copyright (c) 2004, 2006-2014 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
|
||||
September 16, 2013
|
||||
November 7, 2014
|
||||
|
||||
145
Makefile.am
145
Makefile.am
@@ -7,11 +7,21 @@ PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||
ACLOCAL_AMFLAGS = -I scripts
|
||||
|
||||
# test programs - run on make check, make distcheck
|
||||
check_PROGRAMS= pngtest pngunknown pngstest pngvalid
|
||||
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage
|
||||
|
||||
# Utilities - installed
|
||||
bin_PROGRAMS= pngfix png-fix-itxt
|
||||
|
||||
# This ensures that pnglibconf.h gets built at the start of 'make all' or
|
||||
# 'make check', but it does not add dependencies to the individual programs,
|
||||
# this is done below.
|
||||
#
|
||||
# IMPORTANT: always add the object modules of new programs to the list below
|
||||
# because otherwise the sequence 'configure; make new-program' will *sometimes*
|
||||
# result in the installed (system) pnglibconf.h being used and the result is
|
||||
# always wrong and always very confusing.
|
||||
BUILT_SOURCES = pnglibconf.h
|
||||
|
||||
pngtest_SOURCES = pngtest.c
|
||||
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
@@ -24,6 +34,9 @@ pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
pngunknown_SOURCES = contrib/libtests/pngunknown.c
|
||||
pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngimage_SOURCES = contrib/libtests/pngimage.c
|
||||
pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
pngfix_SOURCES = contrib/tools/pngfix.c
|
||||
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
@@ -49,7 +62,8 @@ TESTS =\
|
||||
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
|
||||
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
|
||||
tests/pngimage-quick tests/pngimage-full
|
||||
|
||||
# These tests are expected, and required, to fail:
|
||||
XFAIL_TESTS = tests/pngstest-error
|
||||
@@ -72,7 +86,7 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||
|
||||
if PNG_ARM_NEON
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
||||
arm/filter_neon.S
|
||||
arm/filter_neon.S arm/filter_neon_intrinsics.c
|
||||
endif
|
||||
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
@@ -131,8 +145,8 @@ config.sub configure depcomp install-sh ltmain.sh missing
|
||||
PNG_COPTS = @PNG_COPTS@
|
||||
AM_CFLAGS = ${PNG_COPTS}
|
||||
|
||||
# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe
|
||||
# other operating systems (NeXT?) the C preprocessor selected by configure
|
||||
# DFNCPP is normally just "CPP -E" - the C preprocessor - but on Solaris and
|
||||
# maybe other operating systems (NeXT?) the C preprocessor selected by configure
|
||||
# checks input tokens for validity - effectively it performs part of the ANSI-C
|
||||
# parsing - and therefore fails with the .df files. configure.ac has special
|
||||
# checks for this and sets DFNCPP appropriately.
|
||||
@@ -196,9 +210,22 @@ $(srcdir)/scripts/pnglibconf.h.prebuilt:
|
||||
|
||||
# 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.)
|
||||
pngstest.o pngvalid.o pngtest.o pngunknown.o timepng.o: pnglibconf.h
|
||||
pngfix.o png-fix-itxt.o: pnglibconf.h
|
||||
# 'make test' is the first thing the user does.) Only files which include
|
||||
# one of the png source files (typically png.h or pngpriv.h) need to be listed
|
||||
# here:
|
||||
pngtest.o: pnglibconf.h
|
||||
|
||||
contrib/libtests/makepng.o: pnglibconf.h
|
||||
contrib/libtests/pngstest.o: pnglibconf.h
|
||||
contrib/libtests/pngunknown.o: pnglibconf.h
|
||||
contrib/libtests/pngimage.o: pnglibconf.h
|
||||
contrib/libtests/pngvalid.o: pnglibconf.h
|
||||
contrib/libtests/readpng.o: pnglibconf.h
|
||||
contrib/libtests/tarith.o: pnglibconf.h
|
||||
contrib/libtests/timepng.o: pnglibconf.h
|
||||
|
||||
contrib/tools/makesRGB.o: pnglibconf.h
|
||||
contrib/tools/pngfix.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
|
||||
@@ -267,40 +294,76 @@ check: scripts/symbols.chk
|
||||
dist-hook:
|
||||
cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES)
|
||||
|
||||
# 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 \
|
||||
pngconf.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
|
||||
# Make links between installed files with release-specific names and the generic
|
||||
# file names. If this install rule is run the generic names will be deleted and
|
||||
# recreated - this has obvious issues for systems with multiple installations.
|
||||
|
||||
# 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
|
||||
@set -x;\
|
||||
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;\
|
||||
fi;\
|
||||
install-header-links:
|
||||
@set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \
|
||||
rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done
|
||||
|
||||
uninstall-header-links:
|
||||
cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS)
|
||||
|
||||
install-libpng-pc:
|
||||
@set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \
|
||||
$(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc
|
||||
|
||||
uninstall-libpng-pc:
|
||||
rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc'
|
||||
|
||||
# EXT_LIST is a list of the possibly library directory extensions, this exists
|
||||
# because we can't find a good way of discovering the file extensions that are
|
||||
# actually installed on a given system, so instead we check for every extension
|
||||
# we have seen.
|
||||
|
||||
EXT_LIST = a dll.a so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ la sl dylib
|
||||
|
||||
install-library-links:
|
||||
@set -x; cd '$(DESTDIR)$(libdir)';\
|
||||
for ext in $(EXT_LIST); do\
|
||||
rm -f "libpng.$$ext";\
|
||||
if test -f "$(PNGLIB_BASENAME).$$ext"; then\
|
||||
$(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\
|
||||
fi;\
|
||||
done
|
||||
|
||||
uninstall-hook:
|
||||
cd '$(DESTDIR)$(includedir)'; rm -f png.h pngconf.h pnglibconf.h
|
||||
rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc'
|
||||
uninstall-library-links:
|
||||
@set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\
|
||||
rm -f "libpng.$$ext"; done
|
||||
|
||||
install-libpng-config:
|
||||
@set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \
|
||||
$(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config
|
||||
|
||||
uninstall-libpng-config:
|
||||
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'
|
||||
|
||||
if DO_INSTALL_LINKS
|
||||
# If --enable-unversioned-links is specified the header and lib file links
|
||||
# will be automatically made on a 'make install':
|
||||
|
||||
install-data-hook: install-header-links
|
||||
uninstall-hook: uninstall-header-links
|
||||
install-exec-hook: install-library-links
|
||||
uninstall-hook: uninstall-library-links
|
||||
endif
|
||||
|
||||
if DO_INSTALL_LIBPNG_PC
|
||||
# Likewise, --install-pc causes libpng.pc to be constructed:
|
||||
|
||||
install-data-hook: install-libpng-pc
|
||||
uninstall-hook: uninstall-libpng-pc
|
||||
endif
|
||||
|
||||
if DO_INSTALL_LIBPNG_CONFIG
|
||||
# And --install-config:
|
||||
|
||||
install-exec-hook: install-libpng-config
|
||||
uninstall-hook: uninstall-libpng-config
|
||||
endif
|
||||
|
||||
# The following addition ensures that 'make all' always builds the test programs
|
||||
# too. It used to, but some change either in libpng or configure stopped this
|
||||
# working.
|
||||
all-am: $(check_PROGRAMS)
|
||||
|
||||
29
README
29
README
@@ -1,4 +1,4 @@
|
||||
README for libpng version 1.7.0beta18 - September 16, 2013 (shared library 17.0)
|
||||
README for libpng version 1.7.0beta41 - November 7, 2014 (shared library 17.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
@@ -23,18 +23,25 @@ earlier versions if you are using a shared library. The type of the
|
||||
png_uint_32, which will affect shared-library applications that use
|
||||
this function.
|
||||
|
||||
To avoid problems with changes to the internals of png_info_struct,
|
||||
To avoid problems with changes to the internals of png info_struct,
|
||||
new APIs have been made available in 0.95 to avoid direct application
|
||||
access to info_ptr. These functions are the png_set_<chunk> and
|
||||
png_get_<chunk> functions. These functions should be used when
|
||||
accessing/storing the info_struct data, rather than manipulating it
|
||||
directly, to avoid such problems in the future.
|
||||
|
||||
It is important to note that the APIs do not make current programs
|
||||
It is important to note that the APIs did not make current programs
|
||||
that access the info struct directly incompatible with the new
|
||||
library. However, it is strongly suggested that new programs use
|
||||
the new APIs (as shown in example.c and pngtest.c), and older programs
|
||||
be converted to the new format, to facilitate upgrades in the future.
|
||||
library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
|
||||
be a transitional release, members of the png_struct and the
|
||||
info_struct can still be accessed, but the compiler will issue a
|
||||
warning about deprecated usage. Since libpng-1.5.0, direct access
|
||||
to these structs is not allowed, and the definitions of the structs
|
||||
reside in private pngstruct.h and pnginfo.h header files that are not
|
||||
accessible to applications. It is strongly suggested that new
|
||||
programs use the new APIs (as shown in example.c and pngtest.c), and
|
||||
older programs be converted to the new format, to facilitate upgrades
|
||||
in the future.
|
||||
****
|
||||
|
||||
Additions since 0.90 include the ability to compile libpng as a
|
||||
@@ -87,6 +94,12 @@ This code is currently being archived at libpng.sf.net in the
|
||||
[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.
|
||||
|
||||
I am not a lawyer, but I believe that the Export Control Classification
|
||||
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||
controls or International Traffic in Arms Regulations (ITAR) because it
|
||||
is open source, publicly available software, that does not contain any
|
||||
encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
|
||||
|
||||
If you have any code changes, requests, problems, etc., please e-mail
|
||||
them to me. Also, I'd appreciate any make files or project files,
|
||||
and any modifications you needed to make to get libpng to compile,
|
||||
@@ -121,7 +134,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 eighteen years now, and it is official and
|
||||
been discussing PNG for nineteen 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.
|
||||
@@ -177,7 +190,7 @@ Files in this distribution:
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
tools => Various tools
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
projects => Contains project files and workspaces for
|
||||
building a DLL
|
||||
owatcom => Contains a WATCOM project for building libpng
|
||||
|
||||
2
TODO
2
TODO
@@ -6,10 +6,12 @@ Better C++ wrapper/full C++ implementation?
|
||||
Fix problem with C++ and EXTERN "C".
|
||||
cHRM transformation.
|
||||
Remove setjmp/longjmp usage in favor of returning error codes.
|
||||
Palette creation.
|
||||
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||
Improved dithering.
|
||||
Multi-lingual error and warning message support.
|
||||
Complete sRGB transformation (presently it simply uses gamma=0.45455).
|
||||
Make profile checking optional via a png_set_something() call.
|
||||
Man pages for function calls.
|
||||
Better documentation.
|
||||
Better filter selection
|
||||
|
||||
164
arm/arm_init.c
164
arm/arm_init.c
@@ -1,9 +1,9 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.6 [September 16, 2013]
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -19,132 +19,33 @@
|
||||
#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.
|
||||
/* WARNING: it is strongly recommended that you do not build libpng with
|
||||
* run-time checks for CPU features if at all possible. In the case of the ARM
|
||||
* NEON instructions there is no processor-specific way of detecting the
|
||||
* presence of the required support, therefore run-time detection is extremely
|
||||
* OS specific.
|
||||
*
|
||||
* Documentation: http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
|
||||
* You may set the macro PNG_ARM_NEON_FILE to the file name of file containing
|
||||
* a fragment of C source code which defines the png_have_neon function. There
|
||||
* are a number of implementations in contrib/arm-neon, but the only one that
|
||||
* has partial support is contrib/arm-neon/linux.c - a generic Linux
|
||||
* implementation which reads /proc/cpufino.
|
||||
*/
|
||||
#include <cpu-features.h>
|
||||
#ifndef PNG_ARM_NEON_FILE
|
||||
# ifdef __linux__
|
||||
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
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 */
|
||||
#ifdef PNG_ARM_NEON_FILE
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <elf.h>
|
||||
#include <asm/hwcap.h>
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
static int png_have_neon(png_structp png_ptr);
|
||||
#include PNG_ARM_NEON_FILE
|
||||
|
||||
/* 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 */
|
||||
#else /* PNG_ARM_NEON_FILE */
|
||||
# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks"
|
||||
#endif /* PNG_ARM_NEON_FILE */
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
@@ -154,6 +55,16 @@ png_have_neon(png_structp png_ptr)
|
||||
void
|
||||
png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
|
||||
{
|
||||
/* The switch statement is compiled in for ARM_NEON_API, the call to
|
||||
* png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined
|
||||
* the check is only performed if the API has not set the NEON option on
|
||||
* or off explicitly. In this case the check controls what happens.
|
||||
*
|
||||
* If the CHECK is not compiled in and the option is UNSET the behavior prior
|
||||
* to 1.6.7 was to use the NEON code - this was a bug caused by having the
|
||||
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
|
||||
* as documented in png.h
|
||||
*/
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
switch ((pp->options >> PNG_ARM_NEON) & 3)
|
||||
{
|
||||
@@ -178,13 +89,14 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
|
||||
break;
|
||||
#endif
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
default: /* OFF or INVALID */
|
||||
return;
|
||||
|
||||
case PNG_OPTION_ON:
|
||||
/* Option turned on */
|
||||
break;
|
||||
|
||||
default: /* OFF or INVALID */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.5.17 [July 18, 2013]
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -11,7 +11,8 @@
|
||||
*/
|
||||
|
||||
/* This is required to get the symbol renames, which are #defines, and also
|
||||
* includes the definition (or not) of PNG_ARM_NEON_OPT.
|
||||
* includes the definition (or not) of PNG_ARM_NEON_OPT and
|
||||
* PNG_ARM_NEON_IMPLEMENTATION.
|
||||
*/
|
||||
#define PNG_VERSION_INFO_ONLY
|
||||
#include "../pngpriv.h"
|
||||
@@ -20,6 +21,13 @@
|
||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||
#endif
|
||||
|
||||
/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for
|
||||
* ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it
|
||||
* only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h
|
||||
* for the logic which sets PNG_USE_ARM_NEON_ASM:
|
||||
*/
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
@@ -235,3 +243,4 @@ func png_read_filter_row_paeth3_neon, export=1
|
||||
endfunc
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
|
||||
|
||||
372
arm/filter_neon_intrinsics.c
Normal file
372
arm/filter_neon_intrinsics.c
Normal file
@@ -0,0 +1,372 @@
|
||||
|
||||
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by James Yu <james.yu at linaro.org>, October 2013.
|
||||
* Based on filter_neon.S, written by Mans Rullgard, 2011.
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include "../pngpriv.h"
|
||||
|
||||
/* This code requires -mfpu=neon on the command line: */
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
#include <arm_neon.h>
|
||||
|
||||
/* libpng row pointers are not necessarily aligned to any particular boundary,
|
||||
* however this code will only work with appropriate alignment. arm/arm_init.c
|
||||
* checks for this (and will not compile unless it is done). This code uses
|
||||
* variants of png_aligncast to avoid compiler warnings.
|
||||
*/
|
||||
#define png_ptr(type,pointer) png_aligncast(type *,pointer)
|
||||
#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer)
|
||||
|
||||
/* The following relies on a variable 'temp_pointer' being declared with type
|
||||
* 'type'. This is written this way just to hide the GCC strict aliasing
|
||||
* warning; note that the code is safe because there never is an alias between
|
||||
* the input and output pointers.
|
||||
*/
|
||||
#define png_ldr(type,pointer)\
|
||||
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
void
|
||||
png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||
{
|
||||
uint8x16_t qrp, qpp;
|
||||
|
||||
qrp = vld1q_u8(rp);
|
||||
qpp = vld1q_u8(pp);
|
||||
qrp = vaddq_u8(qrp, qpp);
|
||||
vst1q_u8(rp, qrp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
|
||||
uint8x16_t vtmp = vld1q_u8(rp);
|
||||
uint8x8x2_t *vrpt = png_ptr(uint8x8x2_t, &vtmp);
|
||||
uint8x8x2_t vrp = *vrpt;
|
||||
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop;)
|
||||
{
|
||||
uint8x8_t vtmp1, vtmp2;
|
||||
uint32x2_t *temp_pointer;
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||
vtmp2 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||
vdest.val[1] = vadd_u8(vdest.val[0], vtmp1);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||
vdest.val[2] = vadd_u8(vdest.val[1], vtmp2);
|
||||
vdest.val[3] = vadd_u8(vdest.val[2], vtmp1);
|
||||
|
||||
vtmp = vld1q_u8(rp + 12);
|
||||
vrpt = png_ptr(uint8x8x2_t, &vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||
rp += 3;
|
||||
}
|
||||
|
||||
PNG_UNUSED(prev_row)
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop; rp += 16)
|
||||
{
|
||||
uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
uint8x8x4_t vrp = *vrpt;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
|
||||
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
}
|
||||
|
||||
PNG_UNUSED(prev_row)
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
|
||||
uint8x16_t vtmp;
|
||||
uint8x8x2_t *vrpt;
|
||||
uint8x8x2_t vrp;
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
vtmp = vld1q_u8(rp);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
for (; rp < rp_stop; pp += 12)
|
||||
{
|
||||
uint8x8_t vtmp1, vtmp2, vtmp3;
|
||||
|
||||
uint8x8x2_t *vppt;
|
||||
uint8x8x2_t vpp;
|
||||
|
||||
uint32x2_t *temp_pointer;
|
||||
|
||||
vtmp = vld1q_u8(pp);
|
||||
vppt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
|
||||
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
|
||||
vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||
vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
|
||||
|
||||
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6);
|
||||
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||
|
||||
vtmp = vld1q_u8(rp + 12);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vtmp3);
|
||||
|
||||
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
|
||||
|
||||
vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
|
||||
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||
rp += 3;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||
{
|
||||
uint32x2x4_t vtmp;
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
|
||||
vppt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
vdest.val[1] = vhadd_u8(vdest.val[0], vpp.val[1]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
|
||||
vdest.val[2] = vhadd_u8(vdest.val[1], vpp.val[2]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
|
||||
vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
|
||||
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
}
|
||||
}
|
||||
|
||||
static uint8x8_t
|
||||
paeth(uint8x8_t a, uint8x8_t b, uint8x8_t c)
|
||||
{
|
||||
uint8x8_t d, e;
|
||||
uint16x8_t p1, pa, pb, pc;
|
||||
|
||||
p1 = vaddl_u8(a, b); /* a + b */
|
||||
pc = vaddl_u8(c, c); /* c * 2 */
|
||||
pa = vabdl_u8(b, c); /* pa */
|
||||
pb = vabdl_u8(a, c); /* pb */
|
||||
pc = vabdq_u16(p1, pc); /* pc */
|
||||
|
||||
p1 = vcleq_u16(pa, pb); /* pa <= pb */
|
||||
pa = vcleq_u16(pa, pc); /* pa <= pc */
|
||||
pb = vcleq_u16(pb, pc); /* pb <= pc */
|
||||
|
||||
p1 = vandq_u16(p1, pa); /* pa <= pb && pa <= pc */
|
||||
|
||||
d = vmovn_u16(pb);
|
||||
e = vmovn_u16(p1);
|
||||
|
||||
d = vbsl_u8(d, b, c);
|
||||
e = vbsl_u8(e, a, d);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
|
||||
uint8x16_t vtmp;
|
||||
uint8x8x2_t *vrpt;
|
||||
uint8x8x2_t vrp;
|
||||
uint8x8_t vlast = vdup_n_u8(0);
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
vtmp = vld1q_u8(rp);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
for (; rp < rp_stop; pp += 12)
|
||||
{
|
||||
uint8x8x2_t *vppt;
|
||||
uint8x8x2_t vpp;
|
||||
uint8x8_t vtmp1, vtmp2, vtmp3;
|
||||
uint32x2_t *temp_pointer;
|
||||
|
||||
vtmp = vld1q_u8(pp);
|
||||
vppt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
|
||||
vdest.val[1] = paeth(vdest.val[0], vtmp2, vpp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||
vtmp3 = vext_u8(vpp.val[0], vpp.val[1], 6);
|
||||
vdest.val[2] = paeth(vdest.val[1], vtmp3, vtmp2);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vtmp1);
|
||||
|
||||
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
|
||||
|
||||
vtmp = vld1q_u8(rp + 12);
|
||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
|
||||
vdest.val[3] = paeth(vdest.val[2], vtmp2, vtmp3);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
|
||||
|
||||
vlast = vtmp2;
|
||||
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||
rp += 3;
|
||||
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||
rp += 3;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_bytep rp_stop = row + row_info->rowbytes;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
uint8x8_t vlast = vdup_n_u8(0);
|
||||
uint8x8x4_t vdest;
|
||||
vdest.val[3] = vdup_n_u8(0);
|
||||
|
||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||
{
|
||||
uint32x2x4_t vtmp;
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vrp = *vrpt;
|
||||
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
|
||||
vppt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
vpp = *vppt;
|
||||
|
||||
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
|
||||
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||
vdest.val[1] = paeth(vdest.val[0], vpp.val[1], vpp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
|
||||
vdest.val[2] = paeth(vdest.val[1], vpp.val[2], vpp.val[1]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
|
||||
vdest.val[3] = paeth(vdest.val[2], vpp.val[3], vpp.val[2]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
|
||||
|
||||
vlast = vpp.val[3];
|
||||
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */
|
||||
13
autogen.sh
13
autogen.sh
@@ -9,15 +9,15 @@
|
||||
#
|
||||
# For regular ("tarball") distributions all the files should exist. We do not
|
||||
# want them to be updated *under any circumstances*. It should never be
|
||||
# necessary to rune autogen.sh because ./configure --enable-maintainer-mode says
|
||||
# what to do if Makeile.am or configure.ac are changed.
|
||||
# necessary to run autogen.sh because ./configure --enable-maintainer-mode says
|
||||
# what to do if Makefile.am or configure.ac are changed.
|
||||
#
|
||||
# It is *probably* OK to update the files on a GIT checkout, because they have
|
||||
# come from the local tools, but leave that to the user who is assumed to know
|
||||
# whether it is ok or required.
|
||||
#
|
||||
# This script is intended to work without arguments, there are, however, hidden
|
||||
# arguments for (a) use while testing the script and (b) to fix up systems that
|
||||
# arguments (a) for use while testing the script and (b) to fix up systems that
|
||||
# have been broken. If (b) is required the script prompts for the correct
|
||||
# options. For this reason the options are *NOT* documented in the help; this
|
||||
# is deliberate; UTSL.
|
||||
@@ -76,6 +76,10 @@ done
|
||||
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in\
|
||||
config.sub configure depcomp install-sh ltmain.sh missing test-driver"
|
||||
#
|
||||
# Files generated by versions of configue >2.68 or automake >1.13 (i.e. later
|
||||
# versions than those required by configure.ac):
|
||||
libpng_autotools_extra="compile"
|
||||
#
|
||||
# These are separate because 'maintainer-clean' does not remove them.
|
||||
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
|
||||
scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4"
|
||||
@@ -94,6 +98,7 @@ libpng_configure_dirs=".deps"
|
||||
# of Makefile. These functions do the two bits of cleaning.
|
||||
clean_autotools(){
|
||||
rm -rf $libpng_autotools_files $libpng_libtool_files $libpng_autotools_dirs
|
||||
rm -rf $libpng_autotools_extra
|
||||
}
|
||||
|
||||
clean_configure(){
|
||||
@@ -198,7 +203,7 @@ case "$mode" in
|
||||
echo " You can run autoreconf yourself if you don't like maintainer"
|
||||
echo " mode and you can also just run autoreconf -f -i to initialize"
|
||||
echo " everything in the first place; this script is only for"
|
||||
echo " compatiblity with prior releases."
|
||||
echo " compatibility with prior releases."
|
||||
exit 1
|
||||
else
|
||||
exec >&2
|
||||
|
||||
71
configure.ac
71
configure.ac
@@ -18,7 +18,7 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.7.0beta18],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.7.0beta41],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
@@ -27,7 +27,7 @@ AC_CONFIG_MACRO_DIR([scripts])
|
||||
# dist-xz requires automake 1.11 or later
|
||||
# 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])
|
||||
AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
|
||||
# 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
|
||||
@@ -39,7 +39,7 @@ 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.7.0beta18
|
||||
PNGLIB_VERSION=1.7.0beta41
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=7
|
||||
PNGLIB_RELEASE=0
|
||||
@@ -79,7 +79,7 @@ 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"
|
||||
DFNCPP="$CPP -E"
|
||||
AC_SUBST(DFNCPP)
|
||||
|
||||
# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
|
||||
@@ -137,12 +137,20 @@ AC_CHECK_FUNCS([memset memcpy strncpy],,
|
||||
|
||||
# floor and ceil are required for FLOATING_POINT, but they can be turned off on
|
||||
# the configure command line (and they are independent.) Default is to 'on'
|
||||
AC_ARG_ENABLE([floating-point],[Enable floating point APIs],,
|
||||
[enable_floating_point=yes])
|
||||
AC_ARG_ENABLE([fixed-point],[Enable fixed point APIs],,
|
||||
[enable_fixed_point=yes])
|
||||
AC_ARG_ENABLE([floating-arithmetic],[Use floating point arithmetic internally],,
|
||||
[enable_floating_arithmetic=yes])
|
||||
AC_ARG_ENABLE([floating-point],
|
||||
AS_HELP_STRING([[[--enabled-floating-point]]],
|
||||
[Enable floating point APIs (default: yes)]),,
|
||||
[enable_floating_point=yes])
|
||||
|
||||
AC_ARG_ENABLE([fixed-point],
|
||||
AS_HELP_STRING([[[--enable-fixed-point]]],
|
||||
[Enable fixed point APIs (default: yes)]),,
|
||||
[enable_fixed_point=yes])
|
||||
|
||||
AC_ARG_ENABLE([floating-arithmetic],
|
||||
AS_HELP_STRING([[[--enable-floating-arithmetic]]],
|
||||
[Use floating point arithmetic internally (default: yes)]),,
|
||||
[enable_floating_arithmetic=yes])
|
||||
|
||||
# Check for a requirement for math library support
|
||||
if test "$enable_floating_arithmetic" = yes
|
||||
@@ -286,7 +294,7 @@ 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 \
|
||||
| ${DFNCPP-${CC-gcc -E}} - 2>&1 \
|
||||
| ${EGREP-grep} "^PREFIX=" \
|
||||
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
|
||||
AC_SUBST(SYMBOL_PREFIX)
|
||||
@@ -334,6 +342,45 @@ AC_ARG_WITH(libpng-prefix,
|
||||
fi])
|
||||
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
|
||||
|
||||
# Control over what links are made for installed files. Versioned files are
|
||||
# always installed, when the following options are turned on corresponding
|
||||
# unversioned links are also created (normally as symbolic links):
|
||||
AC_ARG_ENABLE([unversioned-links],
|
||||
AS_HELP_STRING([[[--enable-unversioned-links]]],
|
||||
[Installed libpng header files are placed in a versioned subdirectory]
|
||||
[and installed libpng library (including DLL) files are versioned.]
|
||||
[If this option is enabled unversioned links will be created pointing to]
|
||||
[the corresponding installed files. If you use libpng.pc or]
|
||||
[libpng-config for all builds you do not need these links, but if you]
|
||||
[compile programs directly they will typically #include <png.h> and]
|
||||
[link with -lpng; in that case you need the links.]
|
||||
[The links can be installed manually using 'make install-header-links']
|
||||
[and 'make install-library-links' and can be removed using the]
|
||||
[corresponding uninstall- targets. If you do enable this option every]
|
||||
[libpng 'make install' will recreate the links to point to the just]
|
||||
[installed version of libpng. The default is to create the links;]
|
||||
[use --disable-unversioned-links to change this]))
|
||||
|
||||
# The AM_CONDITIONAL test is written so that the default is enabled;
|
||||
# --disable-unversioned-links must be given to turn the option off.
|
||||
AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
|
||||
|
||||
AC_ARG_ENABLE([unversioned-libpng-pc],
|
||||
AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
|
||||
[Install the configuration file 'libpng.pc' as a link to the versioned]
|
||||
[version. This is done by default - use --disable-unversioned-libpng-pc]
|
||||
[to change this.]))
|
||||
AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
|
||||
[test "$enable_unversioned_libpng_pc" != "no"])
|
||||
|
||||
AC_ARG_ENABLE([unversioned-libpng-config],
|
||||
AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
|
||||
[Install the configuration file 'libpng-config' as a link to the]
|
||||
[versioned version. This is done by default - use]
|
||||
[--disable-unversioned-libpng-config to change this.]))
|
||||
AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
|
||||
[test "$enable_unversioned_libpng_config" != "no"])
|
||||
|
||||
# HOST SPECIFIC OPTIONS
|
||||
# =====================
|
||||
#
|
||||
@@ -379,7 +426,7 @@ AC_ARG_ENABLE([arm-neon],
|
||||
AM_CONDITIONAL([PNG_ARM_NEON],
|
||||
[test "$enable_arm_neon" != 'no' &&
|
||||
case "$host_cpu" in
|
||||
arm*) :;;
|
||||
arm*|aarch64*) :;;
|
||||
*) test "$enable_arm_neon" != '';;
|
||||
esac])
|
||||
|
||||
|
||||
83
contrib/arm-neon/README
Normal file
83
contrib/arm-neon/README
Normal file
@@ -0,0 +1,83 @@
|
||||
OPERATING SYSTEM SPECIFIC ARM NEON DETECTION
|
||||
--------------------------------------------
|
||||
|
||||
Detection of the ability to exexcute ARM NEON on an ARM processor requires
|
||||
operating system support. (The information is not available in user mode.)
|
||||
|
||||
HOW TO USE THIS
|
||||
---------------
|
||||
|
||||
This directory contains C code fragments that can be included in arm/arm_init.c
|
||||
by setting the macro PNG_ARM_NEON_FILE to the file name in "" or <> at build
|
||||
time. This setting is not recorded in pnglibconf.h and can be changed simply by
|
||||
rebuilding arm/arm_init.o with the required macro definition.
|
||||
|
||||
For any of this code to be used the ARM NEON code must be enabled and run time
|
||||
checks must be supported. I.e.:
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
|
||||
|
||||
This is done in a 'configure' build by passing configure the argument:
|
||||
|
||||
--enable-arm-neon=check
|
||||
|
||||
Apart from the basic Linux implementation in contrib/arm-neon/linux.c this code
|
||||
is unsupported. That means that it is not even compiled on a regular basis and
|
||||
may be broken in any given minor release.
|
||||
|
||||
FILE FORMAT
|
||||
-----------
|
||||
|
||||
Each file documents its testing status as of the last time it was tested (which
|
||||
may have been a long time ago):
|
||||
|
||||
STATUS: one of:
|
||||
SUPPORTED: This indicates that the file is included in the regularly
|
||||
performed test builds and bugs are fixed when discovered.
|
||||
COMPILED: This indicates that the code did compile at least once. See the
|
||||
more detailed description for the extent to which the result was
|
||||
successful.
|
||||
TESTED: This means the code was fully compiled into the libpng test programs
|
||||
and these were run at least once.
|
||||
|
||||
BUG REPORTS: an email address to which to send reports of problems
|
||||
|
||||
The file is a fragment of C code. It should not define any 'extern' symbols;
|
||||
everything should be static. It must define the function:
|
||||
|
||||
static int png_have_neon(png_structp png_ptr);
|
||||
|
||||
That function must return 1 if ARM NEON instructions are supported, 0 if not.
|
||||
It must not execute png_error unless it detects a bug. A png_error will prevent
|
||||
the reading of the PNG and in the future, writing too.
|
||||
|
||||
BUG REPORTS
|
||||
-----------
|
||||
|
||||
If you mail a bug report for any file that is not SUPPORTED there may only be
|
||||
limited response. Consider fixing it and sending a patch to fix the problem -
|
||||
this is more likely to result in action.
|
||||
|
||||
CONTRIBUTIONS
|
||||
-------------
|
||||
|
||||
You may send contributions of new implementations to
|
||||
png-mng-implement@sourceforge.net. Please write code in strict C90 C where
|
||||
possible. Obviously OS dependencies are to be expected. If you submit code you
|
||||
must have the authors permission and it must have a license that is acceptable
|
||||
to the current maintainer; in particular that license must permit modification
|
||||
and redistribution.
|
||||
|
||||
Please try to make the contribution a single file and give the file a clear and
|
||||
unambiguous name that identifies the target OS. If multiple files really are
|
||||
required put them all in a sub-directory.
|
||||
|
||||
You must also be prepared to handle bug reports from users of the code, either
|
||||
by joining the png-mng-implement mailing list or by providing an email for the
|
||||
"BUG REPORTS" entry or both. Please make sure that the header of the file
|
||||
contains the STATUS and BUG REPORTS fields as above.
|
||||
|
||||
Please list the OS requirements as precisely as possible. Ideally you should
|
||||
also list the environment in which the code has been tested and certainly list
|
||||
any environments where you suspect it might not work.
|
||||
39
contrib/arm-neon/android-ndk.c
Normal file
39
contrib/arm-neon/android-ndk.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/* contrib/arm-neon/android-ndk.c
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by John Bowler, 2014.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* SEE contrib/arm-neon/README before reporting bugs
|
||||
*
|
||||
* STATUS: COMPILED, UNTESTED
|
||||
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||
*
|
||||
* png_have_neon implemented for the Android NDK, see:
|
||||
*
|
||||
* Documentation:
|
||||
* http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
|
||||
* http://code.google.com/p/android/issues/detail?id=49065
|
||||
*
|
||||
* NOTE: this requires that libpng is built against the Android NDK and linked
|
||||
* with an implementation of the Android ARM 'cpu-features' library. The code
|
||||
* has been compiled only, not linked: no version of the library has been found,
|
||||
* only the header files exist in the NDK.
|
||||
*/
|
||||
#include <cpu-features.h>
|
||||
|
||||
static int
|
||||
png_have_neon(png_structp png_ptr)
|
||||
{
|
||||
/* This is a whole lot easier than the linux code, 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;
|
||||
}
|
||||
120
contrib/arm-neon/linux-auxv.c
Normal file
120
contrib/arm-neon/linux-auxv.c
Normal file
@@ -0,0 +1,120 @@
|
||||
/* contrib/arm-neon/linux-auxv.c
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* SEE contrib/arm-neon/README before reporting bugs
|
||||
*
|
||||
* STATUS: COMPILED, TESTED
|
||||
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||
*
|
||||
* png_have_neon implemented for Linux versions which allow access to
|
||||
* /proc/self/auxv. This is probably faster, cleaner and safer than the code to
|
||||
* read /proc/cpuinfo in contrib/arm-neon/linux, however it is yet another piece
|
||||
* of potentially untested code and has more complex dependencies than the code
|
||||
* to read cpuinfo.
|
||||
*
|
||||
* This 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;
|
||||
}
|
||||
159
contrib/arm-neon/linux.c
Normal file
159
contrib/arm-neon/linux.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/* contrib/arm-neon/linux.c
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by John Bowler, 2014.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* SEE contrib/arm-neon/README before reporting bugs
|
||||
*
|
||||
* STATUS: SUPPORTED
|
||||
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||
*
|
||||
* png_have_neon implemented for Linux by reading the widely available
|
||||
* pseudo-file /proc/cpuinfo.
|
||||
*
|
||||
* This code is strict ANSI-C and is probably moderately portable, it does
|
||||
* however use <stdio.h> and assumes that /proc/cpuinfo is never localized.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
static int
|
||||
png_have_neon(png_structp png_ptr)
|
||||
{
|
||||
FILE *f = fopen("/proc/cpuinfo", "rb");
|
||||
|
||||
if (f != NULL)
|
||||
{
|
||||
/* This is a simple state machine which reads the input byte-by-byte until
|
||||
* it gets a match on the 'neon' feature or reaches the end of the stream.
|
||||
*/
|
||||
static const char ch_feature[] = { 70, 69, 65, 84, 85, 82, 69, 83 };
|
||||
static const char ch_neon[] = { 78, 69, 79, 78 };
|
||||
|
||||
enum
|
||||
{
|
||||
StartLine, Feature, Colon, StartTag, Neon, HaveNeon, SkipTag, SkipLine
|
||||
} state;
|
||||
int counter;
|
||||
|
||||
for (state=StartLine, counter=0;;)
|
||||
{
|
||||
int ch = fgetc(f);
|
||||
|
||||
if (ch == EOF)
|
||||
{
|
||||
/* EOF means error or end-of-file, return false; neon at EOF is
|
||||
* assumed to be a mistake.
|
||||
*/
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case StartLine:
|
||||
/* Match spaces at the start of line */
|
||||
if (ch <= 32) /* skip control characters and space */
|
||||
break;
|
||||
|
||||
counter=0;
|
||||
state = Feature;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case Feature:
|
||||
/* Match 'FEATURE', ASCII case insensitive. */
|
||||
if ((ch & ~0x20) == ch_feature[counter])
|
||||
{
|
||||
if (++counter == (sizeof ch_feature))
|
||||
state = Colon;
|
||||
break;
|
||||
}
|
||||
|
||||
/* did not match 'feature' */
|
||||
state = SkipLine;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case SkipLine:
|
||||
skipLine:
|
||||
/* Skip everything until we see linefeed or carriage return */
|
||||
if (ch != 10 && ch != 13)
|
||||
break;
|
||||
|
||||
state = StartLine;
|
||||
break;
|
||||
|
||||
case Colon:
|
||||
/* Match any number of space or tab followed by ':' */
|
||||
if (ch == 32 || ch == 9)
|
||||
break;
|
||||
|
||||
if (ch == 58) /* i.e. ':' */
|
||||
{
|
||||
state = StartTag;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Either a bad line format or a 'feature' prefix followed by
|
||||
* other characters.
|
||||
*/
|
||||
state = SkipLine;
|
||||
goto skipLine;
|
||||
|
||||
case StartTag:
|
||||
/* Skip space characters before a tag */
|
||||
if (ch == 32 || ch == 9)
|
||||
break;
|
||||
|
||||
state = Neon;
|
||||
counter = 0;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case Neon:
|
||||
/* Look for 'neon' tag */
|
||||
if ((ch & ~0x20) == ch_neon[counter])
|
||||
{
|
||||
if (++counter == (sizeof ch_neon))
|
||||
state = HaveNeon;
|
||||
break;
|
||||
}
|
||||
|
||||
state = SkipTag;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case SkipTag:
|
||||
/* Skip non-space characters */
|
||||
if (ch == 10 || ch == 13)
|
||||
state = StartLine;
|
||||
|
||||
else if (ch == 32 || ch == 9)
|
||||
state = StartTag;
|
||||
break;
|
||||
|
||||
case HaveNeon:
|
||||
/* Have seen a 'neon' prefix, but there must be a space or new
|
||||
* line character to terminate it.
|
||||
*/
|
||||
if (ch == 10 || ch == 13 || ch == 32 || ch == 9)
|
||||
{
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
state = SkipTag;
|
||||
break;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "png_have_neon: internal error (bug)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
||||
|
||||
return 0;
|
||||
}
|
||||
49
contrib/conftest/README
Normal file
49
contrib/conftest/README
Normal file
@@ -0,0 +1,49 @@
|
||||
This directory contains test configuration files, currently always '.dfa' files
|
||||
intended to be used in the build by setting the make macro DFA_XTRA to the name
|
||||
of the file.
|
||||
|
||||
These files are used in release validation of the 'configure' builds of libpng
|
||||
by building 'make check', or 'make all-am' for cross-builds, with each .dfa
|
||||
file.
|
||||
|
||||
The files in this directory may change between minor releases, however
|
||||
contributions describing specific builds of libpng are welcomed. There is no
|
||||
guarantee that libpng will continue to build with such configurations; support
|
||||
for given configurations can be, and has been, dropped between successive minor
|
||||
releases. However if a .dfa file describing a configuration is not in this
|
||||
directory it is very unlikely that it will be tested before a minor release!
|
||||
|
||||
You can use these .dfa files as the basis of new configurations. Files in this
|
||||
directory should not have any use restrictions or restrictive licenses.
|
||||
|
||||
This directory is not included in the .zip and .7z distributions, which do
|
||||
not contain 'configure' scripts.
|
||||
|
||||
DOCUMENTATION
|
||||
=============
|
||||
|
||||
Examples:
|
||||
${srcdir}/pngusr.dfa
|
||||
${srcdir}/contrib/pngminim/*/pngusr.dfa
|
||||
|
||||
Documentation of the options:
|
||||
${srcdir}/scripts/pnglibconf.dfa
|
||||
|
||||
Documentation of the file format:
|
||||
${srcdir}/scripts/options.awk
|
||||
|
||||
FILE NAMING
|
||||
===========
|
||||
|
||||
File names in this directory may NOT contain any of the five characters:
|
||||
|
||||
- , + * ?
|
||||
|
||||
Neither may they contain any space character.
|
||||
|
||||
While other characters may be used it is strongly suggested that file names be
|
||||
limited to lower case Latiin alphabetic characters (a-z), digits (0-9) and, if
|
||||
necessary the underscore (_) character. File names should be about 8 characters
|
||||
long (excluding the .dfa extension). Submitted .dfa files should have names
|
||||
between 7 and 16 characters long, shorter names (6 characters or less) are
|
||||
reserved for standard tests.
|
||||
58
contrib/conftest/read.dfa
Normal file
58
contrib/conftest/read.dfa
Normal file
@@ -0,0 +1,58 @@
|
||||
# read.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# 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.
|
||||
#
|
||||
# Build libpng with basic read support. This enables the lowest level libpng
|
||||
# read API - the one where the calling code has to use a loop to read each row.
|
||||
# At present this is the API used by most programs.
|
||||
#
|
||||
# Support is enabled only for those chunks and transformations that are
|
||||
# typically required - others can be added easily.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
# The sequential read code is enabled here; the progressive code can be used
|
||||
# instead but there is no point enabling both.
|
||||
|
||||
option SEQUENTIAL_READ on
|
||||
|
||||
# Likewise it is pointless enabling both fixed and floating point APIs. Choose
|
||||
# one or the other for both the API and the internal math.
|
||||
|
||||
#Fixed point:
|
||||
#option FIXED_POINT on
|
||||
#option FLOATING_ARITHMETIC off
|
||||
|
||||
#Floating point:
|
||||
option FLOATING_POINT on
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# Basic error handling, IO and user memory support. The latter allows the
|
||||
# application program to provide its own implementations of 'malloc' and 'free'.
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option USER_MEM on
|
||||
|
||||
# To read the full set of PNG images correctly interlace, transparency and
|
||||
# 16-bit support is required. The application can implement interlace itself,
|
||||
# but very few do and it's no longer possible to disable it when READ is
|
||||
# enabled.
|
||||
option READ_tRNS on
|
||||
option READ_16BIT on
|
||||
|
||||
# Everything else is application dependent. This file assumes the app handles
|
||||
# all the native PNG bit layouts, so it doesn't need any of layout change
|
||||
# transforms, but needs libpng to perform gamma correction. It doesn't do any
|
||||
# colorspace stuff and ignores the 'significant bit' information.
|
||||
#
|
||||
# If your app always expands the image to a limited set of bit layouts you
|
||||
# probably want to consider using the simplified API instead of the low level
|
||||
# one - see png.h and s_read.dfa.
|
||||
option READ_GAMMA on
|
||||
35
contrib/conftest/s_read.dfa
Normal file
35
contrib/conftest/s_read.dfa
Normal file
@@ -0,0 +1,35 @@
|
||||
# s_read.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# 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.
|
||||
#
|
||||
# Build libpng with simplified read support (only). This builds a minimal
|
||||
# libpng able to read all PNG formats and convert them into a small number of
|
||||
# well understood memory formats.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
option SIMPLIFIED_READ on
|
||||
|
||||
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||
# to chose an internal math implementation. The default (because of 'everything
|
||||
# = off') is fixed point - turn the floating point implementation on if you have
|
||||
# hardware floating point or prefer your software floating point implementation.
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# This is not strictly necessary, but without it the message strings in the API
|
||||
# will not be filled in
|
||||
option ERROR_TEXT on
|
||||
|
||||
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||
# need this if you don't use them, they just allow the in-memory layout to be
|
||||
# changed to match common hardware formats.
|
||||
option SIMPLIFIED_READ_AFIRST on
|
||||
option SIMPLIFIED_READ_BGR on
|
||||
33
contrib/conftest/s_write.dfa
Normal file
33
contrib/conftest/s_write.dfa
Normal file
@@ -0,0 +1,33 @@
|
||||
# s_write.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# 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.
|
||||
#
|
||||
# Build libpng with (just) simplified write support
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
option SIMPLIFIED_WRITE on
|
||||
|
||||
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||
# to chose an internal math implementation. The default (because of 'everything
|
||||
# = off') is fixed point - turn the floating point implementation on if you have
|
||||
# hardware floating point or prefer your software floating point implementation.
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# This is not strictly necessary, but without it the message strings in the API
|
||||
# will not be filled in
|
||||
option ERROR_TEXT on
|
||||
|
||||
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||
# need this if you don't use them, they just allow the in-memory layout to be
|
||||
# changed to match common hardware formats.
|
||||
option SIMPLIFIED_WRITE_AFIRST on
|
||||
option SIMPLIFIED_WRITE_BGR on
|
||||
36
contrib/conftest/simple.dfa
Normal file
36
contrib/conftest/simple.dfa
Normal file
@@ -0,0 +1,36 @@
|
||||
# simple.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# 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.
|
||||
#
|
||||
# Build libpng with just the simplified APIs (read and write).
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
option SIMPLIFIED_WRITE on
|
||||
option SIMPLIFIED_READ on
|
||||
|
||||
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||
# to chose an internal math implementation. The default (because of 'everything
|
||||
# = off') is fixed point - turn the floating point implementation on if you have
|
||||
# hardware floating point or prefer your software floating point implementation.
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# This is not strictly necessary, but without it the message strings in the API
|
||||
# will not be filled in
|
||||
option ERROR_TEXT on
|
||||
|
||||
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||
# need this if you don't use them, they just allow the in-memory layout to be
|
||||
# changed to match common hardware formats.
|
||||
option SIMPLIFIED_READ_AFIRST on
|
||||
option SIMPLIFIED_READ_BGR on
|
||||
option SIMPLIFIED_WRITE_AFIRST on
|
||||
option SIMPLIFIED_WRITE_BGR on
|
||||
45
contrib/conftest/write.dfa
Normal file
45
contrib/conftest/write.dfa
Normal file
@@ -0,0 +1,45 @@
|
||||
# write.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# 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.
|
||||
#
|
||||
# Build libpng with no read support and minimal write support.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
# Switch on the write code - this makes a minimalist encoder
|
||||
|
||||
option WRITE on
|
||||
|
||||
# Choose fixed or floating point APIs and arithmetic. The choices are
|
||||
# independent but normally they will match. It is typically better to use the
|
||||
# floating point if you have floating point hardware. If you don't know, or
|
||||
# (perhaps) to make libpng smaller used fixed point throughout.
|
||||
|
||||
#Fixed point:
|
||||
#option FIXED_POINT on
|
||||
#option FLOATING_ARITHMETIC off
|
||||
|
||||
#Floating point:
|
||||
option FLOATING_POINT on
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# Basic error handling, IO and user memory support. The latter allows the
|
||||
# application program to provide its own implementations of 'malloc' and 'free'.
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option USER_MEM on
|
||||
|
||||
# Everything else is optional. Unlike the read code in libpng the write code
|
||||
# does not need to deal with arbitrary formats, so only add support for things
|
||||
# you really do write! For example you might only write sRGB images, sometimes
|
||||
# with transparency and never write 16 bit images, so:
|
||||
option WRITE_sRGB on
|
||||
option WRITE_tRNS on
|
||||
#option WRITE_16BIT off (this is the default with 'everything = off')
|
||||
@@ -6,9 +6,9 @@
|
||||
* United States.
|
||||
*
|
||||
* Extract any icc profiles found in the given PNG files. This is a simple
|
||||
* example of a program which extracts information from the header of a PNG file
|
||||
* example of a program that extracts information from the header of a PNG file
|
||||
* without processing the image. Notice that some header information may occur
|
||||
* after the image data, textual data and comments are an example; the approach
|
||||
* after the image data. Textual data and comments are an example; the approach
|
||||
* in this file won't work reliably for such data because it only looks for the
|
||||
* information in the section of the file that preceeds the image data.
|
||||
*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Read a single pixel value from a PNG file.
|
||||
*
|
||||
* This code illustrates basic 'by-row' reading of a PNG file using libpng.
|
||||
* Rows are read until a particular pixel is found, the value of this pixel is
|
||||
* Rows are read until a particular pixel is found; the value of this pixel is
|
||||
* then printed on stdout.
|
||||
*
|
||||
* The code illustrates how to do this on interlaced as well as non-interlaced
|
||||
@@ -56,7 +56,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
case 8: return row[0];
|
||||
case 16: return (row[0] << 8) + row[1];
|
||||
default:
|
||||
/* This should never happen, it indicates a bug in this program or in
|
||||
/* This should never happen; it indicates a bug in this program or in
|
||||
* libpng itself:
|
||||
*/
|
||||
fprintf(stderr, "pngpixel: invalid bit depth %u\n", bit_depth);
|
||||
@@ -132,7 +132,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
return;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "invalid color type");
|
||||
png_error(png_ptr, "pngpixel: invalid color type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ CC = gcc
|
||||
#CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
|
||||
LD = $(CC)
|
||||
RM = rm -f
|
||||
CFLAGS = -O -Wall $(INCS) $(MINGW_CCFLAGS)
|
||||
CPPFLAGS = $(INCS)
|
||||
CFLAGS = -O -Wall $(MINGW_CCFLAGS)
|
||||
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||
# [-ansi, -pedantic and -W can also be used]
|
||||
LDFLAGS = $(MINGW_LDFLAGS)
|
||||
@@ -85,10 +86,10 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
%.pic$(O): %.c
|
||||
$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
|
||||
|
||||
|
||||
# dependencies --------------------------------------------------------------
|
||||
|
||||
@@ -53,7 +53,8 @@ CC = cc
|
||||
LD = cc
|
||||
RM = rm -f
|
||||
# ABI must be the same as that used to build libpng.
|
||||
ABI=
|
||||
ABI =
|
||||
CPPFLAGS =
|
||||
CFLAGS = $(ABI) -O -fullwarn $(INCS)
|
||||
LDFLAGS = $(ABI)
|
||||
O = .o
|
||||
@@ -73,7 +74,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
|
||||
# dependencies --------------------------------------------------------------
|
||||
|
||||
@@ -64,7 +64,8 @@ WLIBSs = $(PNGLIBs) $(ZLIBs)
|
||||
CC = gcc
|
||||
LD = gcc
|
||||
RM = rm -f
|
||||
CFLAGS = -O -Wall $(INCS) -DFEATURE_LOOP
|
||||
CPPFLAGS = $(INCS) -DFEATURE_LOOP
|
||||
CFLAGS = -O -Wall
|
||||
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||
# [-ansi, -pedantic and -W can also be used]
|
||||
LDFLAGS =
|
||||
@@ -92,7 +93,7 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
|
||||
# dependencies --------------------------------------------------------------
|
||||
|
||||
@@ -53,7 +53,8 @@ WLIBS = $(PNGLIB) $(ZLIB)
|
||||
CC = cl
|
||||
LD = link
|
||||
RM = del
|
||||
CFLAGS = -nologo -O -W3 $(INCS) $(cvars)
|
||||
CPPFLAGS = $(INCS)
|
||||
CFLAGS = -nologo -O -W3 $(cvars)
|
||||
# [note that -W3 is an MSVC-specific compilation flag ("all warnings on")]
|
||||
# [see %devstudio%\vc\include\win32.mak for cvars macro definition]
|
||||
O = .obj
|
||||
@@ -76,7 +77,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
|
||||
# dependencies --------------------------------------------------------------
|
||||
|
||||
@@ -69,6 +69,7 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
png_uint_32 row_num, int pass);
|
||||
static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr);
|
||||
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
|
||||
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg);
|
||||
|
||||
|
||||
|
||||
@@ -104,7 +105,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
/* could also replace libpng warning-handler (final NULL), but no need: */
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
|
||||
readpng2_error_handler, NULL);
|
||||
readpng2_error_handler, readpng2_warning_handler);
|
||||
if (!png_ptr)
|
||||
return 4; /* out of memory */
|
||||
|
||||
@@ -447,6 +448,8 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
/* all done */
|
||||
|
||||
(void)info_ptr; /* Unused */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -467,7 +470,12 @@ void readpng2_cleanup(mainprog_info *mainprog_ptr)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg)
|
||||
{
|
||||
fprintf(stderr, "readpng2 libpng warning: %s\n", msg);
|
||||
fflush(stderr);
|
||||
(void)png_ptr; /* Unused */
|
||||
}
|
||||
|
||||
|
||||
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
|
||||
|
||||
@@ -163,8 +163,12 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
|
||||
/* now we can go ahead and just read the whole image */
|
||||
|
||||
fread(image_data, 1L, rowbytes*height, saved_infile);
|
||||
|
||||
if (fread(image_data, 1L, rowbytes*height, saved_infile) <
|
||||
rowbytes*height) {
|
||||
free (image_data);
|
||||
image_data = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return image_data;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2012 John Cunningham Bowler
|
||||
# Copyright (c) 2013 John Cunningham Bowler
|
||||
#
|
||||
# Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
# Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* makepng.c
|
||||
*
|
||||
* Copyright (c) 2012 John Cunningham Bowler
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
||||
1652
contrib/libtests/pngimage.c
Normal file
1652
contrib/libtests/pngimage.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
/*-
|
||||
* pngstest.c
|
||||
*
|
||||
* Copyright (c) 2012 John Cunningham Bowler
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -517,14 +517,23 @@ static void format_default(format_list *pf, int redundant)
|
||||
|
||||
for (f=0; f<FORMAT_COUNT; ++f)
|
||||
{
|
||||
/* Eliminate redundant settings. */
|
||||
/* BGR is meaningless if no color: */
|
||||
if ((f & PNG_FORMAT_FLAG_COLOR) == 0 && (f & PNG_FORMAT_FLAG_BGR) != 0)
|
||||
/* Eliminate redundant and unsupported settings. */
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
/* BGR is meaningless if no color: */
|
||||
if ((f & PNG_FORMAT_FLAG_COLOR) == 0 &&
|
||||
(f & PNG_FORMAT_FLAG_BGR) != 0)
|
||||
# else
|
||||
if ((f & 0x10U/*HACK: fixed value*/) != 0)
|
||||
# endif
|
||||
continue;
|
||||
|
||||
/* AFIRST is meaningless if no alpha: */
|
||||
if ((f & PNG_FORMAT_FLAG_ALPHA) == 0 &&
|
||||
(f & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if ((f & PNG_FORMAT_FLAG_ALPHA) == 0 &&
|
||||
(f & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
# else
|
||||
if ((f & 0x20U/*HACK: fixed value*/) != 0)
|
||||
# endif
|
||||
continue;
|
||||
|
||||
format_set(pf, f);
|
||||
@@ -786,6 +795,7 @@ gp_ga8(Pixel *p, png_const_voidp pb)
|
||||
p->a = pp[1];
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
static void
|
||||
gp_ag8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -794,6 +804,7 @@ gp_ag8(Pixel *p, png_const_voidp pb)
|
||||
p->r = p->g = p->b = pp[1];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_rgb8(Pixel *p, png_const_voidp pb)
|
||||
@@ -806,6 +817,7 @@ gp_rgb8(Pixel *p, png_const_voidp pb)
|
||||
p->a = 255;
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
static void
|
||||
gp_bgr8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -816,6 +828,7 @@ gp_bgr8(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[0];
|
||||
p->a = 255;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_rgba8(Pixel *p, png_const_voidp pb)
|
||||
@@ -828,6 +841,7 @@ gp_rgba8(Pixel *p, png_const_voidp pb)
|
||||
p->a = pp[3];
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
static void
|
||||
gp_bgra8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -838,7 +852,9 @@ gp_bgra8(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[0];
|
||||
p->a = pp[3];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
static void
|
||||
gp_argb8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -849,7 +865,9 @@ gp_argb8(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[3];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED)
|
||||
static void
|
||||
gp_abgr8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -860,6 +878,7 @@ gp_abgr8(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[1];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_g16(Pixel *p, png_const_voidp pb)
|
||||
@@ -879,6 +898,7 @@ gp_ga16(Pixel *p, png_const_voidp pb)
|
||||
p->a = pp[1];
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
static void
|
||||
gp_ag16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -887,6 +907,7 @@ gp_ag16(Pixel *p, png_const_voidp pb)
|
||||
p->r = p->g = p->b = pp[1];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_rgb16(Pixel *p, png_const_voidp pb)
|
||||
@@ -899,6 +920,7 @@ gp_rgb16(Pixel *p, png_const_voidp pb)
|
||||
p->a = 65535;
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
static void
|
||||
gp_bgr16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -909,6 +931,7 @@ gp_bgr16(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[0];
|
||||
p->a = 65535;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_rgba16(Pixel *p, png_const_voidp pb)
|
||||
@@ -921,6 +944,7 @@ gp_rgba16(Pixel *p, png_const_voidp pb)
|
||||
p->a = pp[3];
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
static void
|
||||
gp_bgra16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -931,7 +955,9 @@ gp_bgra16(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[0];
|
||||
p->a = pp[3];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
static void
|
||||
gp_argb16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -942,7 +968,9 @@ gp_argb16(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[3];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED)
|
||||
static void
|
||||
gp_abgr16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -953,6 +981,7 @@ gp_abgr16(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[1];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Given a format, return the correct one of the above functions. */
|
||||
static void (*
|
||||
@@ -966,29 +995,35 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_COLOR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_abgr16;
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_abgr16;
|
||||
|
||||
else
|
||||
# endif
|
||||
return gp_bgra16;
|
||||
}
|
||||
|
||||
else
|
||||
return gp_bgra16;
|
||||
return gp_bgr16;
|
||||
}
|
||||
|
||||
else
|
||||
return gp_bgr16;
|
||||
}
|
||||
|
||||
else
|
||||
# endif
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_argb16;
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_argb16;
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
return gp_rgba16;
|
||||
}
|
||||
|
||||
@@ -1001,10 +1036,12 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_ag16;
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_ag16;
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
return gp_ga16;
|
||||
}
|
||||
|
||||
@@ -1017,29 +1054,35 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_COLOR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_abgr8;
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_abgr8;
|
||||
|
||||
else
|
||||
# endif
|
||||
return gp_bgra8;
|
||||
}
|
||||
|
||||
else
|
||||
return gp_bgra8;
|
||||
return gp_bgr8;
|
||||
}
|
||||
|
||||
else
|
||||
return gp_bgr8;
|
||||
}
|
||||
|
||||
else
|
||||
# endif
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_argb8;
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_argb8;
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
return gp_rgba8;
|
||||
}
|
||||
|
||||
@@ -1052,10 +1095,12 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_ag8;
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_ag8;
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
return gp_ga8;
|
||||
}
|
||||
|
||||
@@ -2618,13 +2663,15 @@ component_loc(png_byte loc[4], png_uint_32 format)
|
||||
|
||||
loc[2] = 1;
|
||||
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
loc[1] = 2;
|
||||
loc[3] = 0;
|
||||
}
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
loc[1] = 2;
|
||||
loc[3] = 0;
|
||||
}
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
{
|
||||
loc[1] = 0;
|
||||
loc[3] = 2;
|
||||
@@ -2639,15 +2686,17 @@ component_loc(png_byte loc[4], png_uint_32 format)
|
||||
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
loc[0] = 0;
|
||||
++loc[1];
|
||||
++loc[2];
|
||||
++loc[3];
|
||||
}
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
loc[0] = 0;
|
||||
++loc[1];
|
||||
++loc[2];
|
||||
++loc[3];
|
||||
}
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
loc[0] = channels;
|
||||
|
||||
++channels;
|
||||
@@ -3017,17 +3066,25 @@ read_file(Image *image, png_uint_32 format, png_const_colorp background)
|
||||
return logerror(image, "memory init: ", image->file_name, "");
|
||||
}
|
||||
|
||||
else if (image->input_file != NULL)
|
||||
{
|
||||
if (!png_image_begin_read_from_stdio(&image->image, image->input_file))
|
||||
return logerror(image, "stdio init: ", image->file_name, "");
|
||||
}
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
else if (image->input_file != NULL)
|
||||
{
|
||||
if (!png_image_begin_read_from_stdio(&image->image, image->input_file))
|
||||
return logerror(image, "stdio init: ", image->file_name, "");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (!png_image_begin_read_from_file(&image->image, image->file_name))
|
||||
return logerror(image, "file init: ", image->file_name, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!png_image_begin_read_from_file(&image->image, image->file_name))
|
||||
return logerror(image, "file init: ", image->file_name, "");
|
||||
}
|
||||
# else
|
||||
else
|
||||
{
|
||||
return logerror(image, "unsupported file/stdio init: ",
|
||||
image->file_name, "");
|
||||
}
|
||||
# endif
|
||||
|
||||
/* This must be set after the begin_read call: */
|
||||
if (image->opts & sRGB_16BIT)
|
||||
@@ -3466,11 +3523,19 @@ main(int argc, char **argv)
|
||||
memset(gpc_error_via_linear, 0, sizeof gpc_error_via_linear);
|
||||
}
|
||||
else if (strcmp(arg, "--file") == 0)
|
||||
opts |= READ_FILE;
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
opts |= READ_FILE;
|
||||
# else
|
||||
return 77; /* skipped: no support */
|
||||
# endif
|
||||
else if (strcmp(arg, "--memory") == 0)
|
||||
opts &= ~READ_FILE;
|
||||
else if (strcmp(arg, "--stdio") == 0)
|
||||
opts |= USE_STDIO;
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
opts |= USE_STDIO;
|
||||
# else
|
||||
return 77; /* skipped: no support */
|
||||
# endif
|
||||
else if (strcmp(arg, "--name") == 0)
|
||||
opts &= ~USE_STDIO;
|
||||
else if (strcmp(arg, "--verbose") == 0)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngunknown.c - test the read side unknown chunk handling
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by John Cunningham Bowler
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
@@ -30,7 +30,19 @@
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Since this program tests the ability to change the unknown chunk handling
|
||||
* these must be defined:
|
||||
*/
|
||||
#if defined(PNG_SET_UNKNOWN_CHUNKS_SUPPORTED) &&\
|
||||
defined(PNG_READ_SUPPORTED)
|
||||
|
||||
/* One of these must be defined to allow us to find out what happened. It is
|
||||
* still useful to set unknown chunk handling without either of these in order
|
||||
* to cause *known* chunks to be discarded. This can be a significant
|
||||
* efficiency gain, but it can't really be tested here.
|
||||
*/
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) ||\
|
||||
defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
/* This deliberately lacks the PNG_CONST. */
|
||||
@@ -75,6 +87,71 @@ typedef png_byte *png_const_bytep;
|
||||
# define png_const_structp png_structp
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* Copied from libpng 1.7.0 png.h */
|
||||
#define PNG_u2(b1, b2) (((unsigned int)(b1) << 8) + (b2))
|
||||
|
||||
#define PNG_U16(b1, b2) ((png_uint_16)PNG_u2(b1, b2))
|
||||
#define PNG_U32(b1, b2, b3, b4)\
|
||||
(((png_uint_32)PNG_u2(b1, b2) << 16) + PNG_u2(b3, b4))
|
||||
|
||||
/* Constants for known chunk types.
|
||||
*/
|
||||
#define png_IDAT PNG_U32( 73, 68, 65, 84)
|
||||
#define png_IEND PNG_U32( 73, 69, 78, 68)
|
||||
#define png_IHDR PNG_U32( 73, 72, 68, 82)
|
||||
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
||||
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
||||
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
|
||||
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
||||
#define png_gIFg PNG_U32(103, 73, 70, 103)
|
||||
#define png_gIFt PNG_U32(103, 73, 70, 116) /* deprecated */
|
||||
#define png_gIFx PNG_U32(103, 73, 70, 120)
|
||||
#define png_hIST PNG_U32(104, 73, 83, 84)
|
||||
#define png_iCCP PNG_U32(105, 67, 67, 80)
|
||||
#define png_iTXt PNG_U32(105, 84, 88, 116)
|
||||
#define png_oFFs PNG_U32(111, 70, 70, 115)
|
||||
#define png_pCAL PNG_U32(112, 67, 65, 76)
|
||||
#define png_pHYs PNG_U32(112, 72, 89, 115)
|
||||
#define png_sBIT PNG_U32(115, 66, 73, 84)
|
||||
#define png_sCAL PNG_U32(115, 67, 65, 76)
|
||||
#define png_sPLT PNG_U32(115, 80, 76, 84)
|
||||
#define png_sRGB PNG_U32(115, 82, 71, 66)
|
||||
#define png_sTER PNG_U32(115, 84, 69, 82)
|
||||
#define png_tEXt PNG_U32(116, 69, 88, 116)
|
||||
#define png_tIME PNG_U32(116, 73, 77, 69)
|
||||
#define png_tRNS PNG_U32(116, 82, 78, 83)
|
||||
#define png_zTXt PNG_U32(122, 84, 88, 116)
|
||||
|
||||
/* Test on flag values as defined in the spec (section 5.4): */
|
||||
#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29))
|
||||
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c))
|
||||
#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
|
||||
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
|
||||
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
|
||||
|
||||
#endif /* PNG_LIBPNG_VER < 10700 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define this not_the_cpp_this
|
||||
# define new not_the_cpp_new
|
||||
# define voidcast(type, value) static_cast<type>(value)
|
||||
#else
|
||||
# define voidcast(type, value) (value)
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Unused formal parameter errors are removed using the following macro which is
|
||||
* expected to have no bad effects on performance.
|
||||
*/
|
||||
#ifndef UNUSED
|
||||
# if defined(__GNUC__) || defined(_MSC_VER)
|
||||
# define UNUSED(param) (void)param;
|
||||
# else
|
||||
# define UNUSED(param)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Types of chunks not known to libpng */
|
||||
#define png_vpAg PNG_U32(118, 112, 65, 103)
|
||||
|
||||
@@ -105,8 +182,8 @@ static struct
|
||||
{ "PLTE", PNG_INFO_PLTE, png_PLTE, 0, 0, ABSENT, 0 },
|
||||
|
||||
/* Non-critical chunks that libpng handles */
|
||||
/* This is a mess but it seems to be the only way to do it - there is no way to
|
||||
* check for definition outside a #if.
|
||||
/* This is a mess but it seems to be the only way to do it - there is no way
|
||||
* to check for a definition outside a #if.
|
||||
*/
|
||||
{ "bKGD", PNG_INFO_bKGD, png_bKGD,
|
||||
# ifdef PNG_READ_bKGD_SUPPORTED
|
||||
@@ -286,11 +363,13 @@ ancillary(const char *name)
|
||||
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
|
||||
}
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
static int
|
||||
ancillaryb(const png_byte *name)
|
||||
{
|
||||
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Type of an error_ptr */
|
||||
typedef struct
|
||||
@@ -298,8 +377,11 @@ typedef struct
|
||||
jmp_buf error_return;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr, end_ptr;
|
||||
png_uint_32 before_IDAT;
|
||||
png_uint_32 after_IDAT;
|
||||
int error_count;
|
||||
int warning_count;
|
||||
int keep; /* the default value */
|
||||
const char *program;
|
||||
const char *file;
|
||||
const char *test;
|
||||
@@ -332,9 +414,6 @@ clean_display(display *d)
|
||||
d->test);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Invalidate the test */
|
||||
d->test = init;
|
||||
}
|
||||
|
||||
PNG_FUNCTION(void, display_exit, (display *d), static PNG_NORETURN)
|
||||
@@ -360,7 +439,7 @@ display_rc(const display *d, int strict)
|
||||
}
|
||||
|
||||
/* libpng error and warning callbacks */
|
||||
PNG_FUNCTION(void, error, (png_structp png_ptr, const char *message),
|
||||
PNG_FUNCTION(void, (PNGCBAPI error), (png_structp png_ptr, const char *message),
|
||||
static PNG_NORETURN)
|
||||
{
|
||||
display *d = (display*)png_get_error_ptr(png_ptr);
|
||||
@@ -369,7 +448,7 @@ PNG_FUNCTION(void, error, (png_structp png_ptr, const char *message),
|
||||
display_exit(d);
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
warning(png_structp png_ptr, const char *message)
|
||||
{
|
||||
display *d = (display*)png_get_error_ptr(png_ptr);
|
||||
@@ -410,11 +489,88 @@ get_valid(display *d, png_infop info_ptr)
|
||||
return flags;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
static int PNGCBAPI
|
||||
read_callback(png_structp pp, png_unknown_chunkp pc)
|
||||
{
|
||||
/* This function mimics the behavior of png_set_keep_unknown_chunks by
|
||||
* returning '0' to keep the chunk and '1' to discard it.
|
||||
*/
|
||||
display *d = voidcast(display*, png_get_user_chunk_ptr(pp));
|
||||
int chunk = findb(pc->name);
|
||||
int keep, discard;
|
||||
|
||||
if (chunk < 0) /* not one in our list, so not a known chunk */
|
||||
keep = d->keep;
|
||||
|
||||
else
|
||||
{
|
||||
keep = chunk_info[chunk].keep;
|
||||
if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
{
|
||||
/* See the comments in png.h - use the default for unknown chunks,
|
||||
* do not keep known chunks.
|
||||
*/
|
||||
if (chunk_info[chunk].unknown)
|
||||
keep = d->keep;
|
||||
|
||||
else
|
||||
keep = PNG_HANDLE_CHUNK_NEVER;
|
||||
}
|
||||
}
|
||||
|
||||
switch (keep)
|
||||
{
|
||||
default:
|
||||
fprintf(stderr, "%s(%s): %d: unrecognized chunk option\n", d->file,
|
||||
d->test, chunk_info[chunk].keep);
|
||||
display_exit(d);
|
||||
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
discard = 1/*handled; discard*/;
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||
discard = 0/*not handled; keep*/;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Also store information about this chunk in the display, the relevant flag
|
||||
* is set if the chunk is to be kept ('not handled'.)
|
||||
*/
|
||||
if (chunk >= 0) if (!discard) /* stupidity to stop a GCC warning */
|
||||
{
|
||||
png_uint_32 flag = chunk_info[chunk].flag;
|
||||
|
||||
if (pc->location & PNG_AFTER_IDAT)
|
||||
d->after_IDAT |= flag;
|
||||
|
||||
else
|
||||
d->before_IDAT |= flag;
|
||||
}
|
||||
|
||||
/* However if there is no support to store unknown chunks don't ask libpng to
|
||||
* do it; there will be an png_error.
|
||||
*/
|
||||
# ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
return discard;
|
||||
# else
|
||||
return 1; /*handled; discard*/
|
||||
# endif
|
||||
}
|
||||
#endif /* READ_USER_CHUNKS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
static png_uint_32
|
||||
get_unknown(display *d, int def, png_infop info_ptr)
|
||||
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
||||
{
|
||||
/* Create corresponding 'unknown' flags */
|
||||
png_uint_32 flags = 0;
|
||||
|
||||
UNUSED(after_IDAT)
|
||||
|
||||
{
|
||||
png_unknown_chunkp unknown;
|
||||
int num_unknown = png_get_unknown_chunks(d->png_ptr, info_ptr, &unknown);
|
||||
@@ -424,16 +580,16 @@ get_unknown(display *d, int def, png_infop info_ptr)
|
||||
int chunk = findb(unknown[num_unknown].name);
|
||||
|
||||
/* Chunks not known to pngunknown must be validated here; since they
|
||||
* must also be unknown to libpng the 'def' behavior should have been
|
||||
* used.
|
||||
* must also be unknown to libpng the 'display->keep' behavior should
|
||||
* have been used.
|
||||
*/
|
||||
if (chunk < 0) switch (def)
|
||||
if (chunk < 0) switch (d->keep)
|
||||
{
|
||||
default: /* impossible */
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
fprintf(stderr, "%s(%s): %s: %s: unknown chunk saved\n",
|
||||
d->file, d->test, def ? "discard" : "default",
|
||||
d->file, d->test, d->keep ? "discard" : "default",
|
||||
unknown[num_unknown].name);
|
||||
++(d->error_count);
|
||||
break;
|
||||
@@ -459,14 +615,39 @@ get_unknown(display *d, int def, png_infop info_ptr)
|
||||
|
||||
return flags;
|
||||
}
|
||||
#else
|
||||
static png_uint_32
|
||||
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
||||
/* Otherwise this will return the cached values set by any user callback */
|
||||
{
|
||||
UNUSED(info_ptr);
|
||||
|
||||
if (after_IDAT)
|
||||
return d->after_IDAT;
|
||||
|
||||
else
|
||||
return d->before_IDAT;
|
||||
}
|
||||
|
||||
# ifndef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* The #defines above should mean this is never reached, it's just here as
|
||||
* a check to ensure the logic is correct.
|
||||
*/
|
||||
# error No store support and no user chunk support, this will not work
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static int
|
||||
check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
display *d)
|
||||
display *d, int set_callback)
|
||||
{
|
||||
int i, def = PNG_HANDLE_CHUNK_AS_DEFAULT, npasses, ipass;
|
||||
int i, npasses, ipass;
|
||||
png_uint_32 height;
|
||||
|
||||
d->keep = PNG_HANDLE_CHUNK_AS_DEFAULT;
|
||||
d->before_IDAT = 0;
|
||||
d->after_IDAT = 0;
|
||||
|
||||
/* Some of these errors are permanently fatal and cause an exit here, others
|
||||
* are per-test and cause an error return.
|
||||
*/
|
||||
@@ -492,6 +673,16 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
|
||||
png_init_io(d->png_ptr, fp);
|
||||
|
||||
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* This is only done if requested by the caller; it interferes with the
|
||||
* standard store/save mechanism.
|
||||
*/
|
||||
if (set_callback)
|
||||
png_set_read_user_chunk_fn(d->png_ptr, d, read_callback);
|
||||
# else
|
||||
UNUSED(set_callback)
|
||||
# endif
|
||||
|
||||
/* Handle each argument in turn; multiple settings are possible for the same
|
||||
* chunk and multiple calls will occur (the last one should override all
|
||||
* preceding ones).
|
||||
@@ -531,13 +722,11 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
* in this case, so we just check the arguments! This could
|
||||
* be improved in the future by using the read callback.
|
||||
*/
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_byte name[5];
|
||||
png_byte name[5];
|
||||
|
||||
memcpy(name, chunk_info[chunk].name, 5);
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, name, 1);
|
||||
chunk_info[chunk].keep = option;
|
||||
# endif
|
||||
memcpy(name, chunk_info[chunk].name, 5);
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, name, 1);
|
||||
chunk_info[chunk].keep = option;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -546,10 +735,8 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
case 7: /* default */
|
||||
if (memcmp(argv[i], "default", 7) == 0)
|
||||
{
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0);
|
||||
# endif
|
||||
def = option;
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0);
|
||||
d->keep = option;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -558,14 +745,12 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
case 3: /* all */
|
||||
if (memcmp(argv[i], "all", 3) == 0)
|
||||
{
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1);
|
||||
def = option;
|
||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1);
|
||||
d->keep = option;
|
||||
|
||||
for (chunk = 0; chunk < NINFO; ++chunk)
|
||||
if (chunk_info[chunk].all)
|
||||
chunk_info[chunk].keep = option;
|
||||
# endif
|
||||
for (chunk = 0; chunk < NINFO; ++chunk)
|
||||
if (chunk_info[chunk].all)
|
||||
chunk_info[chunk].keep = option;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -639,18 +824,18 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
png_read_end(d->png_ptr, d->end_ptr);
|
||||
|
||||
flags[0] = get_valid(d, d->info_ptr);
|
||||
flags[1] = get_unknown(d, def, d->info_ptr);
|
||||
flags[1] = get_unknown(d, d->info_ptr, 0/*before IDAT*/);
|
||||
|
||||
/* Only png_read_png sets PNG_INFO_IDAT! */
|
||||
flags[chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT] |=
|
||||
PNG_INFO_IDAT;
|
||||
|
||||
flags[2] = get_valid(d, d->end_ptr);
|
||||
flags[3] = get_unknown(d, def, d->end_ptr);
|
||||
flags[3] = get_unknown(d, d->end_ptr, 1/*after IDAT*/);
|
||||
|
||||
clean_display(d);
|
||||
|
||||
return def;
|
||||
return d->keep;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -671,7 +856,7 @@ check_error(display *d, png_uint_32 flags, const char *message)
|
||||
|
||||
static void
|
||||
check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
|
||||
png_uint_32 unknown, const char *position)
|
||||
png_uint_32 unknown, const char *position, int set_callback)
|
||||
{
|
||||
while (chunks)
|
||||
{
|
||||
@@ -778,8 +963,9 @@ check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
|
||||
if (errorx != NULL)
|
||||
{
|
||||
++(d->error_count);
|
||||
fprintf(stderr, "%s(%s): %s %s %s: %s\n",
|
||||
d->file, d->test, type, chunk_info[i].name, position, errorx);
|
||||
fprintf(stderr, "%s(%s%s): %s %s %s: %s\n", d->file, d->test,
|
||||
set_callback ? ",callback" : "",
|
||||
type, chunk_info[i].name, position, errorx);
|
||||
}
|
||||
|
||||
chunks &= ~flag;
|
||||
@@ -788,7 +974,7 @@ check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
|
||||
|
||||
static void
|
||||
perform_one_test(FILE *fp, int argc, const char **argv,
|
||||
png_uint_32 *default_flags, display *d)
|
||||
png_uint_32 *default_flags, display *d, int set_callback)
|
||||
{
|
||||
int def;
|
||||
png_uint_32 flags[2][4];
|
||||
@@ -797,7 +983,7 @@ perform_one_test(FILE *fp, int argc, const char **argv,
|
||||
clear_keep();
|
||||
memcpy(flags[0], default_flags, sizeof flags[0]);
|
||||
|
||||
def = check(fp, argc, argv, flags[1], d);
|
||||
def = check(fp, argc, argv, flags[1], d, set_callback);
|
||||
|
||||
/* Chunks should either be known or unknown, never both and this should apply
|
||||
* whether the chunk is before or after the IDAT (actually, the app can
|
||||
@@ -832,9 +1018,9 @@ perform_one_test(FILE *fp, int argc, const char **argv,
|
||||
* it or not.
|
||||
*/
|
||||
check_handling(d, def, flags[0][0] | flags[0][1], flags[1][0], flags[1][1],
|
||||
"before IDAT");
|
||||
"before IDAT", set_callback);
|
||||
check_handling(d, def, flags[0][2] | flags[0][3], flags[1][2], flags[1][3],
|
||||
"after IDAT");
|
||||
"after IDAT", set_callback);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -844,7 +1030,12 @@ perform_one_test_safe(FILE *fp, int argc, const char **argv,
|
||||
if (setjmp(d->error_return) == 0)
|
||||
{
|
||||
d->test = test; /* allow use of d->error_return */
|
||||
perform_one_test(fp, argc, argv, default_flags, d);
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
perform_one_test(fp, argc, argv, default_flags, d, 0);
|
||||
# endif
|
||||
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
perform_one_test(fp, argc, argv, default_flags, d, 1);
|
||||
# endif
|
||||
d->test = init; /* prevent use of d->error_return */
|
||||
}
|
||||
}
|
||||
@@ -868,7 +1059,7 @@ usage(const char *program, const char *reason)
|
||||
fprintf(stderr, "pngunknown: %s: usage:\n %s [--strict] "
|
||||
"--default|{(CHNK|default|all)=(default|discard|if-safe|save)} "
|
||||
"testfile.png\n", reason, program);
|
||||
exit(2);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -916,11 +1107,6 @@ main(int argc, const char **argv)
|
||||
else if (default_tests) if (argc != 1)
|
||||
usage(d.program, "extra arguments");
|
||||
|
||||
# ifndef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
fprintf(stderr, "%s: warning: no 'save' support so arguments ignored\n",
|
||||
d.program);
|
||||
# endif
|
||||
|
||||
/* The name of the test file is the last argument; remove it. */
|
||||
d.file = argv[--argc];
|
||||
|
||||
@@ -928,24 +1114,40 @@ main(int argc, const char **argv)
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror(d.file);
|
||||
exit(2);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
/* First find all the chunks, known and unknown, in the test file, a failure
|
||||
* here aborts the whole test.
|
||||
*
|
||||
* If 'save' is supported then the normal saving method should happen,
|
||||
* otherwise if 'read' is supported then the read callback will do the
|
||||
* same thing. If both are supported the 'read' callback won't be
|
||||
* instantiated by default. If 'save' is *not* supported then a user
|
||||
* callback is required even though we can call png_get_unknown_chunks.
|
||||
*/
|
||||
if (check(fp, 1, &count_argv, default_flags, &d) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS)
|
||||
if (check(fp, 1, &count_argv, default_flags, &d,
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
0
|
||||
# else
|
||||
1
|
||||
# endif
|
||||
) != PNG_HANDLE_CHUNK_ALWAYS)
|
||||
{
|
||||
fprintf(stderr, "%s: %s: internal error\n", d.program, d.file);
|
||||
exit(3);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
/* Now find what the various supplied options cause to change: */
|
||||
if (!default_tests)
|
||||
{
|
||||
d.test = cmd; /* acts as a flag to say exit, do not longjmp */
|
||||
perform_one_test(fp, argc, argv, default_flags, &d);
|
||||
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
perform_one_test(fp, argc, argv, default_flags, &d, 0);
|
||||
# endif
|
||||
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
perform_one_test(fp, argc, argv, default_flags, &d, 1);
|
||||
# endif
|
||||
d.test = init;
|
||||
}
|
||||
|
||||
@@ -1003,14 +1205,14 @@ main(int argc, const char **argv)
|
||||
if (fclose(fsuccess) || err)
|
||||
{
|
||||
fprintf(stderr, "%s: write failed\n", touch_file);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: open failed\n", touch_file);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1020,13 +1222,24 @@ main(int argc, const char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
#else /* !(READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS) */
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
" test ignored because libpng was not built with unknown chunk support\n");
|
||||
" test ignored: no support to find out about unknown chunks\n");
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
#endif
|
||||
#endif /* READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS */
|
||||
|
||||
#else /* !(SET_UNKNOWN_CHUNKS && READ) */
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
" test ignored: no support to modify unknown chunk handling\n");
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
#endif /* SET_UNKNOWN_CHUNKS && READ*/
|
||||
|
||||
@@ -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.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by John Cunningham Bowler
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
@@ -34,18 +34,44 @@
|
||||
# include <fenv.h>
|
||||
#endif
|
||||
|
||||
#ifndef FE_DIVBYZERO
|
||||
# define FE_DIVBYZERO 0
|
||||
#endif
|
||||
#ifndef FE_INVALID
|
||||
# define FE_INVALID 0
|
||||
#endif
|
||||
#ifndef FE_OVERFLOW
|
||||
# define FE_OVERFLOW 0
|
||||
#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>
|
||||
# include <zlib.h> /* For crc32 */
|
||||
#else
|
||||
# include "../../png.h"
|
||||
# include PNG_ZLIB_HEADER
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED /* else pngvalid can do nothing */
|
||||
#ifdef PNG_ZLIB_HEADER
|
||||
# include PNG_ZLIB_HEADER
|
||||
#else
|
||||
# include <zlib.h> /* For crc32 */
|
||||
#endif
|
||||
|
||||
/* 1.6.1 added support for the configure test harness, which uses 77 to indicate
|
||||
* a skipped test, in earlier versions we need to succeed on a skipped test, so:
|
||||
*/
|
||||
#if PNG_LIBPNG_VER < 10601
|
||||
# define SKIP 0
|
||||
#else
|
||||
# define SKIP 77
|
||||
#endif
|
||||
|
||||
/* pngvalid requires write support and one of the fixed or floating point APIs.
|
||||
*/
|
||||
#if defined(PNG_WRITE_SUPPORTED) &&\
|
||||
(defined(PNG_FIXED_POINT_SUPPORTED) || defined(PNG_FLOATING_POINT_SUPPORTED))
|
||||
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
/* This deliberately lacks the PNG_CONST. */
|
||||
@@ -131,6 +157,13 @@ define_exception_type(struct png_store*);
|
||||
&(ps)->exception_context
|
||||
#define context(ps,fault) anon_context(ps); png_store *fault
|
||||
|
||||
/* This macro returns the number of elements in an array as an (unsigned int),
|
||||
* it is necessary to avoid the inability of certain versions of GCC to use
|
||||
* the value of a compile-time constant when performing range checks. It must
|
||||
* be passed an array name.
|
||||
*/
|
||||
#define ARRAY_SIZE(a) ((unsigned int)((sizeof (a))/(sizeof (a)[0])))
|
||||
|
||||
/******************************* UTILITIES ************************************/
|
||||
/* Error handling is particularly problematic in production code - error
|
||||
* handlers often themselves have bugs which lead to programs that detect
|
||||
@@ -370,9 +403,9 @@ next_format(png_bytep colour_type, png_bytep bit_depth,
|
||||
|
||||
/* Palette images are restricted to 8 bit depth */
|
||||
if (*bit_depth <= 8
|
||||
# ifdef DO_16BIT
|
||||
#ifdef DO_16BIT
|
||||
|| (*colour_type != 3 && *bit_depth <= 16)
|
||||
# endif
|
||||
#endif
|
||||
)
|
||||
return 1;
|
||||
|
||||
@@ -621,7 +654,12 @@ typedef struct png_store
|
||||
unsigned int validated :1; /* used as a temporary flag */
|
||||
int nerrors;
|
||||
int nwarnings;
|
||||
char test[128]; /* Name of test */
|
||||
int noptions; /* number of options below: */
|
||||
struct {
|
||||
unsigned char option; /* option number, 0..30 */
|
||||
unsigned char setting; /* setting (unset,invalid,on,off) */
|
||||
} options[16];
|
||||
char test[128]; /* Name of test */
|
||||
char error[256];
|
||||
|
||||
/* Read fields */
|
||||
@@ -665,7 +703,7 @@ static png_uint_32
|
||||
random_32(void)
|
||||
{
|
||||
|
||||
for(;;)
|
||||
for (;;)
|
||||
{
|
||||
png_byte mark[4];
|
||||
png_uint_32 result;
|
||||
@@ -722,6 +760,7 @@ store_init(png_store* ps)
|
||||
ps->new.prev = NULL;
|
||||
ps->palette = NULL;
|
||||
ps->npalette = 0;
|
||||
ps->noptions = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -899,7 +938,7 @@ internal_error(png_store *ps, png_const_charp message)
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/* Functions to use as PNG callbacks. */
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
store_error(png_structp ppIn, png_const_charp message) /* PNG_NORETURN */
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -915,7 +954,7 @@ store_error(png_structp ppIn, png_const_charp message) /* PNG_NORETURN */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
store_warning(png_structp ppIn, png_const_charp message)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -1066,7 +1105,7 @@ store_image_check(PNG_CONST png_store* ps, png_const_structp pp, int iImage)
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
store_write(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -1094,7 +1133,7 @@ store_write(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
store_flush(png_structp ppIn)
|
||||
{
|
||||
UNUSED(ppIn) /*DOES NOTHING*/
|
||||
@@ -1188,7 +1227,7 @@ store_read_imp(png_store *ps, png_bytep pb, png_size_t st)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
store_read(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -1262,6 +1301,7 @@ store_current_palette(png_store *ps, int *npalette)
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/***************************** MEMORY MANAGEMENT*** ***************************/
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
/* A store_memory is simply the header for an allocated block of memory. The
|
||||
* pointer returned to libpng is just after the end of the header block, the
|
||||
* allocated memory is followed by a second copy of the 'mark'.
|
||||
@@ -1380,7 +1420,7 @@ store_pool_delete(png_store *ps, store_pool *pool)
|
||||
}
|
||||
|
||||
/* The memory callbacks: */
|
||||
static png_voidp
|
||||
static png_voidp PNGCBAPI
|
||||
store_malloc(png_structp ppIn, png_alloc_size_t cb)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -1429,7 +1469,7 @@ store_malloc(png_structp ppIn, png_alloc_size_t cb)
|
||||
return new;
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
store_free(png_structp ppIn, png_voidp memory)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -1462,6 +1502,7 @@ store_free(png_structp ppIn, png_voidp memory)
|
||||
this->next = NULL;
|
||||
store_memory_free(pp, pool, this);
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
/* Setup functions. */
|
||||
/* Cleanup when aborting a write or after storing the new file. */
|
||||
@@ -1487,7 +1528,9 @@ store_write_reset(png_store *ps)
|
||||
/* And make sure that all the memory has been freed - this will output
|
||||
* spurious errors in the case of memory corruption above, but this is safe.
|
||||
*/
|
||||
store_pool_delete(ps, &ps->write_memory_pool);
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
store_pool_delete(ps, &ps->write_memory_pool);
|
||||
# endif
|
||||
|
||||
store_freenew(ps);
|
||||
}
|
||||
@@ -1511,18 +1554,32 @@ set_store_for_write(png_store *ps, png_infopp ppi,
|
||||
store_write_reset(ps);
|
||||
safecat(ps->wname, sizeof ps->wname, 0, name);
|
||||
|
||||
/* Don't do the slow memory checks if doing a speed test. */
|
||||
if (ps->speed)
|
||||
/* Don't do the slow memory checks if doing a speed test, also if user
|
||||
* memory is not supported we can't do it anyway.
|
||||
*/
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (!ps->speed)
|
||||
ps->pwrite = png_create_write_struct_2(PNG_LIBPNG_VER_STRING,
|
||||
ps, store_error, store_warning, &ps->write_memory_pool,
|
||||
store_malloc, store_free);
|
||||
|
||||
else
|
||||
# endif
|
||||
ps->pwrite = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
ps, store_error, store_warning);
|
||||
|
||||
else
|
||||
ps->pwrite = png_create_write_struct_2(PNG_LIBPNG_VER_STRING,
|
||||
ps, store_error, store_warning, &ps->write_memory_pool,
|
||||
store_malloc, store_free);
|
||||
|
||||
png_set_write_fn(ps->pwrite, ps, store_write, store_flush);
|
||||
|
||||
# ifdef PNG_SET_OPTION_SUPPORTED
|
||||
{
|
||||
int opt;
|
||||
for (opt=0; opt<ps->noptions; ++opt)
|
||||
if (png_set_option(ps->pwrite, ps->options[opt].option,
|
||||
ps->options[opt].setting) == PNG_OPTION_INVALID)
|
||||
png_error(ps->pwrite, "png option invalid");
|
||||
}
|
||||
# endif
|
||||
|
||||
if (ppi != NULL)
|
||||
*ppi = ps->piwrite = png_create_info_struct(ps->pwrite);
|
||||
}
|
||||
@@ -1558,8 +1615,10 @@ store_read_reset(png_store *ps)
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Always do this to be safe. */
|
||||
store_pool_delete(ps, &ps->read_memory_pool);
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
/* Always do this to be safe. */
|
||||
store_pool_delete(ps, &ps->read_memory_pool);
|
||||
# endif
|
||||
|
||||
ps->current = NULL;
|
||||
ps->next = NULL;
|
||||
@@ -1586,14 +1645,14 @@ store_read_set(png_store *ps, png_uint_32 id)
|
||||
pf = pf->next;
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
size_t pos;
|
||||
char msg[FILE_NAME_SIZE+64];
|
||||
|
||||
pos = standard_name_from_id(msg, sizeof msg, 0, id);
|
||||
pos = safecat(msg, sizeof msg, pos, ": file not found");
|
||||
png_error(ps->pread, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The main interface for reading a saved file - pass the id number of the file
|
||||
@@ -1619,14 +1678,16 @@ set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id,
|
||||
* However, given that store_error works correctly in these circumstances
|
||||
* we don't ever expect NULL in this program.
|
||||
*/
|
||||
if (ps->speed)
|
||||
ps->pread = png_create_read_struct(PNG_LIBPNG_VER_STRING, ps,
|
||||
store_error, store_warning);
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (!ps->speed)
|
||||
ps->pread = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, ps,
|
||||
store_error, store_warning, &ps->read_memory_pool, store_malloc,
|
||||
store_free);
|
||||
|
||||
else
|
||||
ps->pread = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, ps,
|
||||
store_error, store_warning, &ps->read_memory_pool, store_malloc,
|
||||
store_free);
|
||||
else
|
||||
# endif
|
||||
ps->pread = png_create_read_struct(PNG_LIBPNG_VER_STRING, ps, store_error,
|
||||
store_warning);
|
||||
|
||||
if (ps->pread == NULL)
|
||||
{
|
||||
@@ -1638,6 +1699,16 @@ set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id,
|
||||
Throw ps;
|
||||
}
|
||||
|
||||
# ifdef PNG_SET_OPTION_SUPPORTED
|
||||
{
|
||||
int opt;
|
||||
for (opt=0; opt<ps->noptions; ++opt)
|
||||
if (png_set_option(ps->pread, ps->options[opt].option,
|
||||
ps->options[opt].setting) == PNG_OPTION_INVALID)
|
||||
png_error(ps->pread, "png option invalid");
|
||||
}
|
||||
# endif
|
||||
|
||||
store_read_set(ps, id);
|
||||
|
||||
if (ppi != NULL)
|
||||
@@ -1919,7 +1990,7 @@ typedef struct png_modifier
|
||||
|
||||
/* This returns true if the test should be stopped now because it has already
|
||||
* failed and it is running silently.
|
||||
*/
|
||||
*/
|
||||
static int fail(png_modifier *pm)
|
||||
{
|
||||
return !pm->log && !pm->this.verbose && (pm->this.nerrors > 0 ||
|
||||
@@ -2617,7 +2688,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
|
||||
}
|
||||
|
||||
/* The callback: */
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
modifier_read(png_structp ppIn, png_bytep pb, png_size_t st)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -2937,6 +3008,12 @@ sbit_modification_init(sbit_modification *me, png_modifier *pm, png_byte sbit)
|
||||
* height of 16 rows. The width and height are stored in the FILEID and, being
|
||||
* non-zero, indicate a size file.
|
||||
*
|
||||
* Because the PNG filter code is typically the largest CPU consumer within
|
||||
* libpng itself there is a tendency to attempt to optimize it. This results in
|
||||
* special case code which needs to be validated. To cause this to happen the
|
||||
* 'size' images are made to use each possible filter, in so far as this is
|
||||
* possible for smaller images.
|
||||
*
|
||||
* For palette image (colour type 3) multiple transform images are stored with
|
||||
* the same bit depth to allow testing of more colour combinations -
|
||||
* particularly important for testing the gamma code because libpng uses a
|
||||
@@ -3095,8 +3172,10 @@ init_standard_palette(png_store *ps, png_structp pp, png_infop pi, int npalette,
|
||||
for (; i<256; ++i)
|
||||
tRNS[i] = 24;
|
||||
|
||||
if (j > 0)
|
||||
png_set_tRNS(pp, pi, tRNS, j, 0/*color*/);
|
||||
#ifdef PNG_WRITE_tRNS_SUPPORTED
|
||||
if (j > 0)
|
||||
png_set_tRNS(pp, pi, tRNS, j, 0/*color*/);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3342,6 +3421,31 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
*/
|
||||
#define DEPTH(bd) ((png_byte)(1U << (bd)))
|
||||
|
||||
/* This is just a helper for compiling on minimal systems with no write
|
||||
* interlacing support. If there is no write interlacing we can't generate test
|
||||
* cases with interlace:
|
||||
*/
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
# define INTERLACE_LAST PNG_INTERLACE_LAST
|
||||
# define check_interlace_type(type) ((void)(type))
|
||||
#else
|
||||
# define INTERLACE_LAST (PNG_INTERLACE_NONE+1)
|
||||
# define png_set_interlace_handling(a) (1)
|
||||
|
||||
static void
|
||||
check_interlace_type(int PNG_CONST interlace_type)
|
||||
{
|
||||
if (interlace_type != PNG_INTERLACE_NONE)
|
||||
{
|
||||
/* This is an internal error - --interlace tests should be skipped, not
|
||||
* attempted.
|
||||
*/
|
||||
fprintf(stderr, "pngvalid: no interlace support\n");
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make a standardized image given a an image colour type, bit depth and
|
||||
* interlace type. The standard images have a very restricted range of
|
||||
* rows and heights and are used for testing transforms rather than image
|
||||
@@ -3355,6 +3459,8 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
{
|
||||
context(ps, fault);
|
||||
|
||||
check_interlace_type(interlace_type);
|
||||
|
||||
Try
|
||||
{
|
||||
png_infop pi;
|
||||
@@ -3496,7 +3602,7 @@ make_transform_images(png_store *ps)
|
||||
int interlace_type;
|
||||
|
||||
for (interlace_type = PNG_INTERLACE_NONE;
|
||||
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
|
||||
interlace_type < INTERLACE_LAST; ++interlace_type)
|
||||
{
|
||||
char name[FILE_NAME_SIZE];
|
||||
|
||||
@@ -3586,6 +3692,12 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
{
|
||||
context(ps, fault);
|
||||
|
||||
/* At present libpng does not support the write of an interlaced image unless
|
||||
* PNG_WRITE_INTERLACING_SUPPORTED, even with do_interlace so the code here
|
||||
* does the pixel interlace itself, so:
|
||||
*/
|
||||
check_interlace_type(interlace_type);
|
||||
|
||||
Try
|
||||
{
|
||||
png_infop pi;
|
||||
@@ -3652,6 +3764,9 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
int npasses = npasses_from_interlace_type(pp, interlace_type);
|
||||
png_uint_32 y;
|
||||
int pass;
|
||||
# ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
int nfilter = PNG_FILTER_VALUE_LAST;
|
||||
# endif
|
||||
png_byte image[16][SIZE_ROWMAX];
|
||||
|
||||
/* To help consistent error detection make the parts of this buffer
|
||||
@@ -3705,7 +3820,24 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Only get to here if the row has some pixels in it. */
|
||||
# ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
/* Only get to here if the row has some pixels in it, set the
|
||||
* filters to 'all' for the very first row and thereafter to a
|
||||
* single filter. It isn't well documented, but png_set_filter
|
||||
* does accept a filter number (per the spec) as well as a bit
|
||||
* mask.
|
||||
*
|
||||
* The apparent wackiness of decrementing nfilter rather than
|
||||
* incrementing is so that Paeth gets used in all images bigger
|
||||
* than 1 row - it's the tricky one.
|
||||
*/
|
||||
png_set_filter(pp, 0/*method*/,
|
||||
nfilter >= PNG_FILTER_VALUE_LAST ? PNG_ALL_FILTERS : nfilter);
|
||||
|
||||
if (nfilter-- == 0)
|
||||
nfilter = PNG_FILTER_VALUE_LAST-1;
|
||||
# endif
|
||||
|
||||
png_write_row(pp, row);
|
||||
}
|
||||
}
|
||||
@@ -3772,10 +3904,12 @@ make_size(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type, int bdlo,
|
||||
width, height, 0);
|
||||
make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_NONE,
|
||||
width, height, 1);
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7,
|
||||
width, height, 0);
|
||||
make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7,
|
||||
width, height, 1);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3866,6 +4000,8 @@ make_error(png_store* volatile psIn, png_byte PNG_CONST colour_type,
|
||||
|
||||
context(ps, fault);
|
||||
|
||||
check_interlace_type(interlace_type);
|
||||
|
||||
Try
|
||||
{
|
||||
png_structp pp;
|
||||
@@ -3969,7 +4105,7 @@ make_errors(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
|
||||
int interlace_type;
|
||||
|
||||
for (interlace_type = PNG_INTERLACE_NONE;
|
||||
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
|
||||
interlace_type < INTERLACE_LAST; ++interlace_type)
|
||||
{
|
||||
unsigned int test;
|
||||
char name[FILE_NAME_SIZE];
|
||||
@@ -3977,7 +4113,7 @@ make_errors(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
|
||||
standard_name(name, sizeof name, 0, colour_type, 1<<bdlo, 0,
|
||||
interlace_type, 0, 0, 0);
|
||||
|
||||
for (test=0; test<(sizeof error_test)/(sizeof error_test[0]); ++test)
|
||||
for (test=0; test<ARRAY_SIZE(error_test); ++test)
|
||||
{
|
||||
make_error(&pm->this, colour_type, DEPTH(bdlo), interlace_type,
|
||||
test, name);
|
||||
@@ -3990,7 +4126,7 @@ make_errors(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
|
||||
|
||||
return 1; /* keep going */
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
static void
|
||||
perform_error_test(png_modifier *pm)
|
||||
@@ -4167,6 +4303,7 @@ standard_display_init(standard_display *dp, png_store* ps, png_uint_32 id,
|
||||
dp->red_sBIT = dp->blue_sBIT = dp->green_sBIT = dp->alpha_sBIT =
|
||||
dp->bit_depth;
|
||||
dp->interlace_type = INTERLACE_FROM_ID(id);
|
||||
check_interlace_type(dp->interlace_type);
|
||||
dp->id = id;
|
||||
/* All the rest are filled in after the read_info: */
|
||||
dp->w = 0;
|
||||
@@ -4555,7 +4692,7 @@ standard_info_imp(standard_display *dp, png_structp pp, png_infop pi,
|
||||
standard_info_part2(dp, pp, pi, nImages);
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
standard_info(png_structp pp, png_infop pi)
|
||||
{
|
||||
standard_display *dp = voidcast(standard_display*,
|
||||
@@ -4567,7 +4704,7 @@ standard_info(png_structp pp, png_infop pi)
|
||||
standard_info_imp(dp, pp, pi, 1 /*only one image*/);
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -4776,7 +4913,7 @@ standard_check_text(png_const_structp pp, png_const_textp tp,
|
||||
|
||||
static void
|
||||
standard_text_validate(standard_display *dp, png_const_structp pp,
|
||||
png_infop pi)
|
||||
png_infop pi, int check_end)
|
||||
{
|
||||
png_textp tp = NULL;
|
||||
png_uint_32 num_text = png_get_text(pp, pi, &tp, NULL);
|
||||
@@ -4784,7 +4921,13 @@ standard_text_validate(standard_display *dp, png_const_structp pp,
|
||||
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");
|
||||
|
||||
/* This exists because prior to 1.5.18 the progressive reader left the
|
||||
* png_struct z_stream unreset at the end of the image, so subsequent
|
||||
* attempts to use it simply returns Z_STREAM_END.
|
||||
*/
|
||||
if (check_end)
|
||||
standard_check_text(pp, tp+1, "end marker", "end");
|
||||
}
|
||||
|
||||
else
|
||||
@@ -4797,7 +4940,7 @@ standard_text_validate(standard_display *dp, png_const_structp pp,
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define standard_text_validate(dp,pp,pi) ((void)0)
|
||||
# define standard_text_validate(dp,pp,pi,check_end) ((void)0)
|
||||
#endif
|
||||
|
||||
static void
|
||||
@@ -4875,7 +5018,7 @@ standard_image_validate(standard_display *dp, png_const_structp pp, int iImage,
|
||||
dp->ps->validated = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
standard_end(png_structp ppIn, png_infop pi)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -4887,7 +5030,8 @@ 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_text_validate(dp, pp, pi,
|
||||
PNG_LIBPNG_VER >= 10518/*check_end: see comments above*/);
|
||||
standard_image_validate(dp, pp, 0, -1);
|
||||
}
|
||||
|
||||
@@ -4958,7 +5102,7 @@ standard_test(png_store* PNG_CONST psIn, png_uint_32 PNG_CONST id,
|
||||
*/
|
||||
if (!d.speed)
|
||||
{
|
||||
standard_text_validate(&d, pp, pi);
|
||||
standard_text_validate(&d, pp, pi, 1/*check_end*/);
|
||||
standard_image_validate(&d, pp, 0, 1);
|
||||
}
|
||||
else
|
||||
@@ -4989,7 +5133,7 @@ test_standard(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
|
||||
int interlace_type;
|
||||
|
||||
for (interlace_type = PNG_INTERLACE_NONE;
|
||||
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
|
||||
interlace_type < INTERLACE_LAST; ++interlace_type)
|
||||
{
|
||||
standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
|
||||
interlace_type, 0, 0, 0), 0/*do_interlace*/, pm->use_update_info);
|
||||
@@ -5064,6 +5208,7 @@ test_size(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
|
||||
if (fail(pm))
|
||||
return 0;
|
||||
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
|
||||
PNG_INTERLACE_ADAM7, w, h, 0), 0/*do_interlace*/,
|
||||
pm->use_update_info);
|
||||
@@ -5077,6 +5222,7 @@ test_size(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
|
||||
|
||||
if (fail(pm))
|
||||
return 0;
|
||||
# endif
|
||||
|
||||
/* Now validate the interlaced read side - do_interlace true,
|
||||
* in the progressive case this does actually make a difference
|
||||
@@ -5089,12 +5235,14 @@ test_size(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
|
||||
if (fail(pm))
|
||||
return 0;
|
||||
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
|
||||
PNG_INTERLACE_ADAM7, w, h, 0), 1/*do_interlace*/,
|
||||
pm->use_update_info);
|
||||
|
||||
if (fail(pm))
|
||||
return 0;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5705,7 +5853,7 @@ transform_info_imp(transform_display *dp, png_structp pp, png_infop pi)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
transform_info(png_structp pp, png_infop pi)
|
||||
{
|
||||
transform_info_imp(voidcast(transform_display*, png_get_progressive_ptr(pp)),
|
||||
@@ -5912,7 +6060,7 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
|
||||
dp->this.ps->validated = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
transform_end(png_structp ppIn, png_infop pi)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -6004,7 +6152,7 @@ transform_test(png_modifier *pmIn, PNG_CONST png_uint_32 idIn,
|
||||
|
||||
Catch(fault)
|
||||
{
|
||||
modifier_reset((png_modifier*)fault);
|
||||
modifier_reset(voidcast(png_modifier*,(void*)fault));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6645,6 +6793,14 @@ image_transform_png_set_rgb_to_gray_ini(PNG_CONST image_transform *this,
|
||||
* conversion adds another +/-2 in the 16-bit case and
|
||||
* +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case.
|
||||
*/
|
||||
that->pm->limit +=
|
||||
# if PNG_MAX_GAMMA_8 < 14
|
||||
pow((that->this.bit_depth == 16 ?
|
||||
8. : 6. + (1<<(15-PNG_MAX_GAMMA_8)))/65535, data.gamma);
|
||||
# else
|
||||
pow((that->this.bit_depth == 16 ?
|
||||
8. : 8. + (1<<(15-PNG_MAX_GAMMA_8)))/65535, data.gamma);
|
||||
# endif
|
||||
that->pm->limit += pow(
|
||||
# if PNG_MAX_GAMMA_8 < 14
|
||||
(that->this.bit_depth == 16 ? 8. :
|
||||
@@ -6660,8 +6816,22 @@ image_transform_png_set_rgb_to_gray_ini(PNG_CONST image_transform *this,
|
||||
/* Rounding to 8 bits in the linear space causes massive errors which
|
||||
* will trigger the error check in transform_range_check. Fix that
|
||||
* here by taking the gamma encoding into account.
|
||||
*
|
||||
* When DIGITIZE is set because a pre-1.7 version of libpng is being
|
||||
* tested allow a bigger slack.
|
||||
*
|
||||
* NOTE: this magic number was determined by experiment to be 1.1 (when
|
||||
* using fixed point arithmetic). There's no great merit to the value
|
||||
* below, however it only affects the limit used for checking for
|
||||
* internal calculation errors, not the actual limit imposed by
|
||||
* pngvalid on the output errors.
|
||||
*/
|
||||
that->pm->limit += pow(1./255, data.gamma);
|
||||
that->pm->limit +=
|
||||
# if DIGITIZE
|
||||
pow(1.1 /255, data.gamma);
|
||||
# else
|
||||
pow(1.0 /255, data.gamma);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7267,7 +7437,7 @@ transform_enable(PNG_CONST char *name)
|
||||
{
|
||||
fprintf(stderr, "pngvalid: --transform-enable=%s: unknown transform\n",
|
||||
name);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7289,7 +7459,7 @@ transform_disable(PNG_CONST char *name)
|
||||
|
||||
fprintf(stderr, "pngvalid: --transform-disable=%s: unknown transform\n",
|
||||
name);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -7714,7 +7884,7 @@ gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi)
|
||||
standard_info_part2(&dp->this, pp, pi, 1 /*images*/);
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
gamma_info(png_structp pp, png_infop pi)
|
||||
{
|
||||
gamma_info_imp(voidcast(gamma_display*, png_get_progressive_ptr(pp)), pp,
|
||||
@@ -8678,7 +8848,7 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
dp->this.ps->validated = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
gamma_end(png_structp ppIn, png_infop pi)
|
||||
{
|
||||
png_const_structp pp = ppIn;
|
||||
@@ -8848,7 +9018,7 @@ gamma_test(png_modifier *pmIn, PNG_CONST png_byte colour_typeIn,
|
||||
}
|
||||
|
||||
Catch(fault)
|
||||
modifier_reset((png_modifier*)fault);
|
||||
modifier_reset(voidcast(png_modifier*,(void*)fault));
|
||||
}
|
||||
|
||||
static void gamma_threshold_test(png_modifier *pm, png_byte colour_type,
|
||||
@@ -9640,7 +9810,7 @@ perform_interlace_macro_validation(void)
|
||||
if (m != f)
|
||||
{
|
||||
fprintf(stderr, "PNG_PASS_START_ROW(%d) = %u != %x\n", pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
m = PNG_PASS_START_COL(pass);
|
||||
@@ -9648,7 +9818,7 @@ perform_interlace_macro_validation(void)
|
||||
if (m != f)
|
||||
{
|
||||
fprintf(stderr, "PNG_PASS_START_COL(%d) = %u != %x\n", pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
m = PNG_PASS_ROW_SHIFT(pass);
|
||||
@@ -9656,7 +9826,7 @@ perform_interlace_macro_validation(void)
|
||||
if (m != f)
|
||||
{
|
||||
fprintf(stderr, "PNG_PASS_ROW_SHIFT(%d) = %u != %x\n", pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
m = PNG_PASS_COL_SHIFT(pass);
|
||||
@@ -9664,7 +9834,7 @@ perform_interlace_macro_validation(void)
|
||||
if (m != f)
|
||||
{
|
||||
fprintf(stderr, "PNG_PASS_COL_SHIFT(%d) = %u != %x\n", pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
/* Macros that depend on the image or sub-image height too:
|
||||
@@ -9685,7 +9855,7 @@ perform_interlace_macro_validation(void)
|
||||
{
|
||||
fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n",
|
||||
v, pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
m = PNG_COL_FROM_PASS_COL(v, pass);
|
||||
@@ -9694,7 +9864,7 @@ perform_interlace_macro_validation(void)
|
||||
{
|
||||
fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n",
|
||||
v, pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
m = PNG_ROW_IN_INTERLACE_PASS(v, pass);
|
||||
@@ -9703,7 +9873,7 @@ perform_interlace_macro_validation(void)
|
||||
{
|
||||
fprintf(stderr, "PNG_ROW_IN_INTERLACE_PASS(%u, %d) = %u != %x\n",
|
||||
v, pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
m = PNG_COL_IN_INTERLACE_PASS(v, pass);
|
||||
@@ -9712,7 +9882,7 @@ perform_interlace_macro_validation(void)
|
||||
{
|
||||
fprintf(stderr, "PNG_COL_IN_INTERLACE_PASS(%u, %d) = %u != %x\n",
|
||||
v, pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
/* Then the base 1 stuff: */
|
||||
@@ -9723,7 +9893,7 @@ perform_interlace_macro_validation(void)
|
||||
{
|
||||
fprintf(stderr, "PNG_PASS_ROWS(%u, %d) = %u != %x\n",
|
||||
v, pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
m = PNG_PASS_COLS(v, pass);
|
||||
@@ -9732,7 +9902,7 @@ perform_interlace_macro_validation(void)
|
||||
{
|
||||
fprintf(stderr, "PNG_PASS_COLS(%u, %d) = %u != %x\n",
|
||||
v, pass, m, f);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
/* Move to the next v - the stepping algorithm starts skipping
|
||||
@@ -9921,12 +10091,12 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Store the test gammas */
|
||||
pm.gammas = gammas;
|
||||
pm.ngammas = (sizeof gammas) / (sizeof gammas[0]);
|
||||
pm.ngammas = ARRAY_SIZE(gammas);
|
||||
pm.ngamma_tests = 0; /* default to off */
|
||||
|
||||
/* And the test encodings */
|
||||
pm.encodings = test_encodings;
|
||||
pm.nencodings = (sizeof test_encodings) / (sizeof test_encodings[0]);
|
||||
pm.nencodings = ARRAY_SIZE(test_encodings);
|
||||
|
||||
pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */
|
||||
|
||||
@@ -10098,7 +10268,14 @@ int main(int argc, char **argv)
|
||||
++pm.use_update_info; /* Can call multiple times */
|
||||
|
||||
else if (strcmp(*argv, "--interlace") == 0)
|
||||
pm.interlace_type = PNG_INTERLACE_ADAM7;
|
||||
{
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
pm.interlace_type = PNG_INTERLACE_ADAM7;
|
||||
# else
|
||||
fprintf(stderr, "pngvalid: no write interlace support\n");
|
||||
return SKIP;
|
||||
# endif
|
||||
}
|
||||
|
||||
else if (strcmp(*argv, "--use-input-precision") == 0)
|
||||
pm.use_input_precision = 1U;
|
||||
@@ -10156,7 +10333,7 @@ int main(int argc, char **argv)
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "pngvalid: %s: unknown 'max' option\n", *argv);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
catmore = 1;
|
||||
@@ -10168,10 +10345,53 @@ int main(int argc, char **argv)
|
||||
else if (strcmp(*argv, "--log16") == 0)
|
||||
--argc, pm.log16 = atof(*++argv), catmore = 1;
|
||||
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
else if (strncmp(*argv, "--option=", 9) == 0)
|
||||
{
|
||||
/* Syntax of the argument is <option>:{on|off} */
|
||||
const char *arg = 9+*argv;
|
||||
unsigned char option=0, setting=0;
|
||||
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
if (strncmp(arg, "arm-neon:", 9) == 0)
|
||||
option = PNG_ARM_NEON, arg += 9;
|
||||
|
||||
else
|
||||
#endif
|
||||
#ifdef PNG_MAXIMUM_INFLATE_WINDOW
|
||||
if (strncmp(arg, "max-inflate-window:", 19) == 0)
|
||||
option = PNG_MAXIMUM_INFLATE_WINDOW, arg += 19;
|
||||
|
||||
else
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr, "pngvalid: %s: %s: unknown option\n", *argv, arg);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
if (strcmp(arg, "off") == 0)
|
||||
setting = PNG_OPTION_OFF;
|
||||
|
||||
else if (strcmp(arg, "on") == 0)
|
||||
setting = PNG_OPTION_ON;
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr,
|
||||
"pngvalid: %s: %s: unknown setting (use 'on' or 'off')\n",
|
||||
*argv, arg);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
pm.this.options[pm.this.noptions].option = option;
|
||||
pm.this.options[pm.this.noptions++].setting = setting;
|
||||
}
|
||||
#endif /* PNG_SET_OPTION_SUPPORTED */
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "pngvalid: %s: unknown argument\n", *argv);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
if (catmore) /* consumed an extra *argv */
|
||||
@@ -10345,13 +10565,17 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* This is required because some very minimal configurations do not use it:
|
||||
*/
|
||||
UNUSED(fail)
|
||||
return 0;
|
||||
}
|
||||
#else /* write not supported */
|
||||
#else /* write or low level APIs not supported */
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "pngvalid: no write support in libpng, all tests skipped\n");
|
||||
fprintf(stderr,
|
||||
"pngvalid: no low level write support in libpng, all tests skipped\n");
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
return SKIP;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
/* tarith.c
|
||||
*
|
||||
* Copyright (c) 2011,2012 John Cunningham Bowler
|
||||
* Copyright (c) 2011-2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -15,7 +15,7 @@ RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1
|
||||
CFLAGS=-O1 -Wall
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@@ -100,12 +100,12 @@ $(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\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) clean
|
||||
$(RM) pngm2pnm$(O)
|
||||
$(RM) pngm2pnm$(E)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# pngminim/decoder/pngusr.dfa
|
||||
#
|
||||
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
||||
*
|
||||
* Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -18,7 +18,6 @@
|
||||
* affect the API (so are not recorded in pnglibconf.h)
|
||||
*/
|
||||
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||
|
||||
#endif /* MINRDPNGCONF_H */
|
||||
|
||||
@@ -15,7 +15,7 @@ RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1
|
||||
CFLAGS=-O1 -Wall
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@@ -99,12 +99,12 @@ $(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\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) clean
|
||||
$(RM) pnm2pngm$(O)
|
||||
$(RM) pnm2pngm$(E)
|
||||
|
||||
@@ -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
|
||||
@@ -14,6 +14,10 @@ everything = off
|
||||
|
||||
option WRITE on
|
||||
|
||||
# These 2 options are required if you need to read PBM (P1 or P4) 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
|
||||
@@ -18,7 +18,6 @@
|
||||
* affect the API (so are not recorded in pnglibconf.h)
|
||||
*/
|
||||
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||
|
||||
#endif /* MINWRPNGCONF_H */
|
||||
|
||||
@@ -31,7 +31,7 @@ XLIB = -L/usr/X11R6/lib -lX11
|
||||
LIBS = $(XLIB) -lm #platforms that need libm
|
||||
|
||||
CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1
|
||||
CFLAGS=-O1 -Wall
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@@ -115,12 +115,12 @@ $(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\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||
srcdir=$(PNGSRC) clean
|
||||
$(RM) rpng2-x$(O)
|
||||
$(RM) rpng2-x$(E)
|
||||
|
||||
@@ -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
|
||||
@@ -18,7 +18,6 @@
|
||||
* affect the API (so are not recorded in pnglibconf.h)
|
||||
*/
|
||||
|
||||
#define PNG_NO_WARNINGS
|
||||
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||
|
||||
#endif /* MINPRDPNGCONF_H */
|
||||
|
||||
0
contrib/pngminus/png2pnm.bat
Normal file → Executable file
0
contrib/pngminus/png2pnm.bat
Normal file → Executable file
0
contrib/pngminus/png2pnm.sh
Normal file → Executable file
0
contrib/pngminus/png2pnm.sh
Normal file → Executable file
0
contrib/pngminus/pngminus.bat
Normal file → Executable file
0
contrib/pngminus/pngminus.bat
Normal file → Executable file
0
contrib/pngminus/pngminus.sh
Normal file → Executable file
0
contrib/pngminus/pngminus.sh
Normal file → Executable file
0
contrib/pngminus/pnm2png.bat
Normal file → Executable file
0
contrib/pngminus/pnm2png.bat
Normal file → Executable file
0
contrib/pngminus/pnm2png.sh
Normal file → Executable file
0
contrib/pngminus/pnm2png.sh
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
/* checksum-icc.c
|
||||
*
|
||||
* Copyright (c) 2012 John Cunningham Bowler
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2013.
|
||||
* COPYRIGHT: Written by John Cunningham Bowler, 2014.
|
||||
* To the extent possible under law, the author has waived all copyright and
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*-
|
||||
* 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.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* png-fix-itxt version 1.0.0
|
||||
*
|
||||
* Copyright 2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.3 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.3 [July 18, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* pngfix.c
|
||||
*
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
* Copyright (c) 2014 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.6.14 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -31,7 +32,6 @@
|
||||
# define FIX_GCC volatile
|
||||
#else
|
||||
# define FIX_GCC
|
||||
# error not tested
|
||||
#endif
|
||||
|
||||
#define PROGRAM_NAME "pngfix"
|
||||
@@ -49,14 +49,40 @@
|
||||
# error "pngfix will not work with libpng prior to 1.6.3"
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#include <setjmp.h>
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_EASY_ACCESS_SUPPORTED)
|
||||
/* zlib.h defines the structure z_stream, an instance of which is included
|
||||
* 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
|
||||
|
||||
#ifndef PNG_MAXIMUM_INFLATE_WINDOW
|
||||
# error "pngfix not supported in this libpng version"
|
||||
#endif
|
||||
|
||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
||||
#if ZLIB_VERNUM >= 0x1240
|
||||
|
||||
/* Copied from pngpriv.h */
|
||||
#ifdef __cplusplus
|
||||
@@ -118,6 +144,11 @@
|
||||
/* Is it safe to copy? */
|
||||
#define SAFE_TO_COPY(chunk) (((chunk) & PNG_U32(0,0,0,32)) != 0)
|
||||
|
||||
/* Fix ups for builds with limited read support */
|
||||
#ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
# define png_error(a,b) png_err(a)
|
||||
#endif
|
||||
|
||||
/********************************* UTILITIES **********************************/
|
||||
/* UNREACHED is a value to cause an assert to fail. Because of the way the
|
||||
* assert macro is written the string "UNREACHED" is produced in the error
|
||||
@@ -885,10 +916,10 @@ emit_string(const char *str, FILE *out)
|
||||
*/
|
||||
{
|
||||
for (; *str; ++str)
|
||||
if (isgraph(*str))
|
||||
if (isgraph(UCHAR_MAX & *str))
|
||||
putc(*str, out);
|
||||
|
||||
else if (isspace(*str))
|
||||
else if (isspace(UCHAR_MAX & *str))
|
||||
putc('_', out);
|
||||
|
||||
else
|
||||
@@ -1546,7 +1577,7 @@ chunk_end(struct chunk **chunk_var)
|
||||
}
|
||||
|
||||
static void
|
||||
chunk_init(struct chunk *chunk, struct file *file)
|
||||
chunk_init(struct chunk * const chunk, struct file * const file)
|
||||
/* When a chunk is initialized the file length/type/pos are copied into the
|
||||
* corresponding chunk fields and the new chunk is registered in the file
|
||||
* structure. There can only be one chunk at a time.
|
||||
@@ -1755,7 +1786,7 @@ IDAT_end(struct IDAT **idat_var)
|
||||
}
|
||||
|
||||
static void
|
||||
IDAT_init(struct IDAT *idat, struct file *file)
|
||||
IDAT_init(struct IDAT * const idat, struct file * const file)
|
||||
/* When the chunk is png_IDAT instantiate an IDAT control structure in place
|
||||
* of a chunk control structure. The IDAT will instantiate a chunk control
|
||||
* structure using the file alloc routine.
|
||||
@@ -2636,7 +2667,7 @@ zlib_check(struct file *file, png_uint_32 offset)
|
||||
|
||||
case ZLIB_OK:
|
||||
/* Truncated stream; unrecoverable, gets converted to ZLIB_FATAL */
|
||||
zlib.z.msg = png_constcast(char*, "[truncated]");
|
||||
zlib.z.msg = PNGZ_MSG_CAST("[truncated]");
|
||||
zlib_message(&zlib, 0/*expected*/);
|
||||
/* FALL THROUGH */
|
||||
|
||||
@@ -2675,7 +2706,7 @@ zlib_check(struct file *file, png_uint_32 offset)
|
||||
|
||||
/* Output the error that wasn't output before: */
|
||||
if (zlib.z.msg == NULL)
|
||||
zlib.z.msg = png_constcast(char*,
|
||||
zlib.z.msg = PNGZ_MSG_CAST(
|
||||
"invalid distance too far back");
|
||||
zlib_message(&zlib, 0/*stream error*/);
|
||||
zlib_end(&zlib);
|
||||
@@ -3131,13 +3162,13 @@ read_chunk(struct file *file)
|
||||
/* This returns a file* from a png_struct in an implementation specific way. */
|
||||
static struct file *get_control(png_const_structrp png_ptr);
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
error_handler(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
stop(get_control(png_ptr), LIBPNG_ERROR_CODE, message);
|
||||
}
|
||||
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
warning_handler(png_structp png_ptr, png_const_charp message)
|
||||
{
|
||||
struct file *file = get_control(png_ptr);
|
||||
@@ -3149,7 +3180,7 @@ warning_handler(png_structp png_ptr, png_const_charp message)
|
||||
/* Read callback - this is where the work gets done to check the stream before
|
||||
* passing it to libpng
|
||||
*/
|
||||
static void
|
||||
static void PNGCBAPI
|
||||
read_callback(png_structp png_ptr, png_bytep buffer, size_t count)
|
||||
/* Return 'count' bytes to libpng in 'buffer' */
|
||||
{
|
||||
@@ -3294,6 +3325,8 @@ read_callback(png_structp png_ptr, png_bytep buffer, size_t count)
|
||||
|
||||
else
|
||||
{
|
||||
assert(chunk != NULL);
|
||||
|
||||
/* Set up for write, notice that repositioning the input stream
|
||||
* is only necessary if something is to be read from it. Also
|
||||
* notice that for the IDAT stream this must only happen once -
|
||||
@@ -3307,6 +3340,8 @@ read_callback(png_structp png_ptr, png_bytep buffer, size_t count)
|
||||
/* FALL THROUGH */
|
||||
|
||||
default:
|
||||
assert(chunk != NULL);
|
||||
|
||||
/* NOTE: the arithmetic below overflows and gives a large positive
|
||||
* png_uint_32 value until the whole chunk data has been written.
|
||||
*/
|
||||
@@ -3512,22 +3547,14 @@ allocate(struct file *file, int allocate_idat)
|
||||
|
||||
if (allocate_idat)
|
||||
{
|
||||
struct IDAT *idat;
|
||||
|
||||
assert(file->idat == NULL);
|
||||
idat = &control->idat;
|
||||
IDAT_init(idat, file);
|
||||
file->idat = idat;
|
||||
IDAT_init(&control->idat, file);
|
||||
}
|
||||
|
||||
else /* chunk */
|
||||
{
|
||||
struct chunk *chunk;
|
||||
|
||||
assert(file->chunk == NULL);
|
||||
chunk = &control->chunk;
|
||||
chunk_init(chunk, file);
|
||||
file->chunk = chunk;
|
||||
chunk_init(&control->chunk, file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3620,7 +3647,7 @@ read_png(struct control *control)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
one_file(struct global *global, const char *file_name, const char *out_name)
|
||||
{
|
||||
int rc;
|
||||
@@ -3639,6 +3666,8 @@ one_file(struct global *global, const char *file_name, const char *out_name)
|
||||
rc = read_png(&control);
|
||||
|
||||
rc |= control_end(&control);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3658,7 +3687,7 @@ usage(const char *prog)
|
||||
" --optimize (-o):",
|
||||
" Find the smallest deflate window size for the compressed data.",
|
||||
" --strip=[none|crc|unsafe|unused|transform|color|all]:",
|
||||
" none: Retain all chunks.",
|
||||
" none (default): Retain all chunks.",
|
||||
" crc: Remove chunks with a bad CRC.",
|
||||
" unsafe: Remove chunks that may be unsafe to retain if the image data",
|
||||
" is modified. This is set automatically if --max is given but",
|
||||
@@ -3682,7 +3711,7 @@ usage(const char *prog)
|
||||
" --max=<number>:",
|
||||
" Use IDAT chunks sized <number>. If no number is given the the IDAT",
|
||||
" chunks will be the maximum size permitted; 2^31-1 bytes. If the option",
|
||||
" is ommited the original chunk sizes will not be changed. When the",
|
||||
" is omitted the original chunk sizes will not be changed. When the",
|
||||
" option is given --strip=unsafe is set automatically, this may be",
|
||||
" cancelled if you know that all unknown unsafe-to-copy chunks really are",
|
||||
" safe to copy across an IDAT size change. This is true of all chunks",
|
||||
@@ -3690,7 +3719,7 @@ usage(const char *prog)
|
||||
" MESSAGES",
|
||||
" By default the program only outputs summaries for each file.",
|
||||
" --quiet (-q):",
|
||||
" Do not output the summaries except for files which cannot be read, with",
|
||||
" Do not output the summaries except for files which cannot be read. With",
|
||||
" two --quiets these are not output either.",
|
||||
" --errors (-e):",
|
||||
" Output errors from libpng and the program (except too-far-back).",
|
||||
@@ -3988,16 +4017,16 @@ main(int argc, const char **argv)
|
||||
return global_end(&global);
|
||||
}
|
||||
|
||||
#else /* PNG_ZLIB_VERNUM < 0x1240 */
|
||||
#else /* ZLIB_VERNUM < 0x1240 */
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"pngfix needs libpng with a zlib >=1.2.4 (not 0x%x)\n",
|
||||
PNG_ZLIB_VERNUM);
|
||||
ZLIB_VERNUM);
|
||||
return 77;
|
||||
}
|
||||
#endif /* PNG_ZLIB_VERNUM */
|
||||
#endif /* ZLIB_VERNUM */
|
||||
|
||||
#else /* No read support */
|
||||
|
||||
@@ -4007,4 +4036,13 @@ main(void)
|
||||
fprintf(stderr, "pngfix does not work without read support\n");
|
||||
return 77;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED && PNG_EASY_ACCESS_SUPPORTED */
|
||||
#else /* No setjmp support */
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(stderr, "pngfix does not work without setjmp support\n");
|
||||
return 77;
|
||||
}
|
||||
#endif /* PNG_SETJMP_SUPPORTED */
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
40
example.c
40
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.3 [(PENDING RELEASE)]
|
||||
* Maintained 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Maintained 1998-2014 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
|
||||
@@ -52,7 +52,7 @@ int main(int argc, const char **argv)
|
||||
image.version = PNG_IMAGE_VERSION;
|
||||
|
||||
/* The first argument is the file to read: */
|
||||
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||
if (png_image_begin_read_from_file(&image, argv[1]) != 0)
|
||||
{
|
||||
png_bytep buffer;
|
||||
|
||||
@@ -97,7 +97,7 @@ int main(int argc, const char **argv)
|
||||
*/
|
||||
if (buffer != NULL &&
|
||||
png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/, NULL/*colormap*/))
|
||||
0/*row_stride*/, NULL/*colormap*/) != 0)
|
||||
{
|
||||
/* 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
|
||||
@@ -105,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*/, NULL/*colormap*/))
|
||||
buffer, 0/*row_stride*/, NULL/*colormap*/) != 0)
|
||||
{
|
||||
/* The image has been written successfully. */
|
||||
exit(0);
|
||||
@@ -188,13 +188,13 @@ int main(int argc, const char **argv)
|
||||
*
|
||||
* Don't repeatedly convert between the 8-bit and 16-bit forms. There is
|
||||
* significant data loss when 16-bit data is converted to the 8-bit encoding and
|
||||
* the current libpng implementation of convertion to 16-bit is also
|
||||
* the current libpng implementation of conversion to 16-bit is also
|
||||
* significantly lossy. The latter will be fixed in the future, but the former
|
||||
* is unavoidable - the 8-bit format just doesn't have enough resolution.
|
||||
*/
|
||||
|
||||
/* If your program needs more information from the PNG data it reads, or if you
|
||||
* need to do more complex transformations, or minimise transformations, on the
|
||||
* need to do more complex transformations, or minimize transformations, on the
|
||||
* data you read, then you must use one of the several lower level libpng
|
||||
* interfaces.
|
||||
*
|
||||
@@ -405,7 +405,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
/* Expand paletted or RGB images with transparency to full alpha channels
|
||||
* so the data will be available as RGBA quartets.
|
||||
*/
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) != 0)
|
||||
png_set_tRNS_to_alpha(png_ptr);
|
||||
|
||||
/* Set the background color to draw transparent and alpha images over.
|
||||
@@ -417,7 +417,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
|
||||
png_color_16 my_background, *image_background;
|
||||
|
||||
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
|
||||
if (png_get_bKGD(png_ptr, info_ptr, &image_background) != 0)
|
||||
png_set_background(png_ptr, image_background,
|
||||
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
else
|
||||
@@ -454,12 +454,12 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
|
||||
int intent;
|
||||
|
||||
if (png_get_sRGB(png_ptr, info_ptr, &intent))
|
||||
if (png_get_sRGB(png_ptr, info_ptr, &intent) != 0)
|
||||
png_set_gamma(png_ptr, screen_gamma, PNG_DEFAULT_sRGB);
|
||||
else
|
||||
{
|
||||
double image_gamma;
|
||||
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma))
|
||||
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma) != 0)
|
||||
png_set_gamma(png_ptr, screen_gamma, image_gamma);
|
||||
else
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.45455);
|
||||
@@ -469,7 +469,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
/* Quantize RGB files down to 8 bit palette or reduce palettes
|
||||
* to the number of colors available on your screen.
|
||||
*/
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
int num_palette;
|
||||
png_colorp palette;
|
||||
@@ -484,7 +484,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
MAX_SCREEN_COLORS, NULL, 0);
|
||||
}
|
||||
/* This reduces the image to the palette supplied in the file */
|
||||
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
|
||||
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) != 0)
|
||||
{
|
||||
png_uint_16p histogram = NULL;
|
||||
|
||||
@@ -494,7 +494,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
max_screen_colors, histogram, 0);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
#endif /* READ_QUANTIZE */
|
||||
|
||||
/* Invert monochrome files to have 0 as white and 1 as black */
|
||||
png_set_invert_mono(png_ptr);
|
||||
@@ -503,7 +503,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
* [0,65535] to the original [0,7] or [0,31], or whatever range the
|
||||
* colors were originally in:
|
||||
*/
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT) != 0)
|
||||
{
|
||||
png_color_8p sig_bit_p;
|
||||
|
||||
@@ -512,7 +512,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
}
|
||||
|
||||
/* Flip the RGB pixels to BGR (or RGBA to BGRA) */
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
png_set_bgr(png_ptr);
|
||||
|
||||
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
|
||||
@@ -532,7 +532,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
#else
|
||||
number_passes = 1;
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
|
||||
/* Optional call to gamma correct and add the background to the palette
|
||||
@@ -744,7 +744,7 @@ row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
* to pass the current row as new_row, and the function will combine
|
||||
* the old row and the new row.
|
||||
*/
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
}
|
||||
|
||||
end_callback(png_structp png_ptr, png_infop info)
|
||||
@@ -932,7 +932,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
*/
|
||||
|
||||
/* Once we write out the header, the compression type on the text
|
||||
* chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or
|
||||
* chunk gets changed to PNG_TEXT_COMPRESSION_NONE_WR or
|
||||
* PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again
|
||||
* at the end.
|
||||
*/
|
||||
@@ -970,7 +970,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
png_set_packswap(png_ptr);
|
||||
|
||||
/* Turn on interlace handling if you are not using png_write_image() */
|
||||
if (interlacing)
|
||||
if (interlacing != 0)
|
||||
number_passes = png_set_interlace_handling(png_ptr);
|
||||
|
||||
else
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.7.0beta18 - September 16, 2013
|
||||
libpng version 1.7.0beta41 - November 7, 2014
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2014 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.7.0beta18 - September 16, 2013
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta41 - November 7, 2014
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
|
||||
libpng 1.0 beta 6 version 0.96 May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
@@ -55,7 +55,7 @@ This file describes how to use and modify the PNG reference library
|
||||
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
|
||||
INSTALL file for instructions on how to install libpng.
|
||||
INSTALL file for instructions on how to configure and install libpng.
|
||||
|
||||
For examples of libpng usage, see the files "example.c", "pngtest.c",
|
||||
and the files in the "contrib" directory, all of which are included in
|
||||
@@ -275,10 +275,10 @@ This method of building a customized pnglibconf.h is illustrated in
|
||||
contrib/pngminim/*. See the "$(PNGCONF):" target in the makefile and
|
||||
pngusr.dfa in these directories.
|
||||
|
||||
C. Configuration using PNG_USR_CONFIG
|
||||
C. Configuration using PNG_USER_CONFIG
|
||||
|
||||
If -DPNG_USR_CONFIG is added to the CFLAGS when pnglibconf.h is built the file
|
||||
pngusr.h will automatically be included before the options in
|
||||
If -DPNG_USER_CONFIG is added to the CPPFLAGS when pnglibconf.h is built,
|
||||
the file pngusr.h will automatically be included before the options in
|
||||
scripts/pnglibconf.dfa are processed. Your pngusr.h file should contain only
|
||||
macro definitions turning features on or off or setting settings.
|
||||
|
||||
@@ -428,7 +428,7 @@ an end_info structure.
|
||||
|
||||
If you would rather avoid the complexity of setjmp/longjmp issues,
|
||||
you can compile libpng with PNG_NO_SETJMP, in which case
|
||||
errors will result in a call to PNG_ABORT() which defaults to abort().
|
||||
errors will result in a call to PNG_ABORT which defaults to abort().
|
||||
|
||||
You can #define PNG_ABORT to a function or other C code that does something
|
||||
more useful than abort(), as long as your function does not
|
||||
@@ -711,12 +711,12 @@ value. You can also specify a default encoding for the PNG file in
|
||||
case the required information is missing from the file. By default libpng
|
||||
assumes that the PNG data matches your system, to keep this default call:
|
||||
|
||||
png_set_gamma(png_ptr, screen_gamma, 1/screen_gamma/*file gamma*/);
|
||||
png_set_gamma(png_ptr, screen_gamma, output_gamma);
|
||||
|
||||
or you can use the fixed point equivalent:
|
||||
|
||||
png_set_gamma_fixed(png_ptr, PNG_FP_1*screen_gamma,
|
||||
PNG_FP_1/screen_gamma);
|
||||
PNG_FP_1*output_gamma);
|
||||
|
||||
If you don't know the gamma for your system it is probably 2.2 - a good
|
||||
approximation to the IEC standard for display systems (sRGB). If images are
|
||||
@@ -744,6 +744,70 @@ component value whenever arithmetic is performed. A lot of graphics software
|
||||
uses linear values for this reason, often with higher precision component values
|
||||
to preserve overall accuracy.
|
||||
|
||||
|
||||
The output_gamma value 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 computer display system; for example 2.2 for
|
||||
an sRGB conformant system. The values are scaled by 100000 in the _fixed
|
||||
version of the API (so 220000 for sRGB.)
|
||||
|
||||
The inverse of the value is always used to provide a default for the PNG file
|
||||
encoding if it has no gAMA chunk and if png_set_gamma() has not been called
|
||||
to override the PNG gamma information.
|
||||
|
||||
When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode
|
||||
opaque pixels however pixels with lower alpha values are not encoded,
|
||||
regardless of the output gamma setting.
|
||||
|
||||
When the standard Porter Duff handling is requested with mode 1 the output
|
||||
encoding is set to be linear and the output_gamma value is only relevant
|
||||
as a default for input data that has no gamma information. The linear output
|
||||
encoding will be overridden if png_set_gamma() is called - the results may be
|
||||
highly unexpected!
|
||||
|
||||
The following numbers are derived from the sRGB standard and the research
|
||||
behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of
|
||||
0.45455 (1/2.2) for PNG. The value implicitly includes any viewing
|
||||
correction required to take account of any differences in the color
|
||||
environment of the original scene and the intended display environment; the
|
||||
value expresses how to *decode* the image for display, not how the original
|
||||
data was *encoded*.
|
||||
|
||||
sRGB provides a peg for the PNG standard by defining a viewing environment.
|
||||
sRGB itself, and earlier TV standards, actually use a more complex transform
|
||||
(a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is
|
||||
limited to simple power laws.) By saying that an image for direct display on
|
||||
an sRGB conformant system should be stored with a gAMA chunk value of 45455
|
||||
(11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification
|
||||
makes it possible to derive values for other display systems and
|
||||
environments.
|
||||
|
||||
The Mac value is deduced from the sRGB based on an assumption that the actual
|
||||
extra viewing correction used in early Mac display systems was implemented as
|
||||
a power 1.45 lookup table.
|
||||
|
||||
Any system where a programmable lookup table is used or where the behavior of
|
||||
the final display device characteristics can be changed requires system
|
||||
specific code to obtain the current characteristic. However this can be
|
||||
difficult and most PNG gamma correction only requires an approximate value.
|
||||
|
||||
By default, if png_set_alpha_mode() is not called, libpng assumes that all
|
||||
values are unencoded, linear, values and that the output device also has a
|
||||
linear characteristic. This is only very rarely correct - it is invariably
|
||||
better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the
|
||||
default if you don't know what the right answer is!
|
||||
|
||||
The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS
|
||||
10.6) which used a correction table to implement a somewhat lower gamma on an
|
||||
otherwise sRGB system.
|
||||
|
||||
Both these values are reserved (not simple gamma values) in order to allow
|
||||
more precise correction internally in the future.
|
||||
|
||||
NOTE: the values can be passed to either the fixed or floating
|
||||
point APIs, but the floating point API will also accept floating point
|
||||
values.
|
||||
|
||||
The second thing you may need to tell libpng about is how your system handles
|
||||
alpha channel information. Some, but not all, PNG files contain an alpha
|
||||
channel. To display these files correctly you need to compose the data onto a
|
||||
@@ -768,11 +832,11 @@ by png_set_alpha_mode().
|
||||
|
||||
The mode is as follows:
|
||||
|
||||
PNG_ALPHA_PNG: The data is encoded according to the PNG specification. Red,
|
||||
green and blue, or gray, components are gamma encoded color
|
||||
values and are not premultiplied by the alpha value. The
|
||||
alpha value is a linear measure of the contribution of the
|
||||
pixel to the corresponding final output pixel.
|
||||
PNG_ALPHA_PNG: The data is encoded according to the PNG
|
||||
specification. Red, green and blue, or gray, components are
|
||||
gamma encoded color values and are not premultiplied by the
|
||||
alpha value. The alpha value is a linear measure of the
|
||||
contribution of the pixel to the corresponding final output pixel.
|
||||
|
||||
You should normally use this format if you intend to perform
|
||||
color correction on the color values; most, maybe all, color
|
||||
@@ -789,11 +853,35 @@ be used!
|
||||
|
||||
The remaining modes assume you don't need to do any further color correction or
|
||||
that if you do, your color correction software knows all about alpha (it
|
||||
probably doesn't!)
|
||||
probably doesn't!). They 'associate' the alpha with the color information by
|
||||
storing color channel values that have been scaled by the alpha. The
|
||||
advantage is that the color channels can be resampled (the image can be
|
||||
scaled) in this form. The disadvantage is that normal practice is to store
|
||||
linear, not (gamma) encoded, values and this requires 16-bit channels for
|
||||
still images rather than the 8-bit channels that are just about sufficient if
|
||||
gamma encoding is used. In addition all non-transparent pixel values,
|
||||
including completely opaque ones, must be gamma encoded to produce the final
|
||||
image. These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes
|
||||
described below (the latter being the two common names for associated alpha
|
||||
color channels). Note that PNG files always contain non-associated color
|
||||
channels; png_set_alpha_mode() with one of the modes causes the decoder to
|
||||
convert the pixels to an associated form before returning them to your
|
||||
application.
|
||||
|
||||
PNG_ALPHA_STANDARD: The data libpng produces
|
||||
is encoded in the standard way
|
||||
assumed by most correctly written graphics software.
|
||||
Since it is not necessary to perform arithmetic on opaque color values so
|
||||
long as they are not to be resampled and are in the final color space it is
|
||||
possible to optimize the handling of alpha by storing the opaque pixels in
|
||||
the PNG format (adjusted for the output color space) while storing partially
|
||||
opaque pixels in the standard, linear, format. The accuracy required for
|
||||
standard alpha composition is relatively low, because the pixels are
|
||||
isolated, therefore typically the accuracy loss in storing 8-bit linear
|
||||
values is acceptable. (This is not true if the alpha channel is used to
|
||||
simulate transparency over large areas - use 16 bits or the PNG mode in
|
||||
this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is
|
||||
treated as opaque only if the alpha value is equal to the maximum value.
|
||||
|
||||
PNG_ALPHA_STANDARD: The data libpng produces is encoded in the
|
||||
standard way assumed by most correctly written graphics software.
|
||||
The gamma encoding will be removed by libpng and the
|
||||
linear component values will be pre-multiplied by the
|
||||
alpha channel.
|
||||
@@ -822,9 +910,8 @@ dynamic range. To avoid problems, and if your software
|
||||
supports it, use png_set_expand_16() to force all
|
||||
components to 16 bits.
|
||||
|
||||
PNG_ALPHA_OPTIMIZED: This mode is the same
|
||||
as PNG_ALPHA_STANDARD except that
|
||||
completely opaque pixels are gamma encoded according to
|
||||
PNG_ALPHA_OPTIMIZED: This mode is the same as PNG_ALPHA_STANDARD
|
||||
except that completely opaque pixels are gamma encoded according to
|
||||
the screen_gamma value. Pixels with alpha less than 1.0
|
||||
will still have linear components.
|
||||
|
||||
@@ -843,18 +930,16 @@ representation of non-opaque pixels are irrelevant.
|
||||
You can also try this format if your software is broken;
|
||||
it might look better.
|
||||
|
||||
PNG_ALPHA_BROKEN: This is PNG_ALPHA_STANDARD;
|
||||
however, all component values,
|
||||
including the alpha channel are gamma encoded. This is
|
||||
an appropriate format to try if your software, or more
|
||||
likely hardware, is totally broken, i.e., if it performs
|
||||
linear arithmetic directly on gamma encoded values.
|
||||
|
||||
In most cases of broken software or hardware the bug in the final display
|
||||
manifests as a subtle halo around composited parts of the image. You may not
|
||||
even perceive this as a halo; the composited part of the image may simply appear
|
||||
separate from the background, as though it had been cut out of paper and pasted
|
||||
on afterward.
|
||||
PNG_ALPHA_BROKEN: This is PNG_ALPHA_STANDARD; however, all component
|
||||
values, including the alpha channel are gamma encoded. This is
|
||||
broken because, in practice, no implementation that uses this choice
|
||||
correctly undoes the encoding before handling alpha composition. Use this
|
||||
choice only if other serious errors in the software or hardware you use
|
||||
mandate it. In most cases of broken software or hardware the bug in the
|
||||
final display manifests as a subtle halo around composited parts of the
|
||||
image. You may not even perceive this as a halo; the composited part of
|
||||
the image may simply appear separate from the background, as though it had
|
||||
been cut out of paper and pasted on afterward.
|
||||
|
||||
If you don't have to deal with bugs in software or hardware, or if you can fix
|
||||
them, there are three recommended ways of using png_set_alpha_mode():
|
||||
@@ -885,6 +970,89 @@ All you can do is compose the result onto a matching output. Since this
|
||||
mode is libpng-specific you also need to write your own composition
|
||||
software.
|
||||
|
||||
The following are examples of calls to png_set_alpha_mode to achieve the
|
||||
required overall gamma correction and, where necessary, alpha
|
||||
premultiplication.
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
|
||||
|
||||
This is the default libpng handling of the alpha channel - it is not
|
||||
pre-multiplied into the color components. In addition the call states
|
||||
that the output is for a sRGB system and causes all PNG files without gAMA
|
||||
chunks to be assumed to be encoded using sRGB.
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
|
||||
|
||||
In this case the output is assumed to be something like an sRGB conformant
|
||||
display preceeded by a power-law lookup table of power 1.45. This is how
|
||||
early Mac systems behaved.
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);
|
||||
|
||||
This is the classic Jim Blinn approach and will work in academic
|
||||
environments where everything is done by the book. It has the shortcoming
|
||||
of assuming that input PNG data with no gamma information is linear - this
|
||||
is unlikely to be correct unless the PNG files where generated locally.
|
||||
Most of the time the output precision will be so low as to show
|
||||
significant banding in dark areas of the image.
|
||||
|
||||
png_set_expand_16(pp);
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);
|
||||
|
||||
This is a somewhat more realistic Jim Blinn inspired approach. PNG files
|
||||
are assumed to have the sRGB encoding if not marked with a gamma value and
|
||||
the output is always 16 bits per component. This permits accurate scaling
|
||||
and processing of the data. If you know that your input PNG files were
|
||||
generated locally you might need to replace PNG_DEFAULT_sRGB with the
|
||||
correct value for your system.
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);
|
||||
|
||||
If you just need to composite the PNG image onto an existing background
|
||||
and if you control the code that does this you can use the optimization
|
||||
setting. In this case you just copy completely opaque pixels to the
|
||||
output. For pixels that are not completely transparent (you just skip
|
||||
those) you do the composition math using png_composite or png_composite_16
|
||||
below then encode the resultant 8-bit or 16-bit values to match the output
|
||||
encoding.
|
||||
|
||||
Other cases
|
||||
|
||||
If neither the PNG nor the standard linear encoding work for you because
|
||||
of the software or hardware you use then you have a big problem. The PNG
|
||||
case will probably result in halos around the image. The linear encoding
|
||||
will probably result in a washed out, too bright, image (it's actually too
|
||||
contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably
|
||||
substantially reduce the halos. Alternatively try:
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);
|
||||
|
||||
This option will also reduce the halos, but there will be slight dark
|
||||
halos round the opaque parts of the image where the background is light.
|
||||
In the OPTIMIZED mode the halos will be light halos where the background
|
||||
is dark. Take your pick - the halos are unavoidable unless you can get
|
||||
your hardware/software fixed! (The OPTIMIZED approach is slightly
|
||||
faster.)
|
||||
|
||||
When the default gamma of PNG files doesn't match the output gamma.
|
||||
If you have PNG files with no gamma information png_set_alpha_mode allows
|
||||
you to provide a default gamma, but it also sets the ouput gamma to the
|
||||
matching value. If you know your PNG files have a gamma that doesn't
|
||||
match the output you can take advantage of the fact that
|
||||
png_set_alpha_mode always sets the output gamma but only sets the PNG
|
||||
default if it is not already set:
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
|
||||
|
||||
The first call sets both the default and the output gamma values, the
|
||||
second call overrides the output gamma without changing the default. This
|
||||
is easier than achieving the same effect with png_set_gamma. You must use
|
||||
PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will
|
||||
fire if more than one call to png_set_alpha_mode and png_set_background is
|
||||
made in the same read operation, however multiple calls with PNG_ALPHA_PNG
|
||||
are ignored.
|
||||
|
||||
If you don't need, or can't handle, the alpha channel you can call
|
||||
png_set_background() to remove it by compositing against a fixed color. Don't
|
||||
call png_set_strip_alpha() to do this - it will leave spurious pixel values in
|
||||
@@ -992,7 +1160,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/(sizeof (png_byte))
|
||||
if (height > PNG_UINT_32_MAX/(sizeof (png_byte)))
|
||||
png_error (png_ptr,
|
||||
"Image is too tall to process in memory");
|
||||
|
||||
@@ -1215,7 +1383,7 @@ png_set_rgb_to_gray()).
|
||||
|
||||
png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
|
||||
|
||||
file_srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
The presence of the sRGB chunk
|
||||
means that the pixel data is in the
|
||||
sRGB color space. This chunk also
|
||||
@@ -2165,10 +2333,15 @@ how pngvalid.c does it.
|
||||
Finishing a sequential read
|
||||
|
||||
After you are finished reading the image through the
|
||||
low-level interface, you can finish reading the file. If you are
|
||||
interested in comments or time, which may be stored either before or
|
||||
after the image data, you should pass the separate png_info struct if
|
||||
you want to keep the comments from before and after the image
|
||||
low-level interface, you can finish reading the file.
|
||||
|
||||
If you want to use a different crc action for handling CRC errors in
|
||||
chunks after the image data, you can call png_set_crc_action()
|
||||
again at this point.
|
||||
|
||||
If you are interested in comments or time, which may be stored either
|
||||
before or after the image data, you should pass the separate png_info
|
||||
struct if you want to keep the comments from before and after the image
|
||||
separate.
|
||||
|
||||
png_infop end_info = png_create_info_struct(png_ptr);
|
||||
@@ -2184,6 +2357,9 @@ separate.
|
||||
|
||||
If you are not interested, you should still call png_read_end()
|
||||
but you can pass NULL, avoiding the need to create an end_info structure.
|
||||
If you do this, libpng will not process any chunks after IDAT other than
|
||||
skipping over them and perhaps (depending on whether you have called
|
||||
png_set_crc_action) checking their CRCs while looking for the IEND chunk.
|
||||
|
||||
png_read_end(png_ptr, (png_infop)NULL);
|
||||
|
||||
@@ -2459,7 +2635,7 @@ png_infop info_ptr;
|
||||
png_progressive_combine_row(png_ptr, old_row,
|
||||
new_row);
|
||||
|
||||
/* where old_row is what was displayed for
|
||||
/* where old_row is what was displayed
|
||||
previously for the row. Note that the first
|
||||
pass (pass == 0, really) will completely cover
|
||||
the old row, so the rows do not have to be
|
||||
@@ -2565,8 +2741,7 @@ you can compile libpng with PNG_NO_SETJMP, in which case
|
||||
errors will result in a call to PNG_ABORT which defaults to abort().
|
||||
|
||||
You can #define PNG_ABORT to a function or other C code that does something
|
||||
more useful than abort(), as long as your function does not
|
||||
return.
|
||||
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
|
||||
@@ -3117,6 +3292,19 @@ Here is an example of writing two private chunks, prVt and miNE:
|
||||
/* 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
|
||||
@@ -3603,8 +3791,9 @@ and matches the 8-bit format expected by typical display devices.
|
||||
The color/gray channels are not scaled (pre-multiplied) by the alpha
|
||||
channel and are suitable for passing to color management software.
|
||||
|
||||
b) As a value in the range 0..65535, contained in a 2-byte integer. All
|
||||
channels can be converted to the original value by dividing by 65535; all
|
||||
b) As a value in the range 0..65535, contained in a 2-byte integer, in
|
||||
the native byte order of the platform on which the application is running.
|
||||
All channels can be converted to the original value by dividing by 65535; all
|
||||
channels are linear. Color channels use the RGB encoding (RGB end-points) of
|
||||
the sRGB specification. This encoding is identified by the
|
||||
PNG_FORMAT_FLAG_LINEAR flag below.
|
||||
@@ -3671,7 +3860,9 @@ First the single byte formats:
|
||||
Then the linear 2-byte formats. When naming these "Y" is used to
|
||||
indicate a luminance (gray) channel. The component order within the pixel
|
||||
is always the same - there is no provision for swapping the order of the
|
||||
components in the linear format.
|
||||
components in the linear format. The components are 16-bit integers in
|
||||
the native byte order for your platform, and there is no provision for
|
||||
swapping the bytes to a different endian condition.
|
||||
|
||||
PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR
|
||||
PNG_FORMAT_LINEAR_Y_ALPHA
|
||||
@@ -3736,7 +3927,7 @@ First the information about the samples.
|
||||
*
|
||||
* png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];
|
||||
*
|
||||
* Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
|
||||
* 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.
|
||||
*/
|
||||
@@ -3765,9 +3956,16 @@ Information about the whole row, or whole image
|
||||
row. For a color-mapped image this is the minimum number of bytes in a
|
||||
row.
|
||||
|
||||
If you need the stride measured in bytes, row_stride_bytes is
|
||||
PNG_IMAGE_ROW_STRIDE(image) * PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)
|
||||
plus any padding bytes that your application might need, for example
|
||||
to start the next row on a 4-byte boundary.
|
||||
|
||||
PNG_IMAGE_BUFFER_SIZE(image, row_stride)
|
||||
Returns the size, in bytes, of an image buffer given a png_image and a row
|
||||
stride - the number of components to leave space for in each row.
|
||||
stride - the number of components to leave space for in each row. This
|
||||
macro takes care of multiplying row_stride by PNG_IMAGE_PIXEL_COMONENT_SIZE
|
||||
when the image has 2-byte components.
|
||||
|
||||
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
|
||||
This indicates the the RGB values of the in-memory bitmap do not
|
||||
@@ -3896,14 +4094,11 @@ 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
|
||||
of allocating and freeing data, you can use png_create_read_struct_2() or
|
||||
png_create_write_struct_2() to register your own functions as described
|
||||
above. These functions also provide a void pointer that can be retrieved
|
||||
via
|
||||
will have to use appropriate pointers in your application. If you prefer
|
||||
to use a different method of allocating and freeing data, you can use
|
||||
png_create_read_struct_2() or png_create_write_struct_2() to register your
|
||||
own functions as described above. These functions also provide a void
|
||||
pointer that can be retrieved via
|
||||
|
||||
mem_ptr=png_get_mem_ptr(png_ptr);
|
||||
|
||||
@@ -4046,29 +4241,6 @@ the simpler ones to get an idea of how they work. Try to find a similar
|
||||
transformation to the one you want to add and copy off of it. More details
|
||||
can be found in the comments inside the code itself.
|
||||
|
||||
Configuring for 16-bit platforms
|
||||
|
||||
You will want to look into zconf.h to tell zlib (and thus libpng) that
|
||||
it cannot allocate more then 64K at a time. Even if you can, the memory
|
||||
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
|
||||
|
||||
Configuring for DOS
|
||||
|
||||
For DOS users who only have access to the lower 640K, you will
|
||||
have to limit zlib's memory usage via a png_set_compression_mem_level()
|
||||
call. See zlib.h or zconf.h in the zlib library for more information.
|
||||
|
||||
Configuring for Medium Model
|
||||
|
||||
Libpng's support for medium model has been tested on most of the popular
|
||||
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
|
||||
defined, and FAR gets defined to far in pngconf.h, and you should be
|
||||
all set. Everything in the library (except for zlib's structure) is
|
||||
expecting far data. You must use the typedefs with the p or pp on
|
||||
the end for pointers (or at least look at them and be careful). Make
|
||||
note that the rows of data are defined as png_bytepp, which is
|
||||
an "unsigned char far * far *".
|
||||
|
||||
Configuring for gui/windowing platforms:
|
||||
|
||||
You will need to write new error and warning functions that use the GUI
|
||||
@@ -4078,18 +4250,6 @@ in order to have them available during the structure initialization.
|
||||
They can be changed later via png_set_error_fn(). On some compilers,
|
||||
you may also have to change the memory allocators (png_malloc, etc.).
|
||||
|
||||
Configuring for compiler xxx:
|
||||
|
||||
All includes for libpng are in pngconf.h. If you need to add, change
|
||||
or delete an include, this is the place to do it.
|
||||
The includes that are not needed outside libpng are placed in pngpriv.h,
|
||||
which is only used by the routines inside libpng itself.
|
||||
The files in libpng proper only include pngpriv.h and png.h, which
|
||||
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
|
||||
As of libpng-1.5.0, pngpriv.h also includes three other private header
|
||||
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
|
||||
that previously appeared in the public headers.
|
||||
|
||||
Configuring zlib:
|
||||
|
||||
There are special functions to configure the compression. Perhaps the
|
||||
@@ -4131,6 +4291,8 @@ zlib.h for more information on what these mean.
|
||||
|
||||
png_set_compression_method(png_ptr, method);
|
||||
|
||||
This controls the size of the IDAT chunks (default 8192):
|
||||
|
||||
png_set_compression_buffer_size(png_ptr, size);
|
||||
|
||||
As of libpng version 1.5.4, additional APIs became
|
||||
@@ -4229,46 +4391,6 @@ Note that the numbers above were invented purely for this example and
|
||||
are given only to help explain the function usage. Little testing has
|
||||
been done to find optimum values for either the costs or the weights.
|
||||
|
||||
Removing unwanted object code
|
||||
|
||||
There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use a capability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space, or
|
||||
you can turn off individual capabilities with defines that begin with
|
||||
PNG_NO_.
|
||||
|
||||
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
|
||||
|
||||
You can also turn all of the transforms and ancillary chunk capabilities
|
||||
off en masse with compiler directives that define
|
||||
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
|
||||
or all four,
|
||||
along with directives to turn on any of the capabilities that you do
|
||||
want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra
|
||||
transformations but still leave the library fully capable of reading
|
||||
and writing PNG files with all known public chunks. Use of the
|
||||
PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
|
||||
that is incapable of reading or writing ancillary chunks. If you are
|
||||
not using the progressive reading capability, you can turn that off
|
||||
with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
|
||||
capability, which you'll still have).
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
make sure, or if you are building a stand alone library, all the
|
||||
reading files start with "pngr" and all the writing files start with "pngw".
|
||||
The files that don't match either (like png.c, pngtrans.c, etc.)
|
||||
are used for both reading and writing, and always need to be included.
|
||||
The progressive reader is in pngpread.c
|
||||
|
||||
If you are creating or distributing a dynamically linked library (a .so
|
||||
or DLL file), you should not remove or disable any parts of the library,
|
||||
as this will cause applications linked with different versions of the
|
||||
library to fail if they call functions not available in your library.
|
||||
The size of the library itself should not be an issue, because only
|
||||
those sections that are actually used will be loaded into memory.
|
||||
|
||||
Requesting debug printout
|
||||
|
||||
The macro definition PNG_DEBUG can be used to request debugging
|
||||
@@ -4306,17 +4428,6 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
|
||||
having level = 0 will be printed. There aren't any such statements in
|
||||
this version of libpng, but if you insert some they will be printed.
|
||||
|
||||
Prepending a prefix to exported symbols
|
||||
|
||||
Starting with libpng-1.6.0, you can configure libpng (when using the
|
||||
"configure" script) to prefix all exported symbols by means of the
|
||||
configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
|
||||
string beginning with a letter and containing only uppercase
|
||||
and lowercase letters, digits, and the underscore (i.e., a C language
|
||||
identifier). This creates a set of macros in pnglibconf.h, so this is
|
||||
transparent to applications; their function calls get transformed by
|
||||
the macros to use the modified names.
|
||||
|
||||
VII. MNG support
|
||||
|
||||
The MNG specification (available at http://www.libpng.org/pub/mng) allows
|
||||
@@ -4379,6 +4490,9 @@ png_set_error_fn(), which is essentially the same function, but with a new
|
||||
name to force compilation errors with applications that try to use the old
|
||||
method.
|
||||
|
||||
Support for the sCAL, iCCP, iTXt, and sPLT chunks was added at libpng-1.0.6;
|
||||
however, iTXt support was not enabled by default.
|
||||
|
||||
Starting with version 1.0.7, you can find out which version of the library
|
||||
you are using at run-time:
|
||||
|
||||
@@ -4607,12 +4721,13 @@ 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.
|
||||
The incorrect macro was removed from libpng-1.4.5.
|
||||
|
||||
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
|
||||
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, allowed);
|
||||
|
||||
@@ -4639,8 +4754,6 @@ 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
|
||||
members of the main libpng control structures, png_struct and png_info,
|
||||
@@ -4711,7 +4824,10 @@ and the accuracy of PNG fixed point values is insufficient for
|
||||
representation of these values. Consequently a "string" API
|
||||
(png_get_sCAL_s and png_set_sCAL_s) is the only reliable way of reading
|
||||
arbitrary sCAL chunks in the absence of either the floating point API or
|
||||
internal floating point calculations.
|
||||
internal floating point calculations. Starting with libpng-1.5.0, both
|
||||
of these functions are present when PNG_sCAL_SUPPORTED is defined. Prior
|
||||
to libpng-1.5.0, their presence also depended upon PNG_FIXED_POINT_SUPPORTED
|
||||
being defined and PNG_FLOATING_POINT_SUPPORTED not being defined.
|
||||
|
||||
Applications no longer need to include the optional distribution header
|
||||
file pngusr.h or define the corresponding macros during application
|
||||
@@ -4731,11 +4847,6 @@ reset by pngusr.h or by explicit settings on the compiler command line.
|
||||
These settings may produce compiler warnings or errors in 1.5.0 because
|
||||
of macro redefinition.
|
||||
|
||||
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. libpng 1.5.0
|
||||
is consistent with the implementation in 1.4.5 and 1.2.x (where the macro
|
||||
did not exist.)
|
||||
|
||||
Applications can now choose whether to use these macros or to call the
|
||||
corresponding function by defining PNG_USE_READ_MACROS or
|
||||
PNG_NO_USE_READ_MACROS before including png.h. Notice that this is
|
||||
@@ -4753,7 +4864,10 @@ option was off by default, and slightly inaccurate scaling occurred.
|
||||
This option can no longer be turned off, and the choice of accurate
|
||||
or inaccurate 16-to-8 scaling is by using the new png_set_scale_16_to_8()
|
||||
API for accurate scaling or the old png_set_strip_16_to_8() API for simple
|
||||
chopping.
|
||||
chopping. In libpng-1.5.4, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
macro became PNG_READ_SCALE_16_TO_8_SUPPORTED, and the PNG_READ_16_TO_8
|
||||
macro became PNG_READ_STRIP_16_TO_8_SUPPORTED, to enable the two
|
||||
png_set_*_16_to_8() functions separately.
|
||||
|
||||
Prior to libpng-1.5.4, the png_set_user_limits() function could only be
|
||||
used to reduce the width and height limits from the value of
|
||||
@@ -4778,26 +4892,6 @@ limits are now
|
||||
The png_set_option() function (and the "options" member of the png struct) was
|
||||
added to libpng-1.5.15.
|
||||
|
||||
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
|
||||
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
|
||||
to build pnglibconf.h where the corresponding makefile does not do so.
|
||||
|
||||
Building libpng with a non-default configuration has changed completely.
|
||||
The old method using pngusr.h should still work correctly even though the
|
||||
way pngusr.h is used in the build has been changed; however, library
|
||||
builders will probably want to examine the changes to take advantage of
|
||||
new capabilities and to simplify their build system.
|
||||
|
||||
B.1 Specific changes to library configuration capabilities
|
||||
|
||||
The library now supports a complete fixed point implementation and can
|
||||
thus be used on systems that have no floating point support or very
|
||||
limited or slow support. Previously gamma correction, an essential part
|
||||
@@ -4808,27 +4902,7 @@ independent of the choice of fixed versus floating point APIs and all the
|
||||
missing fixed point APIs have been implemented.
|
||||
|
||||
The exact mechanism used to control attributes of API functions has
|
||||
changed. A single set of operating system independent macro definitions
|
||||
is used and operating system specific directives are defined in
|
||||
pnglibconf.h
|
||||
|
||||
As part of this the mechanism used to choose procedure call standards on
|
||||
those systems that allow a choice has been changed. At present this only
|
||||
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
|
||||
running on Intel processors. As before, PNGAPI is defined where required
|
||||
to control the exported API functions; however, two new macros, PNGCBAPI
|
||||
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
|
||||
(PNGCAPI) for functions that must match a C library prototype (currently
|
||||
only png_longjmp_ptr, which must match the C longjmp function.) The new
|
||||
approach is documented in pngconf.h
|
||||
|
||||
Despite these changes, libpng 1.5.0 only supports the native C function
|
||||
calling standard on those platforms tested so far (__cdecl on Microsoft
|
||||
Windows). This is because the support requirements for alternative
|
||||
calling conventions seem to no longer exist. Developers who find it
|
||||
necessary to set PNG_API_RULE to 1 should advise the mailing list
|
||||
(png-mng-implement) of this and library builders who use Openwatcom and
|
||||
therefore set PNG_API_RULE to 2 should also contact the mailing list.
|
||||
changed, as described in the INSTALL file.
|
||||
|
||||
A new test program, pngvalid, is provided in addition to pngtest.
|
||||
pngvalid validates the arithmetic accuracy of the gamma correction
|
||||
@@ -4904,46 +4978,6 @@ even though the default is to use the macros - this allows applications
|
||||
to choose at app buildtime whether or not to use macros (previously
|
||||
impossible because the functions weren't in the default build.)
|
||||
|
||||
B.2 Changes to the configuration mechanism
|
||||
|
||||
Prior to libpng-1.5.0 library builders who needed to configure libpng
|
||||
had either to modify the exported pngconf.h header file to add system
|
||||
specific configuration or had to write feature selection macros into
|
||||
pngusr.h and cause this to be included into pngconf.h by defining
|
||||
PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
|
||||
application built without PNG_USER_CONFIG defined would see the
|
||||
unmodified, default, libpng API and thus would probably fail to link.
|
||||
|
||||
These mechanisms still work in the configure build and in any makefile
|
||||
build that builds pnglibconf.h, although the feature selection macros
|
||||
have changed somewhat as described above. In 1.5.0, however, pngusr.h is
|
||||
processed only once, when the exported header file pnglibconf.h is built.
|
||||
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
|
||||
copied to pnglibconf.h and this may produce macro redefinition warnings
|
||||
when the individual C files are compiled.
|
||||
|
||||
All configuration now only works if pnglibconf.h is built from
|
||||
scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
|
||||
(the original author of awk) maintains C source code of that awk and this
|
||||
and all known later implementations (often called by subtly different
|
||||
names - nawk and gawk for example) are adequate to build pnglibconf.h.
|
||||
The Sun Microsystems (now Oracle) program 'awk' is an earlier version
|
||||
and does not work; this may also apply to other systems that have a
|
||||
functioning awk called 'nawk'.
|
||||
|
||||
Configuration options are now documented in scripts/pnglibconf.dfa. This
|
||||
file also includes dependency information that ensures a configuration is
|
||||
consistent; that is, if a feature is switched off dependent features are
|
||||
also removed. As a recommended alternative to using feature macros in
|
||||
pngusr.h a system builder may also define equivalent options in pngusr.dfa
|
||||
(or, indeed, any file) and add that to the configuration by setting
|
||||
DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
|
||||
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
|
||||
@@ -4979,7 +5013,6 @@ 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()
|
||||
@@ -5001,19 +5034,38 @@ 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.
|
||||
profiles that were previously accepted are now accepted with a warning or
|
||||
rejected, depending upon the png_set_benign_errors() setting, in particular the
|
||||
very old broken Microsoft/HP 3144-byte sRGB profile. Starting with
|
||||
libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by
|
||||
means of
|
||||
|
||||
#if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \
|
||||
defined(PNG_SET_OPTION_SUPPORTED)
|
||||
png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE,
|
||||
PNG_OPTION_ON);
|
||||
#endif
|
||||
|
||||
It's not a good idea to do this if you are using the "simplified API",
|
||||
which needs to be able to recognize an sRGB profile conveyed via the iCCP
|
||||
chunk.
|
||||
|
||||
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
|
||||
and is interpreted by libpng to convey a one-tracer-curve gray profile or a
|
||||
three-tracer-curve RGB profile as appropriate.
|
||||
|
||||
|
||||
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().
|
||||
transform after it calls png_read_update_info() or if it attempts to call
|
||||
both png_read_update_info() and png_start_read_image() or to call either
|
||||
of them more than once.
|
||||
|
||||
The default condition for benign_errors is now to treat benign errors as
|
||||
warnings while reading and as errors while writing.
|
||||
@@ -5034,19 +5086,20 @@ 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), by using
|
||||
Libpng-1.6.0 through 1.6.2 used 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 caused
|
||||
zlib to issue the "invalid distance too far back" error and reject the file.
|
||||
Libpng-1.6.3 and later calculate their own safe CMF from the image dimensions,
|
||||
provide a way to revert to the libpng-1.5.x behavior (ignoring the CMF bytes
|
||||
and using a 32-kbyte sliding window), by using
|
||||
|
||||
png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW,
|
||||
PNG_OPTION_ON);
|
||||
|
||||
and provides a tool (contrib/tools/pngfix) for optimizing the CMF bytes
|
||||
correctly.
|
||||
and provide a tool (contrib/tools/pngfix) for rewriting a PNG file while
|
||||
optimizing the CMF bytes in its IDAT chunk 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
|
||||
@@ -5121,7 +5174,8 @@ mailing list, or directly to glennrp.
|
||||
|
||||
XVI. Coding style
|
||||
|
||||
Our coding style is similar to the "Allman" style, with curly
|
||||
Our coding style is similar to the "Allman" style
|
||||
(See http://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
|
||||
braces on separate lines:
|
||||
|
||||
if (condition)
|
||||
@@ -5184,6 +5238,9 @@ exported functions are marked with PNGAPI:
|
||||
body;
|
||||
}
|
||||
|
||||
The return type and decorations are placed on a separate line
|
||||
ahead of the function name, as illustrated above.
|
||||
|
||||
The prototypes for all exported functions appear in png.h,
|
||||
above the comment that says
|
||||
|
||||
@@ -5198,12 +5255,15 @@ We mark all non-exported functions with "/* PRIVATE */"":
|
||||
}
|
||||
|
||||
The prototypes for non-exported functions (except for those in
|
||||
pngtest) appear in
|
||||
pngpriv.h
|
||||
above the comment that says
|
||||
pngtest) appear in pngpriv.h above the comment that says
|
||||
|
||||
/* Maintainer: Put new private prototypes here ^ */
|
||||
|
||||
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
|
||||
use libpng *not* begin any of their own symbols with either of these strings.
|
||||
|
||||
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
|
||||
@@ -5215,10 +5275,8 @@ sizeof operator, with its argument, in parentheses:
|
||||
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
|
||||
use libpng *not* begin any of their own symbols with either of these strings.
|
||||
Control keywords if, for, while, and switch are always followed by a space
|
||||
to distinguish them from function calls, which have no trailing space.
|
||||
|
||||
We put a space after each comma and after each semicolon
|
||||
in "for" statements, and we put spaces before and after each
|
||||
@@ -5231,7 +5289,8 @@ left parenthesis that follows it:
|
||||
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.
|
||||
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).
|
||||
@@ -5239,6 +5298,9 @@ 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 prefer "if (something != 0)" and "if (something == 0)"
|
||||
over "if (something)" and if "(!something)", respectively.
|
||||
|
||||
We do not use the TAB character for indentation in the C sources.
|
||||
|
||||
Lines do not exceed 80 characters.
|
||||
@@ -5247,13 +5309,13 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
XVII. Y2K Compliance in libpng
|
||||
|
||||
September 16, 2013
|
||||
November 7, 2014
|
||||
|
||||
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.7.0beta18 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.7.0beta41 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
|
||||
|
||||
607
libpng.3
607
libpng.3
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNG 3 "September 16, 2013"
|
||||
.TH LIBPNG 3 "November 7, 2014"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta18
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta41
|
||||
.SH SYNOPSIS
|
||||
\fB
|
||||
#include <png.h>\fP
|
||||
@@ -494,10 +494,10 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
|
||||
.SH LIBPNG.TXT
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.7.0beta18 - September 16, 2013
|
||||
libpng version 1.7.0beta41 - November 7, 2014
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
|
||||
This document is released under the libpng license.
|
||||
For conditions of distribution and use, see the disclaimer
|
||||
@@ -505,9 +505,9 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta18 - September 16, 2013
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta41 - November 7, 2014
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
|
||||
libpng 1.0 beta 6 version 0.96 May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
@@ -549,7 +549,7 @@ This file describes how to use and modify the PNG reference library
|
||||
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
|
||||
INSTALL file for instructions on how to install libpng.
|
||||
INSTALL file for instructions on how to configure and install libpng.
|
||||
|
||||
For examples of libpng usage, see the files "example.c", "pngtest.c",
|
||||
and the files in the "contrib" directory, all of which are included in
|
||||
@@ -769,10 +769,10 @@ This method of building a customized pnglibconf.h is illustrated in
|
||||
contrib/pngminim/*. See the "$(PNGCONF):" target in the makefile and
|
||||
pngusr.dfa in these directories.
|
||||
|
||||
C. Configuration using PNG_USR_CONFIG
|
||||
C. Configuration using PNG_USER_CONFIG
|
||||
|
||||
If \-DPNG_USR_CONFIG is added to the CFLAGS when pnglibconf.h is built the file
|
||||
pngusr.h will automatically be included before the options in
|
||||
If \-DPNG_USER_CONFIG is added to the CPPFLAGS when pnglibconf.h is built,
|
||||
the file pngusr.h will automatically be included before the options in
|
||||
scripts/pnglibconf.dfa are processed. Your pngusr.h file should contain only
|
||||
macro definitions turning features on or off or setting settings.
|
||||
|
||||
@@ -922,7 +922,7 @@ an end_info structure.
|
||||
|
||||
If you would rather avoid the complexity of setjmp/longjmp issues,
|
||||
you can compile libpng with PNG_NO_SETJMP, in which case
|
||||
errors will result in a call to PNG_ABORT() which defaults to abort().
|
||||
errors will result in a call to PNG_ABORT which defaults to abort().
|
||||
|
||||
You can #define PNG_ABORT to a function or other C code that does something
|
||||
more useful than abort(), as long as your function does not
|
||||
@@ -1205,12 +1205,12 @@ value. You can also specify a default encoding for the PNG file in
|
||||
case the required information is missing from the file. By default libpng
|
||||
assumes that the PNG data matches your system, to keep this default call:
|
||||
|
||||
png_set_gamma(png_ptr, screen_gamma, 1/screen_gamma/*file gamma*/);
|
||||
png_set_gamma(png_ptr, screen_gamma, output_gamma);
|
||||
|
||||
or you can use the fixed point equivalent:
|
||||
|
||||
png_set_gamma_fixed(png_ptr, PNG_FP_1*screen_gamma,
|
||||
PNG_FP_1/screen_gamma);
|
||||
PNG_FP_1*output_gamma);
|
||||
|
||||
If you don't know the gamma for your system it is probably 2.2 - a good
|
||||
approximation to the IEC standard for display systems (sRGB). If images are
|
||||
@@ -1238,6 +1238,70 @@ component value whenever arithmetic is performed. A lot of graphics software
|
||||
uses linear values for this reason, often with higher precision component values
|
||||
to preserve overall accuracy.
|
||||
|
||||
|
||||
The output_gamma value 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 computer display system; for example 2.2 for
|
||||
an sRGB conformant system. The values are scaled by 100000 in the _fixed
|
||||
version of the API (so 220000 for sRGB.)
|
||||
|
||||
The inverse of the value is always used to provide a default for the PNG file
|
||||
encoding if it has no gAMA chunk and if png_set_gamma() has not been called
|
||||
to override the PNG gamma information.
|
||||
|
||||
When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode
|
||||
opaque pixels however pixels with lower alpha values are not encoded,
|
||||
regardless of the output gamma setting.
|
||||
|
||||
When the standard Porter Duff handling is requested with mode 1 the output
|
||||
encoding is set to be linear and the output_gamma value is only relevant
|
||||
as a default for input data that has no gamma information. The linear output
|
||||
encoding will be overridden if png_set_gamma() is called - the results may be
|
||||
highly unexpected!
|
||||
|
||||
The following numbers are derived from the sRGB standard and the research
|
||||
behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of
|
||||
0.45455 (1/2.2) for PNG. The value implicitly includes any viewing
|
||||
correction required to take account of any differences in the color
|
||||
environment of the original scene and the intended display environment; the
|
||||
value expresses how to *decode* the image for display, not how the original
|
||||
data was *encoded*.
|
||||
|
||||
sRGB provides a peg for the PNG standard by defining a viewing environment.
|
||||
sRGB itself, and earlier TV standards, actually use a more complex transform
|
||||
(a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is
|
||||
limited to simple power laws.) By saying that an image for direct display on
|
||||
an sRGB conformant system should be stored with a gAMA chunk value of 45455
|
||||
(11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification
|
||||
makes it possible to derive values for other display systems and
|
||||
environments.
|
||||
|
||||
The Mac value is deduced from the sRGB based on an assumption that the actual
|
||||
extra viewing correction used in early Mac display systems was implemented as
|
||||
a power 1.45 lookup table.
|
||||
|
||||
Any system where a programmable lookup table is used or where the behavior of
|
||||
the final display device characteristics can be changed requires system
|
||||
specific code to obtain the current characteristic. However this can be
|
||||
difficult and most PNG gamma correction only requires an approximate value.
|
||||
|
||||
By default, if png_set_alpha_mode() is not called, libpng assumes that all
|
||||
values are unencoded, linear, values and that the output device also has a
|
||||
linear characteristic. This is only very rarely correct - it is invariably
|
||||
better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the
|
||||
default if you don't know what the right answer is!
|
||||
|
||||
The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS
|
||||
10.6) which used a correction table to implement a somewhat lower gamma on an
|
||||
otherwise sRGB system.
|
||||
|
||||
Both these values are reserved (not simple gamma values) in order to allow
|
||||
more precise correction internally in the future.
|
||||
|
||||
NOTE: the values can be passed to either the fixed or floating
|
||||
point APIs, but the floating point API will also accept floating point
|
||||
values.
|
||||
|
||||
The second thing you may need to tell libpng about is how your system handles
|
||||
alpha channel information. Some, but not all, PNG files contain an alpha
|
||||
channel. To display these files correctly you need to compose the data onto a
|
||||
@@ -1262,11 +1326,11 @@ by png_set_alpha_mode().
|
||||
|
||||
The mode is as follows:
|
||||
|
||||
PNG_ALPHA_PNG: The data is encoded according to the PNG specification. Red,
|
||||
green and blue, or gray, components are gamma encoded color
|
||||
values and are not premultiplied by the alpha value. The
|
||||
alpha value is a linear measure of the contribution of the
|
||||
pixel to the corresponding final output pixel.
|
||||
PNG_ALPHA_PNG: The data is encoded according to the PNG
|
||||
specification. Red, green and blue, or gray, components are
|
||||
gamma encoded color values and are not premultiplied by the
|
||||
alpha value. The alpha value is a linear measure of the
|
||||
contribution of the pixel to the corresponding final output pixel.
|
||||
|
||||
You should normally use this format if you intend to perform
|
||||
color correction on the color values; most, maybe all, color
|
||||
@@ -1283,11 +1347,35 @@ be used!
|
||||
|
||||
The remaining modes assume you don't need to do any further color correction or
|
||||
that if you do, your color correction software knows all about alpha (it
|
||||
probably doesn't!)
|
||||
probably doesn't!). They 'associate' the alpha with the color information by
|
||||
storing color channel values that have been scaled by the alpha. The
|
||||
advantage is that the color channels can be resampled (the image can be
|
||||
scaled) in this form. The disadvantage is that normal practice is to store
|
||||
linear, not (gamma) encoded, values and this requires 16-bit channels for
|
||||
still images rather than the 8-bit channels that are just about sufficient if
|
||||
gamma encoding is used. In addition all non-transparent pixel values,
|
||||
including completely opaque ones, must be gamma encoded to produce the final
|
||||
image. These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes
|
||||
described below (the latter being the two common names for associated alpha
|
||||
color channels). Note that PNG files always contain non-associated color
|
||||
channels; png_set_alpha_mode() with one of the modes causes the decoder to
|
||||
convert the pixels to an associated form before returning them to your
|
||||
application.
|
||||
|
||||
PNG_ALPHA_STANDARD: The data libpng produces
|
||||
is encoded in the standard way
|
||||
assumed by most correctly written graphics software.
|
||||
Since it is not necessary to perform arithmetic on opaque color values so
|
||||
long as they are not to be resampled and are in the final color space it is
|
||||
possible to optimize the handling of alpha by storing the opaque pixels in
|
||||
the PNG format (adjusted for the output color space) while storing partially
|
||||
opaque pixels in the standard, linear, format. The accuracy required for
|
||||
standard alpha composition is relatively low, because the pixels are
|
||||
isolated, therefore typically the accuracy loss in storing 8-bit linear
|
||||
values is acceptable. (This is not true if the alpha channel is used to
|
||||
simulate transparency over large areas - use 16 bits or the PNG mode in
|
||||
this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is
|
||||
treated as opaque only if the alpha value is equal to the maximum value.
|
||||
|
||||
PNG_ALPHA_STANDARD: The data libpng produces is encoded in the
|
||||
standard way assumed by most correctly written graphics software.
|
||||
The gamma encoding will be removed by libpng and the
|
||||
linear component values will be pre-multiplied by the
|
||||
alpha channel.
|
||||
@@ -1316,9 +1404,8 @@ dynamic range. To avoid problems, and if your software
|
||||
supports it, use png_set_expand_16() to force all
|
||||
components to 16 bits.
|
||||
|
||||
PNG_ALPHA_OPTIMIZED: This mode is the same
|
||||
as PNG_ALPHA_STANDARD except that
|
||||
completely opaque pixels are gamma encoded according to
|
||||
PNG_ALPHA_OPTIMIZED: This mode is the same as PNG_ALPHA_STANDARD
|
||||
except that completely opaque pixels are gamma encoded according to
|
||||
the screen_gamma value. Pixels with alpha less than 1.0
|
||||
will still have linear components.
|
||||
|
||||
@@ -1337,18 +1424,16 @@ representation of non-opaque pixels are irrelevant.
|
||||
You can also try this format if your software is broken;
|
||||
it might look better.
|
||||
|
||||
PNG_ALPHA_BROKEN: This is PNG_ALPHA_STANDARD;
|
||||
however, all component values,
|
||||
including the alpha channel are gamma encoded. This is
|
||||
an appropriate format to try if your software, or more
|
||||
likely hardware, is totally broken, i.e., if it performs
|
||||
linear arithmetic directly on gamma encoded values.
|
||||
|
||||
In most cases of broken software or hardware the bug in the final display
|
||||
manifests as a subtle halo around composited parts of the image. You may not
|
||||
even perceive this as a halo; the composited part of the image may simply appear
|
||||
separate from the background, as though it had been cut out of paper and pasted
|
||||
on afterward.
|
||||
PNG_ALPHA_BROKEN: This is PNG_ALPHA_STANDARD; however, all component
|
||||
values, including the alpha channel are gamma encoded. This is
|
||||
broken because, in practice, no implementation that uses this choice
|
||||
correctly undoes the encoding before handling alpha composition. Use this
|
||||
choice only if other serious errors in the software or hardware you use
|
||||
mandate it. In most cases of broken software or hardware the bug in the
|
||||
final display manifests as a subtle halo around composited parts of the
|
||||
image. You may not even perceive this as a halo; the composited part of
|
||||
the image may simply appear separate from the background, as though it had
|
||||
been cut out of paper and pasted on afterward.
|
||||
|
||||
If you don't have to deal with bugs in software or hardware, or if you can fix
|
||||
them, there are three recommended ways of using png_set_alpha_mode():
|
||||
@@ -1379,6 +1464,89 @@ All you can do is compose the result onto a matching output. Since this
|
||||
mode is libpng-specific you also need to write your own composition
|
||||
software.
|
||||
|
||||
The following are examples of calls to png_set_alpha_mode to achieve the
|
||||
required overall gamma correction and, where necessary, alpha
|
||||
premultiplication.
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
|
||||
|
||||
This is the default libpng handling of the alpha channel - it is not
|
||||
pre-multiplied into the color components. In addition the call states
|
||||
that the output is for a sRGB system and causes all PNG files without gAMA
|
||||
chunks to be assumed to be encoded using sRGB.
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
|
||||
|
||||
In this case the output is assumed to be something like an sRGB conformant
|
||||
display preceeded by a power-law lookup table of power 1.45. This is how
|
||||
early Mac systems behaved.
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);
|
||||
|
||||
This is the classic Jim Blinn approach and will work in academic
|
||||
environments where everything is done by the book. It has the shortcoming
|
||||
of assuming that input PNG data with no gamma information is linear - this
|
||||
is unlikely to be correct unless the PNG files where generated locally.
|
||||
Most of the time the output precision will be so low as to show
|
||||
significant banding in dark areas of the image.
|
||||
|
||||
png_set_expand_16(pp);
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);
|
||||
|
||||
This is a somewhat more realistic Jim Blinn inspired approach. PNG files
|
||||
are assumed to have the sRGB encoding if not marked with a gamma value and
|
||||
the output is always 16 bits per component. This permits accurate scaling
|
||||
and processing of the data. If you know that your input PNG files were
|
||||
generated locally you might need to replace PNG_DEFAULT_sRGB with the
|
||||
correct value for your system.
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);
|
||||
|
||||
If you just need to composite the PNG image onto an existing background
|
||||
and if you control the code that does this you can use the optimization
|
||||
setting. In this case you just copy completely opaque pixels to the
|
||||
output. For pixels that are not completely transparent (you just skip
|
||||
those) you do the composition math using png_composite or png_composite_16
|
||||
below then encode the resultant 8-bit or 16-bit values to match the output
|
||||
encoding.
|
||||
|
||||
Other cases
|
||||
|
||||
If neither the PNG nor the standard linear encoding work for you because
|
||||
of the software or hardware you use then you have a big problem. The PNG
|
||||
case will probably result in halos around the image. The linear encoding
|
||||
will probably result in a washed out, too bright, image (it's actually too
|
||||
contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably
|
||||
substantially reduce the halos. Alternatively try:
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);
|
||||
|
||||
This option will also reduce the halos, but there will be slight dark
|
||||
halos round the opaque parts of the image where the background is light.
|
||||
In the OPTIMIZED mode the halos will be light halos where the background
|
||||
is dark. Take your pick - the halos are unavoidable unless you can get
|
||||
your hardware/software fixed! (The OPTIMIZED approach is slightly
|
||||
faster.)
|
||||
|
||||
When the default gamma of PNG files doesn't match the output gamma.
|
||||
If you have PNG files with no gamma information png_set_alpha_mode allows
|
||||
you to provide a default gamma, but it also sets the ouput gamma to the
|
||||
matching value. If you know your PNG files have a gamma that doesn't
|
||||
match the output you can take advantage of the fact that
|
||||
png_set_alpha_mode always sets the output gamma but only sets the PNG
|
||||
default if it is not already set:
|
||||
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
|
||||
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
|
||||
|
||||
The first call sets both the default and the output gamma values, the
|
||||
second call overrides the output gamma without changing the default. This
|
||||
is easier than achieving the same effect with png_set_gamma. You must use
|
||||
PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will
|
||||
fire if more than one call to png_set_alpha_mode and png_set_background is
|
||||
made in the same read operation, however multiple calls with PNG_ALPHA_PNG
|
||||
are ignored.
|
||||
|
||||
If you don't need, or can't handle, the alpha channel you can call
|
||||
png_set_background() to remove it by compositing against a fixed color. Don't
|
||||
call png_set_strip_alpha() to do this - it will leave spurious pixel values in
|
||||
@@ -1486,7 +1654,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/(sizeof (png_byte))
|
||||
if (height > PNG_UINT_32_MAX/(sizeof (png_byte)))
|
||||
png_error (png_ptr,
|
||||
"Image is too tall to process in memory");
|
||||
|
||||
@@ -1709,7 +1877,7 @@ png_set_rgb_to_gray()).
|
||||
|
||||
png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
|
||||
|
||||
file_srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
The presence of the sRGB chunk
|
||||
means that the pixel data is in the
|
||||
sRGB color space. This chunk also
|
||||
@@ -2659,10 +2827,15 @@ how pngvalid.c does it.
|
||||
.SS Finishing a sequential read
|
||||
|
||||
After you are finished reading the image through the
|
||||
low-level interface, you can finish reading the file. If you are
|
||||
interested in comments or time, which may be stored either before or
|
||||
after the image data, you should pass the separate png_info struct if
|
||||
you want to keep the comments from before and after the image
|
||||
low-level interface, you can finish reading the file.
|
||||
|
||||
If you want to use a different crc action for handling CRC errors in
|
||||
chunks after the image data, you can call png_set_crc_action()
|
||||
again at this point.
|
||||
|
||||
If you are interested in comments or time, which may be stored either
|
||||
before or after the image data, you should pass the separate png_info
|
||||
struct if you want to keep the comments from before and after the image
|
||||
separate.
|
||||
|
||||
png_infop end_info = png_create_info_struct(png_ptr);
|
||||
@@ -2678,6 +2851,9 @@ separate.
|
||||
|
||||
If you are not interested, you should still call png_read_end()
|
||||
but you can pass NULL, avoiding the need to create an end_info structure.
|
||||
If you do this, libpng will not process any chunks after IDAT other than
|
||||
skipping over them and perhaps (depending on whether you have called
|
||||
png_set_crc_action) checking their CRCs while looking for the IEND chunk.
|
||||
|
||||
png_read_end(png_ptr, (png_infop)NULL);
|
||||
|
||||
@@ -2953,7 +3129,7 @@ png_infop info_ptr;
|
||||
png_progressive_combine_row(png_ptr, old_row,
|
||||
new_row);
|
||||
|
||||
/* where old_row is what was displayed for
|
||||
/* where old_row is what was displayed
|
||||
previously for the row. Note that the first
|
||||
pass (pass == 0, really) will completely cover
|
||||
the old row, so the rows do not have to be
|
||||
@@ -3059,8 +3235,7 @@ you can compile libpng with PNG_NO_SETJMP, in which case
|
||||
errors will result in a call to PNG_ABORT which defaults to abort().
|
||||
|
||||
You can #define PNG_ABORT to a function or other C code that does something
|
||||
more useful than abort(), as long as your function does not
|
||||
return.
|
||||
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
|
||||
@@ -3611,6 +3786,19 @@ Here is an example of writing two private chunks, prVt and miNE:
|
||||
/* 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
|
||||
|
||||
.SS The high-level write interface
|
||||
@@ -4097,8 +4285,9 @@ and matches the 8-bit format expected by typical display devices.
|
||||
The color/gray channels are not scaled (pre-multiplied) by the alpha
|
||||
channel and are suitable for passing to color management software.
|
||||
|
||||
b) As a value in the range 0..65535, contained in a 2-byte integer. All
|
||||
channels can be converted to the original value by dividing by 65535; all
|
||||
b) As a value in the range 0..65535, contained in a 2-byte integer, in
|
||||
the native byte order of the platform on which the application is running.
|
||||
All channels can be converted to the original value by dividing by 65535; all
|
||||
channels are linear. Color channels use the RGB encoding (RGB end-points) of
|
||||
the sRGB specification. This encoding is identified by the
|
||||
PNG_FORMAT_FLAG_LINEAR flag below.
|
||||
@@ -4165,7 +4354,9 @@ First the single byte formats:
|
||||
Then the linear 2-byte formats. When naming these "Y" is used to
|
||||
indicate a luminance (gray) channel. The component order within the pixel
|
||||
is always the same - there is no provision for swapping the order of the
|
||||
components in the linear format.
|
||||
components in the linear format. The components are 16-bit integers in
|
||||
the native byte order for your platform, and there is no provision for
|
||||
swapping the bytes to a different endian condition.
|
||||
|
||||
PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR
|
||||
PNG_FORMAT_LINEAR_Y_ALPHA
|
||||
@@ -4230,7 +4421,7 @@ First the information about the samples.
|
||||
*
|
||||
* png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];
|
||||
*
|
||||
* Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
|
||||
* 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.
|
||||
*/
|
||||
@@ -4259,9 +4450,16 @@ Information about the whole row, or whole image
|
||||
row. For a color-mapped image this is the minimum number of bytes in a
|
||||
row.
|
||||
|
||||
If you need the stride measured in bytes, row_stride_bytes is
|
||||
PNG_IMAGE_ROW_STRIDE(image) * PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)
|
||||
plus any padding bytes that your application might need, for example
|
||||
to start the next row on a 4-byte boundary.
|
||||
|
||||
PNG_IMAGE_BUFFER_SIZE(image, row_stride)
|
||||
Returns the size, in bytes, of an image buffer given a png_image and a row
|
||||
stride - the number of components to leave space for in each row.
|
||||
stride - the number of components to leave space for in each row. This
|
||||
macro takes care of multiplying row_stride by PNG_IMAGE_PIXEL_COMONENT_SIZE
|
||||
when the image has 2-byte components.
|
||||
|
||||
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
|
||||
This indicates the the RGB values of the in-memory bitmap do not
|
||||
@@ -4390,14 +4588,11 @@ 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
|
||||
of allocating and freeing data, you can use png_create_read_struct_2() or
|
||||
png_create_write_struct_2() to register your own functions as described
|
||||
above. These functions also provide a void pointer that can be retrieved
|
||||
via
|
||||
will have to use appropriate pointers in your application. If you prefer
|
||||
to use a different method of allocating and freeing data, you can use
|
||||
png_create_read_struct_2() or png_create_write_struct_2() to register your
|
||||
own functions as described above. These functions also provide a void
|
||||
pointer that can be retrieved via
|
||||
|
||||
mem_ptr=png_get_mem_ptr(png_ptr);
|
||||
|
||||
@@ -4540,29 +4735,6 @@ the simpler ones to get an idea of how they work. Try to find a similar
|
||||
transformation to the one you want to add and copy off of it. More details
|
||||
can be found in the comments inside the code itself.
|
||||
|
||||
.SS Configuring for 16-bit platforms
|
||||
|
||||
You will want to look into zconf.h to tell zlib (and thus libpng) that
|
||||
it cannot allocate more then 64K at a time. Even if you can, the memory
|
||||
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
|
||||
|
||||
.SS Configuring for DOS
|
||||
|
||||
For DOS users who only have access to the lower 640K, you will
|
||||
have to limit zlib's memory usage via a png_set_compression_mem_level()
|
||||
call. See zlib.h or zconf.h in the zlib library for more information.
|
||||
|
||||
.SS Configuring for Medium Model
|
||||
|
||||
Libpng's support for medium model has been tested on most of the popular
|
||||
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
|
||||
defined, and FAR gets defined to far in pngconf.h, and you should be
|
||||
all set. Everything in the library (except for zlib's structure) is
|
||||
expecting far data. You must use the typedefs with the p or pp on
|
||||
the end for pointers (or at least look at them and be careful). Make
|
||||
note that the rows of data are defined as png_bytepp, which is
|
||||
an "unsigned char far * far *".
|
||||
|
||||
.SS Configuring for gui/windowing platforms:
|
||||
|
||||
You will need to write new error and warning functions that use the GUI
|
||||
@@ -4572,19 +4744,6 @@ in order to have them available during the structure initialization.
|
||||
They can be changed later via png_set_error_fn(). On some compilers,
|
||||
you may also have to change the memory allocators (png_malloc, etc.).
|
||||
|
||||
.SS Configuring for compiler xxx:
|
||||
|
||||
All includes for libpng are in pngconf.h. If you need to add, change
|
||||
or delete an include, this is the place to do it.
|
||||
The includes that are not needed outside libpng are placed in pngpriv.h,
|
||||
which is only used by the routines inside libpng itself.
|
||||
The files in libpng proper only include pngpriv.h and png.h, which
|
||||
%14%in turn includes pngconf.h.
|
||||
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
|
||||
As of libpng-1.5.0, pngpriv.h also includes three other private header
|
||||
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
|
||||
that previously appeared in the public headers.
|
||||
|
||||
.SS Configuring zlib:
|
||||
|
||||
There are special functions to configure the compression. Perhaps the
|
||||
@@ -4626,6 +4785,8 @@ zlib.h for more information on what these mean.
|
||||
|
||||
png_set_compression_method(png_ptr, method);
|
||||
|
||||
This controls the size of the IDAT chunks (default 8192):
|
||||
|
||||
png_set_compression_buffer_size(png_ptr, size);
|
||||
|
||||
As of libpng version 1.5.4, additional APIs became
|
||||
@@ -4724,46 +4885,6 @@ Note that the numbers above were invented purely for this example and
|
||||
are given only to help explain the function usage. Little testing has
|
||||
been done to find optimum values for either the costs or the weights.
|
||||
|
||||
.SS Removing unwanted object code
|
||||
|
||||
There are a bunch of #define's in pngconf.h that control what parts of
|
||||
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
||||
never going to use a capability, you can change the #define to #undef
|
||||
before recompiling libpng and save yourself code and data space, or
|
||||
you can turn off individual capabilities with defines that begin with
|
||||
PNG_NO_.
|
||||
|
||||
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
|
||||
|
||||
You can also turn all of the transforms and ancillary chunk capabilities
|
||||
off en masse with compiler directives that define
|
||||
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
|
||||
or all four,
|
||||
along with directives to turn on any of the capabilities that you do
|
||||
want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra
|
||||
transformations but still leave the library fully capable of reading
|
||||
and writing PNG files with all known public chunks. Use of the
|
||||
PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
|
||||
that is incapable of reading or writing ancillary chunks. If you are
|
||||
not using the progressive reading capability, you can turn that off
|
||||
with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
|
||||
capability, which you'll still have).
|
||||
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
make sure, or if you are building a stand alone library, all the
|
||||
reading files start with "pngr" and all the writing files start with "pngw".
|
||||
The files that don't match either (like png.c, pngtrans.c, etc.)
|
||||
are used for both reading and writing, and always need to be included.
|
||||
The progressive reader is in pngpread.c
|
||||
|
||||
If you are creating or distributing a dynamically linked library (a .so
|
||||
or DLL file), you should not remove or disable any parts of the library,
|
||||
as this will cause applications linked with different versions of the
|
||||
library to fail if they call functions not available in your library.
|
||||
The size of the library itself should not be an issue, because only
|
||||
those sections that are actually used will be loaded into memory.
|
||||
|
||||
.SS Requesting debug printout
|
||||
|
||||
The macro definition PNG_DEBUG can be used to request debugging
|
||||
@@ -4801,17 +4922,6 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
|
||||
having level = 0 will be printed. There aren't any such statements in
|
||||
this version of libpng, but if you insert some they will be printed.
|
||||
|
||||
.SS Prepending a prefix to exported symbols
|
||||
|
||||
Starting with libpng-1.6.0, you can configure libpng (when using the
|
||||
"configure" script) to prefix all exported symbols by means of the
|
||||
configuration option "\-\-with\-libpng\-prefix=FOO_", where FOO_ can be any
|
||||
string beginning with a letter and containing only uppercase
|
||||
and lowercase letters, digits, and the underscore (i.e., a C language
|
||||
identifier). This creates a set of macros in pnglibconf.h, so this is
|
||||
transparent to applications; their function calls get transformed by
|
||||
the macros to use the modified names.
|
||||
|
||||
.SH VII. MNG support
|
||||
|
||||
The MNG specification (available at http://www.libpng.org/pub/mng) allows
|
||||
@@ -4874,6 +4984,9 @@ png_set_error_fn(), which is essentially the same function, but with a new
|
||||
name to force compilation errors with applications that try to use the old
|
||||
method.
|
||||
|
||||
Support for the sCAL, iCCP, iTXt, and sPLT chunks was added at libpng-1.0.6;
|
||||
however, iTXt support was not enabled by default.
|
||||
|
||||
Starting with version 1.0.7, you can find out which version of the library
|
||||
you are using at run-time:
|
||||
|
||||
@@ -5102,12 +5215,13 @@ We removed the trailing '.' from the warning and error messages.
|
||||
|
||||
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.
|
||||
The incorrect macro was removed from libpng-1.4.5.
|
||||
|
||||
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
|
||||
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, allowed);
|
||||
|
||||
@@ -5134,8 +5248,6 @@ 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
|
||||
members of the main libpng control structures, png_struct and png_info,
|
||||
@@ -5206,7 +5318,10 @@ and the accuracy of PNG fixed point values is insufficient for
|
||||
representation of these values. Consequently a "string" API
|
||||
(png_get_sCAL_s and png_set_sCAL_s) is the only reliable way of reading
|
||||
arbitrary sCAL chunks in the absence of either the floating point API or
|
||||
internal floating point calculations.
|
||||
internal floating point calculations. Starting with libpng-1.5.0, both
|
||||
of these functions are present when PNG_sCAL_SUPPORTED is defined. Prior
|
||||
to libpng-1.5.0, their presence also depended upon PNG_FIXED_POINT_SUPPORTED
|
||||
being defined and PNG_FLOATING_POINT_SUPPORTED not being defined.
|
||||
|
||||
Applications no longer need to include the optional distribution header
|
||||
file pngusr.h or define the corresponding macros during application
|
||||
@@ -5226,11 +5341,6 @@ reset by pngusr.h or by explicit settings on the compiler command line.
|
||||
These settings may produce compiler warnings or errors in 1.5.0 because
|
||||
of macro redefinition.
|
||||
|
||||
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. libpng 1.5.0
|
||||
is consistent with the implementation in 1.4.5 and 1.2.x (where the macro
|
||||
did not exist.)
|
||||
|
||||
Applications can now choose whether to use these macros or to call the
|
||||
corresponding function by defining PNG_USE_READ_MACROS or
|
||||
PNG_NO_USE_READ_MACROS before including png.h. Notice that this is
|
||||
@@ -5248,7 +5358,10 @@ option was off by default, and slightly inaccurate scaling occurred.
|
||||
This option can no longer be turned off, and the choice of accurate
|
||||
or inaccurate 16-to-8 scaling is by using the new png_set_scale_16_to_8()
|
||||
API for accurate scaling or the old png_set_strip_16_to_8() API for simple
|
||||
chopping.
|
||||
chopping. In libpng-1.5.4, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
macro became PNG_READ_SCALE_16_TO_8_SUPPORTED, and the PNG_READ_16_TO_8
|
||||
macro became PNG_READ_STRIP_16_TO_8_SUPPORTED, to enable the two
|
||||
png_set_*_16_to_8() functions separately.
|
||||
|
||||
Prior to libpng-1.5.4, the png_set_user_limits() function could only be
|
||||
used to reduce the width and height limits from the value of
|
||||
@@ -5273,26 +5386,6 @@ limits are now
|
||||
The png_set_option() function (and the "options" member of the png struct) was
|
||||
added to libpng-1.5.15.
|
||||
|
||||
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
|
||||
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
|
||||
to build pnglibconf.h where the corresponding makefile does not do so.
|
||||
|
||||
Building libpng with a non-default configuration has changed completely.
|
||||
The old method using pngusr.h should still work correctly even though the
|
||||
way pngusr.h is used in the build has been changed; however, library
|
||||
builders will probably want to examine the changes to take advantage of
|
||||
new capabilities and to simplify their build system.
|
||||
|
||||
B.1 Specific changes to library configuration capabilities
|
||||
|
||||
The library now supports a complete fixed point implementation and can
|
||||
thus be used on systems that have no floating point support or very
|
||||
limited or slow support. Previously gamma correction, an essential part
|
||||
@@ -5303,27 +5396,7 @@ independent of the choice of fixed versus floating point APIs and all the
|
||||
missing fixed point APIs have been implemented.
|
||||
|
||||
The exact mechanism used to control attributes of API functions has
|
||||
changed. A single set of operating system independent macro definitions
|
||||
is used and operating system specific directives are defined in
|
||||
pnglibconf.h
|
||||
|
||||
As part of this the mechanism used to choose procedure call standards on
|
||||
those systems that allow a choice has been changed. At present this only
|
||||
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
|
||||
running on Intel processors. As before, PNGAPI is defined where required
|
||||
to control the exported API functions; however, two new macros, PNGCBAPI
|
||||
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
|
||||
(PNGCAPI) for functions that must match a C library prototype (currently
|
||||
only png_longjmp_ptr, which must match the C longjmp function.) The new
|
||||
approach is documented in pngconf.h
|
||||
|
||||
Despite these changes, libpng 1.5.0 only supports the native C function
|
||||
calling standard on those platforms tested so far (__cdecl on Microsoft
|
||||
Windows). This is because the support requirements for alternative
|
||||
calling conventions seem to no longer exist. Developers who find it
|
||||
necessary to set PNG_API_RULE to 1 should advise the mailing list
|
||||
(png-mng-implement) of this and library builders who use Openwatcom and
|
||||
therefore set PNG_API_RULE to 2 should also contact the mailing list.
|
||||
changed, as described in the INSTALL file.
|
||||
|
||||
A new test program, pngvalid, is provided in addition to pngtest.
|
||||
pngvalid validates the arithmetic accuracy of the gamma correction
|
||||
@@ -5399,46 +5472,6 @@ even though the default is to use the macros - this allows applications
|
||||
to choose at app buildtime whether or not to use macros (previously
|
||||
impossible because the functions weren't in the default build.)
|
||||
|
||||
B.2 Changes to the configuration mechanism
|
||||
|
||||
Prior to libpng-1.5.0 library builders who needed to configure libpng
|
||||
had either to modify the exported pngconf.h header file to add system
|
||||
specific configuration or had to write feature selection macros into
|
||||
pngusr.h and cause this to be included into pngconf.h by defining
|
||||
PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
|
||||
application built without PNG_USER_CONFIG defined would see the
|
||||
unmodified, default, libpng API and thus would probably fail to link.
|
||||
|
||||
These mechanisms still work in the configure build and in any makefile
|
||||
build that builds pnglibconf.h, although the feature selection macros
|
||||
have changed somewhat as described above. In 1.5.0, however, pngusr.h is
|
||||
processed only once, when the exported header file pnglibconf.h is built.
|
||||
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
|
||||
copied to pnglibconf.h and this may produce macro redefinition warnings
|
||||
when the individual C files are compiled.
|
||||
|
||||
All configuration now only works if pnglibconf.h is built from
|
||||
scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
|
||||
(the original author of awk) maintains C source code of that awk and this
|
||||
and all known later implementations (often called by subtly different
|
||||
names - nawk and gawk for example) are adequate to build pnglibconf.h.
|
||||
The Sun Microsystems (now Oracle) program 'awk' is an earlier version
|
||||
and does not work; this may also apply to other systems that have a
|
||||
functioning awk called 'nawk'.
|
||||
|
||||
Configuration options are now documented in scripts/pnglibconf.dfa. This
|
||||
file also includes dependency information that ensures a configuration is
|
||||
consistent; that is, if a feature is switched off dependent features are
|
||||
also removed. As a recommended alternative to using feature macros in
|
||||
pngusr.h a system builder may also define equivalent options in pngusr.dfa
|
||||
(or, indeed, any file) and add that to the configuration by setting
|
||||
DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
|
||||
how to do this, and a case where pngusr.h is still required.
|
||||
|
||||
.SH XII. Changes to Libpng from version 1.5.x to 1.6.x
|
||||
|
||||
A "simplified API" has been added (see documentation in png.h and a simple
|
||||
@@ -5474,7 +5507,6 @@ 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()
|
||||
@@ -5496,19 +5528,38 @@ 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.
|
||||
profiles that were previously accepted are now accepted with a warning or
|
||||
rejected, depending upon the png_set_benign_errors() setting, in particular the
|
||||
very old broken Microsoft/HP 3144-byte sRGB profile. Starting with
|
||||
libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by
|
||||
means of
|
||||
|
||||
#if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \
|
||||
defined(PNG_SET_OPTION_SUPPORTED)
|
||||
png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE,
|
||||
PNG_OPTION_ON);
|
||||
#endif
|
||||
|
||||
It's not a good idea to do this if you are using the "simplified API",
|
||||
which needs to be able to recognize an sRGB profile conveyed via the iCCP
|
||||
chunk.
|
||||
|
||||
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
|
||||
and is interpreted by libpng to convey a one-tracer-curve gray profile or a
|
||||
three-tracer-curve RGB profile as appropriate.
|
||||
|
||||
|
||||
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().
|
||||
transform after it calls png_read_update_info() or if it attempts to call
|
||||
both png_read_update_info() and png_start_read_image() or to call either
|
||||
of them more than once.
|
||||
|
||||
The default condition for benign_errors is now to treat benign errors as
|
||||
warnings while reading and as errors while writing.
|
||||
@@ -5529,19 +5580,20 @@ 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), by using
|
||||
Libpng-1.6.0 through 1.6.2 used 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 caused
|
||||
zlib to issue the "invalid distance too far back" error and reject the file.
|
||||
Libpng-1.6.3 and later calculate their own safe CMF from the image dimensions,
|
||||
provide a way to revert to the libpng-1.5.x behavior (ignoring the CMF bytes
|
||||
and using a 32-kbyte sliding window), by using
|
||||
|
||||
png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW,
|
||||
PNG_OPTION_ON);
|
||||
|
||||
and provides a tool (contrib/tools/pngfix) for optimizing the CMF bytes
|
||||
correctly.
|
||||
and provide a tool (contrib/tools/pngfix) for rewriting a PNG file while
|
||||
optimizing the CMF bytes in its IDAT chunk 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
|
||||
@@ -5616,7 +5668,8 @@ mailing list, or directly to glennrp.
|
||||
|
||||
.SH XVI. Coding style
|
||||
|
||||
Our coding style is similar to the "Allman" style, with curly
|
||||
Our coding style is similar to the "Allman" style
|
||||
(See http://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
|
||||
braces on separate lines:
|
||||
|
||||
if (condition)
|
||||
@@ -5679,6 +5732,9 @@ exported functions are marked with PNGAPI:
|
||||
body;
|
||||
}
|
||||
|
||||
The return type and decorations are placed on a separate line
|
||||
ahead of the function name, as illustrated above.
|
||||
|
||||
The prototypes for all exported functions appear in png.h,
|
||||
above the comment that says
|
||||
|
||||
@@ -5693,12 +5749,15 @@ We mark all non-exported functions with "/* PRIVATE */"":
|
||||
}
|
||||
|
||||
The prototypes for non-exported functions (except for those in
|
||||
pngtest) appear in
|
||||
pngpriv.h
|
||||
above the comment that says
|
||||
pngtest) appear in pngpriv.h above the comment that says
|
||||
|
||||
/* Maintainer: Put new private prototypes here ^ */
|
||||
|
||||
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
|
||||
use libpng *not* begin any of their own symbols with either of these strings.
|
||||
|
||||
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
|
||||
@@ -5710,10 +5769,8 @@ sizeof operator, with its argument, in parentheses:
|
||||
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
|
||||
use libpng *not* begin any of their own symbols with either of these strings.
|
||||
Control keywords if, for, while, and switch are always followed by a space
|
||||
to distinguish them from function calls, which have no trailing space.
|
||||
|
||||
We put a space after each comma and after each semicolon
|
||||
in "for" statements, and we put spaces before and after each
|
||||
@@ -5726,7 +5783,8 @@ left parenthesis that follows it:
|
||||
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.
|
||||
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).
|
||||
@@ -5734,6 +5792,9 @@ 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 prefer "if (something != 0)" and "if (something == 0)"
|
||||
over "if (something)" and if "(!something)", respectively.
|
||||
|
||||
We do not use the TAB character for indentation in the C sources.
|
||||
|
||||
Lines do not exceed 80 characters.
|
||||
@@ -5742,13 +5803,13 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
.SH XVII. Y2K Compliance in libpng
|
||||
|
||||
September 16, 2013
|
||||
November 7, 2014
|
||||
|
||||
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.7.0beta18 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.7.0beta41 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
|
||||
@@ -5955,7 +6016,7 @@ the first widely used release:
|
||||
1.5.7 15 10507 15.so.15.7[.0]
|
||||
1.6.0beta01-37 16 10600 16.so.16.0[.0]
|
||||
1.7.0alpha01-10 17 10700 17.so.17.0[.0]
|
||||
1.7.0beta01-18 17 10700 17.so.17.0[.0]
|
||||
1.7.0beta01-41 17 10700 17.so.17.0[.0]
|
||||
|
||||
Henceforth the source version will match the shared-library minor
|
||||
and patch numbers; the shared-library major version number will be
|
||||
@@ -6012,7 +6073,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.7.0beta18 - September 16, 2013:
|
||||
Libpng version 1.7.0beta41 - November 7, 2014:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
||||
|
||||
@@ -6035,7 +6096,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.7.0beta18, September 16, 2013, are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.7.0beta41, November 7, 2014, are
|
||||
Copyright (c) 2004,2006-2007 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
|
||||
@@ -6134,7 +6195,7 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
September 16, 2013
|
||||
November 7, 2014
|
||||
|
||||
.\" end of man page
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 "September 16, 2013"
|
||||
.TH LIBPNGPF 3 "November 7, 2014"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta18
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta41
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
|
||||
2
png.5
2
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "September 16, 2013"
|
||||
.TH PNG 5 "November 7, 2014"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
||||
140
png.h
140
png.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.7.0beta18 - September 16, 2013
|
||||
* libpng version 1.7.0beta41 - November 7, 2014
|
||||
* 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.7.0beta18 - September 16, 2013: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.7.0beta41 - November 7, 2014: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
@@ -168,7 +168,7 @@
|
||||
* 1.5.7 15 10507 15.so.15.7[.0]
|
||||
* 1.6.0beta01-37 16 10600 16.so.16.0[.0]
|
||||
* 1.7.0alpha01-10 17 10700 17.so.17.0[.0]
|
||||
* 1.7.0beta01-18 17 10700 17.so.17.0[.0]
|
||||
* 1.7.0beta01-41 17 10700 17.so.17.0[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
@@ -200,7 +200,7 @@
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.7.0beta18, September 16, 2013, are
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.7.0beta41, November 7, 2014, 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:
|
||||
@@ -312,13 +312,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* September 16, 2013
|
||||
* November 7, 2014
|
||||
*
|
||||
* 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.7.0beta18 are Y2K compliant. It is my belief that
|
||||
* upward through 1.7.0beta41 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
|
||||
@@ -371,16 +371,18 @@
|
||||
/* This is not the place to learn how to use libpng. The file libpng-manual.txt
|
||||
* describes how to use libpng, and the file example.c summarizes it
|
||||
* with some code on which to build. This file is useful for looking
|
||||
* at the actual function definitions and structure components.
|
||||
* at the actual function definitions and structure components. If that
|
||||
* file has been stripped from your copy of libpng, you can find it at
|
||||
* <http://www.libpng.org/pub/png/libpng-manual.txt>
|
||||
*
|
||||
* If you just need to read a PNG file and don't want to read the documentation
|
||||
* skip to the end of this file and read the section entitled 'simplified API'.
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.7.0beta18"
|
||||
#define PNG_LIBPNG_VER_STRING "1.7.0beta41"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.7.0beta18 - September 16, 2013\n"
|
||||
" libpng version 1.7.0beta41 - November 7, 2014\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 17
|
||||
#define PNG_LIBPNG_VER_DLLNUM 17
|
||||
@@ -394,7 +396,7 @@
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
*/
|
||||
|
||||
#define PNG_LIBPNG_VER_BUILD 18
|
||||
#define PNG_LIBPNG_VER_BUILD 41
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@@ -543,6 +545,10 @@
|
||||
*
|
||||
* In 1.7.0 the definitions were made public in png.h to avoid having to
|
||||
* duplicate the same definitions in application code.
|
||||
*
|
||||
* SOURCE: http://www.libpng.org/pub/png/spec/register/
|
||||
* "Register of PNG Public Chunks and Keywords, version 1.4.6"
|
||||
* "Extensions to the PNG Specification, version 1.4.0"
|
||||
*/
|
||||
#define png_IDAT PNG_U32( 73, 68, 65, 84)
|
||||
#define png_IEND PNG_U32( 73, 69, 78, 68)
|
||||
@@ -550,6 +556,7 @@
|
||||
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
||||
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
||||
#define png_dSIG PNG_U32(100, 83, 73, 71) /* separate spec */
|
||||
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
|
||||
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
||||
#define png_gIFg PNG_U32(103, 73, 70, 103)
|
||||
@@ -640,7 +647,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_7_0beta18;
|
||||
typedef char* png_libpng_version_1_7_0beta41;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
@@ -822,7 +829,8 @@ typedef png_time * png_timep;
|
||||
typedef const png_time * png_const_timep;
|
||||
typedef png_time * * png_timepp;
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\
|
||||
defined(PNG_USER_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
|
||||
@@ -1295,9 +1303,9 @@ PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
/* How the alpha channel is interpreted - this affects how the color channels of
|
||||
* a PNG file are returned when an alpha channel, or tRNS chunk in a palette
|
||||
* file, is present.
|
||||
/* How the alpha channel is interpreted - this affects how the color channels
|
||||
* of a PNG file are returned to the calling application when an alpha channel,
|
||||
* or a tRNS chunk in a palette file, is present.
|
||||
*
|
||||
* This has no effect on the way pixels are written into a PNG output
|
||||
* datastream. The color samples in a PNG datastream are never premultiplied
|
||||
@@ -1305,33 +1313,19 @@ PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
|
||||
*
|
||||
* The default is to return data according to the PNG specification: the alpha
|
||||
* channel is a linear measure of the contribution of the pixel to the
|
||||
* corresponding composited pixel. The gamma encoded color channels must be
|
||||
* scaled according to the contribution and to do this it is necessary to undo
|
||||
* corresponding composited pixel, and the color channels are unassociated
|
||||
* (not premultiplied). The gamma encoded color channels must be scaled
|
||||
* according to the contribution and to do this it is necessary to undo
|
||||
* the encoding, scale the color values, perform the composition and reencode
|
||||
* the values. This is the 'PNG' mode.
|
||||
*
|
||||
* The alternative is to 'associate' the alpha with the color information by
|
||||
* storing color channel values that have been scaled by the alpha. The
|
||||
* advantage is that the color channels can be resampled (the image can be
|
||||
* scaled) in this form. The disadvantage is that normal practice is to store
|
||||
* linear, not (gamma) encoded, values and this requires 16-bit channels for
|
||||
* still images rather than the 8-bit channels that are just about sufficient if
|
||||
* gamma encoding is used. In addition all non-transparent pixel values,
|
||||
* including completely opaque ones, must be gamma encoded to produce the final
|
||||
* image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the
|
||||
* latter being the two common names for associated alpha color channels.)
|
||||
* storing color channel values that have been scaled by the alpha.
|
||||
* image. These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes
|
||||
* (the latter being the two common names for associated alpha color channels).
|
||||
*
|
||||
* Since it is not necessary to perform arithmetic on opaque color values so
|
||||
* long as they are not to be resampled and are in the final color space it is
|
||||
* possible to optimize the handling of alpha by storing the opaque pixels in
|
||||
* the PNG format (adjusted for the output color space) while storing partially
|
||||
* opaque pixels in the standard, linear, format. The accuracy required for
|
||||
* standard alpha composition is relatively low, because the pixels are
|
||||
* isolated, therefore typically the accuracy loss in storing 8-bit linear
|
||||
* values is acceptable. (This is not true if the alpha channel is used to
|
||||
* simulate transparency over large areas - use 16 bits or the PNG mode in
|
||||
* this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is
|
||||
* treated as opaque only if the alpha value is equal to the maximum value.
|
||||
* For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha
|
||||
* value is equal to the maximum value.
|
||||
*
|
||||
* The final choice is to gamma encode the alpha channel as well. This is
|
||||
* broken because, in practice, no implementation that uses this choice
|
||||
@@ -1358,68 +1352,7 @@ PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,
|
||||
|
||||
#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
|
||||
* computer display system; for example 2.2 for an sRGB conformant system. The
|
||||
* values are scaled by 100000 in the _fixed version of the API (so 220000 for
|
||||
* sRGB.)
|
||||
*
|
||||
* The inverse of the value is always used to provide a default for the PNG file
|
||||
* encoding if it has no gAMA chunk and if png_set_gamma() has not been called
|
||||
* to override the PNG gamma information.
|
||||
*
|
||||
* When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode
|
||||
* opaque pixels however pixels with lower alpha values are not encoded,
|
||||
* regardless of the output gamma setting.
|
||||
*
|
||||
* When the standard Porter Duff handling is requested with mode 1 the output
|
||||
* encoding is set to be linear and the output_gamma value is only relevant
|
||||
* as a default for input data that has no gamma information. The linear output
|
||||
* encoding will be overridden if png_set_gamma() is called - the results may be
|
||||
* highly unexpected!
|
||||
*
|
||||
* The following numbers are derived from the sRGB standard and the research
|
||||
* behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of
|
||||
* 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing
|
||||
* correction required to take account of any differences in the color
|
||||
* environment of the original scene and the intended display environment; the
|
||||
* value expresses how to *decode* the image for display, not how the original
|
||||
* data was *encoded*.
|
||||
*
|
||||
* sRGB provides a peg for the PNG standard by defining a viewing environment.
|
||||
* sRGB itself, and earlier TV standards, actually use a more complex transform
|
||||
* (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is
|
||||
* limited to simple power laws.) By saying that an image for direct display on
|
||||
* an sRGB conformant system should be stored with a gAMA chunk value of 45455
|
||||
* (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification
|
||||
* makes it possible to derive values for other display systems and
|
||||
* environments.
|
||||
*
|
||||
* The Mac value is deduced from the sRGB based on an assumption that the actual
|
||||
* extra viewing correction used in early Mac display systems was implemented as
|
||||
* a power 1.45 lookup table.
|
||||
*
|
||||
* Any system where a programmable lookup table is used or where the behavior of
|
||||
* the final display device characteristics can be changed requires system
|
||||
* specific code to obtain the current characteristic. However this can be
|
||||
* difficult and most PNG gamma correction only requires an approximate value.
|
||||
*
|
||||
* By default, if png_set_alpha_mode() is not called, libpng assumes that all
|
||||
* values are unencoded, linear, values and that the output device also has a
|
||||
* linear characteristic. This is only very rarely correct - it is invariably
|
||||
* better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the
|
||||
* default if you don't know what the right answer is!
|
||||
*
|
||||
* The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS
|
||||
* 10.6) which used a correction table to implement a somewhat lower gamma on an
|
||||
* otherwise sRGB system.
|
||||
*
|
||||
* Both these values are reserved (not simple gamma values) in order to allow
|
||||
* more precise correction internally in the future.
|
||||
*
|
||||
* NOTE: the following values can be passed to either the fixed or floating
|
||||
* point APIs, but the floating point API will also accept floating point
|
||||
* values.
|
||||
* how to decode the output values, not how they are encoded.
|
||||
*/
|
||||
#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */
|
||||
#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */
|
||||
@@ -2094,6 +2027,8 @@ PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,
|
||||
#else
|
||||
/* Fatal error in PNG image of libpng - can't continue */
|
||||
PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);
|
||||
# define png_error(s1,s2) png_err(s1)
|
||||
# define png_chunk_error(s1,s2) png_err(s1)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
@@ -2104,6 +2039,9 @@ PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,
|
||||
/* Non-fatal error in libpng, chunk name is prepended to message. */
|
||||
PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#else
|
||||
# define png_warning(s1,s2) ((void)(s1))
|
||||
# define png_chunk_warning(s1,s2) ((void)(s1))
|
||||
#endif
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
@@ -2614,11 +2552,15 @@ PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||
/* The "params" pointer is currently not used and is for future expansion. */
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,
|
||||
int transforms, png_voidp params));
|
||||
#endif
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,
|
||||
int transforms, png_voidp params));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
PNG_EXPORT(180, png_const_charp, png_get_copyright,
|
||||
(png_const_structrp png_ptr));
|
||||
|
||||
46
pngconf.h
46
pngconf.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.7.0beta18 - September 16, 2013
|
||||
* libpng version 1.7.0beta41 - November 7, 2014
|
||||
*
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -360,7 +360,32 @@
|
||||
* version 1.2.41. Disabling these removes the warnings but may also produce
|
||||
* less efficient code.
|
||||
*/
|
||||
# if defined(__GNUC__)
|
||||
# if defined(__clang__) && defined(__has_attribute)
|
||||
/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
|
||||
# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
|
||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||
# endif
|
||||
# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)
|
||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# if !defined(PNG_PRIVATE)
|
||||
# ifdef __has_extension
|
||||
# if __has_extension(attribute_unavailable_with_message)
|
||||
# define PNG_PRIVATE __attribute__((__unavailable__(\
|
||||
"This function is not exported by libpng.")))
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# elif defined(__GNUC__)
|
||||
# ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||
# endif
|
||||
@@ -383,12 +408,12 @@
|
||||
__attribute__((__deprecated__))
|
||||
# endif
|
||||
# endif
|
||||
# if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
|
||||
# if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif /* __GNUC__ == 3.0 */
|
||||
# endif /* __GNUC__ >= 3 */
|
||||
# endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */
|
||||
# endif /* __GNUC__ >= 3 */
|
||||
|
||||
# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# ifndef PNG_USE_RESULT
|
||||
@@ -418,7 +443,7 @@
|
||||
# ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT __restrict
|
||||
# endif
|
||||
# endif /* _MSC_VER */
|
||||
# endif
|
||||
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||
|
||||
#ifndef PNG_DEPRECATED
|
||||
@@ -439,6 +464,15 @@
|
||||
#ifndef PNG_RESTRICT
|
||||
# define PNG_RESTRICT /* The C99 "restrict" feature */
|
||||
#endif
|
||||
|
||||
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||
PNG_EXPORT(ordinal, type, name, args);
|
||||
# else /* No floating point APIs */
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||
|
||||
21
pngdebug.h
21
pngdebug.h
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||
*
|
||||
* 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.8 [December 19, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -25,7 +25,7 @@
|
||||
* (actually ((void)0)).
|
||||
*
|
||||
* level: level of detail of message, starting at 0. A level 'n'
|
||||
* message is preceded by 'n' tab characters (not implemented
|
||||
* message is preceded by 'n' 3-space indentations (not implemented
|
||||
* on Microsoft compilers unless PNG_DEBUG_FILE is also
|
||||
* defined, to allow debug DLL compilation with no standard IO).
|
||||
* message: a printf(3) style text string. A trailing '\n' is added
|
||||
@@ -77,32 +77,29 @@
|
||||
# endif /* PNG_DEBUG_FILE */
|
||||
|
||||
# if (PNG_DEBUG > 1)
|
||||
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
|
||||
* non-ISO compilers
|
||||
*/
|
||||
# ifdef __STDC__
|
||||
# ifndef png_debug
|
||||
# define png_debug(l,m) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
|
||||
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug1
|
||||
# define png_debug1(l,m,p1) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
|
||||
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug2
|
||||
# define png_debug2(l,m,p1,p2) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
|
||||
fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
|
||||
(num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
|
||||
} while (0)
|
||||
# endif
|
||||
# else /* __STDC __ */
|
||||
|
||||
106
pngerror.c
106
pngerror.c
@@ -2,7 +2,7 @@
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -27,7 +27,7 @@ static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
* should not be changed. If there is a need to handle errors differently,
|
||||
@@ -43,8 +43,8 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
char msg[16];
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
if ((png_ptr->flags &
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0
|
||||
{
|
||||
if (*error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
if (error_message[offset] == ' ')
|
||||
break;
|
||||
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < offset - 1; i++)
|
||||
@@ -69,7 +69,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
|
||||
else
|
||||
{
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
{
|
||||
msg[0] = '0';
|
||||
msg[1] = '\0';
|
||||
@@ -103,7 +103,7 @@ png_err,(png_const_structrp png_ptr),PNG_NORETURN)
|
||||
use the default handler, which will not return. */
|
||||
png_default_error(png_ptr, "");
|
||||
}
|
||||
#endif /* PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* ERROR_TEXT */
|
||||
|
||||
/* Utility to safely appends strings to a buffer. This never errors out so
|
||||
* error checking is not required in the caller.
|
||||
@@ -152,7 +152,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_fixed:
|
||||
/* Needs five digits (the fraction) */
|
||||
mincount = 5;
|
||||
if (output || number % 10 != 0)
|
||||
if (output != 0 || number % 10 != 0)
|
||||
{
|
||||
*--end = digits[number % 10];
|
||||
output = 1;
|
||||
@@ -163,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02u:
|
||||
/* Expects at least 2 digits. */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_u:
|
||||
*--end = digits[number % 10];
|
||||
@@ -173,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02x:
|
||||
/* This format expects at least two digits */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
/* FALL THROUGH */
|
||||
|
||||
case PNG_NUMBER_FORMAT_x:
|
||||
*--end = digits[number & 0xf];
|
||||
@@ -189,13 +189,13 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
++count;
|
||||
|
||||
/* Float a fixed number here: */
|
||||
if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
|
||||
if ((format == PNG_NUMBER_FORMAT_fixed) && (count == 5) && (end > start))
|
||||
{
|
||||
/* End of the fraction, but maybe nothing was output? In that case
|
||||
* drop the decimal point. If the number is a true zero handle that
|
||||
* here.
|
||||
*/
|
||||
if (output)
|
||||
if (output != 0)
|
||||
*--end = '.';
|
||||
else if (number == 0) /* and !output */
|
||||
*--end = '0';
|
||||
@@ -219,8 +219,8 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
if ((png_ptr->flags &
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
|
||||
#endif
|
||||
{
|
||||
if (*warning_message == PNG_LITERAL_SHARP)
|
||||
@@ -355,13 +355,13 @@ png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||
*/
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
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) != 0)
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
@@ -382,24 +382,36 @@ png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
# endif
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN)
|
||||
if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(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)
|
||||
if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
#endif /* BENIGN_ERRORS */
|
||||
|
||||
@@ -416,7 +428,8 @@ static PNG_CONST char png_digit[16] = {
|
||||
};
|
||||
|
||||
#define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || \
|
||||
(defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED))
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
error_message)
|
||||
@@ -429,7 +442,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
int c = (int)(chunk_name >> ishift) & 0xff;
|
||||
|
||||
ishift -= 8;
|
||||
if (isnonalpha(c))
|
||||
if (isnonalpha(c) != 0)
|
||||
{
|
||||
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||
@@ -460,7 +473,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
buffer[iout] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* WARNINGS || ERROR_TEXT */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
@@ -477,7 +490,7 @@ png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* READ && ERROR_TEXT */
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void PNGAPI
|
||||
@@ -493,7 +506,7 @@ png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
@@ -501,23 +514,31 @@ void PNGAPI
|
||||
png_chunk_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) != 0)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
|
||||
else
|
||||
png_chunk_error(png_ptr, error_message);
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(error_message)
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
{
|
||||
# ifndef PNG_WARNINGS_SUPPORTED
|
||||
PNG_UNUSED(message)
|
||||
# endif
|
||||
|
||||
/* 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)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
@@ -531,7 +552,7 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
# endif
|
||||
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
else if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
else if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
@@ -562,11 +583,12 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
memcpy(msg, fixed_message, fixed_message_ln);
|
||||
iin = 0;
|
||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
msg[fixed_message_ln + iin] = name[iin];
|
||||
++iin;
|
||||
}
|
||||
if (name != NULL)
|
||||
while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
msg[fixed_message_ln + iin] = name[iin];
|
||||
++iin;
|
||||
}
|
||||
msg[fixed_message_ln + iin] = 0;
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
@@ -742,8 +764,12 @@ PNG_FUNCTION(void,PNGAPI
|
||||
png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
if (png_ptr && png_ptr->longjmp_fn && png_ptr->jmp_buf_ptr)
|
||||
if (png_ptr != NULL && png_ptr->longjmp_fn != NULL &&
|
||||
png_ptr->jmp_buf_ptr != NULL)
|
||||
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(val)
|
||||
#endif
|
||||
|
||||
/* If control reaches this point, png_longjmp() must not return. The only
|
||||
@@ -808,7 +834,7 @@ png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
#endif
|
||||
PNG_UNUSED(png_ptr) /* Make compiler happy */
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
#endif /* WARNINGS */
|
||||
|
||||
/* This function is called when the application wants to use another method
|
||||
* of handling errors and warnings. Note that the error function MUST NOT
|
||||
@@ -865,8 +891,8 @@ png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||
* possible to implement without setjmp support just so long as there is some
|
||||
* way to handle the error return here:
|
||||
*/
|
||||
PNG_FUNCTION(void /* PRIVATE */,
|
||||
png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
|
||||
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
@@ -901,7 +927,7 @@ png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
}
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
void /* PRIVATE */ PNGCBAPI
|
||||
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
@@ -928,7 +954,7 @@ png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||
saved_error_buf = image->opaque->error_buf;
|
||||
result = setjmp(safe_jmpbuf) == 0;
|
||||
|
||||
if (result)
|
||||
if (result != 0)
|
||||
{
|
||||
|
||||
image->opaque->error_buf = safe_jmpbuf;
|
||||
@@ -938,10 +964,10 @@ png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||
image->opaque->error_buf = saved_error_buf;
|
||||
|
||||
/* And do the cleanup prior to any failure return. */
|
||||
if (!result)
|
||||
if (result == 0)
|
||||
png_image_free(image);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* SIMPLIFIED READ/WRITE */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
144
pngget.c
144
pngget.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -116,7 +116,8 @@ 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))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function",
|
||||
"png_get_x_pixels_per_meter");
|
||||
@@ -124,6 +125,9 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
|
||||
return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
@@ -134,7 +138,8 @@ 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))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function",
|
||||
"png_get_y_pixels_per_meter");
|
||||
@@ -142,6 +147,9 @@ png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
|
||||
return (info_ptr->y_pixels_per_unit);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
@@ -151,7 +159,8 @@ png_uint_32 PNGAPI
|
||||
png_get_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))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
|
||||
|
||||
@@ -159,6 +168,9 @@ png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
|
||||
return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
@@ -170,7 +182,8 @@ 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))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
|
||||
|
||||
@@ -193,10 +206,11 @@ png_get_pixel_aspect_ratio_fixed(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)
|
||||
&& info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0
|
||||
&& info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX
|
||||
&& info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0 &&
|
||||
info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
|
||||
info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX &&
|
||||
info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
|
||||
{
|
||||
png_fixed_point res;
|
||||
|
||||
@@ -206,7 +220,7 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
|
||||
* range of 0..2^31-1; otherwise the cast might overflow.
|
||||
*/
|
||||
if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
|
||||
(png_int_32)info_ptr->x_pixels_per_unit))
|
||||
(png_int_32)info_ptr->x_pixels_per_unit) != 0)
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
@@ -222,13 +236,17 @@ png_int_32 PNGAPI
|
||||
png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
|
||||
|
||||
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
|
||||
return (info_ptr->x_offset);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
@@ -238,13 +256,17 @@ png_int_32 PNGAPI
|
||||
png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
|
||||
|
||||
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
|
||||
return (info_ptr->y_offset);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
@@ -254,13 +276,17 @@ png_int_32 PNGAPI
|
||||
png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
|
||||
|
||||
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
|
||||
return (info_ptr->x_offset);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
@@ -270,13 +296,17 @@ png_int_32 PNGAPI
|
||||
png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
|
||||
|
||||
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
|
||||
return (info_ptr->y_offset);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
@@ -307,7 +337,7 @@ ppi_from_ppm(png_uint_32 ppm)
|
||||
*/
|
||||
png_fixed_point result;
|
||||
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
|
||||
5000))
|
||||
5000) != 0)
|
||||
return result;
|
||||
|
||||
/* Overflow. */
|
||||
@@ -393,7 +423,8 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "pHYs");
|
||||
|
||||
@@ -424,12 +455,12 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
return (retval);
|
||||
}
|
||||
#endif /* PNG_pHYs_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
|
||||
#endif /* pHYs */
|
||||
#endif /* INCH_CONVERSIONS */
|
||||
|
||||
/* png_get_channels really belongs in here, too, but it's been around longer */
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
#endif /* EASY_ACCESS */
|
||||
|
||||
|
||||
png_byte PNGAPI
|
||||
@@ -457,8 +488,9 @@ png_uint_32 PNGAPI
|
||||
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_color_16p *background)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
||||
&& background != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_bKGD) != 0 &&
|
||||
background != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "bKGD");
|
||||
|
||||
@@ -488,7 +520,7 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
* consistent.
|
||||
*/
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
@@ -529,7 +561,7 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
|
||||
|
||||
@@ -577,7 +609,7 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
@@ -614,7 +646,7 @@ 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->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
{
|
||||
if (white_x != NULL)
|
||||
*white_x = info_ptr->colorspace.end_points_xy.whitex;
|
||||
@@ -649,7 +681,7 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_debug1(1, "in %s retrieval function", "gAMA");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = info_ptr->colorspace.gamma;
|
||||
@@ -668,7 +700,7 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_debug1(1, "in %s retrieval function", "gAMA(float)");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
|
||||
@@ -688,8 +720,8 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "sRGB");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||
&& file_srgb_intent != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
|
||||
{
|
||||
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
|
||||
return (PNG_INFO_sRGB);
|
||||
@@ -707,9 +739,10 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "iCCP");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
||||
&& name != NULL && compression_type != NULL && profile != NULL &&
|
||||
proflen != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_iCCP) != 0 &&
|
||||
name != NULL && compression_type != NULL && profile != NULL &&
|
||||
proflen != NULL)
|
||||
{
|
||||
*name = info_ptr->iccp_name;
|
||||
*profile = info_ptr->iccp_profile;
|
||||
@@ -747,8 +780,8 @@ png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "hIST");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
||||
&& hist != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
|
||||
{
|
||||
*hist = info_ptr->hist;
|
||||
return (PNG_INFO_hIST);
|
||||
@@ -803,8 +836,9 @@ png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "oFFs");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
|
||||
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0 &&
|
||||
offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
||||
{
|
||||
*offset_x = info_ptr->x_offset;
|
||||
*offset_y = info_ptr->y_offset;
|
||||
@@ -824,8 +858,9 @@ png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "pCAL");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
|
||||
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pCAL) != 0 &&
|
||||
purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
nparams != NULL && units != NULL && params != NULL)
|
||||
{
|
||||
*purpose = info_ptr->pcal_purpose;
|
||||
@@ -850,7 +885,7 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_fixed_point *width, png_fixed_point *height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
(info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
/*TODO: make this work without FP support; the API is currently eliminated
|
||||
@@ -873,7 +908,7 @@ png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, double *width, double *height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
(info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = atof(info_ptr->scal_s_width);
|
||||
@@ -891,7 +926,7 @@ png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_charpp width, png_charpp height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
(info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = info_ptr->scal_s_width;
|
||||
@@ -913,7 +948,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_debug1(1, "in %s retrieval function", "pHYs");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs))
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
if (res_x != NULL)
|
||||
{
|
||||
@@ -944,8 +979,8 @@ png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "PLTE");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
|
||||
&& palette != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL)
|
||||
{
|
||||
*palette = info_ptr->palette;
|
||||
*num_palette = info_ptr->num_palette;
|
||||
@@ -963,8 +998,8 @@ png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "sBIT");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
|
||||
&& sig_bit != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
|
||||
{
|
||||
*sig_bit = &(info_ptr->sig_bit);
|
||||
return (PNG_INFO_sBIT);
|
||||
@@ -1007,8 +1042,8 @@ png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "tIME");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
|
||||
&& mod_time != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
|
||||
{
|
||||
*mod_time = &(info_ptr->mod_time);
|
||||
return (PNG_INFO_tIME);
|
||||
@@ -1024,7 +1059,8 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_tRNS) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "tRNS");
|
||||
|
||||
@@ -1101,7 +1137,7 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
|
||||
return 0;
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
# endif
|
||||
{
|
||||
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
@@ -1145,7 +1181,7 @@ png_get_chunk_malloc_max (png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
|
||||
}
|
||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||
#endif /* ?SET_USER_LIMITS */
|
||||
|
||||
/* These functions were added to libpng 1.4.0 */
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
@@ -1160,7 +1196,7 @@ png_get_io_chunk_type (png_const_structrp png_ptr)
|
||||
{
|
||||
return png_ptr->chunk_name;
|
||||
}
|
||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||
#endif /* ?IO_STATE */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
@@ -1175,4 +1211,4 @@ png_get_palette_max(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
10
pnginfo.h
10
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
|
||||
@@ -223,13 +223,17 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
|
||||
/* 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;
|
||||
int splt_palettes_num;
|
||||
int splt_palettes_num; /* Match type returned by png_get API */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
|
||||
14
pngmem.c
14
pngmem.c
@@ -2,7 +2,7 @@
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -73,9 +73,10 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
* to implement a user memory handler. This checks to be sure it isn't
|
||||
* called with big numbers.
|
||||
*/
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
|
||||
if (size > 0 && size <= PNG_SIZE_MAX
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
&& size <= 65536U
|
||||
@@ -95,6 +96,8 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
|
||||
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* 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.
|
||||
@@ -165,6 +168,7 @@ png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
|
||||
|
||||
return NULL; /* error */
|
||||
}
|
||||
#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */
|
||||
|
||||
/* 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
|
||||
@@ -221,7 +225,7 @@ png_free(png_const_structrp png_ptr, png_voidp ptr)
|
||||
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
|
||||
|
||||
else
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* USER_MEM */
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
@@ -253,5 +257,5 @@ png_get_mem_ptr(png_const_structrp png_ptr)
|
||||
|
||||
return png_ptr->mem_ptr;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* USER_MEM */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
271
pngpread.c
271
pngpread.c
@@ -2,7 +2,7 @@
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -26,6 +26,13 @@
|
||||
#define PNG_READ_iTXt_MODE 7
|
||||
#define PNG_ERROR_MODE 8
|
||||
|
||||
#define PNG_PUSH_SAVE_BUFFER_IF_FULL \
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size) \
|
||||
{ png_push_save_buffer(png_ptr); return; }
|
||||
#define PNG_PUSH_SAVE_BUFFER_IF_LT(N) \
|
||||
if (png_ptr->buffer_size < N) \
|
||||
{ png_push_save_buffer(png_ptr); return; }
|
||||
|
||||
void PNGAPI
|
||||
png_process_data(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep buffer, png_size_t buffer_size)
|
||||
@@ -46,10 +53,10 @@ png_process_data_pause(png_structrp png_ptr, int save)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* It's easiest for the caller if we do the save, then the caller doesn't
|
||||
/* It's easiest for the caller if we do the save; then the caller doesn't
|
||||
* have to supply the same data again:
|
||||
*/
|
||||
if (save)
|
||||
if (save != 0)
|
||||
png_push_save_buffer(png_ptr);
|
||||
else
|
||||
{
|
||||
@@ -185,27 +192,22 @@ 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
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_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
|
||||
/* 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
|
||||
* chunk data. To fully decode each of these chunks, we also make
|
||||
* sure we have enough data in the buffer for the 4 byte CRC at the
|
||||
* sure we have enough data in the buffer for the 4-byte CRC at the
|
||||
* end of every chunk (except IDAT, which is handled separately).
|
||||
*/
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
||||
if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
png_byte chunk_tag[4];
|
||||
|
||||
if (png_ptr->buffer_size < 8)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(8)
|
||||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
@@ -219,28 +221,29 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
|
||||
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))
|
||||
if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||
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_ptr->mode & PNG_HAVE_PLTE) == 0)
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
||||
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
|
||||
if (png_ptr->push_length == 0)
|
||||
return;
|
||||
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
|
||||
png_benign_error(png_ptr, "Too many IDATs found[p]");
|
||||
}
|
||||
|
||||
if (chunk_name == png_IHDR)
|
||||
@@ -248,52 +251,33 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
if (png_ptr->push_length != 13)
|
||||
png_error(png_ptr, "Invalid IHDR length");
|
||||
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
else if (chunk_name == png_IEND)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
|
||||
|
||||
png_ptr->process_mode = PNG_READ_DONE_MODE;
|
||||
png_push_have_end(png_ptr, info_ptr);
|
||||
}
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);
|
||||
|
||||
if (chunk_name == png_PLTE)
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
else if (chunk_name == png_PLTE)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -312,12 +296,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_gAMA)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -325,12 +304,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_sBIT_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_sBIT)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -338,12 +312,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_cHRM)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -351,12 +320,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
else if (chunk_name == png_sRGB)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -364,12 +328,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_iCCP)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -377,12 +336,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
else if (chunk_name == png_sPLT)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -390,12 +344,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
else if (chunk_name == png_tRNS)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -403,12 +352,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_bKGD_SUPPORTED
|
||||
else if (chunk_name == png_bKGD)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -416,12 +360,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_hIST_SUPPORTED
|
||||
else if (chunk_name == png_hIST)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -429,12 +368,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
else if (chunk_name == png_pHYs)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -442,12 +376,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_oFFs_SUPPORTED
|
||||
else if (chunk_name == png_oFFs)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
@@ -455,12 +384,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_pCAL_SUPPORTED
|
||||
else if (chunk_name == png_pCAL)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -468,12 +392,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_sCAL_SUPPORTED
|
||||
else if (chunk_name == png_sCAL)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -481,12 +400,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_tIME_SUPPORTED
|
||||
else if (chunk_name == png_tIME)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -494,12 +408,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
else if (chunk_name == png_tEXt)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -507,12 +416,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
else if (chunk_name == png_zTXt)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
@@ -520,23 +424,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
else if (chunk_name == png_iTXt)
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
else
|
||||
{
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
}
|
||||
@@ -554,7 +449,7 @@ png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)
|
||||
void /* PRIVATE */
|
||||
png_push_crc_finish(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->skip_length && png_ptr->save_buffer_size)
|
||||
if (png_ptr->skip_length != 0 && png_ptr->save_buffer_size != 0)
|
||||
{
|
||||
png_size_t save_size = png_ptr->save_buffer_size;
|
||||
png_uint_32 skip_length = png_ptr->skip_length;
|
||||
@@ -578,7 +473,7 @@ png_push_crc_finish(png_structrp png_ptr)
|
||||
png_ptr->save_buffer_size -= save_size;
|
||||
png_ptr->save_buffer_ptr += save_size;
|
||||
}
|
||||
if (png_ptr->skip_length && png_ptr->current_buffer_size)
|
||||
if (png_ptr->skip_length != 0 && png_ptr->current_buffer_size != 0)
|
||||
{
|
||||
png_size_t save_size = png_ptr->current_buffer_size;
|
||||
png_uint_32 skip_length = png_ptr->skip_length;
|
||||
@@ -599,14 +494,9 @@ png_push_crc_finish(png_structrp png_ptr)
|
||||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
}
|
||||
if (!png_ptr->skip_length)
|
||||
if (png_ptr->skip_length == 0)
|
||||
{
|
||||
if (png_ptr->buffer_size < 4)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
}
|
||||
@@ -621,7 +511,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
return;
|
||||
|
||||
ptr = buffer;
|
||||
if (png_ptr->save_buffer_size)
|
||||
if (png_ptr->save_buffer_size != 0)
|
||||
{
|
||||
png_size_t save_size;
|
||||
|
||||
@@ -638,7 +528,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
png_ptr->save_buffer_size -= save_size;
|
||||
png_ptr->save_buffer_ptr += save_size;
|
||||
}
|
||||
if (length && png_ptr->current_buffer_size)
|
||||
if (length != 0 && png_ptr->current_buffer_size != 0)
|
||||
{
|
||||
png_size_t save_size;
|
||||
|
||||
@@ -658,7 +548,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||
void /* PRIVATE */
|
||||
png_push_save_buffer(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->save_buffer_size)
|
||||
if (png_ptr->save_buffer_size != 0)
|
||||
{
|
||||
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
|
||||
{
|
||||
@@ -694,11 +584,13 @@ png_push_save_buffer(png_structrp png_ptr)
|
||||
if (png_ptr->save_buffer == NULL)
|
||||
{
|
||||
png_free(png_ptr, old_buffer);
|
||||
old_buffer = NULL;
|
||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||
}
|
||||
|
||||
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
png_free(png_ptr, old_buffer);
|
||||
old_buffer = NULL;
|
||||
png_ptr->save_buffer_max = new_max;
|
||||
}
|
||||
if (png_ptr->current_buffer_size)
|
||||
@@ -725,18 +617,13 @@ png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,
|
||||
void /* PRIVATE */
|
||||
png_push_read_IDAT(png_structrp png_ptr)
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
||||
if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
png_byte chunk_tag[4];
|
||||
|
||||
/* TODO: this code can be commoned up with the same code in push_read */
|
||||
if (png_ptr->buffer_size < 8)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(8)
|
||||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
@@ -748,7 +635,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
{
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
|
||||
if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
|
||||
png_error(png_ptr, "Not enough compressed data");
|
||||
|
||||
return;
|
||||
@@ -757,7 +644,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
png_ptr->idat_size = png_ptr->push_length;
|
||||
}
|
||||
|
||||
if (png_ptr->idat_size && png_ptr->save_buffer_size)
|
||||
if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
|
||||
{
|
||||
png_size_t save_size = png_ptr->save_buffer_size;
|
||||
png_uint_32 idat_size = png_ptr->idat_size;
|
||||
@@ -784,7 +671,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
png_ptr->save_buffer_ptr += save_size;
|
||||
}
|
||||
|
||||
if (png_ptr->idat_size && png_ptr->current_buffer_size)
|
||||
if (png_ptr->idat_size != 0 && png_ptr->current_buffer_size != 0)
|
||||
{
|
||||
png_size_t save_size = png_ptr->current_buffer_size;
|
||||
png_uint_32 idat_size = png_ptr->idat_size;
|
||||
@@ -809,14 +696,9 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
}
|
||||
if (!png_ptr->idat_size)
|
||||
if (png_ptr->idat_size == 0)
|
||||
{
|
||||
if (png_ptr->buffer_size < 4)
|
||||
{
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||
png_crc_finish(png_ptr, 0);
|
||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
@@ -844,7 +726,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||
* or the stream marked as finished.
|
||||
*/
|
||||
while (png_ptr->zstream.avail_in > 0 &&
|
||||
!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -961,7 +843,7 @@ png_push_process_row(png_structrp png_ptr)
|
||||
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
if (png_ptr->transformations)
|
||||
if (png_ptr->transformations != 0)
|
||||
png_do_read_transformations(png_ptr, &row_info);
|
||||
#endif
|
||||
|
||||
@@ -978,15 +860,16 @@ png_push_process_row(png_structrp png_ptr)
|
||||
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* Blow up interlaced rows to full size */
|
||||
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
||||
/* Expand interlaced rows to full size */
|
||||
if (png_ptr->interlaced != 0 &&
|
||||
(png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
{
|
||||
if (png_ptr->pass < 6)
|
||||
png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
|
||||
png_ptr->transformations);
|
||||
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
int i;
|
||||
@@ -1189,7 +1072,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
if (png_ptr->interlaced)
|
||||
if (png_ptr->interlaced != 0)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
@@ -1213,7 +1096,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
png_pass_start[png_ptr->pass]) /
|
||||
png_pass_inc[png_ptr->pass];
|
||||
|
||||
if (png_ptr->transformations & PNG_INTERLACE)
|
||||
if ((png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
break;
|
||||
|
||||
png_ptr->num_rows = (png_ptr->height +
|
||||
@@ -1223,7 +1106,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
||||
|
||||
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
|
||||
}
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
@@ -1261,9 +1144,9 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
|
||||
* it must be png_ptr->row_buf+1
|
||||
*/
|
||||
if (new_row != NULL)
|
||||
png_combine_row(png_ptr, old_row, 1/*display*/);
|
||||
png_combine_row(png_ptr, old_row, 1/*blocky display*/);
|
||||
}
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
void PNGAPI
|
||||
png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,
|
||||
@@ -1288,4 +1171,4 @@ png_get_progressive_ptr(png_const_structrp png_ptr)
|
||||
|
||||
return png_ptr->io_ptr;
|
||||
}
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
196
pngpriv.h
196
pngpriv.h
@@ -2,7 +2,7 @@
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -149,9 +149,15 @@
|
||||
* typically the target FPU. If the FPU has been set to NEON (-mfpu=neon
|
||||
* with GCC) then the compiler will define __ARM_NEON__ and we can rely
|
||||
* unconditionally on NEON instructions not crashing, otherwise we must
|
||||
* disable use of NEON instructions:
|
||||
* disable use of NEON instructions.
|
||||
*
|
||||
* NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they
|
||||
* can only be turned on automatically if that is supported too. If
|
||||
* PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail
|
||||
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
|
||||
* off.
|
||||
*/
|
||||
# ifdef __ARM_NEON__
|
||||
# if defined(__ARM_NEON__) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
# define PNG_ARM_NEON_OPT 2
|
||||
# else
|
||||
# define PNG_ARM_NEON_OPT 0
|
||||
@@ -163,7 +169,49 @@
|
||||
* callbacks to do this.
|
||||
*/
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon
|
||||
#endif
|
||||
|
||||
/* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used
|
||||
* if possible - if __ARM_NEON__ is set and the compiler version is not known
|
||||
* to be broken. This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can
|
||||
* be:
|
||||
*
|
||||
* 1 The intrinsics code (the default with __ARM_NEON__)
|
||||
* 2 The hand coded assembler (the default without __ARM_NEON__)
|
||||
*
|
||||
* It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however
|
||||
* this is *NOT* supported and may cease to work even after a minor revision
|
||||
* to libpng. It *is* valid to do this for testing purposes, e.g. speed
|
||||
* testing or a new compiler, but the results should be communicated to the
|
||||
* libpng implementation list for incorporation in the next minor release.
|
||||
*/
|
||||
# ifndef PNG_ARM_NEON_IMPLEMENTATION
|
||||
# ifdef __ARM_NEON__
|
||||
# if defined(__clang__)
|
||||
/* At present it is unknown by the libpng developers which versions
|
||||
* of clang support the intrinsics, however some or perhaps all
|
||||
* versions do not work with the assembler so this may be
|
||||
* irrelevant, so just use the default (do nothing here.)
|
||||
*/
|
||||
# elif defined(__GNUC__)
|
||||
/* GCC 4.5.4 NEON support is known to be broken. 4.6.3 is known to
|
||||
* work, so if this *is* GCC, or G++, look for a version >4.5
|
||||
*/
|
||||
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 2
|
||||
# endif /* no GNUC support */
|
||||
# endif /* __GNUC__ */
|
||||
# else /* !defined __ARM_NEON__ */
|
||||
/* The 'intrinsics' code simply won't compile without this -mfpu=neon:
|
||||
*/
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 2
|
||||
# endif /* __ARM_NEON__ */
|
||||
# endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */
|
||||
|
||||
# ifndef PNG_ARM_NEON_IMPLEMENTATION
|
||||
/* Use the intrinsics code by default. */
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 1
|
||||
# endif
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
|
||||
/* Is this a build of a DLL where compilation of the object modules requires
|
||||
* different preprocessor settings to those required for a simple library? If
|
||||
@@ -243,6 +291,11 @@
|
||||
extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
|
||||
#endif
|
||||
|
||||
#ifndef PNG_INTERNAL_CALLBACK
|
||||
# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
|
||||
extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)
|
||||
#endif
|
||||
|
||||
/* If floating or fixed point APIs are disabled they may still be compiled
|
||||
* internally. To handle this make sure they are declared as the appropriate
|
||||
* internal extern function (otherwise the symbol prefixing stuff won't work and
|
||||
@@ -376,8 +429,6 @@
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
# define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;
|
||||
#else
|
||||
# define png_warning(s1,s2) ((void)(s1))
|
||||
# define png_chunk_warning(s1,s2) ((void)(s1))
|
||||
# define png_warning_parameter(p,number,string) ((void)0)
|
||||
# define png_warning_parameter_unsigned(p,number,format,value) ((void)0)
|
||||
# define png_warning_parameter_signed(p,number,format,value) ((void)0)
|
||||
@@ -385,8 +436,6 @@
|
||||
# define PNG_WARNING_PARAMETERS(p)
|
||||
#endif
|
||||
#ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
# define png_error(s1,s2) png_err(s1)
|
||||
# define png_chunk_error(s1,s2) png_err(s1)
|
||||
# define png_fixed_error(s1,s2) png_err(s1)
|
||||
#endif
|
||||
|
||||
@@ -949,7 +998,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_WRITE_zTXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp
|
||||
key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY);
|
||||
key, png_const_charp text, int compression),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_iTXt_SUPPORTED
|
||||
@@ -1088,7 +1137,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
/* Finish a row while reading, dealing with interlacing passes, etc. */
|
||||
#endif
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
/* Initialize the row buffers, etc. */
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
|
||||
@@ -1099,32 +1148,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,
|
||||
png_inforp info_ptr),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* These are the functions that do the transformations */
|
||||
#ifdef PNG_READ_FILLER_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_read_filler,(png_row_infop row_info,
|
||||
png_bytep row, png_uint_32 filler, png_uint_32 flags),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_read_swap_alpha,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_write_swap_alpha,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_read_invert_alpha,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_write_invert_alpha,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* Shared transform functions, defined in pngtran.c */
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info,
|
||||
@@ -1144,96 +1168,16 @@ PNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(int,png_do_rgb_to_gray,(png_structrp png_ptr,
|
||||
png_row_infop row_info, png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_gray_to_rgb,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_PACK_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_unpack,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_unshift,(png_row_infop row_info,
|
||||
png_bytep row, png_const_color_8p sig_bits),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_scale_16_to_8,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_chop,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_quantize,(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep palette_lookup,
|
||||
png_const_bytep quantize_lookup),PNG_EMPTY);
|
||||
|
||||
# ifdef PNG_CORRECT_PALETTE_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_correct_palette,(png_structrp png_ptr,
|
||||
png_colorp palette, int num_palette),PNG_EMPTY);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_pack,(png_row_infop row_info,
|
||||
png_bytep row, png_uint_32 bit_depth),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_shift,(png_row_infop row_info,
|
||||
png_bytep row, png_const_color_8p bit_depth),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_compose,(png_row_infop row_info,
|
||||
png_bytep row, png_structrp png_ptr),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_gamma,(png_row_infop row_info,
|
||||
png_bytep row, png_structrp png_ptr),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_encode_alpha,(png_row_infop row_info,
|
||||
png_bytep row, png_structrp png_ptr),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_expand_palette,(png_row_infop row_info,
|
||||
png_bytep row, png_const_colorp palette, png_const_bytep trans,
|
||||
int num_trans),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_expand,(png_row_infop row_info,
|
||||
png_bytep row, png_const_color_16p trans_color),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_expand_16,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* The following decodes the appropriate chunks, and does error correction,
|
||||
* then calls the appropriate callback for the chunk if it is valid.
|
||||
*/
|
||||
@@ -1334,7 +1278,6 @@ PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr,
|
||||
png_uint_32 chunk_name),PNG_EMPTY);
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
|
||||
/* This is the function that gets called for unknown chunks. The 'keep'
|
||||
@@ -1343,14 +1286,14 @@ PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
|
||||
* just skips the chunk or errors out if it is critical.
|
||||
*/
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\
|
||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,
|
||||
(png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY);
|
||||
/* Exactly as the API png_handle_as_unknown() except that the argument is a
|
||||
* 32-bit chunk name, not a string.
|
||||
*/
|
||||
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */
|
||||
|
||||
/* Handle the transformations for reading and writing */
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
@@ -1421,13 +1364,6 @@ PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_read_intrapixel,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_do_write_intrapixel,(png_row_infop row_info,
|
||||
png_bytep row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* Added at libpng version 1.6.0 */
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,
|
||||
@@ -1769,7 +1705,7 @@ PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,
|
||||
png_size_t size),PNG_EMPTY);
|
||||
#endif /* pCAL || sCAL */
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) ||\
|
||||
#if defined(PNG_GAMMA_SUPPORTED) ||\
|
||||
defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
|
||||
/* Added at libpng version 1.5.0 */
|
||||
/* This is a utility to provide a*times/div (rounded) and indicate
|
||||
@@ -1860,11 +1796,11 @@ typedef struct png_control
|
||||
* errors that might occur. Returns true on success, false on failure (either
|
||||
* of the function or as a result of a png_error.)
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(void,png_safe_error,(png_structp png_ptr,
|
||||
PNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr,
|
||||
png_const_charp error_message),PNG_NORETURN);
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_safe_warning,(png_structp png_ptr,
|
||||
PNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr,
|
||||
png_const_charp warning_message),PNG_EMPTY);
|
||||
#else
|
||||
# define png_safe_warning 0/*dummy argument*/
|
||||
|
||||
6
pngrio.c
6
pngrio.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -117,4 +117,4 @@ png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_ptr->output_flush_fn = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
983
pngrtran.c
983
pngrtran.c
File diff suppressed because it is too large
Load Diff
164
pngrutil.c
164
pngrutil.c
@@ -2,7 +2,7 @@
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -59,7 +59,11 @@ png_get_uint_32)(png_const_bytep buf)
|
||||
return PNG_U32(buf[0], buf[1], buf[2], buf[3]);
|
||||
}
|
||||
|
||||
/* Grab a signed 32-bit integer from a buffer in big-endian format. */
|
||||
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
|
||||
* data is stored in the PNG file in two's complement format and there
|
||||
* is no guarantee that a 'png_int_32' is exactly 32 bits, therefore
|
||||
* the following code does a two's complement to native conversion.
|
||||
*/
|
||||
png_int_32 (PNGAPI
|
||||
png_get_int_32)(png_const_bytep buf)
|
||||
{
|
||||
@@ -72,7 +76,7 @@ png_get_uint_16)(png_const_bytep buf)
|
||||
{
|
||||
return PNG_U16(buf[0], buf[1]);
|
||||
}
|
||||
#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */
|
||||
#endif /* READ_INT_FUNCTIONS */
|
||||
|
||||
/* This is an exported function however its error handling is too harsh for most
|
||||
* internal use. For example if it were used for reading the chunk parameters
|
||||
@@ -199,17 +203,14 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
|
||||
if (png_crc_error(png_ptr))
|
||||
{
|
||||
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) ?
|
||||
!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) :
|
||||
(png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))
|
||||
(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0:
|
||||
(png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE) != 0)
|
||||
{
|
||||
png_chunk_warning(png_ptr, "CRC error");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "CRC error");
|
||||
return (0);
|
||||
}
|
||||
png_chunk_error(png_ptr, "CRC error");
|
||||
|
||||
return (1);
|
||||
}
|
||||
@@ -247,7 +248,7 @@ png_crc_error(png_structrp png_ptr)
|
||||
/* The chunk CRC must be serialized in a single I/O call. */
|
||||
png_read_data(png_ptr, crc_bytes, 4);
|
||||
|
||||
if (need_crc)
|
||||
if (need_crc != 0)
|
||||
{
|
||||
crc = png_get_uint_32(crc_bytes);
|
||||
return ((int)(crc != png_ptr->crc));
|
||||
@@ -257,6 +258,10 @@ png_crc_error(png_structrp png_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\
|
||||
defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_sCAL_SUPPORTED) ||\
|
||||
defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) ||\
|
||||
defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_SEQUENTIAL_READ_SUPPORTED)
|
||||
/* Manage the read buffer; this simply reallocates the buffer if it is not small
|
||||
* enough (or if it is not allocated). The routine returns a pointer to the
|
||||
* buffer; if an error occurs and 'warn' is set the routine returns NULL, else
|
||||
@@ -289,21 +294,17 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
|
||||
|
||||
else if (warn < 2) /* else silent */
|
||||
{
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
if (warn)
|
||||
if (warn != 0)
|
||||
png_chunk_warning(png_ptr, "insufficient memory to read chunk");
|
||||
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
png_chunk_error(png_ptr, "insufficient memory to read chunk");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
#endif /* READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */
|
||||
|
||||
/* png_inflate_claim: claim the zstream for some nefarious purpose that involves
|
||||
* decompression. Returns Z_OK on success, else a zlib error code. It checks
|
||||
@@ -500,7 +501,7 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
|
||||
* end of the output buffer.
|
||||
*/
|
||||
ret = inflate(&png_ptr->zstream, avail_out > 0 ? Z_NO_FLUSH :
|
||||
(finish ? Z_FINISH : Z_SYNC_FLUSH));
|
||||
(finish ? Z_FINISH : Z_SYNC_FLUSH));
|
||||
} while (ret == Z_OK);
|
||||
|
||||
/* For safety kill the local buffer pointer now */
|
||||
@@ -619,7 +620,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
{
|
||||
if (new_size == *newlength)
|
||||
{
|
||||
if (terminate)
|
||||
if (terminate != 0)
|
||||
text[prefix_size + *newlength] = 0;
|
||||
|
||||
if (prefix_size > 0)
|
||||
@@ -700,7 +701,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_COMPRESSED_TEXT_SUPPORTED */
|
||||
#endif /* READ_COMPRESSED_TEXT */
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
/* Perform a partial read and decompress, producing 'avail_out' bytes and
|
||||
@@ -960,15 +961,10 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "CRC error");
|
||||
}
|
||||
return;
|
||||
|
||||
else
|
||||
{
|
||||
png_chunk_warning(png_ptr, "CRC error");
|
||||
return;
|
||||
}
|
||||
png_chunk_error(png_ptr, "CRC error");
|
||||
}
|
||||
|
||||
/* Otherwise, we (optionally) emit a warning and use the chunk. */
|
||||
@@ -1000,7 +996,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
*/
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
if (png_ptr->num_trans > 0 ||
|
||||
(info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0))
|
||||
(info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0))
|
||||
{
|
||||
/* Cancel this because otherwise it would be used if the transforms
|
||||
* require it. Don't cancel the 'valid' flag because this would prevent
|
||||
@@ -1086,13 +1082,12 @@ png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
void /* PRIVATE */
|
||||
png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
unsigned int truelen;
|
||||
unsigned int truelen, i;
|
||||
png_byte sample_depth;
|
||||
png_byte buf[4];
|
||||
|
||||
png_debug(1, "in png_handle_sBIT");
|
||||
|
||||
buf[0] = buf[1] = buf[2] = buf[3] = 0;
|
||||
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_chunk_error(png_ptr, "missing IHDR");
|
||||
|
||||
@@ -1111,10 +1106,16 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
}
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
truelen = 3;
|
||||
sample_depth = 8;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
truelen = png_ptr->channels;
|
||||
sample_depth = png_ptr->bit_depth;
|
||||
}
|
||||
|
||||
if (length != truelen || length > 4)
|
||||
{
|
||||
@@ -1123,11 +1124,19 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
return;
|
||||
}
|
||||
|
||||
buf[0] = buf[1] = buf[2] = buf[3] = sample_depth;
|
||||
png_crc_read(png_ptr, buf, truelen);
|
||||
|
||||
if (png_crc_finish(png_ptr, 0))
|
||||
return;
|
||||
|
||||
for (i=0; i<truelen; ++i)
|
||||
if (buf[i] == 0 || buf[i] > sample_depth)
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
png_ptr->sig_bit.red = buf[0];
|
||||
@@ -1269,7 +1278,7 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
(void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);
|
||||
png_colorspace_sync(png_ptr, info_ptr);
|
||||
}
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
#endif /* READ_sRGB */
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
@@ -1295,9 +1304,9 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
* chunk is just ignored, so does not invalidate the color space. An
|
||||
* alternative is to set the 'invalid' flags at the start of this routine
|
||||
* and only clear them in they were not set before and all the tests pass.
|
||||
* The minimum 'deflate' stream is assumed to be just the 2 byte header and 4
|
||||
* byte checksum. The keyword must be one character and there is a
|
||||
* terminator (0) byte and the compression method.
|
||||
* The minimum 'deflate' stream is assumed to be just the 2 byte header and
|
||||
* 4 byte checksum. The keyword must be at least one character and there is
|
||||
* a terminator (0) byte and the compression method.
|
||||
*/
|
||||
if (length < 9)
|
||||
{
|
||||
@@ -1397,7 +1406,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
(sizeof local_buffer), &length,
|
||||
profile + (sizeof profile_header), &size, 0);
|
||||
|
||||
/* Still expect a a buffer error because we expect
|
||||
/* Still expect a buffer error because we expect
|
||||
* there to be some tag data!
|
||||
*/
|
||||
if (size == 0)
|
||||
@@ -1534,7 +1543,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
errmsg = "too many profiles";
|
||||
|
||||
/* Failure: the reason is in 'errmsg' */
|
||||
if (!finished)
|
||||
if (finished == 0)
|
||||
png_crc_finish(png_ptr, length);
|
||||
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
|
||||
@@ -1542,7 +1551,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (errmsg != NULL) /* else already output */
|
||||
png_chunk_benign_error(png_ptr, errmsg);
|
||||
}
|
||||
#endif /* PNG_READ_iCCP_SUPPORTED */
|
||||
#endif /* READ_iCCP */
|
||||
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
@@ -1572,7 +1581,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (--png_ptr->user_chunk_cache_max == 1)
|
||||
{
|
||||
/* Warn the first time */
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
png_crc_finish(png_ptr, length);
|
||||
return;
|
||||
}
|
||||
@@ -1720,7 +1729,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
png_free(png_ptr, new_palette.entries);
|
||||
}
|
||||
#endif /* PNG_READ_sPLT_SUPPORTED */
|
||||
#endif /* READ_sPLT */
|
||||
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
@@ -2362,7 +2371,7 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (--png_ptr->user_chunk_cache_max == 1)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2441,7 +2450,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (--png_ptr->user_chunk_cache_max == 1)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2550,7 +2559,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (--png_ptr->user_chunk_cache_max == 1)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2619,7 +2628,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
/* prefix_length should now be at the trailing '\0' of the translated
|
||||
* keyword, but it may already be over the end. None of this arithmetic
|
||||
* can overflow because chunks are at most 2^31 bytes long, but on 16-bit
|
||||
* systems the available allocaton may overflow.
|
||||
* systems the available allocation may overflow.
|
||||
*/
|
||||
++prefix_length;
|
||||
|
||||
@@ -2651,7 +2660,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
buffer[uncompressed_length+prefix_length] = 0;
|
||||
|
||||
if (compressed)
|
||||
if (compressed == 0)
|
||||
text.compression = PNG_ITXT_COMPRESSION_NONE;
|
||||
|
||||
else
|
||||
@@ -2735,7 +2744,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
#endif /* READ_UNKNOWN_CHUNKS */
|
||||
|
||||
/* Handle an unknown, or known but disabled, chunk */
|
||||
void /* PRIVATE */
|
||||
@@ -2746,6 +2755,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
png_debug(1, "in png_handle_unknown");
|
||||
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* NOTE: this code is based on the code in libpng-1.4.12 except for fixing
|
||||
* the bug which meant that setting a non-default behavior for a specific
|
||||
* chunk would be ignored (the default was always used unless a user
|
||||
@@ -2758,14 +2768,15 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
* function.
|
||||
*/
|
||||
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name);
|
||||
# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* One of the following methods will read the chunk or skip it (at least one
|
||||
* of these is always defined because this is the only way to switch on
|
||||
* PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
*/
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* The user callback takes precedence over the chunk keep value, but the
|
||||
* keep value is still required to validate a save of a critical chunk.
|
||||
@@ -2790,19 +2801,26 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
if (ret < 0)
|
||||
png_chunk_error(png_ptr, "error in user chunk");
|
||||
|
||||
else if (ret > 0) /* chunk was handled */
|
||||
else if (ret == 0)
|
||||
{
|
||||
/* Use the default handling, note that if there is per-chunk
|
||||
* handling specified it has already been set into 'keep'.
|
||||
*
|
||||
* NOTE: this is an API change in 1.7.0. Prior to 1.7.0 libpng
|
||||
* would force keep to PNG_HANDLE_CHUNK_IF_SAFE at this point,
|
||||
* and 1.6.0 would issue a warning if this caused a default of
|
||||
* discarding the chunk to be changed.
|
||||
*/
|
||||
if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
keep = png_ptr->unknown_default;
|
||||
}
|
||||
|
||||
else /* chunk was handled */
|
||||
{
|
||||
handled = 1;
|
||||
/* Critical chunks can be safely discarded at this point. */
|
||||
keep = PNG_HANDLE_CHUNK_NEVER;
|
||||
}
|
||||
|
||||
/* else: use the default handling.
|
||||
* NOTE: this is an API change in 1.7.0, prior to 1.7.0 libpng would
|
||||
* force keep to PNG_HANDLE_CHUNK_IF_SAFE at this point, and 1.6.0
|
||||
* would issue a warning if this caused a default of discarding the
|
||||
* chunk to be changed.
|
||||
*/
|
||||
}
|
||||
|
||||
else
|
||||
@@ -2851,7 +2869,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
png_crc_finish(png_ptr, length);
|
||||
}
|
||||
# endif /* PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
# endif
|
||||
|
||||
# ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Now store the chunk in the chunk list if appropriate, and if the limits
|
||||
@@ -2866,7 +2884,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
case 2:
|
||||
png_ptr->user_chunk_cache_max = 1;
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
/* FALL THROUGH */
|
||||
case 1:
|
||||
/* NOTE: prior to 1.6.0 this case resulted in an unknown critical
|
||||
@@ -2890,9 +2908,8 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
# endif
|
||||
}
|
||||
# else /* no store support! */
|
||||
# else /* no store support: the chunk must be handled by the user callback */
|
||||
PNG_UNUSED(info_ptr)
|
||||
# error untested code (reading unknown chunks with no store support)
|
||||
# endif
|
||||
|
||||
/* Regardless of the error handling below the cached data (if any) can be
|
||||
@@ -2908,7 +2925,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_crc_finish(png_ptr, length);
|
||||
PNG_UNUSED(info_ptr)
|
||||
PNG_UNUSED(keep)
|
||||
#endif /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
#endif /* !READ_UNKNOWN_CHUNKS */
|
||||
|
||||
/* Check for unhandled critical chunks */
|
||||
if (!handled && PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
|
||||
@@ -3109,7 +3126,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
# define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\
|
||||
S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) }
|
||||
|
||||
# define B_MASKS(d,s) { B_MASK(1,d,s), S_MASK(3,d,s), S_MASK(5,d,s) }
|
||||
# define B_MASKS(d,s) { B_MASK(1,d,s), B_MASK(3,d,s), B_MASK(5,d,s) }
|
||||
|
||||
# define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2))
|
||||
|
||||
@@ -3145,10 +3162,10 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
*/
|
||||
# define MASK(pass,depth,display,png)\
|
||||
((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png))
|
||||
#endif /* !PNG_USE_COMPILE_TIME_MASKS */
|
||||
#endif /* !USE_COMPILE_TIME_MASKS */
|
||||
|
||||
/* Use the appropriate mask to copy the required bits. In some cases
|
||||
* the byte mask will be 0 or 0xff, optimize these cases. row_width is
|
||||
* the byte mask will be 0 or 0xff; optimize these cases. row_width is
|
||||
* the number of pixels, but the code copies bytes, so it is necessary
|
||||
* to special case the end.
|
||||
*/
|
||||
@@ -3220,7 +3237,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
}
|
||||
|
||||
/* Work out the bytes to copy. */
|
||||
if (display)
|
||||
if (display != 0)
|
||||
{
|
||||
/* When doing the 'block' algorithm the pixel in the pass gets
|
||||
* replicated to adjacent pixels. This is why the even (0,2,4,6)
|
||||
@@ -3287,7 +3304,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
/* This can only be the RGB case, so each copy is exactly one
|
||||
* pixel and it is not necessary to check for a partial copy.
|
||||
*/
|
||||
for(;;)
|
||||
for (;;)
|
||||
{
|
||||
dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];
|
||||
|
||||
@@ -3396,7 +3413,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_ALIGN_ code */
|
||||
#endif /* ALIGN_ code */
|
||||
|
||||
/* The true default - use a memcpy: */
|
||||
for (;;)
|
||||
@@ -3676,7 +3693,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
PNG_UNUSED(transformations) /* Silence compiler warning */
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
static void
|
||||
png_read_filter_row_sub(png_row_infop row_info, png_bytep row,
|
||||
@@ -3830,7 +3847,6 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
||||
if (pb < pa) pa = pb, a = b;
|
||||
if (pc < pa) a = c;
|
||||
|
||||
c = b;
|
||||
a += *row;
|
||||
*row++ = (png_byte)a;
|
||||
}
|
||||
@@ -4085,7 +4101,7 @@ png_read_finish_row(png_structrp png_ptr)
|
||||
|
||||
/* Offset to next interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
png_debug(1, "in png_read_finish_row");
|
||||
png_ptr->row_number++;
|
||||
@@ -4130,12 +4146,12 @@ png_read_finish_row(png_structrp png_ptr)
|
||||
if (png_ptr->pass < 7)
|
||||
return;
|
||||
}
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
/* Here after at the end of the last row of the last pass. */
|
||||
png_read_finish_IDAT(png_ptr);
|
||||
}
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_read_start_row(png_structrp png_ptr)
|
||||
@@ -4181,7 +4197,7 @@ png_read_start_row(png_structrp png_ptr)
|
||||
}
|
||||
|
||||
else
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
#endif /* READ_INTERLACING */
|
||||
{
|
||||
png_ptr->num_rows = png_ptr->height;
|
||||
png_ptr->iwidth = png_ptr->width;
|
||||
@@ -4431,4 +4447,4 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* READ */
|
||||
|
||||
94
pngset.c
94
pngset.c
@@ -2,7 +2,7 @@
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -59,7 +59,7 @@ png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
xy.whitey = white_y;
|
||||
|
||||
if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy,
|
||||
2/* override with app values*/))
|
||||
2/* override with app values*/) != 0)
|
||||
info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
@@ -90,7 +90,8 @@ png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
XYZ.blue_Y = int_blue_Y;
|
||||
XYZ.blue_Z = int_blue_Z;
|
||||
|
||||
if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace, &XYZ, 2))
|
||||
if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace,
|
||||
&XYZ, 2) != 0)
|
||||
info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
@@ -131,7 +132,7 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
||||
}
|
||||
# endif /* PNG_FLOATING_POINT_SUPPORTED */
|
||||
|
||||
#endif /* PNG_cHRM_SUPPORTED */
|
||||
#endif /* cHRM */
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
void PNGFAPI
|
||||
@@ -227,13 +228,13 @@ png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
info_ptr->channels = 1;
|
||||
|
||||
else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
info_ptr->channels = 3;
|
||||
|
||||
else
|
||||
info_ptr->channels = 1;
|
||||
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
info_ptr->channels++;
|
||||
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
||||
@@ -288,12 +289,14 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
/* Validate params[nparams] */
|
||||
for (i=0; i<nparams; ++i)
|
||||
{
|
||||
if (params[i] == NULL ||
|
||||
!png_check_fp_string(params[i], strlen(params[i])))
|
||||
!png_check_fp_string(params[i], strlen(params[i])))
|
||||
png_error(png_ptr, "Invalid format for pCAL parameter");
|
||||
}
|
||||
|
||||
info_ptr->pcal_purpose = png_voidcast(png_charp,
|
||||
png_malloc_warn(png_ptr, length));
|
||||
png_malloc_warn(png_ptr, length));
|
||||
|
||||
if (info_ptr->pcal_purpose == NULL)
|
||||
{
|
||||
@@ -528,7 +531,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
# endif
|
||||
))
|
||||
{
|
||||
png_chunk_report(png_ptr, "Invalid palette", PNG_CHUNK_ERROR);
|
||||
png_error(png_ptr, "Invalid palette");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -595,7 +598,8 @@ png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent))
|
||||
if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace,
|
||||
srgb_intent) != 0)
|
||||
{
|
||||
/* This causes the gAMA and cHRM to be written too */
|
||||
info_ptr->colorspace.flags |=
|
||||
@@ -638,7 +642,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
|
||||
/* Don't do any of the copying if the profile was bad, or inconsistent. */
|
||||
if (!result)
|
||||
if (result == 0)
|
||||
return;
|
||||
|
||||
/* But do write the gAMA and cHRM chunks from the profile. */
|
||||
@@ -662,6 +666,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (new_iccp_profile == NULL)
|
||||
{
|
||||
png_free(png_ptr, new_iccp_name);
|
||||
new_iccp_name = NULL;
|
||||
png_benign_error(png_ptr,
|
||||
"Insufficient memory to process iCCP profile");
|
||||
return;
|
||||
@@ -687,7 +692,7 @@ png_set_text(png_structrp png_ptr, png_inforp info_ptr,
|
||||
int ret;
|
||||
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
|
||||
|
||||
if (ret)
|
||||
if (ret != 0)
|
||||
png_error(png_ptr, "Insufficient memory to store text");
|
||||
}
|
||||
|
||||
@@ -727,7 +732,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
|
||||
else
|
||||
max_text = INT_MAX;
|
||||
|
||||
/* Now allocate a new array and copy the old members in, this does all
|
||||
/* Now allocate a new array and copy the old members in; this does all
|
||||
* the overflow checks.
|
||||
*/
|
||||
new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
|
||||
@@ -857,7 +862,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
|
||||
textp->text = textp->key + key_len + 1;
|
||||
}
|
||||
|
||||
if (text_length)
|
||||
if (text_length != 0)
|
||||
memcpy(textp->text, text_ptr[i].text, text_length);
|
||||
|
||||
*(textp->text + text_length) = '\0';
|
||||
@@ -892,7 +897,7 @@ png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_debug1(1, "in %s storage function", "tIME");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL ||
|
||||
(png_ptr->mode & PNG_WROTE_tIME))
|
||||
(png_ptr->mode & PNG_WROTE_tIME) != 0)
|
||||
return;
|
||||
|
||||
if (mod_time->month == 0 || mod_time->month > 12 ||
|
||||
@@ -1061,8 +1066,8 @@ png_set_sPLT(png_structrp png_ptr,
|
||||
|
||||
np->depth = entries->depth;
|
||||
|
||||
/* In the even of out-of-memory just return - there's no point keeping on
|
||||
* trying to add sPLT chunks.
|
||||
/* In the event of out-of-memory just return - there's no point keeping
|
||||
* on trying to add sPLT chunks.
|
||||
*/
|
||||
length = strlen(entries->name) + 1;
|
||||
np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));
|
||||
@@ -1073,8 +1078,8 @@ png_set_sPLT(png_structrp png_ptr,
|
||||
memcpy(np->name, entries->name, length);
|
||||
|
||||
/* IMPORTANT: we have memory now that won't get freed if something else
|
||||
* goes wrong, this code must free it. png_malloc_array produces no
|
||||
* warnings, use a png_chunk_report (below) if there is an error.
|
||||
* goes wrong; this code must free it. png_malloc_array produces no
|
||||
* warnings; use a png_chunk_report (below) if there is an error.
|
||||
*/
|
||||
np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr,
|
||||
entries->nentries, sizeof (png_sPLT_entry)));
|
||||
@@ -1082,6 +1087,7 @@ png_set_sPLT(png_structrp png_ptr,
|
||||
if (np->entries == NULL)
|
||||
{
|
||||
png_free(png_ptr, np->name);
|
||||
np->name = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1104,7 +1110,7 @@ png_set_sPLT(png_structrp png_ptr,
|
||||
if (nentries > 0)
|
||||
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
|
||||
}
|
||||
#endif /* PNG_sPLT_SUPPORTED */
|
||||
#endif /* sPLT */
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
static png_byte
|
||||
@@ -1113,10 +1119,10 @@ check_location(png_const_structrp png_ptr, int location)
|
||||
location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT);
|
||||
|
||||
/* New in 1.6.0; copy the location and check it. This is an API
|
||||
* change, previously the app had to use the
|
||||
* change; previously the app had to use the
|
||||
* png_set_unknown_chunk_location API below for each chunk.
|
||||
*/
|
||||
if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
if (location == 0 && (png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
{
|
||||
/* Write struct, so unknown chunks come from the app */
|
||||
png_app_warning(png_ptr,
|
||||
@@ -1162,7 +1168,7 @@ png_set_unknown_chunks(png_structrp png_ptr,
|
||||
*/
|
||||
# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_READ_SUPPORTED)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on read");
|
||||
return;
|
||||
@@ -1170,7 +1176,7 @@ png_set_unknown_chunks(png_structrp png_ptr,
|
||||
# endif
|
||||
# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_WRITE_SUPPORTED)
|
||||
if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on write");
|
||||
return;
|
||||
@@ -1255,7 +1261,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
png_app_error(png_ptr, "invalid unknown chunk location");
|
||||
/* Fake out the pre 1.6.0 behavior: */
|
||||
if ((location & PNG_HAVE_IDAT)) /* undocumented! */
|
||||
if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */
|
||||
location = PNG_AFTER_IDAT;
|
||||
|
||||
else
|
||||
@@ -1297,10 +1303,13 @@ add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)
|
||||
/* Utility function: update the 'keep' state of a chunk if it is already in
|
||||
* the list, otherwise add it to the list.
|
||||
*/
|
||||
for (i=0; i<count; ++i, list += 5) if (memcmp(list, add, 4) == 0)
|
||||
for (i=0; i<count; ++i, list += 5)
|
||||
{
|
||||
list[4] = (png_byte)keep;
|
||||
return count;
|
||||
if (memcmp(list, add, 4) == 0)
|
||||
{
|
||||
list[4] = (png_byte)keep;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
if (keep != PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
@@ -1364,7 +1373,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
};
|
||||
|
||||
chunk_list = chunks_to_ignore;
|
||||
num_chunks = (sizeof chunks_to_ignore)/5;
|
||||
num_chunks = (unsigned int)/*SAFE*/(sizeof chunks_to_ignore)/5U;
|
||||
}
|
||||
|
||||
else /* num_chunks_in > 0 */
|
||||
@@ -1397,7 +1406,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
* required because add_one_chunk above doesn't extend the list if the 'keep'
|
||||
* parameter is the default.
|
||||
*/
|
||||
if (keep)
|
||||
if (keep != 0)
|
||||
{
|
||||
new_list = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
5 * (num_chunks + old_num_chunks)));
|
||||
@@ -1424,12 +1433,15 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
unsigned int i;
|
||||
|
||||
for (i=0; i<num_chunks; ++i)
|
||||
{
|
||||
old_num_chunks = add_one_chunk(new_list, old_num_chunks,
|
||||
chunk_list+5*i, keep);
|
||||
}
|
||||
|
||||
/* Now remove any spurious 'default' entries. */
|
||||
num_chunks = 0;
|
||||
for (i=0, inlist=outlist=new_list; i<old_num_chunks; ++i, inlist += 5)
|
||||
{
|
||||
if (inlist[4])
|
||||
{
|
||||
if (outlist != inlist)
|
||||
@@ -1437,6 +1449,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
outlist += 5;
|
||||
++num_chunks;
|
||||
}
|
||||
}
|
||||
|
||||
/* This means the application has removed all the specialized handling. */
|
||||
if (num_chunks == 0)
|
||||
@@ -1488,12 +1501,13 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
|
||||
if (info_ptr->row_pointers != NULL &&
|
||||
(info_ptr->row_pointers != row_pointers))
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
||||
|
||||
info_ptr->row_pointers = row_pointers;
|
||||
|
||||
if (row_pointers)
|
||||
if (row_pointers != NULL)
|
||||
info_ptr->valid |= PNG_INFO_IDAT;
|
||||
}
|
||||
#endif
|
||||
@@ -1508,7 +1522,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
||||
png_error(png_ptr, "invalid compression buffer size");
|
||||
|
||||
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
{
|
||||
png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */
|
||||
return;
|
||||
@@ -1516,7 +1530,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
{
|
||||
if (png_ptr->zowner != 0)
|
||||
{
|
||||
@@ -1554,7 +1568,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
||||
void PNGAPI
|
||||
png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
|
||||
{
|
||||
if (png_ptr && info_ptr)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
info_ptr->valid &= ~mask;
|
||||
}
|
||||
|
||||
@@ -1592,7 +1606,7 @@ png_set_chunk_malloc_max (png_structrp png_ptr,
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
|
||||
}
|
||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||
#endif /* ?SET_USER_LIMITS */
|
||||
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
@@ -1607,7 +1621,7 @@ png_set_benign_errors(png_structrp png_ptr, int allowed)
|
||||
* is the default behavior if png_set_benign_errors() is not called).
|
||||
*/
|
||||
|
||||
if (allowed)
|
||||
if (allowed != 0)
|
||||
png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN |
|
||||
PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN;
|
||||
|
||||
@@ -1615,14 +1629,14 @@ png_set_benign_errors(png_structrp png_ptr, int allowed)
|
||||
png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN |
|
||||
PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN);
|
||||
}
|
||||
#endif /* PNG_BENIGN_ERRORS_SUPPORTED */
|
||||
#endif /* BENIGN_ERRORS */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Whether to report invalid palette index; added at libng-1.5.10.
|
||||
* It is possible for an indexed (color-type==3) PNG file to contain
|
||||
* pixels with invalid (out-of-range) indexes if the PLTE chunk has
|
||||
* fewer entries than the image's bit-depth would allow. We recover
|
||||
* from this gracefully by filling any incomplete palette with zeroes
|
||||
* from this gracefully by filling any incomplete palette with zeros
|
||||
* (opaque black). By default, when this occurs libpng will issue
|
||||
* a benign error. This API can be used to override that behavior.
|
||||
*/
|
||||
@@ -1638,4 +1652,4 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
|
||||
png_ptr->num_palette_max = -1;
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
|
||||
226
pngtest.c
226
pngtest.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -45,6 +45,11 @@
|
||||
|
||||
/* 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
|
||||
*
|
||||
* pngtest allocates a single row buffer for each row and overwrites it,
|
||||
* therefore if the write side doesn't support the writing of interlaced images
|
||||
* nothing can be done for an interlaced image (and the code below will fail
|
||||
* horribly trying to write extra data after writing garbage).
|
||||
*/
|
||||
#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
|
||||
defined PNG_READ_bKGD_SUPPORTED &&\
|
||||
@@ -58,9 +63,15 @@
|
||||
defined PNG_READ_sRGB_SUPPORTED &&\
|
||||
defined PNG_READ_tEXt_SUPPORTED &&\
|
||||
defined PNG_READ_tIME_SUPPORTED &&\
|
||||
defined PNG_READ_zTXt_SUPPORTED
|
||||
defined PNG_READ_zTXt_SUPPORTED &&\
|
||||
defined PNG_WRITE_INTERLACING_SUPPORTED
|
||||
|
||||
#ifdef PNG_ZLIB_HEADER
|
||||
# include PNG_ZLIB_HEADER /* defined by pnglibconf.h from 1.7 */
|
||||
#else
|
||||
# include "zlib.h"
|
||||
#endif
|
||||
|
||||
#include PNG_ZLIB_HEADER /* defined by pnglibconf.h */
|
||||
/* Copied from pngpriv.h but only used in error messages below. */
|
||||
#ifndef PNG_ZBUF_SIZE
|
||||
# define PNG_ZBUF_SIZE 8192
|
||||
@@ -272,7 +283,8 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
png_uint_32 n, nstop;
|
||||
int channel;
|
||||
int color_channels = row_info->channels;
|
||||
if (row_info->color_type > 3)color_channels--;
|
||||
if (row_info->color_type > 3)
|
||||
color_channels--;
|
||||
|
||||
for (n = 0, nstop=row_info->width; n<nstop; n++)
|
||||
{
|
||||
@@ -299,7 +311,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* WRITE_USER_TRANSFORM */
|
||||
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
/* START of code to validate stdio-free compilation */
|
||||
@@ -348,7 +360,7 @@ pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||
default:
|
||||
err = 1; /* uninitialized */
|
||||
}
|
||||
if (err)
|
||||
if (err != 0)
|
||||
png_error(png_ptr, "Bad I/O state or buffer size");
|
||||
}
|
||||
#endif
|
||||
@@ -408,7 +420,7 @@ 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 */
|
||||
#endif /* !STDIO */
|
||||
|
||||
/* 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
|
||||
@@ -529,7 +541,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
/* Make sure the caller isn't assuming zeroed memory. */
|
||||
memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||
|
||||
if (verbose)
|
||||
if (verbose != 0)
|
||||
printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
|
||||
pinfo->pointer);
|
||||
|
||||
@@ -569,14 +581,15 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
/* We must free the list element too, but first kill
|
||||
the memory that is to be freed. */
|
||||
memset(ptr, 0x55, pinfo->size);
|
||||
png_free_default(png_ptr, pinfo);
|
||||
if (pinfo != NULL)
|
||||
free(pinfo);
|
||||
pinfo = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pinfo->next == NULL)
|
||||
{
|
||||
fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr);
|
||||
fprintf(STDERR, "Pointer %p not found\n", ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -585,13 +598,14 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||
}
|
||||
|
||||
/* Finally free the data. */
|
||||
if (verbose)
|
||||
if (verbose != 0)
|
||||
printf("Freeing %p\n", ptr);
|
||||
|
||||
png_free_default(png_ptr, ptr);
|
||||
if (ptr != NULL)
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */
|
||||
#endif /* USER_MEM && DEBUG */
|
||||
/* END of code to test memory allocation/deallocation */
|
||||
|
||||
|
||||
@@ -630,16 +644,16 @@ set_location(png_structp png_ptr, struct user_chunk_data *data, int what)
|
||||
{
|
||||
int location;
|
||||
|
||||
if ((data->location[0] & what) || (data->location[1] & what))
|
||||
if ((data->location[0] & what) != 0 || (data->location[1] & what) != 0)
|
||||
return 0; /* already have one of these */
|
||||
|
||||
/* Find where we are (the code below zeros info_ptr to indicate that the
|
||||
/* Find where we are (the code below zeroes 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))
|
||||
else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE) != 0)
|
||||
location = what | before_IDAT;
|
||||
|
||||
else
|
||||
@@ -654,8 +668,8 @@ set_location(png_structp png_ptr, struct user_chunk_data *data, int what)
|
||||
return 1; /* handled */
|
||||
}
|
||||
|
||||
static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
png_unknown_chunkp chunk)
|
||||
static int PNGCBAPI
|
||||
read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk)
|
||||
{
|
||||
struct user_chunk_data *my_user_chunk_data =
|
||||
(struct user_chunk_data*)png_get_user_chunk_ptr(png_ptr);
|
||||
@@ -686,7 +700,7 @@ static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
if (chunk->data[0] != 0 && chunk->data[0] != 1)
|
||||
return (-1); /* Invalid mode */
|
||||
|
||||
if (set_location(png_ptr, my_user_chunk_data, have_sTER))
|
||||
if (set_location(png_ptr, my_user_chunk_data, have_sTER) != 0)
|
||||
{
|
||||
my_user_chunk_data->sTER_mode=chunk->data[0];
|
||||
return (1);
|
||||
@@ -705,7 +719,7 @@ static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
if (chunk->size != 9)
|
||||
return (-1); /* Error return */
|
||||
|
||||
if (!set_location(png_ptr, my_user_chunk_data, have_vpAg))
|
||||
if (set_location(png_ptr, my_user_chunk_data, have_vpAg) == 0)
|
||||
return (0); /* duplicate vpAg */
|
||||
|
||||
my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data);
|
||||
@@ -721,7 +735,7 @@ write_sTER_chunk(png_structp write_ptr)
|
||||
{
|
||||
png_byte sTER[5] = {115, 84, 69, 82, '\0'};
|
||||
|
||||
if (verbose)
|
||||
if (verbose != 0)
|
||||
fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode);
|
||||
|
||||
png_write_chunk(write_ptr, sTER, &user_chunk_data.sTER_mode, 1);
|
||||
@@ -734,7 +748,7 @@ write_vpAg_chunk(png_structp write_ptr)
|
||||
|
||||
png_byte vpag_chunk_data[9];
|
||||
|
||||
if (verbose)
|
||||
if (verbose != 0)
|
||||
fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
|
||||
(unsigned long)user_chunk_data.vpAg_width,
|
||||
(unsigned long)user_chunk_data.vpAg_height,
|
||||
@@ -766,7 +780,7 @@ write_chunks(png_structp write_ptr, int location)
|
||||
write_vpAg_chunk(write_ptr);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
#else /* !PNG_READ_USER_CHUNKS_SUPPORTED */
|
||||
# define write_chunks(pp,loc) ((void)0)
|
||||
#endif
|
||||
@@ -824,6 +838,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_structp write_ptr;
|
||||
png_infop write_info_ptr;
|
||||
png_infop write_end_info_ptr;
|
||||
int interlace_preserved = 1;
|
||||
#else
|
||||
png_structp write_ptr = NULL;
|
||||
png_infop write_info_ptr = NULL;
|
||||
@@ -832,7 +847,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_bytep row_buf;
|
||||
png_uint_32 y;
|
||||
png_uint_32 width, height;
|
||||
int num_pass, pass;
|
||||
int num_pass = 1, pass;
|
||||
int bit_depth, color_type;
|
||||
|
||||
row_buf = NULL;
|
||||
@@ -924,7 +939,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (strict)
|
||||
if (strict != 0)
|
||||
{
|
||||
/* Treat png_benign_error() as errors on read */
|
||||
png_set_benign_errors(read_ptr, 0);
|
||||
@@ -940,7 +955,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
*/
|
||||
}
|
||||
|
||||
else if (relaxed)
|
||||
else if (relaxed != 0)
|
||||
{
|
||||
/* Allow application (pngtest) errors and warnings to pass */
|
||||
png_set_benign_errors(read_ptr, 1);
|
||||
@@ -1035,13 +1050,29 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int interlace_type, compression_type, filter_type;
|
||||
|
||||
if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth,
|
||||
&color_type, &interlace_type, &compression_type, &filter_type))
|
||||
&color_type, &interlace_type, &compression_type, &filter_type) != 0)
|
||||
{
|
||||
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
color_type, interlace_type, compression_type, filter_type);
|
||||
#else
|
||||
color_type, PNG_INTERLACE_NONE, compression_type, filter_type);
|
||||
#ifndef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* num_pass will not be set below, set it here if the image is
|
||||
* interlaced: what happens is that write interlacing is *not* turned
|
||||
* on an the partial interlaced rows are written directly.
|
||||
*/
|
||||
switch (interlace_type)
|
||||
{
|
||||
case PNG_INTERLACE_NONE:
|
||||
num_pass = 1;
|
||||
break;
|
||||
|
||||
case PNG_INTERLACE_ADAM7:
|
||||
num_pass = 7;
|
||||
break;
|
||||
|
||||
default:
|
||||
png_error(read_ptr, "invalid interlace type");
|
||||
/*NOT REACHED*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1052,7 +1083,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
blue_y;
|
||||
|
||||
if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y,
|
||||
&red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y))
|
||||
&red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
|
||||
{
|
||||
png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,
|
||||
red_y, green_x, green_y, blue_x, blue_y);
|
||||
@@ -1063,7 +1094,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
png_fixed_point gamma;
|
||||
|
||||
if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))
|
||||
if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma) != 0)
|
||||
png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);
|
||||
}
|
||||
#endif
|
||||
@@ -1075,7 +1106,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
blue_y;
|
||||
|
||||
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
|
||||
&red_y, &green_x, &green_y, &blue_x, &blue_y))
|
||||
&red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
|
||||
{
|
||||
png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
|
||||
red_y, green_x, green_y, blue_x, blue_y);
|
||||
@@ -1086,7 +1117,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
double gamma;
|
||||
|
||||
if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))
|
||||
if (png_get_gAMA(read_ptr, read_info_ptr, &gamma) != 0)
|
||||
png_set_gAMA(write_ptr, write_info_ptr, gamma);
|
||||
}
|
||||
#endif
|
||||
@@ -1100,7 +1131,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int compression_type;
|
||||
|
||||
if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
|
||||
&profile, &proflen))
|
||||
&profile, &proflen) != 0)
|
||||
{
|
||||
png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
|
||||
profile, proflen);
|
||||
@@ -1111,7 +1142,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
int intent;
|
||||
|
||||
if (png_get_sRGB(read_ptr, read_info_ptr, &intent))
|
||||
if (png_get_sRGB(read_ptr, read_info_ptr, &intent) != 0)
|
||||
png_set_sRGB(write_ptr, write_info_ptr, intent);
|
||||
}
|
||||
#endif
|
||||
@@ -1119,14 +1150,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_colorp palette;
|
||||
int num_palette;
|
||||
|
||||
if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))
|
||||
if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette) != 0)
|
||||
png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
|
||||
}
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
{
|
||||
png_color_16p background;
|
||||
|
||||
if (png_get_bKGD(read_ptr, read_info_ptr, &background))
|
||||
if (png_get_bKGD(read_ptr, read_info_ptr, &background) != 0)
|
||||
{
|
||||
png_set_bKGD(write_ptr, write_info_ptr, background);
|
||||
}
|
||||
@@ -1136,7 +1167,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
png_uint_16p hist;
|
||||
|
||||
if (png_get_hIST(read_ptr, read_info_ptr, &hist))
|
||||
if (png_get_hIST(read_ptr, read_info_ptr, &hist) != 0)
|
||||
png_set_hIST(write_ptr, write_info_ptr, hist);
|
||||
}
|
||||
#endif
|
||||
@@ -1146,7 +1177,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int unit_type;
|
||||
|
||||
if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,
|
||||
&unit_type))
|
||||
&unit_type) != 0)
|
||||
{
|
||||
png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);
|
||||
}
|
||||
@@ -1160,7 +1191,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int type, nparams;
|
||||
|
||||
if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
|
||||
&nparams, &units, ¶ms))
|
||||
&nparams, &units, ¶ms) != 0)
|
||||
{
|
||||
png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
|
||||
nparams, units, params);
|
||||
@@ -1172,7 +1203,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_uint_32 res_x, res_y;
|
||||
int unit_type;
|
||||
|
||||
if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type))
|
||||
if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y,
|
||||
&unit_type) != 0)
|
||||
png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);
|
||||
}
|
||||
#endif
|
||||
@@ -1180,7 +1212,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
png_color_8p sig_bit;
|
||||
|
||||
if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit))
|
||||
if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit) != 0)
|
||||
png_set_sBIT(write_ptr, write_info_ptr, sig_bit);
|
||||
}
|
||||
#endif
|
||||
@@ -1192,7 +1224,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
double scal_width, scal_height;
|
||||
|
||||
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
|
||||
&scal_height))
|
||||
&scal_height) != 0)
|
||||
{
|
||||
png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
|
||||
}
|
||||
@@ -1204,7 +1236,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_charp scal_width, scal_height;
|
||||
|
||||
if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
|
||||
&scal_height))
|
||||
&scal_height) != 0)
|
||||
{
|
||||
png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,
|
||||
scal_height);
|
||||
@@ -1224,7 +1256,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
pngtest_check_text_support(read_ptr, text_ptr, num_text);
|
||||
|
||||
if (verbose)
|
||||
if (verbose != 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1244,11 +1276,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
png_timep mod_time;
|
||||
|
||||
if (png_get_tIME(read_ptr, read_info_ptr, &mod_time))
|
||||
if (png_get_tIME(read_ptr, read_info_ptr, &mod_time) != 0)
|
||||
{
|
||||
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))
|
||||
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time) != 0)
|
||||
tIME_string[(sizeof tIME_string) - 1] = '\0';
|
||||
|
||||
else
|
||||
@@ -1258,7 +1290,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#endif /* TIME_RFC1123 */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1269,7 +1301,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_color_16p trans_color;
|
||||
|
||||
if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,
|
||||
&trans_color))
|
||||
&trans_color) != 0)
|
||||
{
|
||||
int sample_max = (1 << bit_depth);
|
||||
/* libpng doesn't reject a tRNS chunk with out-of-range samples */
|
||||
@@ -1290,7 +1322,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr,
|
||||
&unknowns);
|
||||
|
||||
if (num_unknowns)
|
||||
if (num_unknowns != 0)
|
||||
{
|
||||
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
@@ -1334,14 +1366,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif /* SINGLE_ROWBUF_ALLOC */
|
||||
pngtest_debug("Writing row data");
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
num_pass = png_set_interlace_handling(read_ptr);
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
png_set_interlace_handling(write_ptr);
|
||||
# endif
|
||||
#else
|
||||
num_pass = 1;
|
||||
if (png_set_interlace_handling(write_ptr) != num_pass)
|
||||
png_error(write_ptr, "png_set_interlace_handling: inconsistent num_pass");
|
||||
#endif
|
||||
|
||||
#ifdef PNGTEST_TIMING
|
||||
@@ -1356,11 +1384,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
#ifndef SINGLE_ROWBUF_ALLOC
|
||||
pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
|
||||
|
||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
|
||||
pngtest_debug2("\t0x%08lx (%u bytes)", (unsigned long)row_buf,
|
||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
|
||||
(unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
|
||||
#endif /* !SINGLE_ROWBUF_ALLOC */
|
||||
png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
|
||||
@@ -1377,7 +1406,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
t_encode += (t_stop - t_start);
|
||||
t_start = t_stop;
|
||||
#endif
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
#ifndef SINGLE_ROWBUF_ALLOC
|
||||
pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y);
|
||||
@@ -1387,11 +1416,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1);
|
||||
#endif
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1);
|
||||
# endif
|
||||
# ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
pngtest_debug("Reading and writing end_info data");
|
||||
@@ -1408,7 +1439,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
pngtest_check_text_support(read_ptr, text_ptr, num_text);
|
||||
|
||||
if (verbose)
|
||||
if (verbose != 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1428,11 +1459,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
png_timep mod_time;
|
||||
|
||||
if (png_get_tIME(read_ptr, end_info_ptr, &mod_time))
|
||||
if (png_get_tIME(read_ptr, end_info_ptr, &mod_time) != 0)
|
||||
{
|
||||
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))
|
||||
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time) != 0)
|
||||
tIME_string[(sizeof tIME_string) - 1] = '\0';
|
||||
|
||||
else
|
||||
@@ -1442,7 +1473,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
|
||||
tIME_chunk_present++;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#endif /* TIME_RFC1123 */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1452,7 +1483,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr,
|
||||
&unknowns);
|
||||
|
||||
if (num_unknowns)
|
||||
if (num_unknowns != 0)
|
||||
{
|
||||
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
@@ -1493,7 +1524,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
if (verbose)
|
||||
if (verbose != 0)
|
||||
{
|
||||
png_uint_32 iwidth, iheight;
|
||||
iwidth = png_get_image_width(write_ptr, write_info_ptr);
|
||||
@@ -1571,15 +1602,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED /* else nothing was written */
|
||||
if (interlace_preserved != 0) /* else the files will be changed */
|
||||
{
|
||||
int wrote_question = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
static int wrote_question = 0;
|
||||
png_size_t num_in, num_out;
|
||||
char inbuf[256], outbuf[256];
|
||||
|
||||
|
||||
num_in = fread(inbuf, 1, sizeof inbuf, fpin);
|
||||
num_out = fread(outbuf, 1, sizeof outbuf, fpout);
|
||||
|
||||
@@ -1611,7 +1641,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (!num_in)
|
||||
if (num_in == 0)
|
||||
break;
|
||||
|
||||
if (memcmp(inbuf, outbuf, num_in))
|
||||
@@ -1648,7 +1678,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
@@ -1753,10 +1783,11 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (!multiple && argc == 3 + verbose)
|
||||
if (multiple == 0 && argc == 3 + verbose)
|
||||
outname = argv[2 + verbose];
|
||||
|
||||
if ((!multiple && argc > 3 + verbose) || (multiple && argc < 2))
|
||||
if ((multiple == 0 && argc > 3 + verbose) ||
|
||||
(multiple != 0 && argc < 2))
|
||||
{
|
||||
fprintf(STDERR,
|
||||
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
|
||||
@@ -1768,7 +1799,7 @@ main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (multiple)
|
||||
if (multiple != 0)
|
||||
{
|
||||
int i;
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
@@ -1778,6 +1809,9 @@ main(int argc, char *argv[])
|
||||
{
|
||||
int kerror;
|
||||
fprintf(STDERR, "\n Testing %s:", argv[i]);
|
||||
#if PNG_DEBUG > 0
|
||||
fprintf(STDERR, "\n");
|
||||
#endif
|
||||
kerror = test_one_file(argv[i], outname);
|
||||
if (kerror == 0)
|
||||
{
|
||||
@@ -1792,7 +1826,7 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
for (k = 0; k<256; k++)
|
||||
if (filters_used[k])
|
||||
if (filters_used[k] != 0)
|
||||
fprintf(STDERR, " Filter %d was used %lu times\n",
|
||||
k, (unsigned long)filters_used[k]);
|
||||
#endif
|
||||
@@ -1801,7 +1835,7 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR, " tIME = %s\n", tIME_string);
|
||||
|
||||
tIME_chunk_present = 0;
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#endif /* TIME_RFC1123 */
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1823,9 +1857,9 @@ main(int argc, char *argv[])
|
||||
|
||||
while (pinfo != NULL)
|
||||
{
|
||||
fprintf(STDERR, " %lu bytes at %x\n",
|
||||
fprintf(STDERR, " %lu bytes at %p\n",
|
||||
(unsigned long)pinfo->size,
|
||||
(unsigned int)pinfo->pointer);
|
||||
pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
@@ -1859,7 +1893,12 @@ main(int argc, char *argv[])
|
||||
status_dots_requested = 0;
|
||||
|
||||
if (i == 0 || verbose == 1 || ierror != 0)
|
||||
{
|
||||
fprintf(STDERR, "\n Testing %s:", inname);
|
||||
#if PNG_DEBUG > 0
|
||||
fprintf(STDERR, "\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
kerror = test_one_file(inname, outname);
|
||||
|
||||
@@ -1878,21 +1917,26 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
for (k = 0; k<256; k++)
|
||||
if (filters_used[k])
|
||||
if (filters_used[k] != 0)
|
||||
fprintf(STDERR, " Filter %d was used %lu times\n",
|
||||
k, (unsigned long)filters_used[k]);
|
||||
#endif
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
if (tIME_chunk_present != 0)
|
||||
fprintf(STDERR, " tIME = %s\n", tIME_string);
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#endif /* TIME_RFC1123 */
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (verbose == 0 && i != 2)
|
||||
{
|
||||
fprintf(STDERR, "\n Testing %s:", inname);
|
||||
#if PNG_DEBUG > 0
|
||||
fprintf(STDERR, "\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
fprintf(STDERR, " FAIL\n");
|
||||
ierror += kerror;
|
||||
@@ -1911,8 +1955,8 @@ main(int argc, char *argv[])
|
||||
|
||||
while (pinfo != NULL)
|
||||
{
|
||||
fprintf(STDERR, " %lu bytes at %x\n",
|
||||
(unsigned long)pinfo->size, (unsigned int)pinfo->pointer);
|
||||
fprintf(STDERR, " %lu bytes at %p\n",
|
||||
(unsigned long)pinfo->size, pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
@@ -1959,9 +2003,9 @@ main(void)
|
||||
fprintf(STDERR,
|
||||
" test ignored because libpng was not built with read support\n");
|
||||
/* And skip this test */
|
||||
return 77;
|
||||
return PNG_LIBPNG_VER < 10600 ? 0 : 77;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_7_0beta18 Your_png_h_is_not_version_1_7_0beta18;
|
||||
typedef png_libpng_version_1_7_0beta41 Your_png_h_is_not_version_1_7_0beta41;
|
||||
|
||||
41
pngtrans.c
41
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.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -100,7 +100,7 @@ png_set_interlace_handling(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_interlace handling");
|
||||
|
||||
if (png_ptr && png_ptr->interlaced)
|
||||
if (png_ptr != 0 && png_ptr->interlaced != 0)
|
||||
{
|
||||
png_ptr->transformations |= PNG_INTERLACE;
|
||||
return (7);
|
||||
@@ -127,7 +127,7 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
/* 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)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
{
|
||||
# ifdef PNG_READ_FILLER_SUPPORTED
|
||||
/* On read png_set_filler is always valid, regardless of the base PNG
|
||||
@@ -210,7 +210,7 @@ png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
/* The above may fail to do anything. */
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
}
|
||||
|
||||
@@ -327,9 +327,16 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
||||
|
||||
for (i = 0; i < istop; i++, rp += 2)
|
||||
{
|
||||
#ifdef PNG_BUILTIN_BSWAP16_SUPPORTED
|
||||
/* Feature added to libpng-1.6.11 for testing purposes, not
|
||||
* enabled by default.
|
||||
*/
|
||||
*(png_uint_16*)rp = __builtin_bswap16(*(png_uint_16*)rp);
|
||||
#else
|
||||
png_byte t = *rp;
|
||||
*rp = *(rp + 1);
|
||||
*(rp + 1) = t;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -471,7 +478,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
*rp = table[*rp];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */
|
||||
#endif /* READ_PACKSWAP or WRITE_PACKSWAP */
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
@@ -503,7 +510,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 2, ++dp;
|
||||
@@ -517,7 +524,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 4, dp += 2;
|
||||
@@ -543,7 +550,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 4, dp += 3;
|
||||
@@ -557,7 +564,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
if (at_start != 0) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 8, dp += 6;
|
||||
@@ -598,7 +605,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_bgr");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
@@ -668,7 +675,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
#endif /* READ_BGR or WRITE_BGR */
|
||||
|
||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||
@@ -771,7 +778,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
@@ -821,7 +828,7 @@ png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_current_row_number(png_const_structrp png_ptr)
|
||||
{
|
||||
/* See the comments in png.h - this is the sub-image row when reading and
|
||||
/* See the comments in png.h - this is the sub-image row when reading an
|
||||
* interlaced image.
|
||||
*/
|
||||
if (png_ptr != NULL)
|
||||
@@ -837,7 +844,7 @@ png_get_current_pass_number(png_const_structrp png_ptr)
|
||||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
#endif /* USER_TRANSFORM_INFO */
|
||||
#endif /* READ_USER_TRANSFORM ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
#endif /* READ || WRITE */
|
||||
|
||||
10
pngwio.c
10
pngwio.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -149,7 +149,9 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
# else
|
||||
png_ptr->output_flush_fn = output_flush_fn;
|
||||
# endif
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#else
|
||||
PNG_UNUSED(output_flush_fn)
|
||||
#endif /* WRITE_FLUSH */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* It is an error to read while writing a png file */
|
||||
@@ -163,4 +165,4 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
397
pngwrite.c
397
pngwrite.c
@@ -2,7 +2,7 @@
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -24,7 +24,7 @@ static void
|
||||
write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
||||
unsigned int where)
|
||||
{
|
||||
if (info_ptr->unknown_chunks_num)
|
||||
if (info_ptr->unknown_chunks_num != 0)
|
||||
{
|
||||
png_const_unknown_chunkp up;
|
||||
|
||||
@@ -33,7 +33,7 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
||||
for (up = info_ptr->unknown_chunks;
|
||||
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
|
||||
++up)
|
||||
if (up->location & where)
|
||||
if ((up->location & where) != 0)
|
||||
{
|
||||
/* If per-chunk unknown chunk handling is enabled use it, otherwise
|
||||
* just write the chunks the application has set.
|
||||
@@ -69,7 +69,7 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
#endif /* WRITE_UNKNOWN_CHUNKS */
|
||||
|
||||
/* 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,
|
||||
@@ -88,14 +88,14 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
|
||||
if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
|
||||
{
|
||||
/* Write PNG signature */
|
||||
png_write_sig(png_ptr);
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) && \
|
||||
(png_ptr->mng_features_permitted))
|
||||
if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
|
||||
png_ptr->mng_features_permitted != 0)
|
||||
{
|
||||
png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
|
||||
png_ptr->mng_features_permitted = 0;
|
||||
@@ -129,9 +129,9 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
*/
|
||||
#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))
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 &&
|
||||
(info_ptr->valid & PNG_INFO_gAMA) != 0)
|
||||
png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);
|
||||
# endif
|
||||
#endif
|
||||
@@ -141,11 +141,11 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
* 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))
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->valid & PNG_INFO_iCCP) != 0)
|
||||
{
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_sRGB)
|
||||
if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
|
||||
png_app_warning(png_ptr,
|
||||
"profile matches sRGB but writing iCCP instead");
|
||||
# endif
|
||||
@@ -159,22 +159,22 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB))
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB) != 0)
|
||||
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)
|
||||
if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
|
||||
png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
|
||||
#endif
|
||||
|
||||
#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))
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
|
||||
(info_ptr->valid & PNG_INFO_cHRM) != 0)
|
||||
png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
|
||||
# endif
|
||||
#endif
|
||||
@@ -201,19 +201,19 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
|
||||
png_write_info_before_PLTE(png_ptr, info_ptr);
|
||||
|
||||
if (info_ptr->valid & PNG_INFO_PLTE)
|
||||
if ((info_ptr->valid & PNG_INFO_PLTE) != 0)
|
||||
png_write_PLTE(png_ptr, info_ptr->palette,
|
||||
(png_uint_32)info_ptr->num_palette);
|
||||
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
else if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) !=0)
|
||||
png_error(png_ptr, "Valid palette required for paletted images");
|
||||
|
||||
#ifdef PNG_WRITE_tRNS_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_tRNS)
|
||||
if ((info_ptr->valid & PNG_INFO_tRNS) !=0)
|
||||
{
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
/* Invert the alpha channel (in tRNS) */
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int j, jend;
|
||||
@@ -232,42 +232,42 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_WRITE_bKGD_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_bKGD)
|
||||
if ((info_ptr->valid & PNG_INFO_bKGD) != 0)
|
||||
png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_hIST_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_hIST)
|
||||
if ((info_ptr->valid & PNG_INFO_hIST) != 0)
|
||||
png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_oFFs_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
if ((info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset,
|
||||
info_ptr->offset_unit_type);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_pCAL_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_pCAL)
|
||||
if ((info_ptr->valid & PNG_INFO_pCAL) != 0)
|
||||
png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,
|
||||
info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,
|
||||
info_ptr->pcal_units, info_ptr->pcal_params);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_sCAL_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_sCAL)
|
||||
if ((info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
|
||||
info_ptr->scal_s_width, info_ptr->scal_s_height);
|
||||
#endif /* sCAL */
|
||||
|
||||
#ifdef PNG_WRITE_pHYs_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
if ((info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
|
||||
info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);
|
||||
#endif /* pHYs */
|
||||
|
||||
#ifdef PNG_WRITE_tIME_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_tIME)
|
||||
if ((info_ptr->valid & PNG_INFO_tIME) != 0)
|
||||
{
|
||||
png_write_tIME(png_ptr, &(info_ptr->mod_time));
|
||||
png_ptr->mode |= PNG_WROTE_tIME;
|
||||
@@ -275,7 +275,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
#endif /* tIME */
|
||||
|
||||
#ifdef PNG_WRITE_sPLT_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_sPLT)
|
||||
if ((info_ptr->valid & PNG_INFO_sPLT) != 0)
|
||||
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
|
||||
png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
|
||||
#endif /* sPLT */
|
||||
@@ -297,11 +297,14 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
info_ptr->text[i].lang,
|
||||
info_ptr->text[i].lang_key,
|
||||
info_ptr->text[i].text);
|
||||
/* Mark this chunk as written */
|
||||
if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
|
||||
else
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write international text");
|
||||
png_warning(png_ptr, "Unable to write international text");
|
||||
#endif
|
||||
/* Mark this chunk as written */
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
|
||||
}
|
||||
|
||||
/* If we want a compressed text chunk */
|
||||
@@ -310,13 +313,12 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
#ifdef PNG_WRITE_zTXt_SUPPORTED
|
||||
/* Write compressed chunk */
|
||||
png_write_zTXt(png_ptr, info_ptr->text[i].key,
|
||||
info_ptr->text[i].text, 0,
|
||||
info_ptr->text[i].compression);
|
||||
info_ptr->text[i].text, info_ptr->text[i].compression);
|
||||
/* Mark this chunk as written */
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write compressed text");
|
||||
#endif
|
||||
/* Mark this chunk as written */
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
|
||||
}
|
||||
|
||||
else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
|
||||
@@ -354,7 +356,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
|
||||
png_error(png_ptr, "No IDATs written into file");
|
||||
|
||||
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
@@ -370,8 +372,8 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#endif
|
||||
#ifdef PNG_WRITE_tIME_SUPPORTED
|
||||
/* Check to see if user has supplied a time chunk */
|
||||
if ((info_ptr->valid & PNG_INFO_tIME) &&
|
||||
!(png_ptr->mode & PNG_WROTE_tIME))
|
||||
if ((info_ptr->valid & PNG_INFO_tIME) != 0 &&
|
||||
(png_ptr->mode & PNG_WROTE_tIME) == 0)
|
||||
png_write_tIME(png_ptr, &(info_ptr->mod_time));
|
||||
|
||||
#endif
|
||||
@@ -392,11 +394,14 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
info_ptr->text[i].lang,
|
||||
info_ptr->text[i].lang_key,
|
||||
info_ptr->text[i].text);
|
||||
/* Mark this chunk as written */
|
||||
if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
|
||||
else
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write international text");
|
||||
#endif
|
||||
/* Mark this chunk as written */
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
|
||||
}
|
||||
|
||||
else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
|
||||
@@ -404,13 +409,12 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_WRITE_zTXt_SUPPORTED
|
||||
/* Write compressed chunk */
|
||||
png_write_zTXt(png_ptr, info_ptr->text[i].key,
|
||||
info_ptr->text[i].text, 0,
|
||||
info_ptr->text[i].compression);
|
||||
info_ptr->text[i].text, info_ptr->text[i].compression);
|
||||
/* Mark this chunk as written */
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write compressed text");
|
||||
#endif
|
||||
/* Mark this chunk as written */
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
|
||||
}
|
||||
|
||||
else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
|
||||
@@ -419,12 +423,11 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
/* Write uncompressed chunk */
|
||||
png_write_tEXt(png_ptr, info_ptr->text[i].key,
|
||||
info_ptr->text[i].text, 0);
|
||||
/* Mark this chunk as written */
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
|
||||
#else
|
||||
png_warning(png_ptr, "Unable to write uncompressed text");
|
||||
#endif
|
||||
|
||||
/* Mark this chunk as written */
|
||||
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -498,7 +501,7 @@ 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 */
|
||||
#endif /* USER_MEM */
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@@ -523,7 +526,7 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
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 */
|
||||
#endif /* WRITE_COMPRESSED_TEXT */
|
||||
|
||||
/* This is a highly dubious configuration option; by default it is off,
|
||||
* but it may be appropriate for private builds that are testing
|
||||
@@ -613,6 +616,71 @@ png_write_image(png_structrp png_ptr, png_bytepp image)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
/* Performs intrapixel differencing */
|
||||
static void
|
||||
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_intrapixel");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
int bytes_per_pixel;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 3;
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 4;
|
||||
|
||||
else
|
||||
return;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
*(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff);
|
||||
*(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 6;
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 8;
|
||||
|
||||
else
|
||||
return;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
*(rp + 1) = (png_byte)(red & 0xff);
|
||||
*(rp + 4) = (png_byte)((blue >> 8) & 0xff);
|
||||
*(rp + 5) = (png_byte)(blue & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
#endif /* MNG_FEATURES */
|
||||
|
||||
/* Called by user to write a row of image data */
|
||||
void PNGAPI
|
||||
png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
@@ -630,44 +698,44 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
||||
{
|
||||
/* Make sure we wrote the header info */
|
||||
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
|
||||
if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
|
||||
png_error(png_ptr,
|
||||
"png_write_info was never called before png_write_row");
|
||||
|
||||
/* Check for transforms that have been set but were defined out */
|
||||
#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||
png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined");
|
||||
#endif
|
||||
#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
|
||||
defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
png_warning(png_ptr,
|
||||
"PNG_WRITE_PACKSWAP_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||
png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||
png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
@@ -676,12 +744,13 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* If interlaced and not interested in row, return */
|
||||
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
||||
if (png_ptr->interlaced != 0 &&
|
||||
(png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
{
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
case 0:
|
||||
if (png_ptr->row_number & 0x07)
|
||||
if ((png_ptr->row_number & 0x07) != 0)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
@@ -689,7 +758,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
|
||||
if ((png_ptr->row_number & 0x07) != 0 || png_ptr->width < 5)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
@@ -705,7 +774,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if ((png_ptr->row_number & 0x03) || png_ptr->width < 3)
|
||||
if ((png_ptr->row_number & 0x03) != 0 || png_ptr->width < 3)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
@@ -721,7 +790,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if ((png_ptr->row_number & 0x01) || png_ptr->width < 2)
|
||||
if ((png_ptr->row_number & 0x01) != 0 || png_ptr->width < 2)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
@@ -729,7 +798,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
break;
|
||||
|
||||
case 6:
|
||||
if (!(png_ptr->row_number & 0x01))
|
||||
if ((png_ptr->row_number & 0x01) == 0)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
@@ -763,11 +832,11 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* Handle interlacing */
|
||||
if (png_ptr->interlaced && png_ptr->pass < 6 &&
|
||||
(png_ptr->transformations & PNG_INTERLACE))
|
||||
(png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
{
|
||||
png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);
|
||||
/* This should always get caught above, but still ... */
|
||||
if (!(row_info.width))
|
||||
if (row_info.width == 0)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
@@ -777,7 +846,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* Handle other transformations */
|
||||
if (png_ptr->transformations)
|
||||
if (png_ptr->transformations != 0)
|
||||
png_do_write_transformations(png_ptr, &row_info);
|
||||
#endif
|
||||
|
||||
@@ -798,7 +867,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
* 4. The filter_method is 64 and
|
||||
* 5. The color_type is RGB or RGBA
|
||||
*/
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
|
||||
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
{
|
||||
/* Intrapixel differencing */
|
||||
@@ -851,7 +920,7 @@ png_write_flush(png_structrp png_ptr)
|
||||
png_ptr->flush_rows = 0;
|
||||
png_flush(png_ptr);
|
||||
}
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#endif /* WRITE_FLUSH */
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */
|
||||
@@ -864,18 +933,24 @@ png_write_destroy(png_structrp png_ptr)
|
||||
png_debug(1, "in png_write_destroy");
|
||||
|
||||
/* Free any memory zlib uses */
|
||||
if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
||||
deflateEnd(&png_ptr->zstream);
|
||||
|
||||
/* Free our memory. png_free checks NULL for us. */
|
||||
png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
|
||||
png_free(png_ptr, png_ptr->row_buf);
|
||||
png_ptr->row_buf = NULL;
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->prev_row);
|
||||
png_free(png_ptr, png_ptr->sub_row);
|
||||
png_free(png_ptr, png_ptr->up_row);
|
||||
png_free(png_ptr, png_ptr->avg_row);
|
||||
png_free(png_ptr, png_ptr->paeth_row);
|
||||
png_ptr->prev_row = NULL;
|
||||
png_ptr->sub_row = NULL;
|
||||
png_ptr->up_row = NULL;
|
||||
png_ptr->avg_row = NULL;
|
||||
png_ptr->paeth_row = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
@@ -883,10 +958,13 @@ png_write_destroy(png_structrp png_ptr)
|
||||
png_reset_filter_heuristics(png_ptr);
|
||||
png_free(png_ptr, png_ptr->filter_costs);
|
||||
png_free(png_ptr, png_ptr->inv_filter_costs);
|
||||
png_ptr->filter_costs = NULL;
|
||||
png_ptr->inv_filter_costs = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list = NULL;
|
||||
#endif
|
||||
|
||||
/* The error handling and memory handling information is left intact at this
|
||||
@@ -932,7 +1010,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
return;
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
|
||||
(method == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
method = PNG_FILTER_TYPE_BASE;
|
||||
#endif
|
||||
@@ -1165,7 +1243,7 @@ png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
||||
/* The internal API allocates all the arrays and ensures that the elements of
|
||||
* those arrays are set to the default value.
|
||||
*/
|
||||
if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))
|
||||
if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
|
||||
return;
|
||||
|
||||
/* If using the weighted method copy in the weights. */
|
||||
@@ -1220,7 +1298,7 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
|
||||
/* The internal API allocates all the arrays and ensures that the elements of
|
||||
* those arrays are set to the default value.
|
||||
*/
|
||||
if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))
|
||||
if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
|
||||
return;
|
||||
|
||||
/* If using the weighted method copy in the weights. */
|
||||
@@ -1274,7 +1352,7 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
|
||||
}
|
||||
}
|
||||
#endif /* FIXED_POINT */
|
||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_WEIGHTED_FILTER */
|
||||
|
||||
void PNGAPI
|
||||
png_set_compression_level(png_structrp png_ptr, int level)
|
||||
@@ -1431,7 +1509,7 @@ png_set_text_compression_method(png_structrp png_ptr, int method)
|
||||
|
||||
png_ptr->zlib_text_method = method;
|
||||
}
|
||||
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
|
||||
#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
|
||||
/* end of API added to libpng-1.5.4 */
|
||||
|
||||
void PNGAPI
|
||||
@@ -1467,81 +1545,117 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if ((info_ptr->valid & PNG_INFO_IDAT) == 0)
|
||||
{
|
||||
png_app_error(png_ptr, "no rows for png_write_image to write");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Write the file header information. */
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
/* ------ these transformations don't touch the info structure ------- */
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
/* Invert monochrome pixels */
|
||||
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
||||
if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
png_set_invert_mono(png_ptr);
|
||||
#else
|
||||
png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported");
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
/* Shift the pixels up to a legal bit depth and fill in
|
||||
* as appropriate to correctly scale the image.
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_SHIFT)
|
||||
&& (info_ptr->valid & PNG_INFO_sBIT))
|
||||
png_set_shift(png_ptr, &info_ptr->sig_bit);
|
||||
if ((transforms & PNG_TRANSFORM_SHIFT) != 0)
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
|
||||
png_set_shift(png_ptr, &info_ptr->sig_bit);
|
||||
#else
|
||||
png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported");
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
/* Pack pixels into bytes */
|
||||
if (transforms & PNG_TRANSFORM_PACKING)
|
||||
png_set_packing(png_ptr);
|
||||
if ((transforms & PNG_TRANSFORM_PACKING) != 0)
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
png_set_packing(png_ptr);
|
||||
#else
|
||||
png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported");
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
/* Swap location of alpha bytes from ARGB to RGBA */
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
||||
if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0)
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
png_set_swap_alpha(png_ptr);
|
||||
#else
|
||||
png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported");
|
||||
#endif
|
||||
|
||||
/* Remove a filler (X) from XRGB/RGBX/AG/GA into to convert it into
|
||||
* RGB, note that the code expects the input color type to be G or RGB; no
|
||||
* alpha channel.
|
||||
*/
|
||||
if ((transforms & (PNG_TRANSFORM_STRIP_FILLER_AFTER|
|
||||
PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0)
|
||||
{
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
/* Pack XRGB/RGBX/ARGB/RGBA into RGB (4 channels -> 3 channels) */
|
||||
if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
|
||||
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
|
||||
if ((transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) != 0)
|
||||
{
|
||||
if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
|
||||
png_app_error(png_ptr,
|
||||
"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
|
||||
|
||||
else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
|
||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||
/* Continue if ignored - this is the pre-1.6.10 behavior */
|
||||
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
|
||||
}
|
||||
|
||||
else if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
|
||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||
#else
|
||||
png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_FILLER not supported");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
/* Flip BGR pixels to RGB */
|
||||
if (transforms & PNG_TRANSFORM_BGR)
|
||||
if ((transforms & PNG_TRANSFORM_BGR) != 0)
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
png_set_bgr(png_ptr);
|
||||
#else
|
||||
png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported");
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
/* Swap bytes of 16-bit files to most significant byte first */
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
||||
if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0)
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
png_set_swap(png_ptr);
|
||||
#else
|
||||
png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported");
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
/* Swap bits of 1, 2, 4 bit packed pixel formats */
|
||||
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
||||
if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
png_set_packswap(png_ptr);
|
||||
#else
|
||||
png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported");
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
/* Invert the alpha channel from opacity to transparency */
|
||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||
if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0)
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
png_set_invert_alpha(png_ptr);
|
||||
#else
|
||||
png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported");
|
||||
#endif
|
||||
|
||||
/* ----------------------- end of transformations ------------------- */
|
||||
|
||||
/* Write the bits */
|
||||
if (info_ptr->valid & PNG_INFO_IDAT)
|
||||
png_write_image(png_ptr, info_ptr->row_pointers);
|
||||
png_write_image(png_ptr, info_ptr->row_pointers);
|
||||
|
||||
/* It is REQUIRED to call this to finish writing the rest of the file */
|
||||
png_write_end(png_ptr, info_ptr);
|
||||
|
||||
PNG_UNUSED(transforms) /* Quiet compiler warnings */
|
||||
PNG_UNUSED(params)
|
||||
}
|
||||
#endif
|
||||
@@ -1622,16 +1736,18 @@ png_write_image_16bit(png_voidp argument)
|
||||
int aindex = 0;
|
||||
png_uint_32 y = image->height;
|
||||
|
||||
if (image->format & PNG_FORMAT_FLAG_ALPHA)
|
||||
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
{
|
||||
if (image->format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
aindex = -1;
|
||||
++input_row; /* To point to the first component */
|
||||
++output_row;
|
||||
}
|
||||
# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
{
|
||||
aindex = -1;
|
||||
++input_row; /* To point to the first component */
|
||||
++output_row;
|
||||
}
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
aindex = channels;
|
||||
}
|
||||
|
||||
@@ -1775,19 +1891,21 @@ png_write_image_8bit(png_voidp argument)
|
||||
png_uint_32 y = image->height;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
|
||||
|
||||
if (image->format & PNG_FORMAT_FLAG_ALPHA)
|
||||
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
{
|
||||
png_bytep row_end;
|
||||
int aindex;
|
||||
|
||||
if (image->format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
aindex = -1;
|
||||
++input_row; /* To point to the first component */
|
||||
++output_row;
|
||||
}
|
||||
# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
{
|
||||
aindex = -1;
|
||||
++input_row; /* To point to the first component */
|
||||
++output_row;
|
||||
}
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
aindex = channels;
|
||||
|
||||
/* Use row_end in place of a loop counter: */
|
||||
@@ -1867,7 +1985,8 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
const png_uint_32 format = image->format;
|
||||
const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
|
||||
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
# if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
|
||||
defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
|
||||
const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
(format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
# else
|
||||
@@ -1892,13 +2011,13 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
/* This gets automatically converted to sRGB with reversal of the
|
||||
* pre-multiplication if the color-map has an alpha channel.
|
||||
*/
|
||||
if (format & PNG_FORMAT_FLAG_LINEAR)
|
||||
if ((format & PNG_FORMAT_FLAG_LINEAR) != 0)
|
||||
{
|
||||
png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);
|
||||
|
||||
entry += i * channels;
|
||||
|
||||
if (channels & 1) /* no alpha */
|
||||
if ((channels & 1) != 0) /* no alpha */
|
||||
{
|
||||
if (channels >= 3) /* RGB */
|
||||
{
|
||||
@@ -2025,7 +2144,7 @@ png_image_write_main(png_voidp argument)
|
||||
display->row_stride = PNG_IMAGE_ROW_STRIDE(*image);
|
||||
|
||||
/* Set the required transforms then write the rows in the correct order. */
|
||||
if (format & PNG_FORMAT_FLAG_COLORMAP)
|
||||
if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
||||
{
|
||||
if (display->colormap != NULL && image->colormap_entries > 0)
|
||||
{
|
||||
@@ -2057,12 +2176,12 @@ png_image_write_main(png_voidp argument)
|
||||
* write an interlaced image.
|
||||
*/
|
||||
|
||||
if (write_16bit)
|
||||
if (write_16bit != 0)
|
||||
{
|
||||
/* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */
|
||||
png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR);
|
||||
|
||||
if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB))
|
||||
if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr,
|
||||
/* color x y */
|
||||
/* white */ 31270, 32900,
|
||||
@@ -2072,7 +2191,7 @@ png_image_write_main(png_voidp argument)
|
||||
);
|
||||
}
|
||||
|
||||
else if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB))
|
||||
else if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
|
||||
png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL);
|
||||
|
||||
/* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit
|
||||
@@ -2089,16 +2208,16 @@ png_image_write_main(png_voidp argument)
|
||||
*
|
||||
* First check for a little endian system if writing 16 bit files.
|
||||
*/
|
||||
if (write_16bit)
|
||||
if (write_16bit != 0)
|
||||
{
|
||||
PNG_CONST png_uint_16 le = 0x0001;
|
||||
|
||||
if (*(png_const_bytep)&le)
|
||||
if ((*(png_const_bytep) & le) != 0)
|
||||
png_set_swap(png_ptr);
|
||||
}
|
||||
|
||||
# ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
if ((format & PNG_FORMAT_FLAG_BGR) != 0)
|
||||
{
|
||||
if (!colormap && (format & PNG_FORMAT_FLAG_COLOR) != 0)
|
||||
png_set_bgr(png_ptr);
|
||||
@@ -2107,7 +2226,7 @@ png_image_write_main(png_voidp argument)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
{
|
||||
if (!colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
png_set_swap_alpha(png_ptr);
|
||||
@@ -2118,7 +2237,7 @@ png_image_write_main(png_voidp argument)
|
||||
/* If there are 16 or fewer color-map entries we wrote a lower bit depth
|
||||
* above, but the application data is still byte packed.
|
||||
*/
|
||||
if (colormap && image->colormap_entries <= 16)
|
||||
if (colormap != 0 && image->colormap_entries <= 16)
|
||||
png_set_packing(png_ptr);
|
||||
|
||||
/* That should have handled all (both) the transforms. */
|
||||
@@ -2130,7 +2249,7 @@ png_image_write_main(png_voidp argument)
|
||||
png_const_bytep row = png_voidcast(png_const_bytep, display->buffer);
|
||||
ptrdiff_t row_bytes = display->row_stride;
|
||||
|
||||
if (linear)
|
||||
if (linear != 0)
|
||||
row_bytes *= (sizeof (png_uint_16));
|
||||
|
||||
if (row_bytes < 0)
|
||||
@@ -2163,7 +2282,7 @@ png_image_write_main(png_voidp argument)
|
||||
int result;
|
||||
|
||||
display->local_row = row;
|
||||
if (write_16bit)
|
||||
if (write_16bit != 0)
|
||||
result = png_safe_execute(image, png_write_image_16bit, display);
|
||||
else
|
||||
result = png_safe_execute(image, png_write_image_8bit, display);
|
||||
@@ -2172,7 +2291,7 @@ png_image_write_main(png_voidp argument)
|
||||
png_free(png_ptr, row);
|
||||
|
||||
/* Skip the 'write_end' on error: */
|
||||
if (!result)
|
||||
if (result == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2205,7 +2324,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||
{
|
||||
if (file != NULL)
|
||||
{
|
||||
if (png_image_write_init(image))
|
||||
if (png_image_write_init(image) != 0)
|
||||
{
|
||||
png_image_write_control display;
|
||||
int result;
|
||||
@@ -2260,7 +2379,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
||||
if (fp != NULL)
|
||||
{
|
||||
if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer,
|
||||
row_stride, colormap))
|
||||
row_stride, colormap) != 0)
|
||||
{
|
||||
int error; /* from fflush/fclose */
|
||||
|
||||
@@ -2311,6 +2430,6 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* STDIO */
|
||||
#endif /* SIMPLIFIED_WRITE */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
219
pngwtran.c
219
pngwtran.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -14,90 +14,14 @@
|
||||
#include "pngpriv.h"
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_debug(1, "in png_do_write_transformations");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if (png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
function */
|
||||
(png_ptr, /* png_ptr */
|
||||
row_info, /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_size_t rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_pack(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_do_shift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The
|
||||
* row_info bit depth should be 8 (one pixel per byte). The channels
|
||||
* should be 1 (this only happens on grayscale and paletted images).
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_pack");
|
||||
@@ -242,7 +166,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
* would pass 3 as bit_depth, and this routine would translate the
|
||||
* data to 0 to 15.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
png_const_color_8p bit_depth)
|
||||
{
|
||||
@@ -253,7 +177,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
int shift_start[4], shift_dec[4];
|
||||
int channels = 0;
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_COLOR)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->red;
|
||||
shift_dec[channels] = bit_depth->red;
|
||||
@@ -275,7 +199,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
channels++;
|
||||
}
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
|
||||
shift_dec[channels] = bit_depth->alpha;
|
||||
@@ -381,7 +305,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_swap_alpha");
|
||||
@@ -429,7 +353,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
@@ -468,14 +392,14 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
static void
|
||||
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_invert_alpha");
|
||||
@@ -525,7 +449,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
@@ -563,75 +487,88 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
#endif /* WRITE_16BIT */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
/* Undoes intrapixel differencing */
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
||||
png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_debug(1, "in png_do_write_intrapixel");
|
||||
png_debug(1, "in png_do_write_transformations");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
int bytes_per_pixel;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 3;
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
if (png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
function */
|
||||
(png_ptr, /* png_ptr */
|
||||
row_info, /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_size_t rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 4;
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
else
|
||||
return;
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
*(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff);
|
||||
*(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);
|
||||
}
|
||||
}
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||
png_do_pack(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 i;
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
# ifdef PNG_16BIT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 6;
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||
png_do_shift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 8;
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
|
||||
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
else
|
||||
return;
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
*(rp + 1) = (png_byte)(red & 0xff);
|
||||
*(rp + 4) = (png_byte)((blue >> 8) & 0xff);
|
||||
*(rp + 5) = (png_byte)(blue & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE_TRANSFORMS */
|
||||
#endif /* WRITE */
|
||||
|
||||
158
pngwutil.c
158
pngwutil.c
@@ -2,7 +2,7 @@
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
*
|
||||
@@ -136,7 +136,7 @@ png_write_chunk_data(png_structrp png_ptr, png_const_bytep data,
|
||||
png_write_data(png_ptr, data, length);
|
||||
|
||||
/* Update the CRC after writing the data,
|
||||
* in case that the user I/O routine alters it.
|
||||
* in case the user I/O routine alters it.
|
||||
*/
|
||||
png_calculate_crc(png_ptr, data, length);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
|
||||
/* On 64 bit architectures 'length' may not fit in a png_uint_32. */
|
||||
if (length > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "length exceeds PNG maxima");
|
||||
png_error(png_ptr, "length exceeds PNG maximum");
|
||||
|
||||
png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);
|
||||
png_write_chunk_data(png_ptr, data, length);
|
||||
@@ -204,14 +204,14 @@ png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string,
|
||||
static png_alloc_size_t
|
||||
png_image_size(png_structrp png_ptr)
|
||||
{
|
||||
/* Only return sizes up to the maximum of a png_uint_32, do this by limiting
|
||||
/* Only return sizes up to the maximum of a png_uint_32; do this by limiting
|
||||
* the width and height used to 15 bits.
|
||||
*/
|
||||
png_uint_32 h = png_ptr->height;
|
||||
|
||||
if (png_ptr->rowbytes < 32768 && h < 32768)
|
||||
{
|
||||
if (png_ptr->interlaced)
|
||||
if (png_ptr->interlaced != 0)
|
||||
{
|
||||
/* Interlacing makes the image larger because of the replication of
|
||||
* both the filter byte and the padding to a byte boundary.
|
||||
@@ -286,9 +286,7 @@ optimize_cmf(png_bytep data, png_alloc_size_t data_size)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define optimize_cmf(dp,dl) ((void)0)
|
||||
#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
|
||||
#endif /* WRITE_OPTIMIZE_CMF */
|
||||
|
||||
/* Initialize the compressor for the appropriate type of compression. */
|
||||
static int
|
||||
@@ -297,6 +295,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
{
|
||||
if (png_ptr->zowner != 0)
|
||||
{
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
char msg[64];
|
||||
|
||||
PNG_STRING_FROM_CHUNK(msg, owner);
|
||||
@@ -308,7 +307,8 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
* are minimal.
|
||||
*/
|
||||
(void)png_safecat(msg, (sizeof msg), 10, " using zstream");
|
||||
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
#endif
|
||||
#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
png_warning(png_ptr, msg);
|
||||
|
||||
/* Attempt sane error recovery */
|
||||
@@ -319,9 +319,9 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
}
|
||||
|
||||
png_ptr->zowner = 0;
|
||||
# else
|
||||
#else
|
||||
png_error(png_ptr, msg);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
@@ -334,7 +334,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
|
||||
if (owner == png_IDAT)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)
|
||||
if ((png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) != 0)
|
||||
strategy = png_ptr->zlib_strategy;
|
||||
|
||||
else if (png_ptr->do_filter != PNG_FILTER_NONE)
|
||||
@@ -346,20 +346,20 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
|
||||
else
|
||||
{
|
||||
# ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
level = png_ptr->zlib_text_level;
|
||||
method = png_ptr->zlib_text_method;
|
||||
windowBits = png_ptr->zlib_text_window_bits;
|
||||
memLevel = png_ptr->zlib_text_mem_level;
|
||||
strategy = png_ptr->zlib_text_strategy;
|
||||
# else
|
||||
#else
|
||||
/* If customization is not supported the values all come from the
|
||||
* IDAT values except for the strategy, which is fixed to the
|
||||
* default. (This is the pre-1.6.0 behavior too, although it was
|
||||
* implemented in a very different way.)
|
||||
*/
|
||||
strategy = Z_DEFAULT_STRATEGY;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Adjust 'windowBits' down if larger than 'data_size'; to stop this
|
||||
@@ -386,7 +386,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
}
|
||||
|
||||
/* Check against the previous initialized values, if any. */
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) &&
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0 &&
|
||||
(png_ptr->zlib_set_level != level ||
|
||||
png_ptr->zlib_set_method != method ||
|
||||
png_ptr->zlib_set_window_bits != windowBits ||
|
||||
@@ -410,7 +410,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
/* Now initialize if required, setting the new parameters, otherwise just
|
||||
* to a simple reset to the previous parameters.
|
||||
*/
|
||||
if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
||||
ret = deflateReset(&png_ptr->zstream);
|
||||
|
||||
else
|
||||
@@ -492,7 +492,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
int ret;
|
||||
|
||||
/* To find the length of the output it is necessary to first compress the
|
||||
* input, the result is buffered rather than using the two-pass algorithm
|
||||
* input. The result is buffered rather than using the two-pass algorithm
|
||||
* that is used on the inflate side; deflate is assumed to be slower and a
|
||||
* PNG writer is assumed to have more memory available than a PNG reader.
|
||||
*
|
||||
@@ -589,7 +589,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
}
|
||||
while (ret == Z_OK);
|
||||
|
||||
/* There may be some space left in the last output buffer, this needs to
|
||||
/* There may be some space left in the last output buffer. This needs to
|
||||
* be subtracted from output_len.
|
||||
*/
|
||||
output_len -= png_ptr->zstream.avail_out;
|
||||
@@ -612,14 +612,15 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
/* Reset zlib for another zTXt/iTXt or image data */
|
||||
png_ptr->zowner = 0;
|
||||
|
||||
/* The only success case is Z_STREAM_END, input_len must be 0, if not this
|
||||
/* The only success case is Z_STREAM_END, input_len must be 0; if not this
|
||||
* is an internal error.
|
||||
*/
|
||||
if (ret == Z_STREAM_END && input_len == 0)
|
||||
{
|
||||
#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
/* Fix up the deflate header, if required */
|
||||
optimize_cmf(comp->output, comp->input_len);
|
||||
|
||||
#endif
|
||||
/* But Z_OK is returned, not Z_STREAM_END; this allows the claim
|
||||
* function above to return Z_STREAM_END on an error (though it never
|
||||
* does in the current versions of zlib.)
|
||||
@@ -662,7 +663,7 @@ png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp)
|
||||
if (output_len > 0)
|
||||
png_error(png_ptr, "error writing ancillary chunked compressed data");
|
||||
}
|
||||
#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
|
||||
#endif /* WRITE_COMPRESSED_TEXT */
|
||||
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
|
||||
defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
@@ -699,7 +700,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||
if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
|
||||
*new_key++ = ch, ++key_len, space = 0;
|
||||
|
||||
else if (!space)
|
||||
else if (space == 0)
|
||||
{
|
||||
/* A space or an invalid character when one wasn't seen immediately
|
||||
* before; output just a space.
|
||||
@@ -711,14 +712,14 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||
bad_character = ch;
|
||||
}
|
||||
|
||||
else if (!bad_character)
|
||||
else if (bad_character == 0)
|
||||
bad_character = ch; /* just skip it, record the first error */
|
||||
}
|
||||
|
||||
if (key_len > 0 && space) /* trailing space */
|
||||
if (key_len > 0 && space != 0) /* trailing space */
|
||||
{
|
||||
--key_len, --new_key;
|
||||
if (!bad_character)
|
||||
if (bad_character == 0)
|
||||
bad_character = 32;
|
||||
}
|
||||
|
||||
@@ -728,11 +729,12 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||
if (key_len == 0)
|
||||
return 0;
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
/* Try to only output one warning per keyword: */
|
||||
if (*key) /* keyword too long */
|
||||
if (*key != 0) /* keyword too long */
|
||||
png_warning(png_ptr, "keyword truncated");
|
||||
|
||||
else if (bad_character)
|
||||
else if (bad_character != 0)
|
||||
{
|
||||
PNG_WARNING_PARAMETERS(p)
|
||||
|
||||
@@ -741,6 +743,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||
|
||||
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
|
||||
return key_len;
|
||||
}
|
||||
@@ -845,8 +848,8 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
*/
|
||||
if (
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
|
||||
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
|
||||
((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&
|
||||
(color_type == PNG_COLOR_TYPE_RGB ||
|
||||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
|
||||
(filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
|
||||
@@ -898,7 +901,7 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
/* Write the chunk */
|
||||
png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
|
||||
|
||||
if (!(png_ptr->do_filter))
|
||||
if ((png_ptr->do_filter) == PNG_NO_FILTERS)
|
||||
{
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
|
||||
png_ptr->bit_depth < 8)
|
||||
@@ -927,7 +930,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
|
||||
|
||||
if ((
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
|
||||
(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 &&
|
||||
#endif
|
||||
num_pal == 0) || num_pal > 256)
|
||||
{
|
||||
@@ -943,7 +946,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
|
||||
}
|
||||
}
|
||||
|
||||
if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring request to write a PLTE chunk in grayscale PNG");
|
||||
@@ -998,7 +1001,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
|
||||
* Z_FINISH: this is the end of the input, do a Z_FINISH and clean up
|
||||
*
|
||||
* The routine manages the acquire and release of the png_ptr->zstream by
|
||||
* checking and (at the end) clearing png_ptr->zowner, it does some sanity
|
||||
* checking and (at the end) clearing png_ptr->zowner; it does some sanity
|
||||
* checks on the 'mode' flags while doing this.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
@@ -1058,7 +1061,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
||||
input_len += png_ptr->zstream.avail_in;
|
||||
png_ptr->zstream.avail_in = 0;
|
||||
|
||||
/* OUTPUT: write complete IDAT chunks when avail_out drops to zero, note
|
||||
/* OUTPUT: write complete IDAT chunks when avail_out drops to zero. Note
|
||||
* that these two zstream fields are preserved across the calls, therefore
|
||||
* there is no need to set these up on entry to the loop.
|
||||
*/
|
||||
@@ -1070,11 +1073,11 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
||||
/* Write an IDAT containing the data then reset the buffer. The
|
||||
* first IDAT may need deflate header optimization.
|
||||
*/
|
||||
# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT) &&
|
||||
png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
|
||||
#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
|
||||
png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
|
||||
optimize_cmf(data, png_image_size(png_ptr));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
@@ -1090,7 +1093,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* The order of these checks doesn't matter much; it just effect which
|
||||
/* The order of these checks doesn't matter much; it just affects which
|
||||
* possible error might be detected if multiple things go wrong at once.
|
||||
*/
|
||||
if (ret == Z_OK) /* most likely return code! */
|
||||
@@ -1116,11 +1119,11 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
||||
png_bytep data = png_ptr->zbuffer_list->output;
|
||||
uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out;
|
||||
|
||||
# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT) &&
|
||||
png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
|
||||
optimize_cmf(data, png_image_size(png_ptr));
|
||||
# endif
|
||||
#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
|
||||
png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
|
||||
optimize_cmf(data, png_image_size(png_ptr));
|
||||
#endif
|
||||
|
||||
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
||||
png_ptr->zstream.avail_out = 0;
|
||||
@@ -1339,7 +1342,7 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)
|
||||
png_debug(1, "in png_write_sBIT");
|
||||
|
||||
/* Make sure we don't depend upon the order of PNG_COLOR_8 */
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
png_byte maxbits;
|
||||
|
||||
@@ -1372,7 +1375,7 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)
|
||||
size = 1;
|
||||
}
|
||||
|
||||
if (color_type & PNG_COLOR_MASK_ALPHA)
|
||||
if ((color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
{
|
||||
if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth)
|
||||
{
|
||||
@@ -1461,9 +1464,9 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
||||
png_save_uint_16(buf + 2, tran->green);
|
||||
png_save_uint_16(buf + 4, tran->blue);
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
|
||||
#else
|
||||
if (buf[0] | buf[2] | buf[4])
|
||||
if ((buf[0] | buf[2] | buf[4]) != 0)
|
||||
#endif
|
||||
{
|
||||
/* Also checked in png_set_tRNS */
|
||||
@@ -1496,8 +1499,8 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
|
||||
{
|
||||
if (
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
(png_ptr->num_palette ||
|
||||
(!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&
|
||||
(png_ptr->num_palette != 0 ||
|
||||
(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0) &&
|
||||
#endif
|
||||
back->index >= png_ptr->num_palette)
|
||||
{
|
||||
@@ -1509,15 +1512,15 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
|
||||
png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
|
||||
}
|
||||
|
||||
else if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
else if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
png_save_uint_16(buf, back->red);
|
||||
png_save_uint_16(buf + 2, back->green);
|
||||
png_save_uint_16(buf + 4, back->blue);
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
|
||||
#else
|
||||
if (buf[0] | buf[2] | buf[4])
|
||||
if ((buf[0] | buf[2] | buf[4]) != 0)
|
||||
#endif
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
@@ -1612,7 +1615,7 @@ png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
|
||||
*/
|
||||
png_write_chunk_data(png_ptr, new_key, key_len + 1);
|
||||
|
||||
if (text_len)
|
||||
if (text_len != 0)
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len);
|
||||
|
||||
png_write_chunk_end(png_ptr);
|
||||
@@ -1623,14 +1626,13 @@ png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
|
||||
/* Write a compressed text chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
|
||||
png_size_t text_len, int compression)
|
||||
int compression)
|
||||
{
|
||||
png_uint_32 key_len;
|
||||
png_byte new_key[81];
|
||||
compression_state comp;
|
||||
|
||||
png_debug(1, "in png_write_zTXt");
|
||||
PNG_UNUSED(text_len) /* Always use strlen */
|
||||
|
||||
if (compression == PNG_TEXT_COMPRESSION_NONE)
|
||||
{
|
||||
@@ -1738,7 +1740,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
|
||||
|
||||
png_text_compress_init(&comp, (png_const_bytep)text, strlen(text));
|
||||
|
||||
if (compression)
|
||||
if (compression != 0)
|
||||
{
|
||||
if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK)
|
||||
png_error(png_ptr, png_ptr->zstream.msg);
|
||||
@@ -1761,7 +1763,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
|
||||
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len);
|
||||
|
||||
if (compression)
|
||||
if (compression != 0)
|
||||
png_write_compressed_data_out(png_ptr, &comp);
|
||||
|
||||
else
|
||||
@@ -1977,7 +1979,7 @@ png_write_alloc_filter_row_buffers(png_structrp png_ptr, int filters)
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
|
||||
/* Initializes the row writing capability of libpng */
|
||||
void /* PRIVATE */
|
||||
@@ -2038,7 +2040,7 @@ png_write_start_row(png_structrp png_ptr)
|
||||
/* We only need to keep the previous row if we are using one of the following
|
||||
* filters.
|
||||
*/
|
||||
if (filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
|
||||
if ((filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0)
|
||||
png_ptr->prev_row = png_voidcast(png_bytep, png_calloc(png_ptr,
|
||||
buf_size));
|
||||
|
||||
@@ -2047,13 +2049,13 @@ png_write_start_row(png_structrp png_ptr)
|
||||
png_ptr->do_filter = (png_byte)filters; /* in case it was changed above */
|
||||
#else
|
||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* If interlaced, we need to set up width and height of pass */
|
||||
if (png_ptr->interlaced)
|
||||
if (png_ptr->interlaced != 0)
|
||||
{
|
||||
if (!(png_ptr->transformations & PNG_INTERLACE))
|
||||
if ((png_ptr->transformations & PNG_INTERLACE) == 0)
|
||||
{
|
||||
png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
|
||||
png_pass_ystart[0]) / png_pass_yinc[0];
|
||||
@@ -2108,10 +2110,10 @@ png_write_finish_row(png_structrp png_ptr)
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* If interlaced, go to next pass */
|
||||
if (png_ptr->interlaced)
|
||||
if (png_ptr->interlaced != 0)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
if (png_ptr->transformations & PNG_INTERLACE)
|
||||
if ((png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
{
|
||||
png_ptr->pass++;
|
||||
}
|
||||
@@ -2136,7 +2138,7 @@ png_write_finish_row(png_structrp png_ptr)
|
||||
png_pass_ystart[png_ptr->pass]) /
|
||||
png_pass_yinc[png_ptr->pass];
|
||||
|
||||
if (png_ptr->transformations & PNG_INTERLACE)
|
||||
if ((png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
break;
|
||||
|
||||
} while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0);
|
||||
@@ -2414,7 +2416,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
/* We don't need to test the 'no filter' case if this is the only filter
|
||||
* that has been chosen, as it doesn't actually do anything to the data.
|
||||
*/
|
||||
if ((filter_to_do & PNG_FILTER_NONE) && filter_to_do != PNG_FILTER_NONE)
|
||||
if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 sum = 0;
|
||||
@@ -2490,7 +2492,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
best_row = png_ptr->sub_row;
|
||||
}
|
||||
|
||||
else if (filter_to_do & PNG_FILTER_SUB)
|
||||
else if ((filter_to_do & PNG_FILTER_SUB) != 0)
|
||||
{
|
||||
png_bytep rp, dp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
@@ -2611,7 +2613,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
best_row = png_ptr->up_row;
|
||||
}
|
||||
|
||||
else if (filter_to_do & PNG_FILTER_UP)
|
||||
else if ((filter_to_do & PNG_FILTER_UP) != 0)
|
||||
{
|
||||
png_bytep rp, dp, pp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
@@ -2725,7 +2727,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
best_row = png_ptr->avg_row;
|
||||
}
|
||||
|
||||
else if (filter_to_do & PNG_FILTER_AVG)
|
||||
else if ((filter_to_do & PNG_FILTER_AVG) != 0)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
@@ -2827,7 +2829,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
|
||||
/* Paeth filter */
|
||||
if (filter_to_do == PNG_FILTER_PAETH)
|
||||
if ((filter_to_do == PNG_FILTER_PAETH) != 0)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
png_size_t i;
|
||||
@@ -2866,7 +2868,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
best_row = png_ptr->paeth_row;
|
||||
}
|
||||
|
||||
else if (filter_to_do & PNG_FILTER_PAETH)
|
||||
else if ((filter_to_do & PNG_FILTER_PAETH) != 0)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
@@ -2950,7 +2952,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
|
||||
else
|
||||
p = c;
|
||||
#endif /* PNG_SLOW_PAETH */
|
||||
#endif /* SLOW_PAETH */
|
||||
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||
|
||||
@@ -2999,7 +3001,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
best_row = png_ptr->paeth_row;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
|
||||
/* Do the actual writing of the filtered row data from the chosen filter. */
|
||||
png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);
|
||||
@@ -3019,7 +3021,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
||||
png_ptr->prev_filters[j] = best_row[0];
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
}
|
||||
|
||||
|
||||
@@ -3044,7 +3046,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
png_ptr->prev_row = png_ptr->row_buf;
|
||||
png_ptr->row_buf = tptr;
|
||||
}
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
#endif /* WRITE_FILTER */
|
||||
|
||||
/* Finish row - updates counters and flushes zlib if last row */
|
||||
png_write_finish_row(png_ptr);
|
||||
@@ -3059,4 +3061,4 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
#endif /* WRITE */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
VisualStudio instructions
|
||||
|
||||
libpng version 1.7.0beta18 - September 16, 2013
|
||||
libpng version 1.7.0beta41 - November 7, 2014
|
||||
|
||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
* zlib.props - location of zlib source
|
||||
*
|
||||
* libpng version 1.7.0beta18 - September 16, 2013
|
||||
* libpng version 1.7.0beta41 - November 7, 2014
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
*
|
||||
@@ -24,7 +24,7 @@
|
||||
source.
|
||||
|
||||
If you use a relative directory name (as below) then it must be
|
||||
relative to the project directories; these are one level deepers than
|
||||
relative to the project directories; these are one level deeper than
|
||||
the directories containing this file.
|
||||
|
||||
If the version of zlib you use does not match that used when the
|
||||
@@ -32,7 +32,7 @@
|
||||
versions do not match. The zlib version used in this build is recorded
|
||||
below:
|
||||
-->
|
||||
<ZLibSrcDir>..\..\..\..\zlib-1.2.5</ZLibSrcDir>
|
||||
<ZLibSrcDir>..\..\..\..\zlib-1.2.8</ZLibSrcDir>
|
||||
|
||||
<!-- The following line allows compilation for an ARM target with Visual
|
||||
Studio 2012. Notice that this is not supported by the Visual Studio
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Makefiles for libpng version 1.7.0beta18 - September 16, 2013
|
||||
Makefiles for libpng version 1.7.0beta41 - November 7, 2014
|
||||
|
||||
pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng17.so.17.1.7.0beta18)
|
||||
(gcc, creates libpng17.so.17.1.7.0beta41)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
@@ -19,8 +19,6 @@ pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.darwin => Darwin makefile, can use on MacosX
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.elf => Linux/ELF makefile symbol versioning,
|
||||
(gcc, creates libpng17.so.17.1.7.0beta18)
|
||||
makefile.freebsd => FreeBSD makefile
|
||||
makefile.gcc => Generic gcc makefile
|
||||
makefile.hpgcc => HPUX makefile using gcc
|
||||
@@ -35,12 +33,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 libpng17.so.17.1.7.0beta18)
|
||||
creates libpng17.so.17.1.7.0beta41)
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc,
|
||||
creates libpng17.so.17.1.7.0beta18)
|
||||
creates libpng17.so.17.1.7.0beta41)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng17.so.17.1.7.0beta18)
|
||||
creates libpng17.so.17.1.7.0beta41)
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
|
||||
@@ -21,7 +21,7 @@ PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
|
||||
PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
|
||||
PNG_DFN ""
|
||||
PNG_DFN "EXPORTS"
|
||||
PNG_DFN ";Version 1.7.0beta18"
|
||||
PNG_DFN ";Version 1.7.0beta41"
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
|
||||
|
||||
@@ -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
|
||||
pngtest.obj : png.h, pngconf.h, pnglibconf.h
|
||||
|
||||
20
scripts/dfn.awk
Normal file → Executable file
20
scripts/dfn.awk
Normal file → Executable file
@@ -1,9 +1,9 @@
|
||||
#!/bin/awk -f
|
||||
# scripts/dfn.awk - process a .dfn file
|
||||
#
|
||||
# last changed in libpng version 1.5.14 - February 4, 2013
|
||||
# last changed in libpng version 1.5.19 - August 21, 2014
|
||||
#
|
||||
# Copyright (c) 2013-2013 Glenn Randers-Pehrson
|
||||
# Copyright (c) 2013-2014 Glenn Randers-Pehrson
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@@ -25,7 +25,7 @@ BEGIN{
|
||||
# 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
|
||||
# but continue without setting the error code; this allows the
|
||||
# script to be checked easily
|
||||
}
|
||||
|
||||
@@ -61,14 +61,14 @@ $1 ~ /^PNG_DFN_END_SORT/{
|
||||
}
|
||||
|
||||
/^[^"]*PNG_DFN *".*"[^"]*$/{
|
||||
# A definition line, apparently correctly formated, extract the
|
||||
# A definition line, apparently correctly formatted; 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
|
||||
# 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
|
||||
# case it is essential to reject lines that start with '#' because those
|
||||
# are introduced #line directives.
|
||||
orig=$0
|
||||
line=$0
|
||||
@@ -126,13 +126,13 @@ $1 ~ /^PNG_DFN_END_SORT/{
|
||||
else while (1) {
|
||||
if (getline nextline) {
|
||||
# If the line starts with '#' it is a preprocesor line directive
|
||||
# from cc -E, skip it:
|
||||
# from cc -E; skip it:
|
||||
if (nextline !~ /^#/) {
|
||||
line = line " " nextline
|
||||
break
|
||||
}
|
||||
} else {
|
||||
# This is end-of-input - probably a missig "@ on the first line:
|
||||
# This is end-of-input - probably a missing "@ on the first line:
|
||||
print "line", lineno ": unbalanced @\" ... \"@ pair"
|
||||
err=1
|
||||
next
|
||||
@@ -144,7 +144,7 @@ $1 ~ /^PNG_DFN_END_SORT/{
|
||||
}
|
||||
|
||||
# Attempt to remove a trailing " (not preceded by '@') - if this can
|
||||
# be done stop now, if not assume a split line again
|
||||
# be done, stop now; if not assume a split line again
|
||||
if (sub(/"[^"]*$/, "", line))
|
||||
break
|
||||
|
||||
@@ -189,7 +189,7 @@ $1 ~ /^PNG_DFN_END_SORT/{
|
||||
next
|
||||
}
|
||||
|
||||
/PNG_DFN/{
|
||||
/PNG_DFN/{
|
||||
print "line", NR, "incorrectly formatted PNG_DFN line:"
|
||||
print $0
|
||||
err = 1
|
||||
|
||||
@@ -15,5 +15,8 @@
|
||||
#define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNGPREFIX_H /* self generation */
|
||||
#include "../pngpriv.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.7.0beta18
|
||||
version=1.7.0beta41
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
||||
@@ -5,6 +5,6 @@ includedir=@includedir@/libpng17
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.7.0beta18
|
||||
Version: 1.7.0beta41
|
||||
Libs: -L${libdir} -lpng17
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# makefile for libpng on Solaris 2.x with cc
|
||||
# Contributed by William L. Sebok, based on makefile.linux
|
||||
# Copyright (C) 2002, 2006, 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2002, 2006, 2010-2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 1998 Greg Roelofs
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
|
||||
@@ -45,8 +45,8 @@ ZLIBINC=/usr/include
|
||||
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||
CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \
|
||||
# $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
|
||||
CFLAGS=$(SUN_CC_FLAGS) # $(WARNMORE) -g
|
||||
LDFLAGS=$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) libpng.a -lz -lm
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
@@ -77,8 +77,11 @@ OBJSDLL = $(OBJS:.o=.pic.o)
|
||||
|
||||
.SUFFIXES: .c .o .pic.o
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
.c.pic.o:
|
||||
$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -KPIC -o $@ $*.c
|
||||
|
||||
all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
|
||||
|
||||
@@ -104,8 +107,8 @@ libpng-config:
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo R_opts=\"-R$(LIBPATH)\"; \
|
||||
echo ccopts=\"-xtarget=ultra\"; \
|
||||
echo ldopts=\"-xtarget=ultra\"; \
|
||||
echo ccopts=\"-fast -xtarget=ultra\"; \
|
||||
echo ldopts=\"-fast -xtarget=ultra\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
@@ -196,7 +199,7 @@ install: install-static install-shared install-man install-config
|
||||
test-dd:
|
||||
echo
|
||||
echo Testing installed dynamic shared library in $(DL).
|
||||
$(CC) $(SUN_CC_FLAGS) -I$(DI) -I$(ZLIBINC) \
|
||||
$(CC) $(SUN_CC_FLAGS) -I$(DI) $(CPPFLAGS) \
|
||||
`$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
|
||||
-o pngtestd -L$(DL) -R$(DL) `$(BINPATH)/$(LIBNAME)-config --ldflags` \
|
||||
$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB)
|
||||
@@ -205,7 +208,7 @@ test-dd:
|
||||
test-installed:
|
||||
echo
|
||||
echo Testing installed dynamic shared library.
|
||||
$(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \
|
||||
$(CC) $(SUN_CC_FLAGS) $(CPPFLAGS) \
|
||||
`$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
|
||||
-o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \
|
||||
$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB)
|
||||
@@ -222,20 +225,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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# makefile for libpng on Solaris 2.x with cc
|
||||
# Contributed by William L. Sebok, based on makefile.linux
|
||||
# Copyright (C) 2002, 2006, 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2002, 2006, 2010-2014 Glenn Randers-Pehrson
|
||||
# Copyright (C) 1998 Greg Roelofs
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
|
||||
@@ -45,8 +45,8 @@ ZLIBINC=/usr/include
|
||||
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||
CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \
|
||||
# $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
|
||||
CFLAGS= $(SUN_CC_FLAGS) # $(WARNMORE) -g
|
||||
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng17 -lz -lm
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
@@ -77,8 +77,11 @@ OBJSDLL = $(OBJS:.o=.pic.o)
|
||||
|
||||
.SUFFIXES: .c .o .pic.o
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
.c.pic.o:
|
||||
$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -KPIC -o $@ $*.c
|
||||
|
||||
all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
|
||||
|
||||
@@ -104,8 +107,8 @@ libpng-config:
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo R_opts=\"-R$(LIBPATH)\"; \
|
||||
echo ccopts=\"-xtarget=ultra -xarch=v9\"; \
|
||||
echo ldopts=\"-xtarget=ultra -xarch=v9\"; \
|
||||
echo ccopts=\"-fast -xtarget=ultra -xarch=v9\"; \
|
||||
echo ldopts=\"-fast -xtarget=ultra -xarch=v9\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
@@ -196,7 +199,7 @@ install: install-static install-shared install-man install-config
|
||||
test-dd:
|
||||
echo
|
||||
echo Testing installed dynamic shared library in $(DL).
|
||||
$(CC) $(SUN_CC_FLAGS) -I$(DI) -I$(ZLIBINC) \
|
||||
$(CC) $(SUN_CC_FLAGS) -I$(DI) $(CPPFLAGS) \
|
||||
`$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
|
||||
-o pngtestd -L$(DL) -R$(DL) `$(BINPATH)/$(LIBNAME)-config --ldflags` \
|
||||
$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB)
|
||||
@@ -205,7 +208,7 @@ test-dd:
|
||||
test-installed:
|
||||
echo
|
||||
echo Testing installed dynamic shared library.
|
||||
$(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \
|
||||
$(CC) $(SUN_CC_FLAGS) $(CPPFLAGS) \
|
||||
`$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
|
||||
-o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \
|
||||
$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB)
|
||||
@@ -222,20 +225,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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user