Compare commits

..

138 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
9bdba4e630 [libpng16] Imported from libpng-1.6.2rc05.tar 2013-04-23 19:45:07 -05:00
John Bowler
a74b70871c [libpng16] Ensure that NEON filter stuff is completely disabled when
switched 'off'.  Previously the ARM NEON specific files were still built
if the option was switched 'off' as opposed to being explicitly disabled.
2013-04-23 18:18:45 -05:00
Glenn Randers-Pehrson
0d50d6562c [libpng16] Imported from libpng-1.6.2rc04.tar 2013-04-22 20:29:18 -05:00
Glenn Randers-Pehrson
453fbf942c [libpng16] Revised stack marking in arm/filter_neon.S 2013-04-22 19:48:05 -05:00
Glenn Randers-Pehrson
6e1c74b39b [libpng16] Imported from libpng-1.6.2rc03.tar 2013-04-22 11:36:05 -05:00
Glenn Randers-Pehrson
fdc2d5f38f [libpng16] Bump version to 1.6.2rc03 2013-04-19 19:05:34 -05:00
Glenn Randers-Pehrson
67a289ffa9 [libpng16] Fixed some spelling/typos 2013-04-19 19:03:34 -05:00
Glenn Randers-Pehrson
bf15ac7e86 [libpng16] Imported from libpng-1.6.2rc02.tar 2013-04-18 07:40:56 -05:00
Glenn Randers-Pehrson
7ef0c46488 [libpng16] Updated "last changed" comments. 2013-04-18 07:25:45 -05:00
Glenn Randers-Pehrson
8d9e494dfb [libpng16] Merged pngtest.c with version 1.7.0beta08 2013-04-18 07:23:59 -05:00
Glenn Randers-Pehrson
0794df4062 [libpng16] Imported from libpng-1.6.2rc01.tar 2013-04-18 06:32:44 -05:00
Glenn Randers-Pehrson
7a69beda7b [libpng16] in fixitxt.c define MAX_LENGTH, largest iTXT chunk that it
can handle.
2013-04-18 05:53:49 -05:00
John Bowler
e4413a735b [libpng16] Disallow storing sRGB information when the sRGB is not supported.
Reverted previous attempt to allow gAMA and sRGB non-support with the
simplified API.
2013-04-17 21:27:47 -05:00
Glenn Randers-Pehrson
7fdb594e73 [libpng16] Added #ifdef PNG_WRITE_sRGB_SUPPORTED, etc., tests where needed in
png_image_write_main() in pngwrite.c (bug report from Yuriy Levchenko).
2013-04-17 11:05:21 -05:00
Glenn Randers-Pehrson
f1736a636b [libpng16] Added contrib/tools/fixitxt.c, to repair the erroneous iTXt
chunk length written by libpng-1.6.0 and 1.6.1.
2013-04-16 23:12:09 -05:00
Glenn Randers-Pehrson
3b4c60f26b [libpng16] Imported from libpng-1.6.2beta02.tar 2013-04-13 21:27:07 -05:00
Glenn Randers-Pehrson
5c55ccdf4f [libpng16] Imported from libpng-1.6.2beta01.tar 2013-04-13 20:55:04 -05:00
Glenn Randers-Pehrson
5ec05b3d7c [libpng16] Removed extra recently-inserted line from pngwutil.c 2013-04-13 20:01:09 -05:00
John Bowler
70eb0720a0 [libpng16] Fixed previous bugfix to work on 64-bit platforms. 2013-04-13 16:52:09 -05:00
Glenn Randers-Pehrson
9bb775fc8c [libpng16] Corrected length written to uncompressed iTXt chunks (Samuli Suominen). 2013-04-13 14:19:25 -05:00
John Bowler
a8715cabd1 [libpng16] Added "{ }" omitted from previous patch to pngtrans.c 2013-04-13 12:25:16 -05:00
Glenn Randers-Pehrson
364acf40aa [libpng16] Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c
(Flavio Medeiros).
2013-04-13 11:55:08 -05:00
John Bowler
b44cd59ad9 [libpng16] Corrected the test on user transform changes on read. It was in the
png_set of the transform function, but that doesn't matter unless the
transform function changes the rowbuf size, and that is only valid if
transform_info is called.
2013-04-12 22:15:54 -05:00
Glenn Randers-Pehrson
e2d8e11407 [libpng16] Updated the GIT URL in the manual. 2013-04-11 18:53:51 -05:00
John Bowler
43c07e1b48 [libpng16] Fixed incorrect warning of excess deflate data. End condition - the
warning would be produced if the end of the deflate stream wasn't read
in the last row.  The warning is harmless.
2013-04-07 21:33:30 -05:00
Glenn Randers-Pehrson
2e0c5f0dff [libpng16] Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk
handling.
2013-03-31 22:55:55 -05:00
Glenn Randers-Pehrson
3a83aa328d [libpng16] Bump version to 1.6.2beta01 2013-03-29 07:11:42 -05:00
Glenn Randers-Pehrson
5087805e7c [libpng16] Imported from libpng-1.6.1.tar 2013-03-27 20:36:57 -05:00
Glenn Randers-Pehrson
4e6e2166a5 [libpng16] Imported from libpng-1.6.1rc01.tar 2013-03-21 07:38:30 -05:00
Glenn Randers-Pehrson
1affc5622b [libpng16] Bump version to 1.6.1beta10 2013-03-13 07:40:54 -05:00
Glenn Randers-Pehrson
cd1cd2dafc [libpng16] Imported from libpng-1.6.1beta09.tar 2013-03-13 07:40:46 -05:00
John Bowler
caa3f296df [libpng16] Eliminated another warning from the Intel C compiler. 2013-03-10 21:40:27 -05:00
John Bowler
2286a7cef4 [libpng16] Eliminated a warning from the Intel C compiler. The warning is
technically valid, although a reasonable treatment of division would
show it to be incorrect.
2013-03-10 21:35:35 -05:00
Glenn Randers-Pehrson
3c8b422b0a [libpng16] Bump version to 1.6.1beta09 2013-03-07 11:36:55 -06:00
Glenn Randers-Pehrson
0645b62528 [libpng16] Imported from libpng-1.6.1beta08.tar 2013-03-07 11:36:47 -06:00
Claudio Bley
0281dee877 [libpng16] Fixed CMakelists.txt to allow building a single variant of the
library (Claudio Bley):
  Introduced a PNG_LIB_TARGETS variable that lists all activated library
    targets.  It is an error if this variable ends up empty, ie. you have
    to build at least one library variant.
  Made the *_COPY targets only depend on library targets actually being build.
  Use PNG_LIB_TARGETS to unify a code path.
  Changed the CREATE_SYMLINK macro to expact the full path to a file as the
    first argument. When symlinking the filename component of that path is
    determined and used as the link target.
  Use copy_if_different in the CREATE_SYMLINK macro.
2013-03-07 11:17:17 -06:00
Glenn Randers-Pehrson
e55b25a962 [libpng16] Bump version to 1.6.1beta08 2013-03-06 22:42:23 -06:00
Glenn Randers-Pehrson
14638c1f20 [libpng16] Imported from libpng-1.6.1beta07.tar 2013-03-06 22:42:13 -06:00
John Bowler
59ae38984f [libpng16] Corrected simplified API default gamma for color-mapped output, added
a flag to change default. In 1.6.0 when the simplified API was used
to produce color-mapped output from an input image with no gamma
information the gamma assumed for the input could be different from
that assumed for non-color-mapped output.  In particular 16-bit depth
input files were assumed to be sRGB encoded, whereas in the 'direct'
case they were assumed to have linear data.  This was an error.  The
fix makes the simplified API treat all input files the same way and
adds a new flag to the png_image::flags member to allow the
application/user to specify that 16-bit files contain sRGB data
rather than the default linear.
Fixed bugs in the pngpixel and makepng test programs.
2013-03-06 22:15:25 -06:00
Glenn Randers-Pehrson
1f24cb74f2 [libpng16] Update "last changed" dates and fix one comment typo. 2013-03-04 21:58:02 -06:00
Glenn Randers-Pehrson
1cbfa24a93 [libpng16] Bump version to 1.6.1beta07 2013-03-04 17:56:59 -06:00
Glenn Randers-Pehrson
8c87dc88d6 [libpng16] Imported from libpng-1.6.1beta06.tar 2013-03-04 17:56:46 -06:00
John Bowler
f3728100d9 [libpng16] Corrected Android builds and corrected libpng.vers with symbol
prefixing This adds an API to set optimization options externally,
    providing an alternative and general solution for the non-portable
    run-time tests used by the ARM Neon code.  It also makes those tests
    compile and link on Android.
  The order of settings vs options in pnglibconf.h is reversed to allow
    settings to depend on options and options can now set (or override) the
    defaults for settings.
2013-03-04 16:26:31 -06:00
John Bowler
e15b537825 [libpng16] Better documentation of unknown handling API interactions. 2013-03-02 17:59:43 -06:00
Glenn Randers-Pehrson
e57f094fd6 [libpng16] Bump version to 1.6.1beta06 2013-03-02 17:37:23 -06:00
Glenn Randers-Pehrson
4ea113b7f0 [libng16] Reverted recent change that eliminated a warning about storing
an unhandled chunk.
2013-03-02 16:03:45 -06:00
Glenn Randers-Pehrson
871b1d0fab [libpng16] Bump version to 1.6.1beta05 2013-03-02 15:03:15 -06:00
Glenn Randers-Pehrson
f3af706c2a [libpng16] Imported from libpng-1.6.0beta05.tar 2013-03-01 21:38:03 -06:00
Glenn Randers-Pehrson
96cf4bde0e [libpng16] Fixed bug introduced in libpng-1.6.0beta28 that causes libpng to
handle chunks even when they have been tagged PNG_HANDLE_CHUNK_NEVER.
2013-03-01 20:04:06 -06:00
Glenn Randers-Pehrson
1118d6d985 [libpng16] Avoid a possible memory leak in contrib/gregbook/readpng.c 2013-03-01 13:27:05 -06:00
Glenn Randers-Pehrson
e444514a94 [libpng16] Bump version to 1.6.1beta05 2013-02-27 15:11:39 -06:00
Glenn Randers-Pehrson
efda7376c8 [libpng16] Imported from libpng-1.6.1beta04.tar 2013-02-27 15:02:53 -06:00
John Bowler
ccec786ca7 [libpng16] Revised scripts/dfn.awk to work with the buggy MSYS awk that has
trouble with CRLF line endings.
2013-02-27 13:36:08 -06:00
Glenn Randers-Pehrson
2621be1bdb [libpng16] Added info about ordering of png_set_*() calls to the manual. 2013-02-26 08:43:28 -06:00
Glenn Randers-Pehrson
45bb4530fd [libpng16] Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
Revised scripts/makefile.freebsd to respect ZLIBDIR and ZLIBINC.
2013-02-22 20:19:49 -06:00
Glenn Randers-Pehrson
a97fc46e43 [libpng16] Bump version to 1.6.1beta04 2013-02-22 17:12:09 -06:00
Glenn Randers-Pehrson
3fa1893804 [libpng16] Imported from libpng-1.6.1beta03.tar 2013-02-22 17:06:01 -06:00
Glenn Randers-Pehrson
f8a8ead5cb [libpng16] Update the INSTALL document. 2013-02-22 16:52:21 -06:00
Glenn Randers-Pehrson
6df55cece7 [libpng16] Updated scripts/pnglibconf.h.prebuilt 2013-02-19 10:11:43 -06:00
John Bowler
09a5ca72ac [libpng16] Allow run-time ARM NEON checking to be disabled. A new configure
option:
    --enable-arm-neon=always will stop the run-time checks. New checks
    within arm/arm_init.c will cause the code not to be compiled unless
    __ARM_NEON__ is set. This should make it fail safe (if someone asks
    for it on then the build will fail if it can't be done.)
Fixed ALIGNED_MEMORY support.
2013-02-18 22:30:35 -06:00
Glenn Randers-Pehrson
0cc3e9e38c [libpng16] Bump version to 1.6.1beta03 2013-02-18 21:25:56 -06:00
Glenn Randers-Pehrson
adb9613699 [libpng16] Imported from libpng-1.6.1beta02.tar 2013-02-18 21:25:47 -06:00
John Bowler
c0a0d4a6d2 [libpng16] Reenabled code to allow zero length PLTE chunks for MNG. 2013-02-18 21:23:17 -06:00
Glenn Randers-Pehrson
2bad851ab3 [libpng16] Updated "png_sizeof" to "sizeof" in the manual. 2013-02-18 15:21:01 -06:00
Glenn Randers-Pehrson
f2350f3987 [libpng16] Revised "#if defined " in arm/arm_init.c 2013-02-18 12:30:30 -06:00
Glenn Randers-Pehrson
b4ef7c4af2 [libpng16] Use parentheses consistently in "#if defined()" tests.
Folded some long lines.
2013-02-17 15:41:36 -06:00
Glenn Randers-Pehrson
9e8fd50d76 [libpng16] Use parentheses consistently in "#if defined()" tests. 2013-02-17 14:31:00 -06:00
Glenn Randers-Pehrson
ea3288f1c5 [libpng16] Fixed double-underscore typo in an #ifdef in png.c 2013-02-16 16:35:22 -06:00
Glenn Randers-Pehrson
cc074dcaa6 [libpng16] Bump version to 1.6.1beta02 2013-02-16 10:48:39 -06:00
Glenn Randers-Pehrson
3b8e7e869d [libpng16] Imported from libpng-1.6.1beta01.tar 2013-02-16 10:48:29 -06:00
John Bowler
765d145ec4 [libpng16] Use approved/supported Android method to check for NEON, use
Linux/POSIX 1003.1 API to check /proc/self/auxv avoiding buffer allocation
and other library calls (ported from libpng15).
2013-02-16 07:43:48 -06:00
John Bowler
c9b11ff0d4 [libpng16] Fixed a race condition in the creation of the build 'scripts'
directory while building with a parallel make.
2013-02-16 07:38:46 -06:00
John Bowler
23a101e06d [libpng16] scripts/pnglibconf.dfa formatting improvements back ported from libpng 1.7. 2013-02-16 00:18:20 -06:00
John Bowler
b724c812ec [libpng16] Enabled parallel tests - back ported from libpng-1.7. 2013-02-16 00:05:59 -06:00
John Bowler
0695fcd834 [libpng16] Removed cc -E workround, corrected png_get_palette_max API Tested on SUN OS cc 5.9,
which demonstrates the tokenization problem previously avoided by using /lib/cpp.
Since all .dfn output is now protected in double quotes unless it is to be macro
substituted the fix should work everywhere.
2013-02-15 23:46:37 -06:00
John Bowler
42835d3d19 [libpng16] Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug. 2013-02-15 23:40:34 -06:00
John Bowler
2d99978f67 [libpng16] Made sRGB check numbers consistent. 2013-02-15 23:25:18 -06:00
John Bowler
9d2e875826 [libpng16] Made symbol prefixing work with the ARM neon optimizations. Also allow pngpriv.h
to be included for preprocessor definitions only, so it can be used in non-C/C++
files. Back ported from libpng 1.7.
2013-02-15 23:21:42 -06:00
Glenn Randers-Pehrson
681de8c8dc [libpng16] Bump version to 1.6.1beta01 2013-02-13 23:17:52 -06:00
Glenn Randers-Pehrson
c53778ff53 [libpng16] Imported from libpng-1.6.0.tar 2013-02-13 22:53:57 -06:00
Glenn Randers-Pehrson
44db2cfb15 [libpng16] Bump version to 1.6.0rc09 2013-02-10 20:34:23 -06:00
John Bowler
6db8e4dd11 [libpng16] Fixed inconsistencies in png.h and pnglibconf.dfa 2013-02-10 17:49:25 -06:00
Glenn Randers-Pehrson
88c5a2a068 [libpng16] Fixed typo in png.h #ifdef 2013-02-10 16:39:55 -06:00
Glenn Randers-Pehrson
bf9f74b657 [libpng16] Bump version to 1.6.0rc08 2013-02-10 16:20:48 -06:00
Glenn Randers-Pehrson
0d270082d2 [libpng16] Imported from libpng-1.6.0rc07.tar 2013-02-10 16:20:40 -06:00
Glenn Randers-Pehrson
d000fb89c0 [libpng16] Enclosed the new png_get_palette_max
in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED block, and revised pnglibconf.h
and pnglibconf.h.prebuilt accordingly.
2013-02-10 15:46:06 -06:00
Glenn Randers-Pehrson
9fabbedcf3 [libpng16] Bump version to 1.6.0rc07 2013-02-09 07:44:06 -06:00
Glenn Randers-Pehrson
d7dc03e371 [libpng16] Imported from libpng-1.6.0rc06.tar 2013-02-09 07:43:55 -06:00
John Bowler
b8d0534e9d [libpng16] Fixed missing dependency in --prefix builds The intermediate
internal 'prefix.h' file can only be generated correctly after
pnglibconf.h, however the dependency was not in Makefile.am.  The
symptoms are unpredictable depending on the order make chooses to
build pngprefix.h and pnglibconf.h, often the error goes unnoticed
because there is a system pnglibconf.h to use instead.
2013-02-09 07:24:08 -06:00
Glenn Randers-Pehrson
f88ac51a2e [libpng16] Bump version to 1.6.0rc06 2013-02-08 09:13:44 -06:00
Glenn Randers-Pehrson
bbac5e692f [libpng16] Imported from libpng-1.6.0rc05.tar 2013-02-08 09:13:35 -06:00
Glenn Randers-Pehrson
a4081f2990 [libpng16] Updated man page about png_get_palette_max(). 2013-02-08 09:06:08 -06:00
Glenn Randers-Pehrson
1f8e81738a [libpng16] Bump version to 1.6.0rc05 2013-02-06 22:32:13 -06:00
Glenn Randers-Pehrson
9002f5b1f0 [libpng16] Imported from libpng-1.6.0rc04.tar 2013-02-06 22:32:05 -06:00
John Bowler
f5a83fb2b3 [libpng16] Turn serial tests back on (recently turned off by autotools upgrade). 2013-02-06 19:38:42 -06:00
Glenn Randers-Pehrson
154de9398a [libpng16] Bump version to 1.6.0rc04 2013-02-05 12:14:43 -06:00
Glenn Randers-Pehrson
777044a856 [libpng16] Imported from libpng-1.6.0rc03.tar 2013-02-05 10:34:11 -06:00
John Bowler
fe5c8b9755 [libpng16] Fixed palette_max API. 2013-02-05 08:01:09 -06:00
Glenn Randers-Pehrson
8d391c6cea [libpng16] Bump version to 1.6.0rc03 2013-02-04 20:43:27 -06:00
Glenn Randers-Pehrson
32d6a74293 [libpng16] Imported from libpng-1.6.0rc02.tar 2013-02-04 20:12:49 -06:00
Glenn Randers-Pehrson
806477742a [libpng16] Added documentation of the new png_get_palette_max() function. 2013-02-04 19:57:32 -06:00
Glenn Randers-Pehrson
29890b0439 [libpng16] Imported from libpng-1.6.0rc01.tar 2013-01-26 12:13:17 -06:00
Glenn Randers-Pehrson
9f860f59d9 [libpng16] Bump version to 1.6.0beta41 2013-01-20 17:32:13 -06:00
Glenn Randers-Pehrson
f8aa57e791 [libpng16] Imported from libpng-1.6.0beta40.tar 2013-01-20 17:25:00 -06:00
Glenn Randers-Pehrson
4567935fe4 [libpng16] Push two files that weren't updated in previous push. 2013-01-20 00:44:29 -06:00
John Bowler
2414bd99d8 [libpng16] Use consistent handling of overflows in text, sPLT and unknown
png_set_* APIs
2013-01-19 23:18:59 -06:00
Glenn Randers-Pehrson
1f76e62d6c [libpng16] Bump version to 1.6.0beta40 2013-01-19 08:57:40 -06:00
Glenn Randers-Pehrson
e208108dfc [libpng16] Imported from libpng-1.6.0beta39.tar 2013-01-19 08:50:15 -06:00
Glenn Randers-Pehrson
590c8b0987 [libpng16] Added overflow detection in png_set_sPLT() and png_set_text_2(). 2013-01-19 08:49:12 -06:00
Glenn Randers-Pehrson
c5c8b542fb [libpng16] Bump version to 1.6.0beta39 2013-01-17 13:57:58 -06:00
Glenn Randers-Pehrson
91a7ad9d2b [libpng16] Imported from libpng-1.6.0beta38.tar 2013-01-17 13:57:42 -06:00
John Bowler
9dd2bfafe5 [libpng16] Corrected previous attempt at overflow detection in
png_set_unknown_chunks().
2013-01-17 13:24:05 -06:00
Glenn Randers-Pehrson
ba35f1e4c1 [libpng16] Bump version to 1.6.0beta38 2013-01-10 12:21:07 -06:00
Glenn Randers-Pehrson
5851280929 [libpng16] Imported from libpng-1.6.0beta37.tar 2013-01-10 12:20:59 -06:00
John Bowler
1c6e22a360 [libpng16] Fixed conceivable but difficult to repro overflow. Also added
two test programs to generate and test a PNG which should have the problem.
2013-01-10 10:55:34 -06:00
Glenn Randers-Pehrson
37109a9f5b [libpng16] Bump version to 1.6.0beta37 2013-01-01 08:40:25 -06:00
Glenn Randers-Pehrson
a70216aa60 [libpng16] Imported from libpng-1.6.0beta36.tar 2013-01-01 08:40:16 -06:00
Glenn Randers-Pehrson
9477ecdfa6 [libpng16] Updated copyright year to 2013 in newly-changed files 2013-01-01 07:45:42 -06:00
John Bowler
408652acaf [libpng16] Fixed 'make distcheck' on SUN OS - libpng.so was not being removed 2012-12-27 09:56:41 -06:00
Glenn Randers-Pehrson
744f041adf [libpng16] Discontinued distributing libpng-1.x.x.tar.bz2.
Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar.
2012-12-23 22:19:43 -06:00
Glenn Randers-Pehrson
86c739e8bc [libpng16] Bump version to 1.6.0beta36 2012-12-22 18:34:22 -06:00
Glenn Randers-Pehrson
00634fdac8 [libpng16] Imported from libpng-1.6.0beta35.tar 2012-12-22 18:34:13 -06:00
Glenn Randers-Pehrson
79ee877fb4 [libpng16] Reformatted latest CHANGES/ANNOUNCE entry to 80 character lines. 2012-12-22 17:13:35 -06:00
John Bowler
e9d616321a [libpng16] Fixed Windows build issues, enabled ARM compilation. Various warnings issued
by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old GCCs.)
ARM support is enabled by default in zlib.props (unsupported by Microsoft) and
ARM compilation is made possible by deleting the check for x86. The test programs
cannot be run because they are not signed.
2012-12-20 22:48:58 -06:00
John Bowler
24639a63ce [libpng16] Made default Zlib compression settings be configurable. This adds #defines to
pnglibconf.h to control the defaults.
2012-12-20 22:26:18 -06:00
Glenn Randers-Pehrson
5362c9d5e5 [libpng16] Bump version to 1.6.0beta35 2012-12-19 16:21:35 -06:00
Glenn Randers-Pehrson
b6bfd40da2 [libpng16] Imported from libpng-1.6.0beta34.tar 2012-12-19 16:12:30 -06:00
Glenn Randers-Pehrson
a1d32d08e1 [libpng16] ANNOUNCE that location of GIT repository at SourceForge has changed. 2012-12-18 21:53:17 -06:00
Glenn Randers-Pehrson
350cbf14df [libpng16] Fixed typo in contrib/pngminim/encoder/README 2012-12-18 14:54:44 -06:00
Glenn Randers-Pehrson
7bde6e23bb [libpng16] Disassembled the version number in scripts/options.awk (necessary
for building on SunOs)
2012-12-18 08:44:26 -06:00
Glenn Randers-Pehrson
5d9dc4563f [libpng16] Fixed whitespace in libpng.3 manpage. 2012-12-17 20:03:08 -06:00
Glenn Randers-Pehrson
aa41547a4d [libpng16] Updated manual about functions deprecated in libpng-1.6.x 2012-12-16 16:53:54 -06:00
Glenn Randers-Pehrson
8c3d4f387a [libpng16] Bump version to 1.6.0beta34 2012-12-15 08:43:12 -06:00
Glenn Randers-Pehrson
6e265d137c [libpng16] Note in CHANGES that configure files were rebuilt with autoconf-2.69 2012-12-15 08:29:41 -06:00
Glenn Randers-Pehrson
7b26920d9b [libpng16] Imported from libpng-1.6.0beta33.tar 2012-12-15 07:58:38 -06:00
John Bowler
785a8b1505 [libpng16] Fixed cases of unquoted DESTDIR in Makefile.am 2012-12-15 07:57:31 -06:00
John Bowler
6cf32b460f [libpng16] Rearranged the ARM-NEON optimizations: Isolated the machine specific
code to the hardware subdirectory and added comments to pngrutil.c so that
implementors of other optimizations know what to do.
2012-12-15 07:55:54 -06:00
John Bowler
f758d6c813 [libpng16] Rearranged the ARM-NEON optimizations: Isolated the machine specific
code to the hardware subdirectory and added comments to pngrutil.c so that
implementors of other optimizations know what to do.
2012-12-13 11:26:50 -06:00
98 changed files with 2708 additions and 3341 deletions

250
ANNOUNCE
View File

@@ -1,5 +1,5 @@
Libpng 1.7.0beta07 - April 14, 2013
Libpng 1.6.2rc05 - April 23, 2013
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
@@ -9,234 +9,23 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
1.7.0beta07.tar.xz (LZMA-compressed, recommended)
1.7.0beta07.tar.gz
1.6.2rc05.tar.xz (LZMA-compressed, recommended)
1.6.2rc05.tar.gz
Source files with CRLF line endings (for Windows), without the
"configure" script
lp170b07.7z (LZMA-compressed, recommended)
lp170b07.zip
lp162r05.7z (LZMA-compressed, recommended)
lp162r05.zip
Other information:
1.7.0beta07-README.txt
1.7.0beta07-LICENSE.txt
1.6.2rc05-README.txt
1.6.2rc05-LICENSE.txt
Changes since the last public release (1.6.0):
Changes since the last public release (1.6.1):
Version 1.7.0alpha01 [December 15, 2012]
Started 1.7.0 branch from libpng-1.6.0beta33.
Made 8-bit compose and rgb_to_grayscale accuracy improvements. These
changes cause 16-bit arithmetic to be used for 8-bit data in the gamma
corrected compose and grayscale operations. The arithmetic errors have
three sources all of which are fixed in this commit:
1) 8-bit linear calculations produce massive errors for lower intensity
values.
2) The old 16-bit "16 to 8" gamma table code erroneously wrote the lowest
output value into a table entry which corresponded to multiple output
values (so where the value written should have been the closest to the
transformed input value.)
3) In a number of cases the code to access the 16-bit table did not round;
it did a simple shift, which was wrong and made the side effects of (2)
even worse.
The new gamma code does not have the 16-to-8 problem at the cost of slightly
more calculations and the algorithm used to minimize the number of
calculations has been extended to all the 16-bit tables; it has advantages
for any significant gamma correction.
Rearranged png_struct, remove unused members, change png_set_filter handling
png_struct members rearranged - partly to reorder to avoid packing, partly
to put frequently accessed members at the start and partly to make
the grouping more clear. png_set_filter code has been rewritten and the
code shared with png_write_start_row moved to a common function. Comments
in png.h have been made more clear. Minor fixes to
contrib/libtests/timepng.c and some of the png_*_tRNS logic, including
more error detection in png_set_tRNS.
Cleaned up USER_LIMITS feature, removing members from png_struct when not
required.
Rearranged ARM-NEON optimizations to isolate the machine specific code to
the hardware subdirectory, and add comments to pngrutil.c so that
implementors of other optimizations will know what to do.
Fixed cases of unquoted DESTDIR in Makefile.am.
Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.12.5.
Version 1.7.0alpha02 [December 17, 2012]
Removed functions that were deprecated in libpng-1.6.0:
png_reset_zstream(), png_info_init_3(), and png_data_freer() and its
associated flags.
Removed some duplicated lines from contrib/tools/scale.c and png.c.
Changed some instances of png_warning() to png_app_error().
Updated some left over "1.6.0beta32" in code sources.
Fixed a "png_structp" prototype (should be png_structrp) in arm_init.c
Updated the version-number hack in pngvalid.c
Version 1.7.0alpha03 [December 19, 2012]
Cleaned up and enhanced the configure option; libpng now correctly
links and tests against zlib with a prefix; tests have been clarified; and
irrelevant or obsolete things (as defined by the autotools man page) have
been removed.
Documented new PNG_ABORT behavior in the manual and commentary in pngerror.c
Cleaned up whitespace in the synopsis portion of the manpage "libpng.3"
Fixed previous support for Z_PREFIX in configure builds, corrected sCAL APIs;
some of these use floating point arithmetic so they need to be disabled if
floating point arithmetic is switched off. This is a quiet API change -
previously it appeared that the APIs were supported if fixed point
arithmetic was used internally, however they required certain APIs (floor,
modf, frexp, atof) that are part of C floating point support. Changed
png_fixed and the gamma code specific version of the same to avoid floor(),
which may be a library function (not an intrinsic). Removed unused #if 0
code.
Disassembled the version number in scripts/options.awk (necessary for
building on SunOs).
Version 1.7.0alpha04 [December 23, 2012]
Added scripts/makefile.msys contributed by Christopher M. Wheeler
Made default Zlib compression settings be configurable. This adds #defines to
pnglibconf.h to control the defaults.
Fixed Windows build issues, enabled ARM compilation. Various warnings issued
by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old
GCCs.) ARM support is enabled by default in zlib.props (unsupported by
Microsoft) and ARM compilation is made possible by deleting the check for
x86. The test programs cannot be run because they are not signed.
Version 1.7.0alpha05 [December 24, 2012]
Discontinued distributing libpng-1.x.x.tar.bz2.
Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar.
Version 1.7.0alpha06 [January 1, 2013]
Fixed 'make distcheck' on SUN OS - libpng.so was not being removed
Version 1.7.0alpha07 [January 10, 2013]
Fixed conceivable but difficult to repro overflow. Also added two test
programs to generate and test a PNG which should have the problem.
Version 1.7.0alpha08 [January 17, 2013]
Corrected previous attempt at overflow detection in png_set_unknown_chunks().
Version 1.7.0alpha09 [January 21, 2013]
Pulled changes to multi-chunk handling from libpng-1.6.0beta40.
Version 1.7.0alpha10 [February 5, 2013]
Make symbol prefixing work with the ARM neon optimizations. Also
allow pngpriv.h to be included for preprocessor definitions only, so
it can be used in non-C/C++ files.
Added png_get_palette_max() function.
Changed png_size_t to size_t throughout headers, make sRGB check numbers
consistent.
Fixed ARM support (Mans Rullgard).
Removed stray out-of-order #endif and #ifdef (Mans Rullgard).
Ported libpng 1.5 options.awk/dfn file handling to 1.7, fixed one bug.
Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.13.
Minor fixes to assembler changes, verified with a dummy .S file
Removed cc -E workround, corrected png_get_palette_max API. Tested on
SUN OS cc 5.9, which demonstrates the tokenization problem previously
avoided by using /lib/cpp. Since all .dfn output is now protected
in double quotes unless it is to be macro substituted the fix should work
everywhere.
Version 1.7.0beta01 [February 15, 2013]
Enable parallel tests and rearrange TESTS order to take advantage of
the massive speed improvements use a make capable of parallel builds
on a multi-CPU machine and pass the right arguments to make (-j10000
for GNU make) to get the build to run in parallel.
Fixed previous support for Z_PREFIX in configure builds, corrected
sCAL APIs; some of these use floating point arithmetic so need to be
disabled if floating point arithmetic is switched off. This is a quiet API
change - previously it appeared that the APIs were supported if fixed point
arithmetic was used internally, however they required certain APIs (floor,
modf, frexp, atof) that are part of C floating point support. Changed
png_fixed and the gamma code specific version of the same to avoid floor(),
which may be a library function (not an intrinsic). Removed unused #if 0
code.
Fixed make distcheck to skip over the test result files. They were
being included because the whole of the 'tests' directory is included,
fixed to just include the actual test files and tests/pngstest. Also
reverted the previous erroneous change to remove the ${srcdir} from the
front of contrib, scripts, projects and added an explanation of what is
going on to Makefile.am
Fixed missing dependency in --prefix builds. The intermediate
internal 'prefix.h' file can only be generated correctly after pnglibconf.h,
however the dependency was not in Makefile.am. The symptoms are
unpredictable depending on the order make chooses to build pngprefix.h and
pnglibconf.h, often the error goes unnoticed because there is a system
pnglibconf.h to use instead.
Accept "," as a separator in pnglibconf.dfa and allow for
continuation lines. This adds to the syntax of "option" and "chunk" lines,
allowing the elements to be separated by a "," at the end of an element and
interpreting a "," at end of line as a continuation - so the following line
is read. The new syntax is optional and solely provided for readability.
Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly.
Version 1.7.0beta02 [February 18, 2013]
Fixed a race condition in the creation of the build 'scripts' directory
while building with a parallel make.
Use approved/supported Android method to check for NEON, use Linux/POSIX
1003.1 API to check /proc/self/auxv avoiding buffer allocation and other
library calls (ported from libpng15).
Use parentheses more consistently in "#if defined(MACRO)" tests.
Folded long lines.
Version 1.7.0beta03 [February 22, 2013]
Reenabled code to allow zero length PLTE chunks for MNG.
Fixed ALIGNED_MEMORY support.
Allow run-time ARM NEON checking to be disabled. A new configure option:
--enable-arm-neon=always will stop the run-time checks. New checks
within arm/arm_init.c will cause the code not to be compiled unless
__ARM_NEON__ is set. This should make it fail safe (if someone asks
for it on then the build will fail if it can't be done.)
Updated the INSTALL document.
Version 1.7.0beta04 [February 27, 2013]
Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC.
Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
with CRLF line endings.
Version 1.7.0beta05 [March 5, 2013]
Avoid a possible memory leak in contrib/gregbook/readpng.c
Changed user chunk callback API to respect global and per chunk defaults.
Previously a return of 0 from a user chunk callback would result in the
chunk being saved (if this was safe, even if the chunk was unsafe-to-copy);
this change respects the defaults set by the application, so unknown chunks
can be discarded by default and known-safe ones preserved.
Corrected Android builds and corrected libpng.vers with symbol
prefixing. This adds an API to set optimization options externally,
providing an alternative and general solution for the non-portable
run-time tests used by the ARM Neon code. It also makes those tests
compile and link on Android. The order of settings vs options in
pnglibconf.h is reversed to allow settings to depend on options and
options can now set (or override) the defaults for settings.
Version 1.7.0beta06 [March 13, 2013]
Corrected simplified API default gamma for color-mapped output, added
a flag to change default. In 1.6.0 when the simplified API was used
to produce color-mapped output from an input image with no gamma
information the gamma assumed for the input could be different from
that assumed for non-color-mapped output. In particular 16-bit depth
input files were assumed to be sRGB encoded, whereas in the 'direct'
case they were assumed to have linear data. This was an error. The
fix makes the simplified API treat all input files the same way and
adds a new flag to the png_image::flags member to allow the
application/user to specify that 16-bit files contain sRGB data
rather than the default linear.
Fixed bugs in the pngpixel and makepng test programs.
Fixed CMakelists.txt to allow building a single variant of the library
(Claudio Bley):
Introduced a PNG_LIB_TARGETS variable that lists all activated library
targets. It is an error if this variable ends up empty, ie. you have
to build at least one library variant.
Made the *_COPY targets only depend on library targets actually being build.
Use PNG_LIB_TARGETS to unify a code path.
Changed the CREATE_SYMLINK macro to expect the full path to a file as the
first argument. When symlinking the filename component of that path is
determined and used as the link target.
Use copy_if_different in the CREATE_SYMLINK macro.
Eliminated two warnings from the Intel C compiler. The warnings are
technically valid, although a reasonable treatment of division would
show it to be incorrect.
Version 1.7.0beta07 [April 14, 2013]
Version 1.6.2beta01 [April 14, 2013]
Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling.
Fixed incorrect warning of excess deflate data. End condition - the
warning would be produced if the end of the deflate stream wasn't read
@@ -249,6 +38,27 @@ Version 1.7.0beta07 [April 14, 2013]
(Flavio Medeiros).
Corrected length written to uncompressed iTXt chunks (Samuli Suominen).
Version 1.6.2rc01 [April 18, 2013]
Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length
written by libpng-1.6.0 and 1.6.1.
Levchenko).
Disallow storing sRGB information when the sRGB is not supported.
Version 1.6.2rc02 [April 18, 2013]
Merge pngtest.c with libpng-1.7.0
Version 1.6.2rc03 [April 22, 2013]
Trivial spelling cleanup.
Version 1.6.2rc04 [April 22, 2013]
Revised stack marking in arm/filter_neon.S and configure.ac
Version 1.6.2rc05 [April 23, 2013]
Ensure that NEON filter stuff is completely disabled when switched 'off'.
Previously the ARM NEON specific files were still built if the option
was switched 'off' as opposed to being explicitly disabled.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

239
CHANGES
View File

@@ -3780,7 +3780,8 @@ Version 1.5.7 [December 15, 2011]
Version 1.6.0beta01 [December 15, 2011]
Removed machine-generated configure files from the GIT repository (they will
continue to appear in the tarball distributions).
continue to appear in the tarball distributions and in the libpng15 and
earlier GIT branches).
Restored the new 'simplified' API, which was started in libpng-1.5.7beta02
but later deleted from libpng-1.5.7beta05.
Added example programs for the new 'simplified' API.
@@ -4305,79 +4306,24 @@ Version 1.6.0beta32 [November 25, 2012]
Fixed error checking in the simplified write API (Olaf van der Spek)
Made png_user_version_check() ok to use with libpng version 1.10.x and later.
Version 1.6.0beta33 [December 10, 2012]
Version 1.6.0beta33 [December 15, 2012]
Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX)
that causes the MALLOC_MAX limit not to work (John Bowler)
Change png_warning() to png_app_error() in pngwrite.c and comment the
fall-through condition.
Change png_warning() to png_app_warning() in png_write_tRNS().
Rearranged the ARM-NEON optimizations: Isolated the machine specific code
to the hardware subdirectory and added comments to pngrutil.c so that
implementors of other optimizations know what to do.
Fixed cases of unquoted DESTDIR in Makefile.am
Rebuilt Makefile.in, etc., with autoconf-2.69 and automake-1.12.5.
Version 1.7.0alpha01 [December 15, 2012]
Started 1.7.0 branch from libpng-1.6.0beta33.
Made 8-bit compose and rgb_to_grayscale accuracy improvements. These
changes cause 16-bit arithmetic to be used for 8-bit data in the gamma
corrected compose and grayscale operations. The arithmetic errors have
three sources all of which are fixed in this commit:
1) 8-bit linear calculations produce massive errors for lower intensity
values.
2) The old 16-bit "16 to 8" gamma table code erroneously wrote the lowest
output value into a table entry which corresponded to multiple output
values (so where the value written should have been the closest to the
transformed input value.)
3) In a number of cases the code to access the 16-bit table did not round;
it did a simple shift, which was wrong and made the side effects of (2)
even worse.
The new gamma code does not have the 16-to-8 problem at the cost of slightly
more calculations and the algorithm used to minimize the number of
calculations has been extended to all the 16-bit tables; it has advantages
for any significant gamma correction.
Rearranged png_struct, remove unused members, change png_set_filter handling
png_struct members rearranged - partly to reorder to avoid packing, partly
to put frequently accessed members at the start and partly to make
the grouping more clear. png_set_filter code has been rewritten and the
code shared with png_write_start_row moved to a common function. Comments
in png.h have been made more clear. Minor fixes to
contrib/libtests/timepng.c and some of the png_*_tRNS logic, including
more error detection in png_set_tRNS.
Cleaned up USER_LIMITS feature, removing members from png_struct when not
required.
Rearranged ARM-NEON optimizations to isolate the machine specific code to
the hardware subdirectory, and add comments to pngrutil.c so that
implementors of other optimizations will know what to do.
Fixed cases of unquoted DESTDIR in Makefile.am.
Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.12.5.
Version 1.7.0alpha02 [December 17, 2012]
Removed functions that were deprecated in libpng-1.6.0:
png_reset_zstream(), png_info_init_3(), png_data_freer() and its
associated flags, png_malloc_default, and png_free_default.
Removed some duplicated lines from contrib/tools/scale.c and png.c.
Changed some instances of png_warning() to png_app_error().
Updated some left over "1.6.0beta32" in code sources.
Fixed a "png_structp" prototype (should be png_structrp) in arm_init.c
Updated the version-number hack in pngvalid.c
Version 1.7.0alpha03 [December 19, 2012]
Cleaned up and enhanced the configure option; libpng now correctly
links and tests against zlib with a prefix; tests have been clarified; and
irrelevant or obsolete things (as defined by the autotools man page) have
been removed.
Documented new PNG_ABORT behavior in the manual and commentary in pngerror.c
Version 1.6.0beta34 [December 19, 2012]
Cleaned up whitespace in the synopsis portion of the manpage "libpng.3"
Fixed previous support for Z_PREFIX in configure builds, corrected sCAL APIs;
some of these use floating point arithmetic so they need to be disabled if
floating point arithmetic is switched off. This is a quiet API change -
previously it appeared that the APIs were supported if fixed point
arithmetic was used internally, however they required certain APIs (floor,
modf, frexp, atof) that are part of C floating point support. Changed
png_fixed and the gamma code specific version of the same to avoid floor(),
which may be a library function (not an intrinsic). Removed unused #if 0
code.
Disassembled the version number in scripts/options.awk (necessary for
building on SunOs).
Version 1.7.0alpha04 [December 23, 2012]
Added scripts/makefile.msys contributed by Christopher M. Wheeler
Version 1.6.0beta35 [December 23, 2012]
Made default Zlib compression settings be configurable. This adds #defines to
pnglibconf.h to control the defaults.
Fixed Windows build issues, enabled ARM compilation. Various warnings issued
@@ -4386,86 +4332,81 @@ Version 1.7.0alpha04 [December 23, 2012]
Microsoft) and ARM compilation is made possible by deleting the check for
x86. The test programs cannot be run because they are not signed.
Version 1.7.0alpha05 [December 24, 2012]
Version 1.6.0beta36 [January 2, 2013]
Discontinued distributing libpng-1.x.x.tar.bz2.
Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar.
Version 1.7.0alpha06 [January 1, 2013]
Rebuilt configure with autoconf-2.69 (inadvertently not done in beta33)
Fixed 'make distcheck' on SUN OS - libpng.so was not being removed
Version 1.7.0alpha07 [January 10, 2013]
Version 1.6.0beta37 [January 10, 2013]
Fixed conceivable but difficult to repro overflow. Also added two test
programs to generate and test a PNG which should have the problem.
Version 1.7.0alpha08 [January 17, 2013]
Corrected previous attempt at overflow detection in png_set_unknown_chunks().
Version 1.6.0beta39 [January 19, 2013]
Again corrected attempt at overflow detection in png_set_unknown_chunks().
Added overflow detection in png_set_sPLT() and png_set_text_2().
Version 1.7.0alpha09 [January 21, 2013]
Pulled changes to multi-chunk handling from libpng-1.6.0beta40.
Version 1.6.0beta40 [January 20, 2013]
Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs
Version 1.7.0alpha10 [February 5, 2013]
Make symbol prefixing work with the ARM neon optimizations. Also
allow pngpriv.h to be included for preprocessor definitions only, so
it can be used in non-C/C++ files.
Version 1.6.0rc01 [January 26, 2013]
No changes.
Version 1.6.0rc02 [February 4, 2013]
Added png_get_palette_max() function.
Changed png_size_t to size_t throughout headers, make sRGB check numbers
consistent.
Fixed ARM support (Mans Rullgard).
Removed stray out-of-order #endif and #ifdef (Mans Rullgard).
Ported libpng 1.5 options.awk/dfn file handling to 1.7, fixed one bug.
Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.13.
Minor fixes to assembler changes, verified with a dummy .S file
Removed cc -E workround, corrected png_get_palette_max API. Tested on
SUN OS cc 5.9, which demonstrates the tokenization problem previously
avoided by using /lib/cpp. Since all .dfn output is now protected
in double quotes unless it is to be macro substituted the fix should work
everywhere.
Version 1.7.0beta01 [February 15, 2013]
Enable parallel tests and rearrange TESTS order to take advantage of
the massive speed improvements use a make capable of parallel builds
on a multi-CPU machine and pass the right arguments to make (-j10000
for GNU make) to get the build to run in parallel.
Fixed previous support for Z_PREFIX in configure builds, corrected
sCAL APIs; some of these use floating point arithmetic so need to be
disabled if floating point arithmetic is switched off. This is a quiet API
change - previously it appeared that the APIs were supported if fixed point
arithmetic was used internally, however they required certain APIs (floor,
modf, frexp, atof) that are part of C floating point support. Changed
png_fixed and the gamma code specific version of the same to avoid floor(),
which may be a library function (not an intrinsic). Removed unused #if 0
code.
Fixed make distcheck to skip over the test result files. They were
being included because the whole of the 'tests' directory is included,
fixed to just include the actual test files and tests/pngstest. Also
reverted the previous erroneous change to remove the ${srcdir} from the
front of contrib, scripts, projects and added an explanation of what is
going on to Makefile.am
Fixed missing dependency in --prefix builds. The intermediate
internal 'prefix.h' file can only be generated correctly after pnglibconf.h,
however the dependency was not in Makefile.am. The symptoms are
unpredictable depending on the order make chooses to build pngprefix.h and
pnglibconf.h, often the error goes unnoticed because there is a system
pnglibconf.h to use instead.
Accept "," as a separator in pnglibconf.dfa and allow for
continuation lines. This adds to the syntax of "option" and "chunk" lines,
allowing the elements to be separated by a "," at the end of an element and
interpreting a "," at end of line as a continuation - so the following line
is read. The new syntax is optional and solely provided for readability.
Version 1.6.0rc03 [February 5, 2013]
Fixed the png_get_palette_max API.
Version 1.6.0rc04 [February 7, 2013]
Turn serial tests back on (recently turned off by autotools upgrade).
Version 1.6.0rc05 [February 8, 2013]
Update manual about png_get_palette_max().
Version 1.6.0rc06 [February 9, 2013]
Fixed missing dependency in --prefix builds The intermediate
internal 'prefix.h' file can only be generated correctly after
pnglibconf.h, however the dependency was not in Makefile.am. The
symptoms are unpredictable depending on the order make chooses to
build pngprefix.h and pnglibconf.h, often the error goes unnoticed
because there is a system pnglibconf.h to use instead.
Version 1.6.0rc07 [February 10, 2013]
Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly.
Version 1.7.0beta02 [February 18, 2013]
Version 1.6.0rc08 [February 10, 2013]
Fix typo in png.h #ifdef
Version 1.6.0 [February 14, 2013]
No changes.
Version 1.6.1beta01 [February 16, 2013]
Made symbol prefixing work with the ARM neon optimizations. Also allow
pngpriv.h to be included for preprocessor definitions only, so it can
be used in non-C/C++ files. Back ported from libpng 1.7.
Made sRGB check numbers consistent.
Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug.
Removed cc -E workround, corrected png_get_palette_max API Tested on
SUN OS cc 5.9, which demonstrates the tokenization problem previously
avoided by using /lib/cpp. Since all .dfn output is now protected in
double quotes unless it is to be macro substituted the fix should
work everywhere.
Enabled parallel tests - back ported from libpng-1.7.
scripts/pnglibconf.dfa formatting improvements back ported from libpng17.
Fixed a race condition in the creation of the build 'scripts' directory
while building with a parallel make.
Use approved/supported Android method to check for NEON, use Linux/POSIX
1003.1 API to check /proc/self/auxv avoiding buffer allocation and other
library calls (ported from libpng15).
Version 1.6.1beta02 [February 19, 2013]
Use parentheses more consistently in "#if defined(MACRO)" tests.
Folded long lines.
Version 1.7.0beta03 [February 22, 2013]
Reenabled code to allow zero length PLTE chunks for MNG.
Version 1.6.1beta03 [February 22, 2013]
Fixed ALIGNED_MEMORY support.
Allow run-time ARM NEON checking to be disabled. A new configure option:
--enable-arm-neon=always will stop the run-time checks. New checks
@@ -4474,28 +4415,27 @@ Version 1.7.0beta03 [February 22, 2013]
for it on then the build will fail if it can't be done.)
Updated the INSTALL document.
Version 1.7.0beta04 [February 27, 2013]
Version 1.6.1beta04 [February 27, 2013]
Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC.
Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
with CRLF line endings.
Version 1.7.0beta05 [March 5, 2013]
Version 1.6.1beta05 [March 1, 2013]
Avoid a possible memory leak in contrib/gregbook/readpng.c
Changed user chunk callback API to respect global and per chunk defaults.
Previously a return of 0 from a user chunk callback would result in the
chunk being saved (if this was safe, even if the chunk was unsafe-to-copy);
this change respects the defaults set by the application, so unknown chunks
can be discarded by default and known-safe ones preserved.
Version 1.6.1beta06 [March 4, 2013]
Better documentation of unknown handling API interactions.
Corrected Android builds and corrected libpng.vers with symbol
prefixing. This adds an API to set optimization options externally,
prefixing This adds an API to set optimization options externally,
providing an alternative and general solution for the non-portable
run-time tests used by the ARM Neon code. It also makes those tests
compile and link on Android. The order of settings vs options in
pnglibconf.h is reversed to allow settings to depend on options and
options can now set (or override) the defaults for settings.
compile and link on Android.
The order of settings vs options in pnglibconf.h is reversed to allow
settings to depend on options and options can now set (or override) the
defaults for settings.
Version 1.7.0beta06 [March 13, 2013]
Version 1.6.1beta07 [March 7, 2013]
Corrected simplified API default gamma for color-mapped output, added
a flag to change default. In 1.6.0 when the simplified API was used
to produce color-mapped output from an input image with no gamma
@@ -4508,6 +4448,8 @@ Version 1.7.0beta06 [March 13, 2013]
application/user to specify that 16-bit files contain sRGB data
rather than the default linear.
Fixed bugs in the pngpixel and makepng test programs.
Version 1.6.1beta08 [March 7, 2013]
Fixed CMakelists.txt to allow building a single variant of the library
(Claudio Bley):
Introduced a PNG_LIB_TARGETS variable that lists all activated library
@@ -4519,11 +4461,19 @@ Version 1.7.0beta06 [March 13, 2013]
first argument. When symlinking the filename component of that path is
determined and used as the link target.
Use copy_if_different in the CREATE_SYMLINK macro.
Version 1.6.1beta09 [March 13, 2013]
Eliminated two warnings from the Intel C compiler. The warnings are
technically valid, although a reasonable treatment of division would
show it to be incorrect.
Version 1.7.0beta07 [April 14, 2013]
Version 1.6.1rc01 [March 21, 2013]
No changes.
Version 1.6.1 [March 28, 2013]
No changes.
Version 1.6.2beta01 [April 14, 2013]
Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling.
Fixed incorrect warning of excess deflate data. End condition - the
warning would be produced if the end of the deflate stream wasn't read
@@ -4536,6 +4486,25 @@ Version 1.7.0beta07 [April 14, 2013]
(Flavio Medeiros).
Corrected length written to uncompressed iTXt chunks (Samuli Suominen).
Version 1.6.2rc01 [April 18, 2013]
Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length
written by libpng-1.6.0 and 1.6.1.
Disallow storing sRGB information when the sRGB is not supported.
Version 1.6.2rc02 [April 18, 2013]
Merge pngtest.c with libpng-1.7.0
Version 1.6.2rc03 [April 22, 2013]
Trivial spelling cleanup.
Version 1.6.2rc04 [April 22, 2013]
Revised stack marking in arm/filter_neon.S and configure.ac
Version 1.6.2rc05 [April 23, 2013]
Ensure that NEON filter stuff is completely disabled when switched 'off'.
Previously the ARM NEON specific files were still built if the option
was switched 'off' as opposed to being explicitly disabled.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@@ -34,8 +34,8 @@ project(libpng C)
enable_testing()
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 7)
set(PNGLIB_RELEASE 0)
set(PNGLIB_MINOR 6)
set(PNGLIB_RELEASE 2)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
@@ -271,9 +271,9 @@ 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.0beta07
VERSION 17.${PNGLIB_RELEASE}.0
SOVERSION 17
# VERSION 16.${PNGLIB_RELEASE}.1.6.2rc05
VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16
CLEAN_DIRECT_OUTPUT 1)
endif()
if(PNG_STATIC)
@@ -305,7 +305,7 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(PNG_SHARED)
# Create a symlink for libpng.dll.a => libpng17.dll.a on Cygwin
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(CYGWIN OR MINGW)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})

View File

@@ -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.0beta07, April 14, 2013, are
Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
libpng versions 1.2.6, August 15, 2004, through 1.6.2rc05, April 23, 2013, are
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
April 14, 2013
April 23, 2013

View File

@@ -143,8 +143,6 @@ scripts/prefix.out: png.h pngconf.h pnglibconf.out
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
scripts/intprefix.out: pnglibconf.h
pnglibconf.out: config.h
libpng.sym: scripts/sym.out
rm -f $@
cp $? $@
@@ -156,7 +154,7 @@ if DO_PNG_PREFIX
# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix.
# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual
# implementation of the macro).
pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst config.h
pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst
rm -f $@
$(AWK) 's==0 && NR>1{print prev}\
s==0{prev=$$0}\

2
README
View File

@@ -1,4 +1,4 @@
README for libpng version 1.7.0beta07 - April 14, 2013 (shared library 17.0)
README for libpng version 1.6.2rc05 - April 23, 2013 (shared library 16.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2013 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.5.15 [%RDATE%]
* Last changed in libpng 1.5.15 [March 28, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer

View File

@@ -1,9 +1,9 @@
/* filter_neon.S - NEON optimised filter functions
*
* Copyright (c) 2011 Glenn Randers-Pehrson
* Copyright (c) 2013 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.5.7 [December 15, 2011]
* Last changed in libpng 1.6.2 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -16,12 +16,13 @@
#define PNG_VERSION_INFO_ONLY
#include "../pngpriv.h"
#if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \
defined(__ARM_NEON__)
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif
#if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \
defined(__ARM_NEON__)
#ifdef __ELF__
# define ELF
#else

View File

@@ -18,7 +18,7 @@ AC_PREREQ([2.68])
dnl Version number stuff here:
AC_INIT([libpng],[1.7.0beta07],[png-mng-implement@lists.sourceforge.net])
AC_INIT([libpng],[1.6.2rc05],[png-mng-implement@lists.sourceforge.net])
AC_CONFIG_MACRO_DIR([scripts])
# libpng does not follow GNU file name conventions (hence 'foreign')
@@ -39,10 +39,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake
PNGLIB_VERSION=1.7.0beta07
PNGLIB_VERSION=1.6.2rc05
PNGLIB_MAJOR=1
PNGLIB_MINOR=7
PNGLIB_RELEASE=0
PNGLIB_MINOR=6
PNGLIB_RELEASE=2
dnl End of version number stuff
@@ -109,138 +109,30 @@ AC_ARG_ENABLE(werror,
# Checks for header files.
AC_HEADER_STDC
# Headers used in pngpriv.h:
AC_CHECK_HEADERS([assert.h stdlib.h string.h float.h fp.h math.h m68881.h])
# Additional headers used in pngconf.h:
AC_CHECK_HEADERS([limits.h stddef.h stdio.h setjmp.h time.h])
# Used by pngread.c (for the simplified API):
AC_CHECK_HEADERS([errno.h])
# The following are not required for the standard 'make' build of libpng:
# Additional requirements of contrib/libtests/makepng.c:
AC_CHECK_HEADERS([ctype.h])
# Additional requirements of contrib/libtests/pngvalid.c:
AC_CHECK_HEADERS([fenv.h])
# Checks for typedefs, structures, and compiler characteristics.
# Most of these have been removed from 1.7.0 because they checked for non-ANSI-C
# behaviors and the result were, anyway, not used by earlier versions of libpng.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_C_RESTRICT
# Checks for library functions; these need to be in order, least demanding to
# most because the -l directives are added to the head of the list at each
# check.
# ANSI-C functions: all are required but they don't have to be implemented in
# libc, it is perfectly ok to configure with an extra, wrapper, library preset
# in LIBS. NOTE: this list may not be complete
AC_CHECK_FUNCS([memset memcpy strncpy],,
AC_MSG_FAILURE([missing ANSI-C functions]))
# 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])
# Check for a requirement for math library support
if test "$enable_floating_arithmetic" = yes
then
AC_SEARCH_LIBS([floor],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
AC_SEARCH_LIBS([frexp],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
AC_SEARCH_LIBS([modf],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
AC_SEARCH_LIBS([atof],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
AC_SEARCH_LIBS([pow],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
fi
# Set the relevant defines if required (only if required), this will override
# anything on the command line.
if test "$enable_floating_point" != yes
then
AC_MSG_NOTICE([Floating point APIs disabled])
AC_DEFINE([PNG_NO_FLOATING_POINT],[1],
[No support for floating point APIs])
fi
if test "$enable_fixed_point" != yes
then
AC_MSG_NOTICE([Fixed point APIs disabled])
AC_DEFINE([PNG_NO_FIXED_POINT],[1],
[No support for fixed point APIs])
fi
if test "$enable_floating_arithmetic" != yes
then
AC_MSG_NOTICE([Fixed point arithmetic will be used])
AC_DEFINE([PNG_NO_FLOATING_ARITHMETIC],[1],
[No support for floating point arithmetic])
fi
# Checks for library functions.
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
AC_ARG_WITH(zlib-prefix,
AS_HELP_STRING([[[--with-zlib-prefix]]],
[prefix that may have been used in installed zlib]),
[ZPREFIX=${withval}],
[ZPREFIX='z_'])
AC_CHECK_LIB(z, zlibVersion, ,
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
# The following is for pngvalid, to ensure it catches FP errors even on
# platforms that don't enable FP exceptions, the function appears in the math
# library (typically), it's not an error if it is not found.
AC_SEARCH_LIBS([feenableexcept],[m],AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],
[Define to 1 if the feenableexcept function is available]))
# Required by pngvalid:
AC_SEARCH_LIBS([ceil],[m])
# zlib checks and arguments;
# package zlib: argument is the name of the library
# zlib-header: the name of the header file
# zlib-prefix: the prefix for library functions, if any
AC_ARG_WITH([zlib],
AS_HELP_STRING([[[--with-zlib=<name>]]],
[base name of the zlib implementation (e.g. 'z')]),,
[with_zlib='z'])
z_prefix=
AC_ARG_WITH([zlib-prefix],
AS_HELP_STRING([[[--with-zlib-prefix=<prefix>]]],
[prefix for zlib API functions]),
[if test "$withval" = "" -o "$withval" = yes; then
with_zlib_prefix='z_'
AC_DEFINE([PNG_ZLIB_PREFIX],[z_],[Standard zlib prefix])
elif test "${withval}" != "no"; then
AC_DEFINE_UNQUOTED([PNG_ZLIB_PREFIX],[${withval}],
[User defined zlib prefix])
else
with_zlib_prefix=
fi
if test "$with_zlib_prefix" != ""; then
AC_DEFINE([Z_PREFIX],[1],[Tell zlib.h to prefix function names])
z_prefix="#define Z_PREFIX 1"
fi])
AC_ARG_WITH([zlib-header],
AS_HELP_STRING([[[--with-zlib-header='<file>' or '"file"']]],
[C include argument to locate zlib header file, e.g. <zlib.h>, take
care to put single quotes round this on the command line]),
[AC_DEFINE_UNQUOTED([PNG_ZLIB_HEADER],[${withval}],[Zlib header file])],
with_zlib_header='<zlib.h>')
# AC_CHECK_LIB isn't quite enough for this because we need the special header
# file too.
LIBS="-l${with_zlib} $LIBS"
AC_MSG_CHECKING(
[[Library '${with_zlib}' and #include ${with_zlib_header} for symbol '${with_zlib_prefix}zlibVersion']])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
${z_prefix}
#include ${with_zlib_header}
]],
[[(void)${with_zlib_prefix}zlibVersion();]])],
AC_MSG_RESULT([ok]),
AC_MSG_FAILURE([not found]))
AC_CHECK_LIB([m], [feenableexcept])
AC_CHECK_FUNCS([feenableexcept])
AC_MSG_CHECKING([if using Solaris linker])
SLD=`$LD --version 2>&1 | grep Solaris`
@@ -334,11 +226,6 @@ AC_ARG_WITH(libpng-prefix,
fi])
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
# Because GCC by default assembles code with an executable stack, even though it
# compiles C code with a non-executable stack, it is necessary to do a fixup
# here (this may by GCC specific)
AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
AC_ARG_ENABLE([arm-neon],
AS_HELP_STRING([[[--enable-arm-neon]]],
[Enable ARM NEON optimizations: =off, check, api, on:]
@@ -347,9 +234,12 @@ AC_ARG_ENABLE([arm-neon],
[a call to png_set_option; on: turn on unconditionally. The]
[default is 'on' if __ARM_NEON__ is defined, otherwise 'off'.]),
[case "$enableval" in
off)
no|off)
# disable the default enabling on __ARM_NEON__ systems:
AC_DEFINE([PNG_NO_ARM_NEON], [],
[Disable ARM Neon optimizations]);;
[Disable ARM Neon optimizations])
# Prevent use of the assembler files below:
enable_arm_neon=no;;
check)
AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
[Check for ARM Neon support at run-time]);;
@@ -367,7 +257,8 @@ AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" != "no"])
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
# Config files, substituting as above
AC_CONFIG_FILES([Makefile libpng.pc])
AC_CONFIG_FILES([libpng-config], [chmod +x libpng-config])
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
AC_CONFIG_FILES([libpng-config:libpng-config.in],
[chmod +x libpng-config])
AC_OUTPUT

View File

@@ -23,9 +23,9 @@
# macros --------------------------------------------------------------------
PNGINC = -I/usr/local/include/libpng17
PNGLIB = -L/usr/local/lib -lpng17 # dynamically linked against libpng
#PNGLIB = /usr/local/lib/libpng17.a # statically linked against libpng
PNGINC = -I/usr/local/include/libpng16
PNGLIB = -L/usr/local/lib -lpng16 # dynamically linked against libpng
#PNGLIB = /usr/local/lib/libpng16.a # statically linked against libpng
# or:
#PNGINC = -I../..
#PNGLIB = -L../.. -lpng

View File

@@ -26,14 +26,14 @@
# macros --------------------------------------------------------------------
#PNGDIR = /usr/local/lib
#PNGINC = -I/usr/local/include/libpng17
#PNGLIBd = -L$(PNGDIR) -lpng17 # dynamically linked, installed libpng
#PNGLIBs = $(PNGDIR)/libpng17.a # statically linked, installed libpng
#PNGINC = -I/usr/local/include/libpng16
#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng
#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng
# or:
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
#PNGDIR = ../libpng
PNGINC = -I$(PNGDIR)
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng17 # dynamically linked
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
ZDIR = /usr/local/lib

View File

@@ -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

View File

@@ -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

View File

@@ -1,9 +1,9 @@
/*-
* pngstest.c
*
* Copyright (c) 2012 John Cunningham Bowler
* Copyright (c) 2013 John Cunningham Bowler
*
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.1 [March 28, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer

View File

@@ -1,8 +1,8 @@
/* pngunknown.c - test the read side unknown chunk handling
*
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
* Copyright (c) 2012 Glenn Randers-Pehrson
* Last changed in libpng 1.6.0 [February 14, 2013]
* Copyright (c) 2013 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
* This code is released under the libpng license.
@@ -139,23 +139,128 @@ static struct
{ "PLTE", PNG_INFO_PLTE, png_PLTE, 0, 0, ABSENT, 0 },
/* Non-critical chunks that libpng handles */
{ "bKGD", PNG_INFO_bKGD, png_bKGD, 0, 1, START, 0 },
{ "cHRM", PNG_INFO_cHRM, png_cHRM, 0, 1, START, 0 },
{ "gAMA", PNG_INFO_gAMA, png_gAMA, 0, 1, START, 0 },
{ "hIST", PNG_INFO_hIST, png_hIST, 0, 1, ABSENT, 0 },
{ "iCCP", PNG_INFO_iCCP, png_iCCP, 0, 1, ABSENT, 0 },
{ "iTXt", PNG_INFO_iTXt, png_iTXt, 0, 1, ABSENT, 0 },
{ "oFFs", PNG_INFO_oFFs, png_oFFs, 0, 1, START, 0 },
{ "pCAL", PNG_INFO_pCAL, png_pCAL, 0, 1, START, 0 },
{ "pHYs", PNG_INFO_pHYs, png_pHYs, 0, 1, START, 0 },
{ "sBIT", PNG_INFO_sBIT, png_sBIT, 0, 1, START, 0 },
{ "sCAL", PNG_INFO_sCAL, png_sCAL, 0, 1, START, 0 },
{ "sPLT", PNG_INFO_sPLT, png_sPLT, 0, 1, ABSENT, 0 },
{ "sRGB", PNG_INFO_sRGB, png_sRGB, 0, 1, START, 0 },
{ "tEXt", PNG_INFO_tEXt, png_tEXt, 0, 1, START, 0 },
{ "tIME", PNG_INFO_tIME, png_tIME, 0, 1, START, 0 },
{ "tRNS", PNG_INFO_tRNS, png_tRNS, 0, 0, ABSENT, 0 },
{ "zTXt", PNG_INFO_zTXt, png_zTXt, 0, 1, END, 0 },
/* This is a mess but it seems to be the only way to do it - there is no way to
* check for definition outside a #if.
*/
{ "bKGD", PNG_INFO_bKGD, png_bKGD,
# ifdef PNG_READ_bKGD_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "cHRM", PNG_INFO_cHRM, png_cHRM,
# ifdef PNG_READ_cHRM_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "gAMA", PNG_INFO_gAMA, png_gAMA,
# ifdef PNG_READ_gAMA_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "hIST", PNG_INFO_hIST, png_hIST,
# ifdef PNG_READ_hIST_SUPPORTED
0,
# else
1,
# endif
1, ABSENT, 0 },
{ "iCCP", PNG_INFO_iCCP, png_iCCP,
# ifdef PNG_READ_iCCP_SUPPORTED
0,
# else
1,
# endif
1, ABSENT, 0 },
{ "iTXt", PNG_INFO_iTXt, png_iTXt,
# ifdef PNG_READ_iTXt_SUPPORTED
0,
# else
1,
# endif
1, ABSENT, 0 },
{ "oFFs", PNG_INFO_oFFs, png_oFFs,
# ifdef PNG_READ_oFFs_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "pCAL", PNG_INFO_pCAL, png_pCAL,
# ifdef PNG_READ_pCAL_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "pHYs", PNG_INFO_pHYs, png_pHYs,
# ifdef PNG_READ_pHYs_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "sBIT", PNG_INFO_sBIT, png_sBIT,
# ifdef PNG_READ_sBIT_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "sCAL", PNG_INFO_sCAL, png_sCAL,
# ifdef PNG_READ_sCAL_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "sPLT", PNG_INFO_sPLT, png_sPLT,
# ifdef PNG_READ_sPLT_SUPPORTED
0,
# else
1,
# endif
1, ABSENT, 0 },
{ "sRGB", PNG_INFO_sRGB, png_sRGB,
# ifdef PNG_READ_sRGB_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "tEXt", PNG_INFO_tEXt, png_tEXt,
# ifdef PNG_READ_tEXt_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "tIME", PNG_INFO_tIME, png_tIME,
# ifdef PNG_READ_tIME_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "tRNS", PNG_INFO_tRNS, png_tRNS,
# ifdef PNG_READ_tRNS_SUPPORTED
0,
# else
1,
# endif
0, ABSENT, 0 },
{ "zTXt", PNG_INFO_zTXt, png_zTXt,
# ifdef PNG_READ_zTXt_SUPPORTED
0,
# else
1,
# endif
1, END, 0 },
/* No libpng handling */
{ "sTER", PNG_INFO_sTER, png_sTER, 1, 1, START, 0 },
@@ -955,6 +1060,7 @@ main(void)
{
fprintf(stderr,
" test ignored because libpng was not built with unknown chunk support\n");
return 0;
/* So the test is skipped: */
return 77;
}
#endif

View File

@@ -1,8 +1,8 @@
/* pngvalid.c - validate libpng by constructing then reading png files.
*
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
* Copyright (c) 2012 Glenn Randers-Pehrson
* Last changed in libpng 1.6.1 [March 28, 2013]
* Copyright (c) 2013 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
* This code is released under the libpng license.
@@ -39,10 +39,8 @@
*/
#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 */
@@ -90,6 +88,8 @@ typedef png_byte *png_const_bytep;
# define png_const_structp png_structp
#endif
#include <zlib.h> /* For crc32 */
#include <float.h> /* For floating point constants */
#include <stdlib.h> /* For malloc */
#include <string.h> /* For memcpy, memset */
@@ -344,16 +344,11 @@ standard_name_from_id(char *buffer, size_t bufsize, size_t pos, png_uint_32 id)
static int
next_format(png_bytep colour_type, png_bytep bit_depth,
unsigned int* palette_number, int no_low_depth_gray)
unsigned int* palette_number)
{
if (*bit_depth == 0)
{
*colour_type = 0;
if (no_low_depth_gray)
*bit_depth = 8;
else
*bit_depth = 1;
*palette_number = 0;
*colour_type = 0, *bit_depth = 1, *palette_number = 0;
return 1;
}
@@ -1833,7 +1828,6 @@ typedef struct png_modifier
double maxout16; /* Maximum output value error */
double maxabs16; /* Absolute sample error 0..1 */
double maxcalc16;/* Absolute sample error 0..1 */
double maxcalcG; /* Absolute sample error 0..1 */
double maxpc16; /* Percentage sample error 0..100% */
/* This is set by transforms that need to allow a higher limit, it is an
@@ -1873,15 +1867,10 @@ typedef struct png_modifier
/* Run the odd-sized image and interlace read/write tests? */
unsigned int test_size :1;
/* Run tests on reading with a combination of transforms, */
/* Run tests on reading with a combiniation of transforms, */
unsigned int test_transform :1;
/* When to use the use_input_precision option, this controls the gamma
* validation code checks. If set any value that is within the transformed
* range input-.5 to input+.5 will be accepted, otherwise the value must be
* within the normal limits. It should not be necessary to set this; the
* result should always be exact within the permitted error limits.
*/
/* When to use the use_input_precision option: */
unsigned int use_input_precision :1;
unsigned int use_input_precision_sbit :1;
unsigned int use_input_precision_16to8 :1;
@@ -1891,8 +1880,8 @@ typedef struct png_modifier
*/
unsigned int calculations_use_input_precision :1;
/* If set assume that the calculations are done in 16 bits even if the sample
* depth is 8 bits.
/* If set assume that the calculations are done in 16 bits even if both input
* and output are 8 bit or less.
*/
unsigned int assume_16_bit_calculations :1;
@@ -1947,7 +1936,6 @@ modifier_init(png_modifier *pm)
pm->test_uses_encoding = 0;
pm->maxout8 = pm->maxpc8 = pm->maxabs8 = pm->maxcalc8 = 0;
pm->maxout16 = pm->maxpc16 = pm->maxabs16 = pm->maxcalc16 = 0;
pm->maxcalcG = 0;
pm->limit = 4E-3;
pm->log8 = pm->log16 = 0; /* Means 'off' */
pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0;
@@ -1962,7 +1950,6 @@ modifier_init(png_modifier *pm)
pm->use_input_precision_sbit = 0;
pm->use_input_precision_16to8 = 0;
pm->calculations_use_input_precision = 0;
pm->assume_16_bit_calculations = 0;
pm->test_gamma_threshold = 0;
pm->test_gamma_transform = 0;
pm->test_gamma_sbit = 0;
@@ -1977,16 +1964,8 @@ modifier_init(png_modifier *pm)
}
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
/* This controls use of checks that explicitly know how libpng digitizes the
* samples in calculations; setting this circumvents simple error limit checking
* in the rgb_to_gray check, replacing it with an exact copy of the libpng 1.5
* algorithm.
*/
#define DIGITIZE PNG_LIBPNG_VER < 10700
/* If pm->calculations_use_input_precision is set then operations will happen
* with the precision of the input, not the precision of the output depth.
* with only 8 bit precision unless both the input and output bit depth are 16.
*
* If pm->assume_16_bit_calculations is set then even 8 bit calculations use 16
* bit precision. This only affects those of the following limits that pertain
@@ -1994,8 +1973,8 @@ modifier_init(png_modifier *pm)
* called directly.
*/
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
#if DIGITIZE
static double digitize(double value, int depth, int do_round)
static double digitize(PNG_CONST png_modifier *pm, double value,
int sample_depth, int do_round)
{
/* 'value' is in the range 0 to 1, the result is the same value rounded to a
* multiple of the digitization factor - 8 or 16 bits depending on both the
@@ -2003,14 +1982,14 @@ static double digitize(double value, int depth, int do_round)
* rounding and 'do_round' should be 1, if it is 0 the digitized value will
* be truncated.
*/
PNG_CONST unsigned int digitization_factor = (1U << depth) -1;
PNG_CONST unsigned int digitization_factor =
(pm->assume_16_bit_calculations || sample_depth == 16) ? 65535 : 255;
/* Limiting the range is done as a convenience to the caller - it's easier to
* do it once here than every time at the call site.
*/
if (value <= 0)
value = 0;
else if (value >= 1)
value = 1;
@@ -2019,30 +1998,31 @@ static double digitize(double value, int depth, int do_round)
return floor(value)/digitization_factor;
}
#endif
#endif /* RGB_TO_GRAY */
#ifdef PNG_READ_GAMMA_SUPPORTED
#if defined(PNG_READ_GAMMA_SUPPORTED) ||\
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
{
/* Absolute error permitted in linear values - affected by the bit depth of
* the calculations.
*/
if (pm->assume_16_bit_calculations ||
(pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
if (pm->assume_16_bit_calculations || (out_depth == 16 && (in_depth == 16 ||
!pm->calculations_use_input_precision)))
return pm->maxabs16;
else
return pm->maxabs8;
}
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
static double calcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
{
/* Error in the linear composition arithmetic - only relevant when
* composition actually happens (0 < alpha < 1).
*/
if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
if (pm->assume_16_bit_calculations || (out_depth == 16 && (in_depth == 16 ||
!pm->calculations_use_input_precision)))
return pm->maxcalc16;
else if (pm->assume_16_bit_calculations)
return pm->maxcalcG;
else
return pm->maxcalc8;
}
@@ -2052,8 +2032,8 @@ static double pcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
/* Percentage error permitted in the linear values. Note that the specified
* value is a percentage but this routine returns a simple number.
*/
if (pm->assume_16_bit_calculations ||
(pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
if (pm->assume_16_bit_calculations || (out_depth == 16 && (in_depth == 16 ||
!pm->calculations_use_input_precision)))
return pm->maxpc16 * .01;
else
return pm->maxpc8 * .01;
@@ -2085,7 +2065,8 @@ static double outerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
if (out_depth == 4)
return .90644-.5;
if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
if (out_depth == 16 && (in_depth == 16 ||
!pm->calculations_use_input_precision))
return pm->maxout16;
/* This is the case where the value was calculated at 8-bit precision then
@@ -2118,7 +2099,8 @@ static double outlog(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
return pm->log8;
}
if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
if (out_depth == 16 && (in_depth == 16 ||
!pm->calculations_use_input_precision))
{
if (pm->log16 == 0)
return 65536;
@@ -2143,8 +2125,8 @@ static double outlog(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
static int output_quantization_factor(PNG_CONST png_modifier *pm, int in_depth,
int out_depth)
{
if (out_depth == 16 && in_depth != 16 &&
pm->calculations_use_input_precision)
if (out_depth == 16 && in_depth != 16
&& pm->calculations_use_input_precision)
return 257;
else
return 1;
@@ -3491,7 +3473,7 @@ make_transform_images(png_store *ps)
/* Use next_format to enumerate all the combinations we test, including
* generating multiple low bit depth palette images.
*/
while (next_format(&colour_type, &bit_depth, &palette_number, 0))
while (next_format(&colour_type, &bit_depth, &palette_number))
{
int interlace_type;
@@ -5806,9 +5788,12 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
memset(out_palette, 0x5e, sizeof out_palette);
/* use-input-precision means assume that if the input has 8 bit (or less)
* samples and the output has 16 bit samples the calculations will be done
* with 8 bit precision, not 16.
/* assume-8-bit-calculations means assume that if the input has 8 bit
* (or less) samples and the output has 16 bit samples the calculations
* will be done with 8 bit precision, not 16.
*
* TODO: fix this in libpng; png_set_expand_16 should cause 16 bit
* calculations to be used throughout.
*/
if (in_ct == PNG_COLOR_TYPE_PALETTE || in_bd < 16)
in_sample_depth = 8;
@@ -5819,8 +5804,7 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
!dp->pm->calculations_use_input_precision)
digitization_error = .5;
/* Else calculations are at 8 bit precision, and the output actually
* consists of scaled 8-bit values, so scale .5 in 8 bits to the 16 bits:
/* Else errors are at 8 bit precision, scale .5 in 8 bits to the 16 bits:
*/
else
digitization_error = .5 * 257;
@@ -6636,23 +6620,10 @@ image_transform_png_set_rgb_to_gray_ini(PNG_CONST image_transform *this,
{
if (that->this.bit_depth == 16 || pm->assume_16_bit_calculations)
{
/* The computations have the form:
*
* r * rc + g * gc + b * bc
*
* Each component of which is +/-1/65535 from the gamma_to_1 table
* lookup, resulting in a base error of +/-6. The gamma_from_1
* conversion adds another +/-2 in the 16-bit case and
* +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case.
/* The 16 bit case ends up producing a maximum error of about
* +/-5 in 65535, allow for +/-8 with the given gamma.
*/
that->pm->limit += pow(
# if PNG_MAX_GAMMA_8 < 14
(that->this.bit_depth == 16 ? 8. :
6. + (1<<(15-PNG_MAX_GAMMA_8)))
# else
8.
# endif
/65535, data.gamma);
that->pm->limit += pow(8./65535, data.gamma);
}
else
@@ -6670,7 +6641,7 @@ image_transform_png_set_rgb_to_gray_ini(PNG_CONST image_transform *this,
/* With no gamma correction a large error comes from the truncation of the
* calculation in the 8 bit case, allow for that here.
*/
if (that->this.bit_depth != 16 && !pm->assume_16_bit_calculations)
if (that->this.bit_depth != 16)
that->pm->limit += 4E-3;
}
}
@@ -6815,14 +6786,9 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
image_pixel_convert_PLTE(that);
/* Image now has RGB channels... */
# if DIGITIZE
{
PNG_CONST png_modifier *pm = display->pm;
const unsigned int sample_depth = that->sample_depth;
const unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 :
sample_depth);
const unsigned int gamma_depth = (sample_depth == 16 ? 16 :
(pm->assume_16_bit_calculations ? PNG_MAX_GAMMA_8 : sample_depth));
PNG_CONST unsigned int sample_depth = that->sample_depth;
int isgray;
double r, g, b;
double rlo, rhi, glo, ghi, blo, bhi, graylo, grayhi;
@@ -6838,28 +6804,28 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
*/
r = rlo = rhi = that->redf;
rlo -= that->rede;
rlo = digitize(rlo, calc_depth, 1/*round*/);
rlo = digitize(pm, rlo, sample_depth, 1/*round*/);
rhi += that->rede;
rhi = digitize(rhi, calc_depth, 1/*round*/);
rhi = digitize(pm, rhi, sample_depth, 1/*round*/);
g = glo = ghi = that->greenf;
glo -= that->greene;
glo = digitize(glo, calc_depth, 1/*round*/);
glo = digitize(pm, glo, sample_depth, 1/*round*/);
ghi += that->greene;
ghi = digitize(ghi, calc_depth, 1/*round*/);
ghi = digitize(pm, ghi, sample_depth, 1/*round*/);
b = blo = bhi = that->bluef;
blo -= that->bluee;
blo = digitize(blo, calc_depth, 1/*round*/);
blo = digitize(pm, blo, sample_depth, 1/*round*/);
bhi += that->greene;
bhi = digitize(bhi, calc_depth, 1/*round*/);
bhi = digitize(pm, bhi, sample_depth, 1/*round*/);
isgray = r==g && g==b;
if (data.gamma != 1)
{
PNG_CONST double power = 1/data.gamma;
PNG_CONST double abse = calc_depth == 16 ? .5/65535 : .5/255;
PNG_CONST double abse = abserr(pm, sample_depth, sample_depth);
/* 'abse' is the absolute error permitted in linear calculations. It
* is used here to capture the error permitted in the handling
@@ -6868,16 +6834,16 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
* where the real errors are introduced.
*/
r = pow(r, power);
rlo = digitize(pow(rlo, power)-abse, calc_depth, 1);
rhi = digitize(pow(rhi, power)+abse, calc_depth, 1);
rlo = digitize(pm, pow(rlo, power)-abse, sample_depth, 1);
rhi = digitize(pm, pow(rhi, power)+abse, sample_depth, 1);
g = pow(g, power);
glo = digitize(pow(glo, power)-abse, calc_depth, 1);
ghi = digitize(pow(ghi, power)+abse, calc_depth, 1);
glo = digitize(pm, pow(glo, power)-abse, sample_depth, 1);
ghi = digitize(pm, pow(ghi, power)+abse, sample_depth, 1);
b = pow(b, power);
blo = digitize(pow(blo, power)-abse, calc_depth, 1);
bhi = digitize(pow(bhi, power)+abse, calc_depth, 1);
blo = digitize(pm, pow(blo, power)-abse, sample_depth, 1);
bhi = digitize(pm, pow(bhi, power)+abse, sample_depth, 1);
}
/* Now calculate the actual gray values. Although the error in the
@@ -6894,18 +6860,18 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
b * data.blue_coefficient;
{
PNG_CONST int do_round = data.gamma != 1 || calc_depth == 16;
PNG_CONST int do_round = data.gamma != 1 || sample_depth == 16;
PNG_CONST double ce = 1. / 32768;
graylo = digitize(rlo * (data.red_coefficient-ce) +
graylo = digitize(pm, rlo * (data.red_coefficient-ce) +
glo * (data.green_coefficient-ce) +
blo * (data.blue_coefficient-ce), gamma_depth, do_round);
blo * (data.blue_coefficient-ce), sample_depth, do_round);
if (graylo <= 0)
graylo = 0;
grayhi = digitize(rhi * (data.red_coefficient+ce) +
grayhi = digitize(pm, rhi * (data.red_coefficient+ce) +
ghi * (data.green_coefficient+ce) +
bhi * (data.blue_coefficient+ce), gamma_depth, do_round);
bhi * (data.blue_coefficient+ce), sample_depth, do_round);
if (grayhi >= 1)
grayhi = 1;
}
@@ -6916,8 +6882,8 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
PNG_CONST double power = data.gamma;
gray = pow(gray, power);
graylo = digitize(pow(graylo, power), sample_depth, 1);
grayhi = digitize(pow(grayhi, power), sample_depth, 1);
graylo = digitize(pm, pow(graylo, power), sample_depth, 1);
grayhi = digitize(pm, pow(grayhi, power), sample_depth, 1);
}
/* Now the error can be calculated.
@@ -6935,7 +6901,7 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
err = fabs(graylo-gray);
/* Check that this worked: */
if (err > pm->limit)
if (err > display->pm->limit)
{
size_t pos = 0;
char buffer[128];
@@ -6943,120 +6909,12 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
pos = safecat(buffer, sizeof buffer, pos, "rgb_to_gray error ");
pos = safecatd(buffer, sizeof buffer, pos, err, 6);
pos = safecat(buffer, sizeof buffer, pos, " exceeds limit ");
pos = safecatd(buffer, sizeof buffer, pos, pm->limit, 6);
pos = safecatd(buffer, sizeof buffer, pos,
display->pm->limit, 6);
png_error(pp, buffer);
}
}
}
# else /* DIGITIZE */
{
double r = that->redf;
double re = that->rede;
double g = that->greenf;
double ge = that->greene;
double b = that->bluef;
double be = that->bluee;
/* The true gray case involves no math. */
if (r == g && r == b)
{
gray = r;
err = re;
if (err < ge) err = ge;
if (err < be) err = be;
}
else if (data.gamma == 1)
{
/* There is no need to do the conversions to and from linear space,
* so the calculation should be a lot more accurate. There is a
* built in 1/32768 error in the coefficients because they only have
* 15 bits and are adjusted to make sure they add up to 32768, so
* the result may have an additional error up to 1/32768. (Note
* that adding the 1/32768 here avoids needing to increase the
* global error limits to take this into account.)
*/
gray = r * data.red_coefficient + g * data.green_coefficient +
b * data.blue_coefficient;
err = re * data.red_coefficient + ge * data.green_coefficient +
be * data.blue_coefficient + 1./32768 + gray * 5 * DBL_EPSILON;
}
else
{
/* The calculation happens in linear space, and this produces much
* wider errors in the encoded space. These are handled here by
* factoring the errors in to the calculation. There are two table
* lookups in the calculation and each introduces a quantization
* error defined by the table size.
*/
PNG_CONST png_modifier *pm = display->pm;
double in_qe = (that->sample_depth > 8 ? .5/65535 : .5/255);
double out_qe = (that->sample_depth > 8 ? .5/65535 :
(pm->assume_16_bit_calculations ? .5/(1<<PNG_MAX_GAMMA_8) :
.5/255));
double rhi, ghi, bhi, grayhi;
double g1 = 1/data.gamma;
rhi = r + re + in_qe; if (rhi > 1) rhi = 1;
r -= re + in_qe; if (r < 0) r = 0;
ghi = g + ge + in_qe; if (ghi > 1) ghi = 1;
g -= ge + in_qe; if (g < 0) g = 0;
bhi = b + be + in_qe; if (bhi > 1) bhi = 1;
b -= be + in_qe; if (b < 0) b = 0;
r = pow(r, g1)*(1-DBL_EPSILON); rhi = pow(rhi, g1)*(1+DBL_EPSILON);
g = pow(g, g1)*(1-DBL_EPSILON); ghi = pow(ghi, g1)*(1+DBL_EPSILON);
b = pow(b, g1)*(1-DBL_EPSILON); bhi = pow(bhi, g1)*(1+DBL_EPSILON);
/* Work out the lower and upper bounds for the gray value in the
* encoded space, then work out an average and error. Remove the
* previously added input quantization error at this point.
*/
gray = r * data.red_coefficient + g * data.green_coefficient +
b * data.blue_coefficient - 1./32768 - out_qe;
if (gray <= 0)
gray = 0;
else
{
gray *= (1 - 6 * DBL_EPSILON);
gray = pow(gray, data.gamma) * (1-DBL_EPSILON);
}
grayhi = rhi * data.red_coefficient + ghi * data.green_coefficient +
bhi * data.blue_coefficient + 1./32768 + out_qe;
grayhi *= (1 + 6 * DBL_EPSILON);
if (grayhi >= 1)
grayhi = 1;
else
grayhi = pow(grayhi, data.gamma) * (1+DBL_EPSILON);
err = (grayhi - gray) / 2;
gray = (grayhi + gray) / 2;
if (err <= in_qe)
err = gray * DBL_EPSILON;
else
err -= in_qe;
/* Validate that the error is within limits (this has caused
* problems before, it's much easier to detect them here.)
*/
if (err > pm->limit)
{
size_t pos = 0;
char buffer[128];
pos = safecat(buffer, sizeof buffer, pos, "rgb_to_gray error ");
pos = safecatd(buffer, sizeof buffer, pos, err, 6);
pos = safecat(buffer, sizeof buffer, pos, " exceeds limit ");
pos = safecatd(buffer, sizeof buffer, pos, pm->limit, 6);
png_error(pp, buffer);
}
}
}
# endif /* !DIGITIZE */
that->bluef = that->greenf = that->redf = gray;
that->bluee = that->greene = that->rede = err;
@@ -7105,7 +6963,7 @@ IT(rgb_to_gray);
* int background_gamma_code, int need_expand,
* png_fixed_point background_gamma)
*
* This ignores the gamma (at present.)
* As with rgb_to_gray this ignores the gamma (at present.)
*/
#define data ITDATA(background)
static image_pixel data;
@@ -7116,7 +6974,6 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
{
png_byte colour_type, bit_depth;
png_byte random_bytes[8]; /* 8 bytes - 64 bits - the biggest pixel */
int expand;
png_color_16 back;
/* We need a background colour, because we don't know exactly what transforms
@@ -7134,14 +6991,10 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
{
colour_type = PNG_COLOR_TYPE_RGB;
bit_depth = 8;
expand = 0; /* passing in an RGB not a pixel index */
}
else
{
bit_depth = that->this.bit_depth;
expand = 1;
}
image_pixel_init(&data, random_bytes, colour_type,
bit_depth, 0/*x*/, 0/*unused: palette*/);
@@ -7162,9 +7015,11 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
back.gray = (png_uint_16)data.red;
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_set_background(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0);
png_set_background(pp, &back, PNG_BACKGROUND_GAMMA_FILE, 1/*need expand*/,
0);
# else
png_set_background_fixed(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0);
png_set_background_fixed(pp, &back, PNG_BACKGROUND_GAMMA_FILE,
1/*need expand*/, 0);
# endif
this->next->set(this->next, that, pp, pi);
@@ -7496,7 +7351,7 @@ perform_transform_test(png_modifier *pm)
png_byte bit_depth = 0;
unsigned int palette_number = 0;
while (next_format(&colour_type, &bit_depth, &palette_number, 0))
while (next_format(&colour_type, &bit_depth, &palette_number))
{
png_uint_32 counter = 0;
size_t base_pos;
@@ -8181,25 +8036,14 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi,
* passed. Don't do these additional tests here - just log the
* original [es_lo..es_hi] values.
*/
if (pass == 0 && vi->use_input_precision && vi->dp->sbit)
if (pass == 0 && vi->use_input_precision)
{
/* Ok, something is wrong - this actually happens in current libpng
* 16-to-8 processing. Assume that the input value (id, adjusted
* for sbit) can be anywhere between value-.5 and value+.5 - quite a
* large range if sbit is low.
*
* NOTE: at present because the libpng gamma table stuff has been
* changed to use a rounding algorithm to correct errors in 8-bit
* calculations the precise sbit calculation (a shift) has been
* lost. This can result in up to a +/-1 error in the presence of
* an sbit less than the bit depth.
*/
# if PNG_LIBPNG_VER < 10700
# define SBIT_ERROR .5
# else
# define SBIT_ERROR 1.
# endif
double tmp = (isbit - SBIT_ERROR)/sbit_max;
double tmp = (isbit - .5)/sbit_max;
if (tmp <= 0)
tmp = 0;
@@ -8218,10 +8062,10 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi,
if (is_lo < 0)
is_lo = 0;
tmp = (isbit + SBIT_ERROR)/sbit_max;
tmp = (isbit + .5)/sbit_max;
if (tmp >= 1)
tmp = 1;
if (tmp <= 0)
tmp = 0;
else if (alpha >= 0 && vi->file_inverse > 0 && tmp < 1)
tmp = pow(tmp, vi->file_inverse);
@@ -8538,7 +8382,7 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
* Because there is limited precision in the input it is arguable that
* an acceptable result is any valid result from input-.5 to input+.5.
* The basic tests below do not do this, however if 'use_input_precision'
* is set a subsequent test is performed above.
* is set a subsequent test is performed below.
*/
PNG_CONST unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
int processing;
@@ -8880,7 +8724,7 @@ perform_gamma_threshold_tests(png_modifier *pm)
* fact this test is somewhat excessive since libpng doesn't make this
* decision based on colour type or bit depth!
*/
while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/))
while (next_format(&colour_type, &bit_depth, &palette_number))
if (palette_number == 0)
{
double test_gamma = 1.0;
@@ -8941,7 +8785,7 @@ static void perform_gamma_transform_tests(png_modifier *pm)
png_byte bit_depth = 0;
unsigned int palette_number = 0;
while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/))
while (next_format(&colour_type, &bit_depth, &palette_number))
{
unsigned int i, j;
@@ -8971,7 +8815,7 @@ static void perform_gamma_sbit_tests(png_modifier *pm)
png_byte colour_type = 0, bit_depth = 0;
unsigned int npalette = 0;
while (next_format(&colour_type, &bit_depth, &npalette, 1/*gamma*/))
while (next_format(&colour_type, &bit_depth, &npalette))
if ((colour_type & PNG_COLOR_MASK_ALPHA) == 0 &&
((colour_type == 3 && sbit < 8) ||
(colour_type != 3 && sbit < bit_depth)))
@@ -9006,7 +8850,6 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
# ifndef PNG_MAX_GAMMA_8
# define PNG_MAX_GAMMA_8 11
# endif
# define SBIT_16_TO_8 PNG_MAX_GAMMA_8
/* Include the alpha cases here. Note that sbit matches the internal value
* used by the library - otherwise we will get spurious errors from the
* internal sbit style approximation.
@@ -9024,28 +8867,28 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
fabs(pm->gammas[j]/pm->gammas[i]-1) >= PNG_GAMMA_THRESHOLD)
{
gamma_transform_test(pm, 0, 16, 0, pm->interlace_type,
1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8,
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm))
return;
gamma_transform_test(pm, 2, 16, 0, pm->interlace_type,
1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8,
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm))
return;
gamma_transform_test(pm, 4, 16, 0, pm->interlace_type,
1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8,
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm))
return;
gamma_transform_test(pm, 6, 16, 0, pm->interlace_type,
1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8,
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm))
@@ -9191,7 +9034,7 @@ perform_gamma_composition_tests(png_modifier *pm, int do_background,
/* Skip the non-alpha cases - there is no setting of a transparency colour at
* present.
*/
while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/))
while (next_format(&colour_type, &bit_depth, &palette_number))
if ((colour_type & PNG_COLOR_MASK_ALPHA) != 0)
{
unsigned int i, j;
@@ -9213,46 +9056,31 @@ perform_gamma_composition_tests(png_modifier *pm, int do_background,
static void
init_gamma_errors(png_modifier *pm)
{
/* Use -1 to catch tests that were not actually run */
pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = -1.;
pm->error_color_8 = -1.;
pm->error_indexed = -1.;
pm->error_gray_16 = pm->error_color_16 = -1.;
pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0;
pm->error_color_8 = 0;
pm->error_indexed = 0;
pm->error_gray_16 = pm->error_color_16 = 0;
}
static void
print_one(const char *leader, double err)
summarize_gamma_errors(png_modifier *pm, png_const_charp who, int low_bit_depth)
{
if (err != -1.)
printf(" %s %.5f\n", leader, err);
}
static void
summarize_gamma_errors(png_modifier *pm, png_const_charp who, int low_bit_depth,
int indexed)
{
fflush(stderr);
if (who)
printf("\nGamma correction with %s:\n", who);
else
printf("\nBasic gamma correction:\n");
printf("Gamma correction with %s:\n", who);
if (low_bit_depth)
{
print_one(" 2 bit gray: ", pm->error_gray_2);
print_one(" 4 bit gray: ", pm->error_gray_4);
print_one(" 8 bit gray: ", pm->error_gray_8);
print_one(" 8 bit color:", pm->error_color_8);
if (indexed)
print_one(" indexed: ", pm->error_indexed);
printf(" 2 bit gray: %.5f\n", pm->error_gray_2);
printf(" 4 bit gray: %.5f\n", pm->error_gray_4);
printf(" 8 bit gray: %.5f\n", pm->error_gray_8);
printf(" 8 bit color: %.5f\n", pm->error_color_8);
printf(" indexed: %.5f\n", pm->error_indexed);
}
print_one("16 bit gray: ", pm->error_gray_16);
print_one("16 bit color:", pm->error_color_16);
fflush(stdout);
#ifdef DO_16BIT
printf(" 16 bit gray: %.5f\n", pm->error_gray_16);
printf(" 16 bit color: %.5f\n", pm->error_color_16);
#endif
}
static void
@@ -9278,24 +9106,6 @@ perform_gamma_test(png_modifier *pm, int summary)
/* Now some real transforms. */
if (pm->test_gamma_transform)
{
if (summary)
{
fflush(stderr);
printf("Gamma correction error summary\n\n");
printf("The printed value is the maximum error in the pixel values\n");
printf("calculated by the libpng gamma correction code. The error\n");
printf("is calculated as the difference between the output pixel\n");
printf("value (always an integer) and the ideal value from the\n");
printf("libpng specification (typically not an integer).\n\n");
printf("Expect this value to be less than .5 for 8 bit formats,\n");
printf("less than 1 for formats with fewer than 8 bits and a small\n");
printf("number (typically less than 5) for the 16 bit formats.\n");
printf("For performance reasons the value for 16 bit formats\n");
printf("increases when the image file includes an sBIT chunk.\n");
fflush(stdout);
}
init_gamma_errors(pm);
/*TODO: remove this. Necessary because the current libpng
* implementation works in 8 bits:
@@ -9307,10 +9117,22 @@ perform_gamma_test(png_modifier *pm, int summary)
pm->calculations_use_input_precision = 0;
if (summary)
summarize_gamma_errors(pm, 0/*who*/, 1/*low bit depth*/, 1/*indexed*/);
{
printf("Gamma correction error summary\n\n");
printf("The printed value is the maximum error in the pixel values\n");
printf("calculated by the libpng gamma correction code. The error\n");
printf("is calculated as the difference between the output pixel\n");
printf("value (always an integer) and the ideal value from the\n");
printf("libpng specification (typically not an integer).\n\n");
if (fail(pm))
return;
printf("Expect this value to be less than .5 for 8 bit formats,\n");
printf("less than 1 for formats with fewer than 8 bits and a small\n");
printf("number (typically less than 5) for the 16 bit formats.\n");
printf("For performance reasons the value for 16 bit formats\n");
printf("increases when the image file includes an sBIT chunk.\n\n");
summarize_gamma_errors(pm, 0/*who*/, 1);
}
}
/* The sbit tests produce much larger errors: */
@@ -9320,10 +9142,7 @@ perform_gamma_test(png_modifier *pm, int summary)
perform_gamma_sbit_tests(pm);
if (summary)
summarize_gamma_errors(pm, "sBIT", pm->sbitlow < 8U, 1/*indexed*/);
if (fail(pm))
return;
summarize_gamma_errors(pm, "sBIT", pm->sbitlow < 8U);
}
#ifdef DO_16BIT /* Should be READ_16BIT_SUPPORTED */
@@ -9335,15 +9154,10 @@ perform_gamma_test(png_modifier *pm, int summary)
if (summary)
{
fflush(stderr);
printf("\nGamma correction with 16 to 8 bit reduction:\n");
printf("Gamma correction with 16 to 8 bit reduction:\n");
printf(" 16 bit gray: %.5f\n", pm->error_gray_16);
printf(" 16 bit color: %.5f\n", pm->error_color_16);
fflush(stdout);
}
if (fail(pm))
return;
}
#endif
@@ -9367,10 +9181,7 @@ perform_gamma_test(png_modifier *pm, int summary)
pm->maxout8 = maxout8;
if (summary)
summarize_gamma_errors(pm, "background", 1, 0/*indexed*/);
if (fail(pm))
return;
summarize_gamma_errors(pm, "background", 1);
}
#endif
@@ -9395,10 +9206,7 @@ perform_gamma_test(png_modifier *pm, int summary)
pm->calculations_use_input_precision = 0;
if (summary)
summarize_gamma_errors(pm, "alpha mode", 1, 0/*indexed*/);
if (fail(pm))
return;
summarize_gamma_errors(pm, "alpha mode", 1);
}
#endif
}
@@ -9906,19 +9714,6 @@ int main(int argc, char **argv)
/* Default to error on warning: */
pm.this.treat_warnings_as_errors = 1;
/* Default assume_16_bit_calculations appropriately; this tells the checking
* code that 16-bit arithmetic is used for 8-bit samples when it would make a
* difference.
*/
pm.assume_16_bit_calculations = PNG_LIBPNG_VER >= 10700;
/* Currently 16 bit expansion happens at the end of the pipeline, so the
* calculations are done in the input bit depth not the output.
*
* TODO: fix this
*/
pm.calculations_use_input_precision = 1U;
/* Store the test gammas */
pm.gammas = gammas;
pm.ngammas = (sizeof gammas) / (sizeof gammas[0]);
@@ -9929,16 +9724,13 @@ int main(int argc, char **argv)
pm.nencodings = (sizeof test_encodings) / (sizeof test_encodings[0]);
pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */
/* The following allows results to pass if they correspond to anything in the
* transformed range [input-.5,input+.5]; this is is required because of the
* way libpng treates the 16_TO_8 flag when building the gamma tables in
* releases up to 1.6.0.
* way libpng treates the 16_TO_8 flag when building the gamma tables.
*
* TODO: review this
*/
pm.use_input_precision_16to8 = 1U;
pm.use_input_precision_sbit = 1U; /* because libpng now rounds sBIT */
/* Some default values (set the behavior for 'make check' here).
* These values simply control the maximum error permitted in the gamma
@@ -9949,12 +9741,11 @@ int main(int argc, char **argv)
*/
pm.maxout8 = .1; /* Arithmetic error in *encoded* value */
pm.maxabs8 = .00005; /* 1/20000 */
pm.maxcalc8 = 1./255; /* +/-1 in 8 bits for compose errors */
pm.maxcalc8 = .004; /* +/-1 in 8 bits for compose errors */
pm.maxpc8 = .499; /* I.e., .499% fractional error */
pm.maxout16 = .499; /* Error in *encoded* value */
pm.maxabs16 = .00005;/* 1/20000 */
pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */
pm.maxcalcG = 1./((1<<PNG_MAX_GAMMA_8)-1);
pm.maxcalc16 =.000015;/* +/-1 in 16 bits for compose errors */
/* NOTE: this is a reasonable perceptual limit. We assume that humans can
* perceive light level differences of 1% over a 100:1 range, so we need to
@@ -10101,16 +9892,13 @@ int main(int argc, char **argv)
pm.interlace_type = PNG_INTERLACE_ADAM7;
else if (strcmp(*argv, "--use-input-precision") == 0)
pm.use_input_precision = 1U;
else if (strcmp(*argv, "--use-calculation-precision") == 0)
pm.use_input_precision = 0;
pm.use_input_precision = 1;
else if (strcmp(*argv, "--calculations-use-input-precision") == 0)
pm.calculations_use_input_precision = 1U;
pm.calculations_use_input_precision = 1;
else if (strcmp(*argv, "--assume-16-bit-calculations") == 0)
pm.assume_16_bit_calculations = 1U;
pm.assume_16_bit_calculations = 1;
else if (strcmp(*argv, "--calculations-follow-bit-depth") == 0)
pm.calculations_use_input_precision =
@@ -10351,6 +10139,7 @@ int main(int argc, char **argv)
int main(void)
{
fprintf(stderr, "pngvalid: no write support in libpng, all tests skipped\n");
return 0;
/* So the test is skipped: */
return 77;
}
#endif

View File

@@ -2,7 +2,7 @@
*
* 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

View File

@@ -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

View File

@@ -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
@@ -252,7 +252,7 @@ int main(int argc, char **argv)
while (fgets(filename, FILENAME_MAX+1, stdin))
{
size_t len = strlen(filename);
int len = strlen(filename);
if (filename[len-1] == '\n')
{

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -8,9 +8,9 @@ LD=$(CC)
RM=rm -f
#PNGPATH = /usr/local
#PNGINC = -I$(PNGPATH)/include/libpng17
#PNGLIB = -L$(PNGPATH)/lib -lpng17
#PNGLIBS = $(PNGPATH)/lib/libpng17.a
#PNGINC = -I$(PNGPATH)/include/libpng16
#PNGLIB = -L$(PNGPATH)/lib -lpng16
#PNGLIBS = $(PNGPATH)/lib/libpng16.a
PNGINC = -I../..
PNGLIB = -L../.. -lpng
PNGLIBS = ../../libpng.a

View 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

View File

@@ -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.

144
contrib/tools/fixitxt.c Normal file
View File

@@ -0,0 +1,144 @@
#include <stdio.h>
/* fixitxt version 1.0.0
*
* Copyright 2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* Usage:
*
* fixitxt.exe < bad.png > good.png
*
* Fixes a PNG file written with libpng-1.6.0 or 1.6.1 that has one or more
* uncompressed iTXt chunks. Assumes that the actual length is greater
* than or equal to the value in the length byte, and that the CRC is
* correct for the actual length. This program hunts for the CRC and
* adjusts the length byte accordingly. It is not an error to process a
* PNG file that has no iTXt chunks or one that has valid iTXt chunks;
* such files will simply be copied.
*
* Requires zlib (for crc32 and Z_NULL); build with
*
* gcc -O -o fixitxt fixitxt.c -lz
*/
#define MAX_LENGTH 500000
#define GETBREAK c=getchar(); if (c == EOF) break;
#include <zlib.h>
main()
{
unsigned int i;
unsigned char buf[MAX_LENGTH];
unsigned long crc;
unsigned int c;
/* Skip 8-byte signature */
for (i=8; i; i--)
{
c=GETBREAK;
putchar(c);
}
if (c != EOF)
for (;;)
{
/* Read the length */
unsigned long length;
c=GETBREAK; buf[0] = c;
c=GETBREAK; buf[1] = c;
c=GETBREAK; buf[2] = c;
c=GETBREAK; buf[3] = c;
length=((((unsigned long) buf[0]<<8 + buf[1]<<16) + buf[2] << 8) + buf[3]);
/* Read the chunkname */
c=GETBREAK; buf[4] = c;
c=GETBREAK; buf[5] = c;
c=GETBREAK; buf[6] = c;
c=GETBREAK; buf[7] = c;
/* The iTXt chunk type expressed as integers is (105, 84, 88, 116) */
if (buf[4] == 105 && buf[5] == 84 && buf[6] == 88 && buf[7] == 116)
{
if (length >= MAX_LENGTH-12)
break; /* To do: handle this more gracefully */
/* Initialize the CRC */
crc = crc32(0, Z_NULL, 0);
/* Copy the data bytes */
for (i=8; i < length + 12; i++)
{
c=GETBREAK; buf[i] = c;
}
/* Calculate the CRC */
crc = crc32(crc, buf+4, (uInt)length+4);
for (;;)
{
/* Check the CRC */
if (((crc >> 24) & 0xff) == buf[length+8] &&
((crc >> 16) & 0xff) == buf[length+9] &&
((crc >> 8) & 0xff) == buf[length+10] &&
((crc ) & 0xff) == buf[length+11])
break;
length++;
if (length >= MAX_LENGTH-12)
break;
c=GETBREAK;
buf[length+11]=c;
/* Update the CRC */
crc = crc32(crc, buf+7+length, 1);
}
/* Update length bytes */
buf[0] = (length << 24) & 0xff;
buf[1] = (length << 16) & 0xff;
buf[2] = (length << 8) & 0xff;
buf[3] = (length ) & 0xff;
/* Write the fixed iTXt chunk (length, name, data, crc) */
for (i=0; i<length+12; i++)
putchar(buf[i]);
}
else
{
/* Copy bytes that were already read (length and chunk name) */
for (i=0; i<8; i++)
putchar(buf[i]);
/* Copy data bytes and CRC */
for (i=8; i< length+12; i++)
{
c=GETBREAK;
putchar(c);
}
if (c == EOF)
{
break;
}
/* The IEND chunk type expressed as integers is (73, 69, 78, 68) */
if (buf[4] == 73 && buf[5] == 69 && buf[6] == 78 && buf[7] == 68)
break;
}
if (c == EOF)
break;
if (buf[4] == 73 && buf[5] == 69 && buf[6] == 78 && buf[7] == 68)
break;
}
}

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -1,238 +0,0 @@
/* Given a target range and a source range work out an expression to scale from
* the source to the target of the form:
*
* (number * mult + add)>>16
*
* The command arguments are:
*
* scale target source
*
* and the program works out a pair of numbers, mult and add, that evaluate:
*
* number * target
* round( --------------- )
* source
*
* exactly for number in the range 0..source
*/
#define _ISOC99_SOURCE 1
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
static double minerr;
static unsigned long minmult, minadd, minshift;
static long mindelta;
static int
test(unsigned long target, unsigned long source, unsigned long mult,
long add, unsigned long shift, long delta)
{
unsigned long i;
double maxerr = 0;
double rs = (double)target/source;
for (i=0; i<=source; ++i)
{
unsigned long t = i*mult+add;
double err = fabs((t >> shift) - i*rs);
if (err > minerr)
return 0;
if (err > maxerr)
maxerr = err;
}
if (maxerr < minerr)
{
minerr = maxerr;
minmult = mult;
minadd = add;
minshift = shift;
mindelta = delta;
}
return maxerr < .5;
}
static int
dotest(unsigned long target, unsigned long source, unsigned long mult,
long add, unsigned long shift, long delta, int print)
{
if (test(target, source, mult, add, shift, delta))
{
if (print & 4)
printf(" {%11lu,%6ld /* >>%lu */ }, /* %lu/%lu */\n",
mult, add, shift, target, source);
else if (print & 2)
printf(" {%11lu,%6ld,%3lu }, /* %lu/%lu */\n",
mult, add, shift, target, source);
else if (print)
printf("number * %lu/%lu = (number * %lu + %ld) >> %lu [delta %ld]\n",
target, source, mult, add, shift, delta);
return 1;
}
return 0;
}
static int
find(unsigned long target, unsigned long source, int print, int fixshift)
{
unsigned long shift = 0;
unsigned long shiftlim = 0;
/* In the final math the sum is at most (source*mult+add) >> shift, so:
*
* source*mult+add < 1<<32
* mult < (1<<32)/source
*
* but:
*
* mult = (target<<shift)/source
*
* so:
*
* (target<<shift) < (1<<32)
*/
if (fixshift < 0)
while ((target<<shiftlim) < 0x80000000U) ++shiftlim;
else
shift = shiftlim = (unsigned long)fixshift;
minerr = 1E8;
for (; shift<=shiftlim; ++shift)
{
unsigned long mult = ((target<<shift) + (source>>1)) / source;
long delta;
long limit = 1; /* seems to be sufficient */
long add, start, end;
end = 1<<shift;
start = -end;
for (add=start; add<=end; ++add)
if (dotest(target,source,mult,add,shift,0,print))
return 1;
for (delta=1; delta<=limit; ++delta)
{
# if 0
fprintf(stderr, "%lu/%lu: shift %lu, delta %lu\n", target, source,
shift, delta);
# endif
for (add=start; add<=end; ++add)
{
if (dotest(target, source, mult-delta, add, shift, -delta, print))
return 1;
if (dotest(target, source, mult+delta, add, shift, delta, print))
return 1;
}
}
}
if (print & 4)
printf(" {%11lu,%6ld /* >>%lu */ }, /* %lu/%lu ERROR: .5+%g*/\n",
minmult, minadd, minshift, target, source, minerr-.5);
else if (print & 2)
printf(" {%11lu,%6ld,%3lu }, /* %lu/%lu ERROR: .5+%g*/\n",
minmult, minadd, minshift, target, source, minerr-.5);
else if (print)
printf(
"number * %lu/%lu ~= (number * %lu + %ld) >> %lu +/-.5+%g [delta %ld]\n",
target, source, minmult, minadd, minshift, minerr-.5, mindelta);
return 0;
}
static void
usage(const char *prog)
{
fprintf(stderr,
"usage: %s {--denominator|--maxshift|--code} target {source}\n"
" For each 'source' prints 'mult' and 'add' such that:\n\n"
" (number * mult + add) >> 16 = round(number*target/source)\n\n"
" for all integer values of number in the range 0..source.\n\n"
" --denominator: swap target and source (specify a single source first\n"
" and follow with multiple targets.)\n"
" --maxshift: find the lowest shift value that works for all the\n"
" repeated 'source' values\n"
" --code: output C code for array/structure initialization\n",
prog);
exit(1);
}
int
main(int argc, const char **argv)
{
int i, err = 0, maxshift = 0, firstsrc = 1, code = 0, denominator = 0;
unsigned long target, shift = 0;
while (argc > 1)
{
if (strcmp(argv[firstsrc], "--maxshift") == 0)
{
maxshift = 1;
++firstsrc;
}
else if (strcmp(argv[firstsrc], "--code") == 0)
{
code = 1;
++firstsrc;
}
else if (strcmp(argv[firstsrc], "--denominator") == 0)
{
denominator = 1;
++firstsrc;
}
else
break;
}
if (argc < 2+firstsrc)
usage(argv[0]);
target = strtoul(argv[firstsrc++], 0, 0);
if (target == 0) usage(argv[0]);
for (i=firstsrc; i<argc; ++i)
{
unsigned long source = strtoul(argv[i], 0, 0);
if (source == 0) usage(argv[0]);
if (!find(denominator ? source : target, denominator ? target : source,
maxshift ? 0 : 1+code, -1))
err = 1;
if (minshift > shift) shift = minshift;
}
if (maxshift) for (i=firstsrc; i<argc; ++i)
{
unsigned long source = strtoul(argv[i], 0, 0);
if (!find(denominator ? source : target, denominator ? target : source,
code ? 4 : 1, shift))
err = 1;
}
/* Just an exit code - the printout above lists the problem */
return err;
}

View File

@@ -2,7 +2,7 @@
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.0 [February 14, 2013]
* Maintained 1998-2013 Glenn Randers-Pehrson
* Maintained 1996, 1997 Andreas Dilger)
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -39,7 +39,7 @@
#include <string.h>
#include <stdio.h>
#include <png.h>
#include PNG_ZLIB_HEADER /* this is the header libpng was built with */
#include <zlib.h>
int main(int argc, const char **argv)
{

View File

@@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.7.0beta07 - April 14, 2013
libpng version 1.6.2rc05 - April 23, 2013
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2013 Glenn Randers-Pehrson
@@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.7.0beta07 - April 14, 2013
libpng versions 0.97, January 1998, through 1.6.2rc05 - April 23, 2013
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2013 Glenn Randers-Pehrson
@@ -42,11 +42,10 @@ libpng-manual.txt - A description on how to use and modify libpng
X. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
XI. Changes to Libpng from version 1.4.x to 1.5.x
XII. Changes to Libpng from version 1.5.x to 1.6.x
XIII. Changes to Libpng from version 1.6.x to 1.7.x
XIV. Detecting libpng
XV. Source code repository
XVI. Coding style
XVII. Y2K Compliance in libpng
XIII. Detecting libpng
XIV. Source code repository
XV. Coding style
XVI. Y2K Compliance in libpng
I. Introduction
@@ -432,7 +431,7 @@ 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().
You can #define PNG_ABORT to a function or other C code that does something
You can #define PNG_ABORT() to a function that does something
more useful than abort(), as long as your function does not
return.
@@ -527,15 +526,15 @@ you can retrieve with
png_get_user_chunk_ptr(png_ptr);
If you call the png_set_read_user_chunk_fn() function, then all unknown chunks
will be passed to your callback when read. You can cause known chunks to be
passed in as well by using png_set_keep_unknown_chunks (see below) - this will
prevent the normal libpng handling of those known chunks.
If your callback returns 0 the default unknown handling will be used (see
below). This is new behavior in libpng 1.7, prior to 1.7 it was not possible to
discard a chunk; PNG_HANDLE_CHUNK_IF_SAFE was forced. Libpng 1.6.0 issues a
warning when this was done.
If you call the png_set_read_user_chunk_fn() function, then all unknown
chunks which the callback does not handle will be saved when read. You can
cause them to be discarded by returning '1' ("handled") instead of '0'. This
behavior will change in libpng 1.7 and the default handling set by the
png_set_keep_unknown_chunks() function, described below, will be used when the
callback returns 0. If you want the existing behavior you should set the global
default to PNG_HANDLE_CHUNK_IF_SAFE now; this is compatible with all current
versions of libpng and with 1.7. Libpng 1.6 issues a warning if you keep the
default, or PNG_HANDLE_CHUNK_NEVER, and the callback returns 0.
At this point, you can set up a callback function that will be
called after each row has been read, which you can use to control
@@ -634,8 +633,10 @@ callback function:
...
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* ignore all unknown chunks: */
png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
/* ignore all unknown chunks
* (use global setting "2" for libpng16 and earlier):
*/
png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0);
/* except for vpAg: */
png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
@@ -994,7 +995,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");
@@ -2564,9 +2565,9 @@ section below for more information on the libpng error handling.
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
You can #define PNG_ABORT() to a function that does something
more useful than abort(), as long as your function does not
return.
@@ -3945,7 +3946,7 @@ Error handling in libpng is done through png_error() and png_warning().
Errors handled through png_error() are fatal, meaning that png_error()
should never return to its caller. Currently, this is handled via
setjmp() and longjmp() (unless you have compiled libpng with
PNG_NO_SETJMP, in which case it is handled via PNG_ABORT),
PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()),
but you could change this to do things like exit() if you should wish,
as long as your function does not return.
@@ -5002,40 +5003,7 @@ The machine-generated configure files are no longer included in branches
libpng16 and later of the GIT repository. They continue to be included
in the tarball releases, however.
XIII. Changes to Libpng from version 1.6.x to 1.7.x
Some functions that were deprecated in libpng-1.6.0 were removed:
png_reset_zstream(),
png_info_init_3(),
png_data_freer() and its associated flags,
png_malloc_default(),
and png_free_default().
The PNG_ABORT() macro was changed to PNG_ABORT, and the default is now
"abort()" for all platforms (previously it was "ExitProcess(0)" on
Windows platforms). Starting with libpng-1.7.0 you have to define
PNG_ABORT instead of PNG_ABORT(), and you must include a terminating
semicolon in your definition, e.g.,
#if PNGCRUSH_LIBPNG_VER >= 10700
# ifdef _WINDOWS_
# define PNG_ABORT ExitProcess(0);
# else
# define PNG_ABORT abort();
# endif
#else
# ifdef _WINDOWS_
# define PNG_ABORT() ExitProcess(0)
# else
# define PNG_ABORT() abort()
# endif
#endif
The 8-bit compose and rgb_to_grayscale operations were made more accurate.
While these did not introduce API incompatibility, there may be differences
in unit test results.
XIV. Detecting libpng
XIII. Detecting libpng
The png_get_io_ptr() function has been present since libpng-0.88, has never
changed, and is unaffected by conditional compilation macros. It is the
@@ -5068,7 +5036,7 @@ simple verbal discriptions of bug fixes, reported either to the
SourceForge bug tracker, to the png-mng-implement at lists.sf.net
mailing list, or directly to glennrp.
XVI. Coding style
XV. Coding style
Our coding style is similar to the "Allman" style, with curly
braces on separate lines:
@@ -5180,7 +5148,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).
@@ -5194,15 +5163,15 @@ Lines do not exceed 80 characters.
Other rules can be inferred by inspecting the libpng source.
XVII. Y2K Compliance in libpng
XVI. Y2K Compliance in libpng
April 14, 2013
April 23, 2013
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.7.0beta07 are Y2K compliant. It is my belief that earlier
upward through 1.6.2rc05 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

126
libpng.3
View File

@@ -1,6 +1,6 @@
.TH LIBPNG 3 "April 14, 2013"
.TH LIBPNG 3 "April 23, 2013"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta07
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.2rc05
.SH SYNOPSIS
\fB
#include <png.h>\fP
@@ -23,7 +23,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta07
\fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP
\fBpng_charp png_convert_to_rfc1123_buffer (png_structp \fP\fIpng_ptr\fP\fB, char \fP\fIout[29]\fP\fB, png_timep \fIptime\fP\fB);\fP
\fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP
\fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP
@@ -35,6 +35,8 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta07
\fBpng_structp png_create_write_struct_2 (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
\fBvoid png_data_freer (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIfreer\fP\fB, png_uint_32 \fImask)\fP\fB);\fP
\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
\fBvoid png_destroy_read_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fP\fIinfo_ptr_ptr\fP\fB, png_infopp \fIend_info_ptr_ptr\fP\fB);\fP
@@ -49,6 +51,8 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta07
\fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP
\fBvoid png_free_default (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
\fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP
\fBpng_byte png_get_bit_depth (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
@@ -225,12 +229,16 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta07
\fBint png_image_write_to_stdio (png_imagep \fP\fIimage\fP\fB, FILE \fP\fI*file\fP\fB, int \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fP\fIrow_stride\fP\fB, void \fI*colormap)\fP\fB);\fP
\fBvoid png_info_init_3 (png_infopp \fP\fIinfo_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP
\fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP
\fBvoid png_longjmp (png_structp \fP\fIpng_ptr\fP\fB, int \fIval\fP\fB);\fP
\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
\fBpng_voidp png_malloc_default (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
\fBpng_voidp png_malloc_warn (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
\fBpng_uint_32 png_permit_mng_features (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fImng_features_permitted\fP\fB);\fP
@@ -257,6 +265,8 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta07
\fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fBint png_reset_zstream (png_structp \fIpng_ptr\fP\fB);\fP
\fBvoid png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP
\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP
@@ -494,7 +504,7 @@ 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.0beta07 - April 14, 2013
libpng version 1.6.2rc05 - April 23, 2013
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2013 Glenn Randers-Pehrson
@@ -505,7 +515,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.7.0beta07 - April 14, 2013
libpng versions 0.97, January 1998, through 1.6.2rc05 - April 23, 2013
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2013 Glenn Randers-Pehrson
@@ -536,11 +546,10 @@ libpng-manual.txt - A description on how to use and modify libpng
X. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
XI. Changes to Libpng from version 1.4.x to 1.5.x
XII. Changes to Libpng from version 1.5.x to 1.6.x
XIII. Changes to Libpng from version 1.6.x to 1.7.x
XIV. Detecting libpng
XV. Source code repository
XVI. Coding style
XVII. Y2K Compliance in libpng
XIII. Detecting libpng
XIV. Source code repository
XV. Coding style
XVI. Y2K Compliance in libpng
.SH I. Introduction
@@ -926,7 +935,7 @@ 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().
You can #define PNG_ABORT to a function or other C code that does something
You can #define PNG_ABORT() to a function that does something
more useful than abort(), as long as your function does not
return.
@@ -1021,15 +1030,15 @@ you can retrieve with
png_get_user_chunk_ptr(png_ptr);
If you call the png_set_read_user_chunk_fn() function, then all unknown chunks
will be passed to your callback when read. You can cause known chunks to be
passed in as well by using png_set_keep_unknown_chunks (see below) - this will
prevent the normal libpng handling of those known chunks.
If your callback returns 0 the default unknown handling will be used (see
below). This is new behavior in libpng 1.7, prior to 1.7 it was not possible to
discard a chunk; PNG_HANDLE_CHUNK_IF_SAFE was forced. Libpng 1.6.0 issues a
warning when this was done.
If you call the png_set_read_user_chunk_fn() function, then all unknown
chunks which the callback does not handle will be saved when read. You can
cause them to be discarded by returning '1' ("handled") instead of '0'. This
behavior will change in libpng 1.7 and the default handling set by the
png_set_keep_unknown_chunks() function, described below, will be used when the
callback returns 0. If you want the existing behavior you should set the global
default to PNG_HANDLE_CHUNK_IF_SAFE now; this is compatible with all current
versions of libpng and with 1.7. Libpng 1.6 issues a warning if you keep the
default, or PNG_HANDLE_CHUNK_NEVER, and the callback returns 0.
At this point, you can set up a callback function that will be
called after each row has been read, which you can use to control
@@ -1128,8 +1137,10 @@ callback function:
...
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* ignore all unknown chunks: */
png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
/* ignore all unknown chunks
* (use global setting "2" for libpng16 and earlier):
*/
png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0);
/* except for vpAg: */
png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
@@ -1488,7 +1499,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");
@@ -3058,9 +3069,9 @@ section below for more information on the libpng error handling.
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
You can #define PNG_ABORT() to a function that does something
more useful than abort(), as long as your function does not
return.
@@ -4439,7 +4450,7 @@ Error handling in libpng is done through png_error() and png_warning().
Errors handled through png_error() are fatal, meaning that png_error()
should never return to its caller. Currently, this is handled via
setjmp() and longjmp() (unless you have compiled libpng with
PNG_NO_SETJMP, in which case it is handled via PNG_ABORT),
PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()),
but you could change this to do things like exit() if you should wish,
as long as your function does not return.
@@ -5497,40 +5508,7 @@ 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.
.SH XIII. Changes to Libpng from version 1.6.x to 1.7.x
Some functions that were deprecated in libpng-1.6.0 were removed:
png_reset_zstream(),
png_info_init_3(),
png_data_freer() and its associated flags,
png_malloc_default(),
and png_free_default().
The PNG_ABORT() macro was changed to PNG_ABORT, and the default is now
"abort()" for all platforms (previously it was "ExitProcess(0)" on
Windows platforms). Starting with libpng-1.7.0 you have to define
PNG_ABORT instead of PNG_ABORT(), and you must include a terminating
semicolon in your definition, e.g.,
#if PNGCRUSH_LIBPNG_VER >= 10700
# ifdef _WINDOWS_
# define PNG_ABORT ExitProcess(0);
# else
# define PNG_ABORT abort();
# endif
#else
# ifdef _WINDOWS_
# define PNG_ABORT() ExitProcess(0)
# else
# define PNG_ABORT() abort()
# endif
#endif
The 8-bit compose and rgb_to_grayscale operations were made more accurate.
While these did not introduce API incompatibility, there may be differences
in unit test results.
.SH XIV. Detecting libpng
.SH XIII. Detecting libpng
The png_get_io_ptr() function has been present since libpng-0.88, has never
changed, and is unaffected by conditional compilation macros. It is the
@@ -5563,7 +5541,7 @@ simple verbal discriptions of bug fixes, reported either to the
SourceForge bug tracker, to the png-mng-implement at lists.sf.net
mailing list, or directly to glennrp.
.SH XVI. Coding style
.SH XV. Coding style
Our coding style is similar to the "Allman" style, with curly
braces on separate lines:
@@ -5675,7 +5653,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).
@@ -5689,15 +5668,15 @@ Lines do not exceed 80 characters.
Other rules can be inferred by inspecting the libpng source.
.SH XVII. Y2K Compliance in libpng
.SH XVI. Y2K Compliance in libpng
April 14, 2013
April 23, 2013
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.7.0beta07 are Y2K compliant. It is my belief that earlier
upward through 1.6.2rc05 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
@@ -5902,9 +5881,14 @@ the first widely used release:
1.5.7beta01-05 15 10507 15.so.15.7[.0]
1.5.7rc01-03 15 10507 15.so.15.7[.0]
1.5.7 15 10507 15.so.15.7[.0]
1.6.0beta01-37 16 10600 16.so.16.0[.0]
1.7.0alpha01-10 17 10700 17.so.17.0[.0]
1.7.0beta01-07 17 10700 17.so.17.0[.0]
1.6.0beta01-40 16 10600 16.so.16.0[.0]
1.6.0rc01-08 16 10600 16.so.16.0[.0]
1.6.0 16 10600 16.so.16.0[.0]
1.6.1beta01-09 16 10601 16.so.16.1[.0]
1.6.1rc01 16 10601 16.so.16.1[.0]
1.6.1 16 10601 16.so.16.1[.0]
1.6.2beta01 16 10602 16.so.16.2[.0]
1.6.2rc01-05 16 10602 16.so.16.2[.0]
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@@ -5961,7 +5945,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.7.0beta07 - April 14, 2013:
Libpng version 1.6.2rc05 - April 23, 2013:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@@ -5984,7 +5968,7 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.7.0beta07, April 14, 2013, are
libpng versions 1.2.6, August 15, 2004, through 1.6.2rc05, April 23, 2013, 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
@@ -6083,7 +6067,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
April 14, 2013
April 23, 2013
.\" end of man page

View File

@@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "April 14, 2013"
.TH LIBPNGPF 3 "April 23, 2013"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta07
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.2rc05
(private functions)
.SH SYNOPSIS
\fB#include \fI"pngpriv.h"

5
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "April 14, 2013"
.TH PNG 5 "April 23, 2013"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
@@ -24,7 +24,6 @@ PNG specification (second edition), November 2003:
.IP
.br
<http://www.w3.org/TR/2003/REC-PNG-20031110/
.LP
PNG 1.2 specification, July 1999:
.IP
.br
@@ -59,7 +58,7 @@ Thomas Boutell and others (png-list).
.SH COPYRIGHT NOTICE
.LP
This man page is Copyright (c) 1998-2012 Glenn Randers-Pehrson. See png.h
This man page is Copyright (c) 1998-2006 Glenn Randers-Pehrson. See png.h
for conditions of use and distribution.
.LP
The PNG Specification (Second Edition) is

711
png.c
View File

@@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.2 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -14,7 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_7_0beta07 Your_png_h_is_not_version_1_7_0beta07;
typedef png_libpng_version_1_6_2rc05 Your_png_h_is_not_version_1_6_2rc05;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@@ -115,7 +115,7 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
{
int need_crc = 1;
if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))
{
if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
@@ -236,21 +236,22 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
*/
memset(&create_struct, 0, (sizeof create_struct));
/* These limits are only used on read at present, and if READ is not turned
* on neither will USER_LIMITS be. The width/height and chunk malloc limits
* are constants, so if they cannot be set they don't get defined in
* png_struct, the user_chunk_cache limits is a down-counter, when it reaches
* 1 no more chunks will be handled. 0 means unlimited, consequently the
* limit is 1 more than the number of chunks that will be handled.
*/
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* Added at libpng-1.2.6 */
# ifdef PNG_USER_LIMITS_SUPPORTED
create_struct.user_width_max = PNG_USER_WIDTH_MAX;
create_struct.user_height_max = PNG_USER_HEIGHT_MAX;
create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
# endif
# ifdef PNG_USER_LIMITS_SUPPORTED
/* Must exist even if the initial value is constant */
create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;
# ifdef PNG_USER_CHUNK_CACHE_MAX
/* Added at libpng-1.2.43 and 1.4.0 */
create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;
# endif
# ifdef PNG_USER_CHUNK_MALLOC_MAX
/* Added at libpng-1.2.43 and 1.4.1, required only for read but exists
* in png_struct regardless.
*/
create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
# endif
# endif
/* The following two API calls simply set fields in png_struct, so it is safe
@@ -380,6 +381,60 @@ png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)
}
}
/* Initialize the info structure. This is now an internal function (0.89)
* and applications using it are urged to use png_create_info_struct()
* instead. Use deprecated in 1.6.0, internal use removed (used internally it
* is just a memset).
*
* NOTE: it is almost inconceivable that this API is used because it bypasses
* the user-memory mechanism and the user error handling/warning mechanisms in
* those cases where it does anything other than a memset.
*/
PNG_FUNCTION(void,PNGAPI
png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size),
PNG_DEPRECATED)
{
png_inforp info_ptr = *ptr_ptr;
png_debug(1, "in png_info_init_3");
if (info_ptr == NULL)
return;
if ((sizeof (png_info)) > png_info_struct_size)
{
*ptr_ptr = NULL;
/* The following line is why this API should not be used: */
free(info_ptr);
info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL,
(sizeof *info_ptr)));
*ptr_ptr = info_ptr;
}
/* Set everything to 0 */
memset(info_ptr, 0, (sizeof *info_ptr));
}
/* The following API is not called internally */
void PNGAPI
png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,
int freer, png_uint_32 mask)
{
png_debug(1, "in png_data_freer");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (freer == PNG_DESTROY_WILL_FREE_DATA)
info_ptr->free_me |= mask;
else if (freer == PNG_USER_WILL_FREE_DATA)
info_ptr->free_me &= ~mask;
else
png_error(png_ptr, "Unknown freer parameter in png_data_freer");
}
void PNGAPI
png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
int num)
@@ -418,10 +473,9 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
/* Free any tRNS entry */
if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
{
info_ptr->valid &= ~PNG_INFO_tRNS;
png_free(png_ptr, info_ptr->trans_alpha);
info_ptr->trans_alpha = NULL;
info_ptr->num_trans = 0;
info_ptr->valid &= ~PNG_INFO_tRNS;
}
#endif
@@ -678,6 +732,29 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
return 1;
}
# if PNG_LIBPNG_VER < 10700
/* To do: remove the following from libpng-1.7 */
/* Original API that uses a private buffer in png_struct.
* Deprecated because it causes png_struct to carry a spurious temporary
* buffer (png_struct::time_buffer), better to have the caller pass this in.
*/
png_const_charp PNGAPI
png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime)
{
if (png_ptr != NULL)
{
/* The only failure above if png_ptr != NULL is from an invalid ptime */
if (!png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime))
png_warning(png_ptr, "Ignoring invalid time value");
else
return png_ptr->time_buffer;
}
return NULL;
}
# endif
# endif /* PNG_TIME_RFC1123_SUPPORTED */
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
@@ -691,13 +768,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.7.0beta07 - April 14, 2013" PNG_STRING_NEWLINE \
"libpng version 1.6.2rc05 - April 23, 2013" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2013 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
return "libpng version 1.7.0beta07 - April 14, 2013\
return "libpng version 1.6.2rc05 - April 23, 2013\
Copyright (c) 1998-2013 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -790,6 +867,19 @@ png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name)
#endif /* READ_UNKNOWN_CHUNKS */
#endif /* SET_UNKNOWN_CHUNKS */
#ifdef PNG_READ_SUPPORTED
/* This function, added to libpng-1.0.6g, is untested. */
int PNGAPI
png_reset_zstream(png_structrp png_ptr)
{
if (png_ptr == NULL)
return Z_STREAM_ERROR;
/* WARNING: this resets the window bits to the maximum! */
return (inflateReset(&png_ptr->zstream));
}
#endif /* PNG_READ_SUPPORTED */
/* This function was added to libpng-1.0.7 */
png_uint_32 PNGAPI
png_access_version_number(void)
@@ -798,6 +888,8 @@ png_access_version_number(void)
return((png_uint_32)PNG_LIBPNG_VER);
}
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
/* Ensure that png_ptr->zstream.msg holds some appropriate error message string.
* If it doesn't 'ret' is used to set it to something appropriate, even in cases
@@ -1312,7 +1404,7 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
if (!png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse)) return 1;
if (!png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse)) return 1;
if (!png_muldiv(&XYZ->red_Z, PNG_FP_1 - xy->redx - xy->redy, PNG_FP_1,
red_inverse))
red_inverse))
return 1;
if (!png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse))
@@ -1320,7 +1412,7 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
if (!png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse))
return 1;
if (!png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1,
green_inverse))
green_inverse))
return 1;
if (!png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale, PNG_FP_1)) return 1;
@@ -1774,7 +1866,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
"length does not match profile");
temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */
if (temp > 357913930 || /* (2^32-4-132)/12: maxium possible tag count */
if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */
profile_length < 132+12*temp) /* truncated tag table */
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"tag count too large");
@@ -2183,7 +2275,10 @@ png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
profile))
{
png_icc_set_sRGB(png_ptr, colorspace, profile, 0);
# ifdef PNG_sRGB_SUPPORTED
/* If no sRGB support, don't try storing sRGB information */
png_icc_set_sRGB(png_ptr, colorspace, profile, 0);
# endif
return 1;
}
@@ -2197,7 +2292,7 @@ void /* PRIVATE */
png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
{
/* Set the rgb_to_gray coefficients from the colorspace. */
if ((png_ptr->colorspace.flags & PNG_COLORSPACE_RGB_TO_GRAY_SET) == 0 &&
if (!png_ptr->rgb_to_gray_coefficients_set &&
(png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
/* png_set_background has not been called, get the coefficients from the Y
@@ -2978,32 +3073,24 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
png_error(png_ptr, "ASCII conversion buffer too small");
}
# endif /* FIXED_POINT */
#endif /* SCAL */
#endif /* READ_SCAL */
#if !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && (\
defined(PNG_FLOATING_POINT_SUPPORTED) && \
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
!defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
(defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \
(defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) &&\
defined(PNG_sCAL_SUPPORTED)))
(defined(PNG_sCAL_SUPPORTED) && \
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))
png_fixed_point
png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
{
if (fp < 0)
{
if (fp > -21474.836485)
return (png_fixed_point)(100000*fp - .5);
}
double r = floor(100000 * fp + .5);
else
{
if (fp < 21474.836475)
return (png_fixed_point)(100000*fp + .5);
}
if (r > 2147483647. || r < -2147483648.)
png_fixed_error(png_ptr, text);
/* Overflow */
png_fixed_error(png_ptr, text);
return (png_fixed_point)r;
}
#endif
@@ -3181,7 +3268,6 @@ png_gamma_significant(png_fixed_point gamma_val)
#ifdef PNG_READ_GAMMA_SUPPORTED
/* A local convenience routine. */
#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED
static png_fixed_point
png_product2(png_fixed_point a, png_fixed_point b)
{
@@ -3202,7 +3288,6 @@ png_product2(png_fixed_point a, png_fixed_point b)
return 0; /* overflow */
}
#endif
/* The inverse of the above. */
png_fixed_point
@@ -3581,332 +3666,161 @@ png_gamma_correct(png_structrp png_ptr, unsigned int value,
return png_gamma_16bit_correct(value, gamma_val);
}
#define PNG_GAMMA_TABLE_8 0 /* 8-bit entries in png_byte */
#define PNG_GAMMA_TABLE_8_IN_16 1 /* 8-bit entries * 257 in png_uint_16 */
#define PNG_GAMMA_TABLE_16 2 /* 16-bit entries in png_uint_16 */
typedef struct
{
png_fixed_point gamma;
png_uint_32 mult;
unsigned int add;
unsigned int shift; /* input value is (i * mult + add) >> shift */
int output; /* One of the above values */
int adjust; /* Divide or multiple output by 257 */
png_voidp table; /* Lookup table */
} gamma_table_data;
static unsigned int
write_gamma_table_entry(const gamma_table_data *data, png_uint_32 i)
/* Calculate and write a single entry into table[i], the value of the entry
* written is returned.
*/
{
png_uint_32 in = (i * data->mult + data->add) >> data->shift;
unsigned int out;
/* If the output is TABLE_8 with no adjust, or the output is not with an
* adjust, use 8-bit correction.
*/
if ((data->output == PNG_GAMMA_TABLE_8) != (data->adjust != 0))
{
out = png_gamma_8bit_correct((unsigned int)in, data->gamma);
if (data->adjust != 0)
out *= 257U;
}
else /* 16-bit correction */
{
out = png_gamma_16bit_correct((unsigned int)in, data->gamma);
if (data->adjust != 0)
out = PNG_DIV257(out);
}
if (data->output == PNG_GAMMA_TABLE_8)
((png_bytep)data->table)[i] = (png_byte)out;
else
((png_uint_16p)data->table)[i] = (png_uint_16)out;
return out;
}
/* Internal function to build a single 16-bit table - the table consists of
* 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount
* to shift the input values right (or 16-number_of_signifiant_bits).
*
* The caller is responsible for ensuring that the table gets cleaned up on
* png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument
* should be somewhere that will be cleaned.
*/
static void
write_gamma_table(const gamma_table_data *data, png_uint_32 lo,
unsigned int loval, png_uint_32 hi, unsigned int hival)
/* Fill in gamma table entries between lo and hi, exclusive. The entries at
* table[lo] and table[hi] have already been written, the intervening entries
* are written.
*/
png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
{
if (hi > lo+1) /* Else nothing to fill in */
/* Various values derived from 'shift': */
PNG_CONST unsigned int num = 1U << (8U - shift);
PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
PNG_CONST unsigned int max_by_2 = 1U << (15U-shift);
unsigned int i;
png_uint_16pp table = *ptable =
(png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));
for (i = 0; i < num; i++)
{
if (hival == loval)
png_uint_16p sub_table = table[i] =
(png_uint_16p)png_malloc(png_ptr, 256 * (sizeof (png_uint_16)));
/* The 'threshold' test is repeated here because it can arise for one of
* the 16-bit tables even if the others don't hit it.
*/
if (png_gamma_significant(gamma_val))
{
/* All intervening entries must be the same. */
if (data->output == PNG_GAMMA_TABLE_8)
/* The old code would overflow at the end and this would cause the
* 'pow' function to return a result >1, resulting in an
* arithmetic error. This code follows the spec exactly; ig is
* the recovered input sample, it always has 8-16 bits.
*
* We want input * 65535/max, rounded, the arithmetic fits in 32
* bits (unsigned) so long as max <= 32767.
*/
unsigned int j;
for (j = 0; j < 256; j++)
{
png_bytep table8 = ((png_bytep)data->table);
png_uint_32 ig = (j << (8-shift)) + i;
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
/* Inline the 'max' scaling operation: */
double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5);
sub_table[j] = (png_uint_16)d;
# else
if (shift)
ig = (ig * 65535U + max_by_2)/max;
while (++lo < hi)
table8[lo] = (png_byte)loval;
}
else
{
png_uint_16p table16 = ((png_uint_16p)data->table);
while (++lo < hi)
table16[lo] = (png_uint_16)loval;
sub_table[j] = png_gamma_16bit_correct(ig, gamma_val);
# endif
}
}
else
{
png_uint_32 mid = (lo+hi) >> 1;
unsigned int midval = write_gamma_table_entry(data, mid);
/* We must still build a table, but do it the fast way. */
unsigned int j;
/* The algorithm used is to divide the entries to be written in half
* and fill in the middle. For all practical tables with significant
* gamma this will result in a performance gain because the expensive
* gamma correction arithmetic is avoided for some entries.
*/
write_gamma_table(data, lo, loval, mid, midval);
write_gamma_table(data, mid, midval, hi, hival);
for (j = 0; j < 256; j++)
{
png_uint_32 ig = (j << (8-shift)) + i;
if (shift)
ig = (ig * 65535U + max_by_2)/max;
sub_table[j] = (png_uint_16)ig;
}
}
}
}
static void *
png_build_gamma_table(png_structrp png_ptr, png_fixed_point gamma_val,
int output/*as above*/, int input_depth, int use_shift)
/* Build a gamma lookup table to encode input_depth bit input values.
* The table will have 2^input_depth entries plus an extra one if use_shift
* is specified. With shift the table is accessed:
*
* table[(original-value + rounding) >> shift]
*
* And an extra entry exists to accomodate overflow of original-value on
* rounding. If use_shift is not specified the table is accessed with an
* input_depth bit value and the original values must have been correctly
* scaled to this range (not using a shift!)
*
* Each table entry contains input-value^gamma_val rounded to the output
* precision. This is 8 bit precision unless output is specified as
* PNG_GAMMA_TABLE_16, in which case it is 16-bit precision. For
* PNG_GAMMA_TABLE_8_IN_16 the 8-bit value is scaled to 16-bits by
* multiplying by 257.
*/
/* NOTE: this function expects the *inverse* of the overall gamma transformation
* required.
*/
static void
png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
{
png_uint_32 size;
unsigned int hival;
gamma_table_data data;
PNG_CONST unsigned int num = 1U << (8U - shift);
PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
unsigned int i;
png_uint_32 last;
/* If use_shift is true or if the input or output is not 8-bit the gamma
* correction will use the 16-bit correction code. This requires a value in
* the range 0..65535. For use_shift the value is simply:
*
* input << shift
*
* For the scaling case the value is:
*
* round(input * 65535 / ((1<<input_depth)-1)
*
* Both these expressions can be rewritten as:
*
* (input * mult + add) >> shift;
*
* With 'mult' and 'add' chosen to minimize the error for all input values
* in the range 0..((1<<input_depth)-1). The following table does this for
* the scaling case. In fact all the answers are except except for the
* 13-bit case, where the maximum error (from the exact value) is 0.500183.
*
* This table can be produced using the code in contrib/tools/scale.c
png_uint_16pp table = *ptable =
(png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));
/* 'num' is the number of tables and also the number of low bits of low
* bits of the input 16-bit value used to select a table. Each table is
* itself index by the high 8 bits of the value.
*/
static const struct
{
png_uint_32 mult;
png_uint_16 add;
png_byte shift;
} multadd65535[16] =
{
{ 65535, 0, 0 }, /* 65535/1 */
{ 21845, 0, 0 }, /* 65535/3 */
{ 37449, 0, 2 }, /* 65535/7 */
{ 4369, 0, 0 }, /* 65535/15 */
{ 33825, 0, 4 }, /* 65535/31 */
{ 266301, 121, 8 }, /* 65535/63 */
{ 1056817, 970, 11 }, /* 65535/127 */
{ 257, 0, 0 }, /* 65535/255 */
{ 262653, 1020, 11 }, /* 65535/511 */
{ 1049585, 8165, 14 }, /* 65535/1023 */
{ 2098145, 31774, 16 }, /* 65535/2047 */
{ 65551, 2055, 12 }, /* 65535/4095 */
{ 65543, 4100, 13 }, /* 65535/8191 ERROR: .5+0.000183128*/
{ 65539, 8193, 14 }, /* 65535/16383 */
{ 32769, 0, 14 }, /* 65535/32767 */
{ 1, 0, 0 } /* 65535/65535 */
# if 0 /* inverse */
{ 1, 0, 15 }, /* 1/65535 */
{ 3, 32769, 16 }, /* 3/65535 */
{ 28673, 134188470, 28 }, /* 7/65535 */
{ 15, 32775, 16 }, /* 15/65535 */
{ 31745, 33522654, 26 }, /* 31/65535 */
{ 64513, 33552693, 26 }, /* 63/65535 */
{ 65025, 16776620, 25 }, /* 127/65535 */
{ 255, 32895, 16 }, /* 255/65535 */
{ 65409, 4194134, 23 }, /* 511/65535 */
{ 65473, 2097037, 22 }, /* 1023/65535 */
{ 65505, 1048544, 21 }, /* 2047/65535 */
{ 65521, 524167, 20 }, /* 4095/65535 */
{ 65529, 262136, 19 }, /* 8191/65535 */
{ 65533, 131065, 18 }, /* 16383/65535 */
{ 1, 0, 1 }, /* 32767/65535 */
{ 1, 0, 0 } /* 65535/65535 */
# endif
};
for (i = 0; i < num; i++)
table[i] = (png_uint_16p)png_malloc(png_ptr,
256 * (sizeof (png_uint_16)));
/* When both the input and output are 8-bit (i.e. the output is not
* PNG_GAMMA_TABLE_16 and the input_depth is <9) the 8-bit gamma correction
* code can be used, it is slightly faster. This requires values scaled to
* 255, not 65535:
/* 'gamma_val' is set to the reciprocal of the value calculated above, so
* pow(out,g) is an *input* value. 'last' is the last input value set.
*
* In the loop 'i' is used to find output values. Since the output is
* 8-bit there are only 256 possible values. The tables are set up to
* select the closest possible output value for each input by finding
* the input value at the boundary between each pair of output values
* and filling the table up to that boundary with the lower output
* value.
*
* The boundary values are 0.5,1.5..253.5,254.5. Since these are 9-bit
* values the code below uses a 16-bit value in i; the values start at
* 128.5 (for 0.5) and step by 257, for a total of 254 values (the last
* entries are filled with 255). Start i at 128 and fill all 'last'
* table entries <= 'max'
*/
static const struct
last = 0;
for (i = 0; i < 255; ++i) /* 8-bit output value */
{
png_uint_16 mult;
png_byte add;
png_byte shift;
} multadd255[8] =
{
{ 255, 0, 0 }, /* 255/1 */
{ 85, 0, 0 }, /* 255/3 */
{ 73, 0, 1 }, /* 255/7 */
{ 17, 0, 0 }, /* 255/15 */
{ 527, 23, 6 }, /* 255/31 */
{ 259, 33, 6 }, /* 255/63 */
{ 129, 0, 6 }, /* 255/127 */
{ 1, 0, 0 } /* 255/255 */
# if 0 /* inverse */
{ 1, 0, 7 }, /* 1/255 */
{ 3, 129, 8 }, /* 3/255 */
{ 225, 4060, 13 }, /* 7/255 */
{ 15, 135, 8 }, /* 15/255 */
{ 249, 1014, 11 }, /* 31/255 */
{ 253, 505, 10 }, /* 63/255 */
{ 1, 0, 1 }, /* 127/255 */
{ 1, 0, 0 } /* 255/255 */
# endif
};
/* Find the corresponding maximum input value */
png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */
/* Basic table size, increased by one below in the use_shift case where the
* input is rounded.
*/
size = 1U << input_depth;
data.gamma = gamma_val;
data.output = output;
/* Find the boundary value in 16 bits: */
png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val);
if (output < PNG_GAMMA_TABLE_16 && input_depth <= 8)
{
/* The 8-bit correction can only be used if both input and output have no
* more than 8 bits of precision.
*/
data.adjust = output > PNG_GAMMA_TABLE_8;
/* Adjust (round) to (16-shift) bits: */
bound = (bound * max + 32768U)/65535U + 1U;
if (use_shift)
while (last < bound)
{
/* The multiplier does the shift: */
data.mult = 1U << (8-input_depth);
data.add = 0;
data.shift = 0;
if (input_depth < 8) ++size;
}
else
{
data.mult = multadd255[input_depth-1].mult;
data.add = multadd255[input_depth-1].add;
data.shift = multadd255[input_depth-1].shift;
table[last & (0xffU >> shift)][last >> (8U - shift)] = out;
last++;
}
}
else
/* And fill in the final entries. */
while (last < (num << 8))
{
/* 16-bit correction is used for cases where input or output require more
* than 8 bits.
*/
data.adjust = output == PNG_GAMMA_TABLE_8;
if (use_shift)
{
data.mult = 1U << (16-input_depth);
data.add = 0;
data.shift = 0;
if (input_depth < 16) ++size;
}
else
{
data.mult = multadd65535[input_depth-1].mult;
data.add = multadd65535[input_depth-1].add;
data.shift = multadd65535[input_depth-1].shift;
}
table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U;
last++;
}
}
if (output == PNG_GAMMA_TABLE_8)
{
data.table = png_malloc(png_ptr, size * sizeof (png_byte));
((png_bytep)data.table)[0] = 0;
hival = ((png_bytep)data.table)[size-1] = 255;
}
/* Build a single 8-bit table: same as the 16-bit case but much simpler (and
* typically much faster). Note that libpng currently does no sBIT processing
* (apparently contrary to the spec) so a 256 entry table is always generated.
*/
static void
png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
PNG_CONST png_fixed_point gamma_val)
{
unsigned int i;
png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
else
{
/* Output is 16 bits, although it may only have 8 bits of precision */
data.table = png_malloc(png_ptr, size * sizeof (png_uint_16));
((png_uint_16p)data.table)[0] = 0;
hival = ((png_uint_16p)data.table)[size-1] = 65535;
}
if (png_gamma_significant(gamma_val)) for (i=0; i<256; i++)
table[i] = png_gamma_8bit_correct(i, gamma_val);
if (png_gamma_significant(gamma_val))
write_gamma_table(&data, 0, 0, size-1, hival);
else /* gamma_val not significant */
{
if (output == PNG_GAMMA_TABLE_8)
{
png_uint_32 i;
png_bytep table8 = ((png_bytep)data.table);
if (data.adjust)
for (i=1; i<size-1; ++i)
table8[i] = (png_byte)PNG_DIV257((i * data.mult + data.add) >>
data.shift);
else
for (i=1; i<size-1; ++i)
table8[i] = (png_byte)((i * data.mult + data.add) >> data.shift);
}
else
{
png_uint_32 i;
png_uint_16p table16 = ((png_uint_16p)data.table);
if (data.adjust)
for (i=1; i<size-1; ++i)
table16[i] = (png_uint_16)(((i * data.mult + data.add) >>
data.shift) * 257U);
else
for (i=1; i<size-1; ++i)
table16[i] = (png_uint_16)((i * data.mult + data.add) >>
data.shift);
}
}
return data.table;
else for (i=0; i<256; ++i)
table[i] = (png_byte)i;
}
/* Used from png_read_destroy and below to release the memory used by the gamma
@@ -3918,8 +3832,17 @@ png_destroy_gamma_table(png_structrp png_ptr)
png_free(png_ptr, png_ptr->gamma_table);
png_ptr->gamma_table = NULL;
if (png_ptr->gamma_16_table != NULL)
{
int i;
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_table[i]);
}
png_free(png_ptr, png_ptr->gamma_16_table);
png_ptr->gamma_16_table = NULL;
}
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
@@ -3929,10 +3852,28 @@ png_destroy_gamma_table(png_structrp png_ptr)
png_free(png_ptr, png_ptr->gamma_to_1);
png_ptr->gamma_to_1 = NULL;
if (png_ptr->gamma_16_from_1 != NULL)
{
int i;
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
}
png_free(png_ptr, png_ptr->gamma_16_from_1);
png_ptr->gamma_16_from_1 = NULL;
}
if (png_ptr->gamma_16_to_1 != NULL)
{
int i;
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
}
png_free(png_ptr, png_ptr->gamma_16_to_1);
png_ptr->gamma_16_to_1 = NULL;
}
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
}
@@ -3942,7 +3883,7 @@ png_destroy_gamma_table(png_structrp png_ptr)
* we don't need to allocate > 64K chunks for a full 16-bit table.
*/
void /* PRIVATE */
png_build_gamma_tables(png_structrp png_ptr, int bit_depth)
png_build_gamma_table(png_structrp png_ptr, int bit_depth)
{
png_debug(1, "in png_build_gamma_table");
@@ -3960,44 +3901,27 @@ png_build_gamma_tables(png_structrp png_ptr, int bit_depth)
if (bit_depth <= 8)
{
png_ptr->gamma_table = png_voidcast(png_bytep, png_build_gamma_table(
png_ptr, png_ptr->screen_gamma > 0 ?
png_reciprocal2(png_ptr->colorspace.gamma, png_ptr->screen_gamma) :
PNG_FP_1, PNG_GAMMA_TABLE_8, 8/*input depth*/, 0/*scale*/));
png_build_8bit_table(png_ptr, &png_ptr->gamma_table,
png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
png_ptr->screen_gamma) : PNG_FP_1);
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))
{
/* This sets the accuracy of 8-bit composition and the 8-bit RGB to gray
* conversion - PNG_MAX_GAMMA_8 (the number of bits in the sixteen bit
* value that are considered significant.)
*/
png_ptr->gamma_to_1 = png_voidcast(png_uint_16p, png_build_gamma_table(
png_ptr, png_reciprocal(png_ptr->colorspace.gamma),
PNG_GAMMA_TABLE_16, 8/*input depth*/, 0/*scale*/));
png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1,
png_reciprocal(png_ptr->colorspace.gamma));
png_ptr->gamma_from_1 = png_voidcast(png_bytep, png_build_gamma_table(
png_ptr, png_ptr->screen_gamma > 0 ?
png_reciprocal(png_ptr->screen_gamma) :
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */,
PNG_GAMMA_TABLE_8, PNG_MAX_GAMMA_8/*input depth*/, 1/*shift*/));
png_ptr->gamma_shift = 16-PNG_MAX_GAMMA_8;
png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,
png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
}
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
}
else
{
png_byte shift, sig_bit;
int table_type;
# ifdef PNG_16BIT_SUPPORTED
table_type = PNG_GAMMA_TABLE_16;
# else
table_type = PNG_GAMMA_TABLE_8_IN_16;
# endif
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
{
@@ -4012,6 +3936,24 @@ png_build_gamma_tables(png_structrp png_ptr, int bit_depth)
else
sig_bit = png_ptr->sig_bit.gray;
/* 16-bit gamma code uses this equation:
*
* ov = table[(iv & 0xff) >> gamma_shift][iv >> 8]
*
* Where 'iv' is the input color value and 'ov' is the output value -
* pow(iv, gamma).
*
* Thus the gamma table consists of up to 256 256 entry tables. The table
* is selected by the (8-gamma_shift) most significant of the low 8 bits of
* the color value then indexed by the upper 8 bits:
*
* table[low bits][high 8 bits]
*
* So the table 'n' corresponds to all those 'iv' of:
*
* <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1>
*
*/
if (sig_bit > 0 && sig_bit < 16U)
shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */
@@ -4022,40 +3964,51 @@ png_build_gamma_tables(png_structrp png_ptr, int bit_depth)
{
/* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively
* the significant bits in the *input* when the output will
* eventually be 8 bits.
* eventually be 8 bits. By default it is 11.
*/
if (shift < (16U - PNG_MAX_GAMMA_8))
shift = (16U - PNG_MAX_GAMMA_8);
table_type = PNG_GAMMA_TABLE_8_IN_16;
}
if (shift > 8U)
shift = 8U; /* Guarantees at least one table! */
png_ptr->gamma_shift = shift;
png_ptr->gamma_16_table = png_voidcast(png_uint_16p, png_build_gamma_table(
png_ptr, png_ptr->screen_gamma > 0 ? png_reciprocal2(
png_ptr->colorspace.gamma, png_ptr->screen_gamma) : PNG_FP_1,
table_type, (16-shift)/*input depth*/, 1/*shift*/));
#ifdef PNG_16BIT_SUPPORTED
/* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
* PNG_COMPOSE). This effectively smashed the background calculation for
* 16-bit output because the 8-bit table assumes the result will be reduced
* to 8 bits.
*/
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))
#endif
png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma,
png_ptr->screen_gamma) : PNG_FP_1);
#ifdef PNG_16BIT_SUPPORTED
else
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift,
png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
png_ptr->screen_gamma) : PNG_FP_1);
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))
{
png_ptr->gamma_16_to_1 = png_voidcast(png_uint_16p,
png_build_gamma_table(png_ptr,
png_reciprocal(png_ptr->colorspace.gamma), PNG_GAMMA_TABLE_16,
(16-shift)/*input depth*/, 1/*shift*/));
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift,
png_reciprocal(png_ptr->colorspace.gamma));
/* Notice that the '16 from 1' table should be full precision, however
* the lookup on this table still uses gamma_shift, so it can't be.
* TODO: fix this.
*/
png_ptr->gamma_16_from_1 = png_voidcast(png_uint_16p,
png_build_gamma_table(png_ptr, png_ptr->screen_gamma > 0 ?
png_reciprocal(png_ptr->screen_gamma) :
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */,
PNG_GAMMA_TABLE_16, (16-shift)/*input depth*/, 1/*shift*/));
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift,
png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
}
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
}

212
png.h
View File

@@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.7.0beta07 - April 14, 2013
* libpng version 1.6.2rc05 - April 23, 2013
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -11,7 +11,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.7.0beta07 - April 14, 2013: Glenn
* libpng versions 0.97, January 1998, through 1.6.2rc05 - April 23, 2013: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@@ -166,9 +166,14 @@
* 1.5.7beta01-05 15 10507 15.so.15.7[.0]
* 1.5.7rc01-03 15 10507 15.so.15.7[.0]
* 1.5.7 15 10507 15.so.15.7[.0]
* 1.6.0beta01-37 16 10600 16.so.16.0[.0]
* 1.7.0alpha01-10 17 10700 17.so.17.0[.0]
* 1.7.0beta01-07 17 10700 17.so.17.0[.0]
* 1.6.0beta01-40 16 10600 16.so.16.0[.0]
* 1.6.0rc01-08 16 10600 16.so.16.0[.0]
* 1.6.0 16 10600 16.so.16.0[.0]
* 1.6.1beta01-09 16 10601 16.so.16.1[.0]
* 1.6.1rc01 16 10601 16.so.16.1[.0]
* 1.6.1 16 10601 16.so.16.1[.0]
* 1.6.2beta01 16 10602 16.so.16.2[.0]
* 1.6.2rc01-05 16 10602 16.so.16.2[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -200,7 +205,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.7.0beta07, April 14, 2013, are
* libpng versions 1.2.6, August 15, 2004, through 1.6.2rc05, April 23, 2013, are
* Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
@@ -312,13 +317,13 @@
* Y2K compliance in libpng:
* =========================
*
* April 14, 2013
* April 23, 2013
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.7.0beta07 are Y2K compliant. It is my belief that
* upward through 1.6.2rc05 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
@@ -378,23 +383,23 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.7.0beta07"
#define PNG_LIBPNG_VER_STRING "1.6.2rc05"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.7.0beta07 - April 14, 2013\n"
" libpng version 1.6.2rc05 - April 23, 2013\n"
#define PNG_LIBPNG_VER_SONUM 17
#define PNG_LIBPNG_VER_DLLNUM 17
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 7
#define PNG_LIBPNG_VER_RELEASE 0
#define PNG_LIBPNG_VER_MINOR 6
#define PNG_LIBPNG_VER_RELEASE 2
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
*/
#define PNG_LIBPNG_VER_BUILD 07
#define PNG_LIBPNG_VER_BUILD 05
/* Release Status */
#define PNG_LIBPNG_BUILD_ALPHA 1
@@ -411,7 +416,7 @@
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_RC
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
@@ -419,7 +424,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
#define PNG_LIBPNG_VER 10700 /* 1.7.0 */
#define PNG_LIBPNG_VER 10602 /* 1.6.2 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -524,7 +529,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_0beta07;
typedef char* png_libpng_version_1_6_2rc05;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -665,8 +670,8 @@ typedef struct png_text_struct
png_charp key; /* keyword, 1-79 character description of "text" */
png_charp text; /* comment, may be an empty string (ie "")
or a NULL pointer */
size_t text_length; /* length of the text string */
size_t itxt_length; /* length of the itxt string */
png_size_t text_length; /* length of the text string */
png_size_t itxt_length; /* length of the itxt string */
png_charp lang; /* language code, 0-79 characters
or a NULL pointer */
png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
@@ -718,7 +723,7 @@ typedef struct png_unknown_chunk_t
{
png_byte name[5]; /* Textual chunk name with '\0' terminator */
png_byte *data; /* Data, should not be modified on read! */
size_t size;
png_size_t size;
/* On write 'location' must be set using the flag values listed below.
* Notice that on read it is set by libpng however the values stored have
@@ -743,7 +748,7 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
/* Maximum positive integer used in PNG is (2^31)-1 */
#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
#define PNG_UINT_32_MAX ((png_uint_32)(-1))
#define PNG_SIZE_MAX ((size_t)(-1))
#define PNG_SIZE_MAX ((png_size_t)(-1))
/* These are constants for fixed point values encoded in the
* PNG specification manner (x100000)
@@ -848,7 +853,7 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
typedef struct png_row_info_struct
{
png_uint_32 width; /* width of row */
size_t rowbytes; /* number of bytes in row */
png_size_t rowbytes; /* number of bytes in row */
png_byte color_type; /* color type of row */
png_byte bit_depth; /* bit depth of row */
png_byte channels; /* number of channels (1, 2, 3, or 4) */
@@ -867,7 +872,7 @@ typedef png_row_info * * png_row_infopp;
* expected to return the read data in the buffer.
*/
typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));
typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, size_t));
typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));
typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));
typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,
int));
@@ -1002,8 +1007,8 @@ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
* signature, and non-zero otherwise. Having num_to_check == 0 or
* start > 7 will always fail (ie return non-zero).
*/
PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, size_t start,
size_t num_to_check));
PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,
png_size_t num_to_check));
/* Simple signature checking function. This is the same as calling
* png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
@@ -1022,11 +1027,11 @@ PNG_EXPORTA(5, png_structp, png_create_write_struct,
png_error_ptr warn_fn),
PNG_ALLOCATED);
PNG_EXPORT(6, size_t, png_get_compression_buffer_size,
PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,
(png_const_structrp png_ptr));
PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,
size_t size));
png_size_t size));
/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
* match up.
@@ -1056,8 +1061,8 @@ PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),
PNG_NORETURN);
#ifdef PNG_READ_SUPPORTED
/* Reset the compression stream -- Removed from libpng-1.7.0 */
PNG_REMOVED(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED)
/* Reset the compression stream */
PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);
#endif
/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
@@ -1079,7 +1084,7 @@ PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));
/* Write a PNG chunk - size, type, (optional) data, CRC. */
PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep
chunk_name, png_const_bytep data, size_t length));
chunk_name, png_const_bytep data, png_size_t length));
/* Write the start of a PNG chunk - length and chunk name. */
PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,
@@ -1087,7 +1092,7 @@ PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,
png_const_bytep data, size_t length));
png_const_bytep data, png_size_t length));
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));
@@ -1096,9 +1101,12 @@ PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));
PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),
PNG_ALLOCATED);
/* Removed from libpng-1.7.0 */
PNG_REMOVED(19, void, png_info_init_3, (png_infopp info_ptr,
size_t png_info_struct_size), PNG_DEPRECATED)
/* DEPRECATED: this function allowed init structures to be created using the
* default allocation method (typically malloc). Use is deprecated in 1.6.0 and
* the API will be removed in the future.
*/
PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,
png_size_t png_info_struct_size), PNG_DEPRECATED);
/* Writes all the PNG information before the image. */
PNG_EXPORT(20, void, png_write_info_before_PLTE,
@@ -1115,10 +1123,13 @@ PNG_EXPORT(22, void, png_read_info,
#ifdef PNG_TIME_RFC1123_SUPPORTED
/* Convert to a US string format: there is no localization support in this
* routine. The original implementation used a 29 character buffer in
* png_struct, this has been removed (in libpng 1.7.0).
* png_struct, this will be removed in future versions.
*/
PNG_REMOVED(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
png_const_timep ptime),PNG_DEPRECATED)
#if PNG_LIBPNG_VER < 10700
/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */
PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
png_const_timep ptime),PNG_DEPRECATED);
#endif
PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],
png_const_timep ptime));
#endif
@@ -1615,8 +1626,22 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
int filters));
/* Flags for png_set_filter() to say which filters to use. The flags
* are chosen so that they don't conflict with real filter types
* below, in case they are supplied instead of the #defined constants.
* These values should NOT be changed.
*/
#define PNG_NO_FILTERS 0x00
#define PNG_FILTER_NONE 0x08
#define PNG_FILTER_SUB 0x10
#define PNG_FILTER_UP 0x20
#define PNG_FILTER_AVG 0x40
#define PNG_FILTER_PAETH 0x80
#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
PNG_FILTER_AVG | PNG_FILTER_PAETH)
/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
* These defines match the values in the PNG specification.
* These defines should NOT be changed.
*/
#define PNG_FILTER_VALUE_NONE 0
#define PNG_FILTER_VALUE_SUB 1
@@ -1625,26 +1650,6 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
#define PNG_FILTER_VALUE_PAETH 4
#define PNG_FILTER_VALUE_LAST 5
/* The above values are valid arguments to png_set_filter() if only a single
* filter is to be used. If multiple filters are to be allowed (the default is
* to allow any of them) then a combination of the following masks must be used
* and the low three bits of the argument to png_set_filter must be 0.
*
* The resultant argument fits in a single byte.
*/
#define PNG_FILTER_NONE (0x08 << PNG_FILTER_VALUE_NONE)
#define PNG_FILTER_SUB (0x08 << PNG_FILTER_VALUE_SUB)
#define PNG_FILTER_UP (0x08 << PNG_FILTER_VALUE_UP)
#define PNG_FILTER_AVG (0x08 << PNG_FILTER_VALUE_AVG)
#define PNG_FILTER_PAETH (0x08 << PNG_FILTER_VALUE_PAETH)
/* Then two convenience values. PNG_NO_FILTERS is the same as
* PNG_FILTER_VALUE_NONE, but this is harmless because they mean the same thing.
*/
#define PNG_NO_FILTERS 0x00
#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
PNG_FILTER_AVG | PNG_FILTER_PAETH)
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */
/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
* defines, either the default (minimum-sum-of-absolute-differences), or
@@ -1849,14 +1854,12 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
* The integer return from the callback function is interpreted thus:
*
* negative: An error occured, png_chunk_error will be called.
* zero: The chunk was not handled, the default unknown handling is used
* (even if this was a chunk that would otherwise be known.)
* NOTE: prior to libpng 1.7 handling values of
* PNG_HANDLE_CHUNK_AS_DEFAULT and PNG_HANDLE_CHUNK_NEVER were
* converted to PNG_HANDLE_CHUNK_IF_SAFE (libpng 1.6.0 warns if this
* happens) so it was not possible to discard unknown chunk data if a
* user callback was installed.
* zero: The chunk was not handled, the chunk will be saved. A critical
* chunk will cause an error at this point unless it is to be saved.
* positive: The chunk was handled, libpng will ignore/discard it.
*
* See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about
* how this behavior will change in libpng 1.7
*/
PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,
png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
@@ -1880,7 +1883,7 @@ PNG_EXPORT(91, png_voidp, png_get_progressive_ptr,
/* Function to be called when data becomes available */
PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,
png_inforp info_ptr, png_bytep buffer, size_t buffer_size));
png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size));
/* A function which may be called *only* within png_process_data to stop the
* processing of any more data. The function returns the number of bytes
@@ -1889,7 +1892,7 @@ PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,
* 'save' is set to true the routine will first save all the pending data and
* will always return 0.
*/
PNG_EXPORT(219, size_t, png_process_data_pause, (png_structrp, int save));
PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save));
/* A function which may be called *only* outside (after) a call to
* png_process_data. It returns the number of bytes of data to skip in the
@@ -1932,13 +1935,16 @@ PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
* in, it does not change the state for other png_info structures.
*
* It is unlikely that this function works correctly as of 1.6.0 and using it
* may result either in memory leaks or double free of allocated data. It was
* removed in libpng 1.7.0.
* may result either in memory leaks or double free of allocated data.
*/
PNG_REMOVED(99, void, png_data_freer, (png_const_structrp png_ptr,
png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED)
PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr,
png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED);
/* Flags for png_free_data */
/* Assignments for png_data_freer */
#define PNG_DESTROY_WILL_FREE_DATA 1
#define PNG_SET_WILL_FREE_DATA 1
#define PNG_USER_WILL_FREE_DATA 2
/* Flags for png_ptr->free_me and info_ptr->free_me */
#define PNG_FREE_HIST 0x0008
#define PNG_FREE_ICCP 0x0010
#define PNG_FREE_SPLT 0x0020
@@ -1956,14 +1962,10 @@ PNG_REMOVED(99, void, png_data_freer, (png_const_structrp png_ptr,
#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
#ifdef PNG_USER_MEM_SUPPORTED
/* These were deprecated in libpng 1.6.0 and have been removed from libpng
* 1.7.0; the functionality should be accessed by calling malloc or free
* directly or, if png_error handling is required, calling png_malloc.
*/
PNG_REMOVED(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED)
PNG_REMOVED(101, void, png_free_default, (png_const_structrp png_ptr,
png_voidp ptr), PNG_DEPRECATED)
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);
PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,
png_voidp ptr), PNG_DEPRECATED);
#endif
#ifdef PNG_ERROR_TEXT_SUPPORTED
@@ -2031,7 +2033,7 @@ PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,
png_const_inforp info_ptr, png_uint_32 flag));
/* Returns number of bytes needed to hold a transformed row. */
PNG_EXPORT(111, size_t, png_get_rowbytes, (png_const_structrp png_ptr,
PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr,
png_const_inforp info_ptr));
#ifdef PNG_INFO_IMAGE_SUPPORTED
@@ -2287,7 +2289,7 @@ PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,
#endif
#ifdef PNG_sPLT_SUPPORTED
PNG_EXPORT(161, void, png_set_sPLT, (png_structrp png_ptr,
PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,
png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));
#endif
@@ -2305,7 +2307,7 @@ PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,
*/
#ifdef PNG_TEXT_SUPPORTED
PNG_EXPORT(163, void, png_set_text, (png_structrp png_ptr,
PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,
png_inforp info_ptr, png_const_textp text_ptr, int num_text));
#endif
@@ -2332,14 +2334,15 @@ PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,
#endif
#ifdef PNG_sCAL_SUPPORTED
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
/* NOTE: these API are currently implemented using floating point arithmetic,
* consequently they can only be used on systems with floating point support.
PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,
png_const_inforp info_ptr, int *unit, double *width, double *height))
#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
defined(PNG_FLOATING_POINT_SUPPORTED)
/* NOTE: this API is currently implemented using floating point arithmetic,
* consequently it can only be used on systems with floating point support.
* In any case the range of values supported by png_fixed_point is small and it
* is highly recommended that png_get_sCAL_s be used instead.
*/
PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,
png_const_inforp info_ptr, int *unit, double *width, double *height))
PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,
(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
png_fixed_point *width, png_fixed_point *height))
@@ -2348,13 +2351,8 @@ PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
png_charpp swidth, png_charpp sheight));
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
/* This also requires internal floating point arithmetic support - i.e. it
* requires a full math library, not just floating point handling.
*/
PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,
png_inforp info_ptr, int unit, double width, double height))
#endif
PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,
png_inforp info_ptr, int unit, png_fixed_point width,
png_fixed_point height))
@@ -2370,13 +2368,8 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
* NOTE: prior to 1.6.0 the handling specified for particular chunks on read was
* ignored and the default was used, the per-chunk setting only had an effect on
* write. If you wish to have chunk-specific handling on read in code that must
* work on earlier versions you must use a user chunk callback to implement the
* work on earlier versions you must use a user chunk callback to specify the
* desired handling (keep or discard.)
*
* NOTE: prior to 1.7.0 when a user callback returned '0', indicating that the
* chunk had not been handled, libpng would preserve it regardless of the
* default or per-chunk settings. For compatibility with earlier versions
* simply return '1' (handled) from the callback to discard the chunk.
*
* The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The
* parameter is interpreted as follows:
@@ -2400,12 +2393,21 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
* to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks
* it simply resets the behavior to the libpng default.
*
* INTERACTION WTIH USER CHUNK CALLBACKS:
* The per-chunk handling is always used when there is a png_user_chunk_ptr
* callback and the callback returns 0; the chunk is then always stored *unless*
* it is critical and the per-chunk setting is other than ALWAYS. Notice that
* the global default is *not* used in this case. (In effect the per-chunk
* value is incremented to at least IF_SAFE.)
*
* IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and
* per-chunk defaults will be honored. If you want to preserve the current
* behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE
* as the default - if you don't do this libpng 1.6 will issue a warning.
*
* If you want unhandled unknown chunks to be discarded in libpng 1.6 and
* earlier simply return '1' (handled).
*
* PNG_HANDLE_AS_UNKNOWN_SUPPORTED:
* If this is *not* set known chunks will always be handled by libpng and
* will never be stored in the unknown chunk list. Known chunks listed to
@@ -2470,7 +2472,7 @@ PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
#endif
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_structrp png_ptr,
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
png_inforp info_ptr, png_const_unknown_chunkp unknowns,
int num_unknowns));
/* NOTE: prior to 1.6.0 this routine set the 'location' field of the added
@@ -3138,7 +3140,7 @@ PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,
#endif /* PNG_STDIO_SUPPORTED */
PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,
png_const_voidp memory, size_t size));
png_const_voidp memory, png_size_t size));
/* The PNG header is read from the given memory buffer. */
PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,
@@ -3234,8 +3236,8 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
(png_structrp png_ptr, int allowed));
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
PNG_EXPORT(243, int, png_get_palette_max, (png_const_structrp png_ptr,
png_const_inforp info_ptr));
PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
png_const_infop info_ptr));
# endif
#endif /* CHECK_FOR_INVALID_INDEX */
@@ -3281,7 +3283,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
******************************************************************************/
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
* defs
* defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt
*/
/* The last ordinal number (this is the *last* one already used; the next

View File

@@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.7.0beta07 - April 14, 2013
* libpng version 1.6.2rc05 - April 23, 2013
*
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -511,8 +511,6 @@
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
* requires an ISOC90 compiler and relies on consistent behavior of sizeof.
*
* DEPRECATED: don't use these types, instead use size_t and ptrdiff_t.
*/
typedef size_t png_size_t;
typedef ptrdiff_t png_ptrdiff_t;
@@ -533,13 +531,13 @@ typedef ptrdiff_t png_ptrdiff_t;
# endif
#endif
/* png_alloc_size_t is guaranteed to be no smaller than size_t, and no
* smaller than png_uint_32. Casts from size_t or png_uint_32 to
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
* png_alloc_size_t are not necessary; in fact, it is recommended not to use
* them at all so that the compiler can complain when something turns out to be
* problematic.
*
* Casts in the other direction (from png_alloc_size_t to size_t or
* Casts in the other direction (from png_alloc_size_t to png_size_t or
* png_uint_32) should be explicitly applied; however, we do not expect to
* encounter practical situations that require such conversions.
*
@@ -549,7 +547,7 @@ typedef ptrdiff_t png_ptrdiff_t;
#ifdef PNG_SMALL_SIZE_T
typedef png_uint_32 png_alloc_size_t;
#else
typedef size_t png_alloc_size_t;
typedef png_size_t png_alloc_size_t;
#endif
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
@@ -585,8 +583,8 @@ typedef char * png_charp;
typedef const char * png_const_charp;
typedef png_fixed_point * png_fixed_point_p;
typedef const png_fixed_point * png_const_fixed_point_p;
typedef size_t * png_size_tp;
typedef const size_t * png_const_size_tp;
typedef png_size_t * png_size_tp;
typedef const png_size_t * png_const_size_tp;
#ifdef PNG_STDIO_SUPPORTED
typedef FILE * png_FILE_p;

View File

@@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.1 [March 28, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -163,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02u:
/* Expects at least 2 digits. */
mincount = 2;
/* fall through */
/* FALL THROUGH */
case PNG_NUMBER_FORMAT_u:
*--end = digits[number % 10];
@@ -173,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02x:
/* This format expects at least two digits */
mincount = 2;
/* fall through */
/* FALL THROUGH */
case PNG_NUMBER_FORMAT_x:
*--end = digits[number & 0xf];
@@ -546,13 +546,7 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
}
#ifdef PNG_ERROR_TEXT_SUPPORTED
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
(defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \
(defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) &&\
defined(PNG_sCAL_SUPPORTED))
#ifdef PNG_FLOATING_POINT_SUPPORTED
PNG_FUNCTION(void,
png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
{
@@ -746,17 +740,8 @@ png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
#endif
/* If control reaches this point, png_longjmp() must not return. The only
* choice is to terminate the whole process (or maybe the thread); to do
* this the ANSI-C abort() function is used unless a different method is
* implemented by overriding the default configuration setting for
* PNG_ABORT (see scripts/pnglibconf.dfa).
*
* API change: prior to 1.7.0 PNG_ABORT was invoked as a function type macro
* with no arguments 'PNG_ABORT();', in 1.7.0 this is changed to a simple
* macro that is defined in the configuration.
*/
PNG_ABORT
/* Here if not setjmp support or if png_ptr is null. */
PNG_ABORT();
}
#ifdef PNG_WARNINGS_SUPPORTED

View File

@@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct
*
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.1 [March 28, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -843,8 +843,9 @@ png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
#endif
#ifdef PNG_sCAL_SUPPORTED
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
# ifdef PNG_FIXED_POINT_SUPPORTED
# ifdef PNG_FIXED_POINT_SUPPORTED
# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
defined(PNG_FLOATING_POINT_SUPPORTED)
png_uint_32 PNGAPI
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_fixed_point *width, png_fixed_point *height)
@@ -865,9 +866,9 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
return(0);
}
# endif /* FIXED_POINT */
# ifdef PNG_FLOATING_POINT_SUPPORTED
# endif /* FLOATING_ARITHMETIC */
# endif /* FIXED_POINT */
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, double *width, double *height)
@@ -883,9 +884,7 @@ png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
return(0);
}
# endif /* FLOATING POINT */
# endif /* FLOATING_ARITHMETIC */
# endif /* FLOATING POINT */
png_uint_32 PNGAPI
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_charpp width, png_charpp height)
@@ -1165,7 +1164,7 @@ png_get_io_chunk_type (png_const_structrp png_ptr)
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
int PNGAPI
png_get_palette_max(png_const_structrp png_ptr, png_const_inforp info_ptr)
png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return png_ptr->num_palette_max;

View File

@@ -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

View File

@@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.0 [February 14, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -123,7 +123,7 @@ png_malloc_array,(png_const_structrp png_ptr, int nelements,
}
PNG_FUNCTION(png_voidp /* PRIVATE */,
png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
{
/* These are internal errors: */
@@ -154,13 +154,6 @@ png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
}
}
#ifdef PNG_READ_SUPPORTED
/* The potential overflow case. Set the cache counter so libpng will
* not make any more attempts
*/
png_ptr->user_chunk_cache_max = 2;
#endif
return NULL; /* error */
}
@@ -179,11 +172,31 @@ png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
ret = png_malloc_base(png_ptr, size);
if (ret == NULL)
png_error(png_ptr, "Out of memory");
png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */
return ret;
}
#ifdef PNG_USER_MEM_SUPPORTED
PNG_FUNCTION(png_voidp,PNGAPI
png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
PNG_ALLOCATED PNG_DEPRECATED)
{
png_voidp ret;
if (png_ptr == NULL)
return NULL;
/* Passing 'NULL' here bypasses the application provided memory handler. */
ret = png_malloc_base(NULL/*use malloc*/, size);
if (ret == NULL)
png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */
return ret;
}
#endif /* PNG_USER_MEM_SUPPORTED */
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
* function will issue a png_warning and return NULL instead of issuing a
* png_error, if it fails to allocate the requested memory.
@@ -219,8 +232,17 @@ png_free(png_const_structrp png_ptr, png_voidp ptr)
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
else
png_free_default(png_ptr, ptr);
}
PNG_FUNCTION(void,PNGAPI
png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
{
if (png_ptr == NULL || ptr == NULL)
return;
#endif /* PNG_USER_MEM_SUPPORTED */
free(ptr);
free(ptr);
}
#ifdef PNG_USER_MEM_SUPPORTED

View File

@@ -1,7 +1,7 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.0 [February 14, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)

184
pngpriv.h
View File

@@ -6,7 +6,7 @@
* (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.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.2 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -40,17 +40,10 @@
#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
#ifndef PNG_VERSION_INFO_ONLY
/* Keep standard libraries at the top of this file */
/* Standard library headers not required by png.h: */
# include <stdlib.h>
# include <string.h>
/* For headers only required with some build configurations see the lines after
* pnglibconf.h is included!
*/
#endif /* VERSION_INFO_ONLY */
#endif
#define PNGLIB_BUILD /*libpng is being built, not used*/
@@ -95,36 +88,6 @@
# endif
#endif
#ifndef PNG_VERSION_INFO_ONLY
/* Additional standard libaries required in certain cases, put only standard
* ANSI-C89 headers here. If not available, or non-functional, the problem
* should be fixed by writing a wrapper for the header and the file on your
* include path.
*/
#if defined(PNG_sCAL_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
/* png.c requires the following ANSI-C constants if the conversion of
* floating point to ASCII is implemented therein:
*
* DBL_MIN_10_EXP Minimum negative integer such that 10^integer is a
* normalized (double) value.
* DBL_DIG Maximum number of decimal digits (can be set to any constant)
* DBL_MIN Smallest normalized fp number (can be set to an arbitrary value)
* DBL_MAX Maximum floating point number (can be set to an arbitrary value)
*/
# include <float.h>
#endif /* sCAL && FLOATING_POINT */
#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) ||\
defined(PNG_FLOATING_POINT_SUPPORTED)
/* ANSI-C90 math functions are required. Full compliance with the standard
* is probably not a requirement, but the functions must exist and be
* declared in <math.h>
*/
# include <math.h>
#endif /* FLOATING_ARITHMETIC || FLOATING_POINT */
#endif /* VERSION_INFO_ONLY */
/* Is this a build of a DLL where compilation of the object modules requires
* different preprocessor settings to those required for a simple library? If
* so PNG_BUILD_DLL must be set.
@@ -231,9 +194,6 @@
# endif
#endif
/* Include png.h here to get the version info and other macros, pngstruct.h and
* pnginfo.h are included later under the protection of !PNG_VERSION_INFO_ONLY
*/
#include "png.h"
/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */
@@ -241,17 +201,6 @@
# define PNG_DLL_EXPORT
#endif
/* asserts are turned off in release code, but are in even in release candidates
* because often system builders only check future libpng releases when a
* release candidate is available.
*/
#if PNG_LIBPNG_BUILD_BASE_TYPE == PNG_LIBPNG_BUILD_STABLE
# define NDEBUG
#endif
#ifndef PNG_VERSION_INFO_ONLY
# include <assert.h>
#endif
/* SECURITY and SAFETY:
*
* By default libpng is built without any internal limits on image size,
@@ -379,6 +328,67 @@
# define PNGFAPI /* PRIVATE */
#endif
#ifndef PNG_VERSION_INFO_ONLY
/* Other defines specific to compilers can go here. Try to keep
* them inside an appropriate ifdef/endif pair for portability.
*/
#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
/* png.c requires the following ANSI-C constants if the conversion of
* floating point to ASCII is implemented therein:
*
* DBL_DIG Maximum number of decimal digits (can be set to any constant)
* DBL_MIN Smallest normalized fp number (can be set to an arbitrary value)
* DBL_MAX Maximum floating point number (can be set to an arbitrary value)
*/
# include <float.h>
# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
/* We need to check that <math.h> hasn't already been included earlier
* as it seems it doesn't agree with <fp.h>, yet we should really use
* <fp.h> if possible.
*/
# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
# include <fp.h>
# endif
# else
# include <math.h>
# endif
# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
/* Amiga SAS/C: We must include builtin FPU functions when compiling using
* MATH=68881
*/
# include <m68881.h>
# endif
#endif
/* This provides the non-ANSI (far) memory allocation routines. */
#if defined(__TURBOC__) && defined(__MSDOS__)
# include <mem.h>
# include <alloc.h>
#endif
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
defined(_WIN32) || defined(__WIN32__)
# include <windows.h> /* defines _WINDOWS_ macro */
#endif
#endif /* PNG_VERSION_INFO_ONLY */
/* Moved here around 1.5.0beta36 from pngconf.h */
/* Users may want to use these so they are not private. Any library
* functions that are passed far data must be model-independent.
*/
/* Memory model/platform independent fns */
#ifndef PNG_ABORT
# ifdef _WINDOWS_
# define PNG_ABORT() ExitProcess(0)
# else
# define PNG_ABORT() abort()
# endif
#endif
/* These macros may need to be architecture dependent. */
#define PNG_ALIGN_NONE 0 /* do not use data alignment */
#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
@@ -447,7 +457,7 @@
#define PNG_HAVE_CHUNK_HEADER 0x100
#define PNG_WROTE_tIME 0x200
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
/* 0x800 (unused) */
#define PNG_BACKGROUND_IS_GRAY 0x800
#define PNG_HAVE_PNG_SIGNATURE 0x1000
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
/* 0x4000 (unused) */
@@ -461,10 +471,10 @@
#define PNG_SWAP_BYTES 0x0010
#define PNG_INVERT_MONO 0x0020
#define PNG_QUANTIZE 0x0040
#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
/* 0x0100 unused */
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
#define PNG_BACKGROUND_EXPAND 0x0100
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
#define PNG_RGBA 0x0800
#define PNG_EXPAND 0x1000
#define PNG_GAMMA 0x2000
@@ -479,13 +489,13 @@
#define PNG_RGB_TO_GRAY_WARN 0x400000
#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
/* 0x8000000 unused */
/* 0x10000000 unused */
/* 0x20000000 unused */
/* 0x40000000 unused */
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
/* 0x8000000 unused */
/* 0x10000000 unused */
/* 0x20000000 unused */
/* 0x40000000 unused */
/* Flags for png_create_struct */
#define PNG_STRUCT_PNG 0x0001
#define PNG_STRUCT_INFO 0x0002
@@ -518,8 +528,8 @@
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */
#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */
#define PNG_FLAG_BACKGROUND_IS_GRAY 0x800000
#define PNG_FLAG_BACKGROUND_EXPAND 0x1000000
/* 0x800000 unused */
/* 0x1000000 unused */
/* 0x2000000 unused */
/* 0x4000000 unused */
/* 0x8000000 unused */
@@ -542,16 +552,6 @@
abs((int)((c1).green) - (int)((c2).green)) + \
abs((int)((c1).blue) - (int)((c2).blue)))
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
/* See below for the definitions of the tables used in these macros */
#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
* encoded value with maximum error 0.646365. Note that the input is not a
* 16-bit value; it has been multiplied by 255! */
#endif /* PNG_SIMPLIFIED_READ/WRITE */
/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255
* by dividing by 257 *with rounding*. This macro is exact for the given range.
* See the discourse in pngrtran.c png_do_scale_16_to_8. The values in the
@@ -675,8 +675,8 @@
(void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)
/* Test on flag values as defined in the spec (section 5.4): */
#define PNG_CHUNK_ANCILLIARY(c) (1 & ((c) >> 29))
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLIARY(c))
#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29))
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c))
#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
@@ -711,6 +711,12 @@ PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
* encoded value with maximum error 0.646365. Note that the input is not a
* 16-bit value; it has been multiplied by 255! */
#endif /* PNG_SIMPLIFIED_READ/WRITE */
@@ -739,16 +745,6 @@ PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,
/* Free the buffer list used by the compressed write code. */
#endif
#ifdef PNG_WRITE_FILTER_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_write_alloc_filter_row_buffers,
(png_structrp png_ptr, int filters),PNG_EMPTY);
/* Allocate pixel row buffers to cache filtered rows while testing candidate
* filters.
* TODO: avoid this, only one spare row buffer (at most) is required, this
* wastes a lot of memory for large images.
*/
#endif
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
!defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
(defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
@@ -776,7 +772,7 @@ PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
/* Internal array allocator, outputs no error or warning messages on failure,
* just returns NULL.
* just returns NULL.
*/
PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,
int nelements, size_t element_size),PNG_ALLOCATED);
@@ -785,7 +781,7 @@ PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,
* also memsets the new elements to 0 and copies the old elements. The old
* array is not freed or altered.
*/
PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_structrp png_ptr,
PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,
png_const_voidp array, int old_elements, int add_elements,
size_t element_size),PNG_ALLOCATED);
#endif /* text, sPLT or unknown chunks */
@@ -966,7 +962,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr,
#endif
#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_structrp png_ptr,
PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr,
png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY);
#endif
@@ -1835,7 +1831,7 @@ PNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,
png_fixed_point gamma_value),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),
PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_build_gamma_tables,(png_structrp png_ptr,
PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,
int bit_depth),PNG_EMPTY);
#endif
@@ -1896,7 +1892,7 @@ PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);
#endif /* SIMPLIFIED READ/WRITE */
#ifdef PNG_FILTER_OPTIMIZATIONS
PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structrp png_ptr,
PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
unsigned int bpp), PNG_EMPTY);
/* This is the initialization function for hardware specific optimizations,
* one implementation (for ARM NEON machines) is contained in

View File

@@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.1 [March 28, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -877,7 +877,7 @@ png_read_destroy(png_structrp png_ptr)
png_free(png_ptr, png_ptr->save_buffer);
#endif
#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) && \
#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) &&\
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
png_free(png_ptr, png_ptr->unknown_chunk.data);
#endif

View File

@@ -1,7 +1,7 @@
/* pngrio.c - functions for data input
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.0 [February 14, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -102,7 +102,6 @@ png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
png_ptr->read_data_fn = read_data_fn;
#endif
#ifdef PNG_WRITE_SUPPORTED
/* It is an error to write to a read device */
if (png_ptr->write_data_fn != NULL)
{
@@ -111,7 +110,6 @@ png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
"Can't set both read_data_fn and write_data_fn in the"
" same structure");
}
#endif
#ifdef PNG_WRITE_FLUSH_SUPPORTED
png_ptr->output_flush_fn = NULL;

1131
pngrtran.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.2 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -18,6 +18,8 @@
#ifdef PNG_READ_SUPPORTED
#define png_strtod(p,a,b) strtod(a,b)
png_uint_32 PNGAPI
png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
{
@@ -219,7 +221,7 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
if (png_crc_error(png_ptr))
{
if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name) ?
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) ?
!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) :
(png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))
{
@@ -248,7 +250,7 @@ png_crc_error(png_structrp png_ptr)
png_uint_32 crc;
int need_crc = 1;
if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))
{
if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
@@ -560,7 +562,7 @@ png_decompress_chunk(png_structrp png_ptr,
*/
png_alloc_size_t limit = PNG_SIZE_MAX;
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
if (png_ptr->user_chunk_malloc_max > 0 &&
png_ptr->user_chunk_malloc_max < limit)
limit = png_ptr->user_chunk_malloc_max;
@@ -1580,8 +1582,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_warning(png_ptr, "No space in chunk cache for sPLT");
png_crc_finish(png_ptr, length);
return;
}
@@ -1658,8 +1659,8 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (dl > max_dl)
{
png_warning(png_ptr, "sPLT chunk too long");
return;
png_warning(png_ptr, "sPLT chunk too long");
return;
}
new_palette.nentries = (png_int_32)(data_length / entry_size);
@@ -1669,8 +1670,8 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (new_palette.entries == NULL)
{
png_warning(png_ptr, "sPLT chunk requires too much memory");
return;
png_warning(png_ptr, "sPLT chunk requires too much memory");
return;
}
#ifdef PNG_POINTER_INDEXING_SUPPORTED
@@ -1831,8 +1832,6 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
*/
png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
&(png_ptr->trans_color));
png_ptr->trans_alpha = info_ptr->trans_alpha;
}
#endif
@@ -2371,7 +2370,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;
}
}
@@ -2450,7 +2449,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;
}
}
@@ -2559,7 +2558,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;
}
}
@@ -2699,7 +2698,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
png_ptr->unknown_chunk.data = NULL;
}
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
if (png_ptr->user_chunk_malloc_max > 0 &&
png_ptr->user_chunk_malloc_max < limit)
limit = png_ptr->user_chunk_malloc_max;
@@ -2801,19 +2800,41 @@ 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)
{
/* If the keep value is 'default' or 'never' override it, but
* still error out on critical chunks unless the keep value is
* 'always' While this is weird it is the behavior in 1.4.12.
* A possible improvement would be to obey the value set for the
* chunk, but this would be an API change that would probably
* damage some applications.
*
* The png_app_warning below catches the case that matters, where
* the application has not set specific save or ignore for this
* chunk or global save or ignore.
*/
if (keep < PNG_HANDLE_CHUNK_IF_SAFE)
{
# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE)
{
png_chunk_warning(png_ptr, "Saving unknown chunk:");
png_app_warning(png_ptr,
"forcing save of an unhandled chunk;"
" please call png_set_keep_unknown_chunks");
/* with keep = PNG_HANDLE_CHUNK_IF_SAFE */
}
# endif
keep = PNG_HANDLE_CHUNK_IF_SAFE;
}
}
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
@@ -2836,7 +2857,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name)))
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
{
if (!png_cache_unknown_chunk(png_ptr, length))
keep = PNG_HANDLE_CHUNK_NEVER;
@@ -2870,14 +2891,14 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
*/
if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name)))
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
{
# ifdef PNG_USER_LIMITS_SUPPORTED
switch (png_ptr->user_chunk_cache_max)
{
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
@@ -4357,7 +4378,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_error(png_ptr, "This image requires a row greater than 64KB");
#endif
if (row_bytes + 48 > png_ptr->big_row_buf_size)
if (row_bytes + 48 > png_ptr->old_big_row_buf_size)
{
png_free(png_ptr, png_ptr->big_row_buf);
png_free(png_ptr, png_ptr->big_prev_row);
@@ -4394,7 +4415,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_ptr->row_buf = png_ptr->big_row_buf + 31;
png_ptr->prev_row = png_ptr->big_prev_row + 31;
#endif
png_ptr->big_row_buf_size = row_bytes + 48;
png_ptr->old_big_row_buf_size = row_bytes + 48;
}
#ifdef PNG_MAX_MALLOC_64K

142
pngset.c
View File

@@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.2 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -431,8 +431,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
info_ptr->free_me |= PNG_FREE_SCAL;
}
# if defined(PNG_FLOATING_POINT_SUPPORTED) &&\
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
# ifdef PNG_FLOATING_POINT_SUPPORTED
void PNGAPI
png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
double width, double height)
@@ -690,7 +689,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
#ifdef PNG_TEXT_SUPPORTED
void PNGAPI
png_set_text(png_structrp png_ptr, png_inforp info_ptr,
png_set_text(png_const_structrp png_ptr, png_inforp info_ptr,
png_const_textp text_ptr, int num_text)
{
int ret;
@@ -701,7 +700,7 @@ png_set_text(png_structrp png_ptr, png_inforp info_ptr,
}
int /* PRIVATE */
png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
png_const_textp text_ptr, int num_text)
{
int i;
@@ -748,7 +747,6 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
{
png_chunk_report(png_ptr, "too many text chunks",
PNG_CHUNK_WRITE_ERROR);
return 1;
}
@@ -928,97 +926,59 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
png_chunk_report(png_ptr,
"png_set_tRNS: invalid on PNG with alpha channel", PNG_CHUNK_ERROR);
else if (info_ptr->color_type & PNG_COLOR_MASK_PALETTE)
if (trans_alpha != NULL)
{
int max_num;
/* It may not actually be necessary to set png_ptr->trans_alpha here;
* we do it for backward compatibility with the way the png_handle_tRNS
* function used to do the allocation.
*
* 1.6.0: The above statement is incorrect; png_handle_tRNS effectively
* relies on png_set_tRNS storing the information in png_struct
* (otherwise it won't be there for the code in pngrtran.c).
*/
/* Free the old data; num_trans 0 can be used to kill the tRNS */
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
/* Do this just in case the old data was not owned by libpng: */
info_ptr->valid &= ~PNG_INFO_tRNS;
info_ptr->trans_alpha = NULL;
info_ptr->num_trans = 0;
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep,
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
/* Expect png_set_PLTE to happen before png_set_tRNS, so num_palette will
* be set, but this is not a requirement of the API.
*/
if (png_ptr->num_palette)
max_num = png_ptr->num_palette;
else
max_num = 1 << png_ptr->bit_depth;
if (num_trans > max_num)
{
png_chunk_report(png_ptr, "png_set_tRNS: num_trans too large",
PNG_CHUNK_ERROR);
/* If control returns simply limit it; the behavior prior to 1.7 was to
* issue a warning and skip the palette in png_write_tRNS.
*/
num_trans = max_num;
}
/* But only attempt a malloc if there is something to do; so the app can
* set a tRNS array then later delete it.
*/
if (num_trans > 0 && trans_alpha != NULL)
{
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1,
* this avoids issues where a palette image contains out of range
* indices.
*/
info_ptr->trans_alpha = png_voidcast(png_bytep, png_malloc(png_ptr,
PNG_MAX_PALETTE_LENGTH));
info_ptr->free_me |= PNG_FREE_TRNS;
memcpy(info_ptr->trans_alpha, trans_alpha,
(unsigned)/*SAFE*/num_trans);
info_ptr->valid |= PNG_INFO_tRNS;
info_ptr->num_trans = (png_uint_16)num_trans; /* SAFE */
}
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
}
else /* not a PALETTE image */
if (trans_color != NULL)
{
/* Invalidate any prior transparent color, set num_trans too, it is not
* used internally in this case but png_get_tRNS still returns it.
*/
info_ptr->valid &= ~PNG_INFO_tRNS;
info_ptr->num_trans = 0; /* for png_get_tRNS */
int sample_max = (1 << info_ptr->bit_depth);
if (trans_color != NULL)
{
int sample_max = (1 << info_ptr->bit_depth);
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
trans_color->gray > sample_max) ||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
(trans_color->red > sample_max ||
trans_color->green > sample_max ||
trans_color->blue > sample_max)))
png_warning(png_ptr,
"tRNS chunk has out-of-range samples for bit_depth");
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
trans_color->gray <= sample_max) ||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
trans_color->red <= sample_max &&
trans_color->green <= sample_max &&
trans_color->blue <= sample_max))
{
info_ptr->trans_color = *trans_color;
info_ptr->valid |= PNG_INFO_tRNS;
info_ptr->num_trans = 1; /* for png_get_tRNS */
}
info_ptr->trans_color = *trans_color;
else
png_chunk_report(png_ptr,
"tRNS chunk has out-of-range samples for bit_depth",
PNG_CHUNK_ERROR);
}
if (num_trans == 0)
num_trans = 1;
}
info_ptr->num_trans = (png_uint_16)num_trans;
if (num_trans != 0)
{
info_ptr->valid |= PNG_INFO_tRNS;
info_ptr->free_me |= PNG_FREE_TRNS;
}
}
#endif
#ifdef PNG_sPLT_SUPPORTED
void PNGAPI
png_set_sPLT(png_structrp png_ptr,
png_set_sPLT(png_const_structrp png_ptr,
png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)
/*
* entries - array of png_sPLT_t structures
@@ -1045,7 +1005,6 @@ png_set_sPLT(png_structrp png_ptr,
{
/* Out of memory or too many chunks */
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
return;
}
@@ -1154,7 +1113,7 @@ check_location(png_const_structrp png_ptr, int location)
}
void PNGAPI
png_set_unknown_chunks(png_structrp png_ptr,
png_set_unknown_chunks(png_const_structrp png_ptr,
png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
{
png_unknown_chunkp np;
@@ -1199,7 +1158,6 @@ png_set_unknown_chunks(png_structrp png_ptr,
{
png_chunk_report(png_ptr, "too many unknown chunks",
PNG_CHUNK_WRITE_ERROR);
return;
}
@@ -1576,19 +1534,19 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
* rejected by png_set_IHDR(). To accept any PNG datastream
* regardless of dimensions, set both limits to 0x7ffffffL.
*/
if (png_ptr != NULL)
{
png_ptr->user_width_max = user_width_max;
png_ptr->user_height_max = user_height_max;
}
if (png_ptr == NULL)
return;
png_ptr->user_width_max = user_width_max;
png_ptr->user_height_max = user_height_max;
}
/* This function was added to libpng 1.4.0 */
void PNGAPI
png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
{
if (png_ptr != NULL)
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
if (png_ptr)
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
}
/* This function was added to libpng 1.4.1 */
@@ -1596,7 +1554,7 @@ void PNGAPI
png_set_chunk_malloc_max (png_structrp png_ptr,
png_alloc_size_t user_chunk_malloc_max)
{
if (png_ptr != NULL)
if (png_ptr)
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
}
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */

View File

@@ -5,7 +5,7 @@
* (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.7.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
@@ -28,9 +28,7 @@
/* We must ensure that zlib uses 'const' in declarations. */
# define ZLIB_CONST
#endif
#include PNG_ZLIB_HEADER
#include "zlib.h"
#ifdef const
/* zlib.h sometimes #defines const to nothing, undo this. */
# undef const
@@ -50,10 +48,10 @@
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
* can handle at once. This type need be no larger than 16 bits (so maximum of
* 65535), this define allows us to discover how big it is, but limited by the
* maximum for size_t. The value can be overridden in a library build (pngusr.h,
* or set it in CPPFLAGS) and it works to set it to a considerably lower value
* (e.g. 255 works). A lower value may help memory usage (slightly) and may
* even improve performance on some systems (and degrade it on others.)
* maximuum for png_size_t. The value can be overriden in a library build
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
* lower value (e.g. 255 works). A lower value may help memory usage (slightly)
* and may even improve performance on some systems (and degrade it on others.)
*/
#ifndef ZLIB_IO_MAX
# define ZLIB_IO_MAX ((uInt)-1)
@@ -139,373 +137,224 @@ typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
#define PNG_COLORSPACE_FROM_sRGB 0x0020
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
#define PNG_COLORSPACE_RGB_TO_GRAY_SET 0x0100 /* user specified coeffs */
#define PNG_COLORSPACE_INVALID 0x8000
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
#endif /* COLORSPACE || GAMMA */
struct png_struct_def
{
/* Rearranged in libpng 1.7 to attempt to lessen padding; in general
* (char), (short), (int) and pointer types are kept separate, however
* associated members under the control of the same #define are still
* together.
*/
#ifdef PNG_SETJMP_SUPPORTED
/* jmp_buf can have very high alignment requirements on some systems, so put
* it first (the other setjmp members are later as they are infrequently
* accesed.)
*/
jmp_buf jmp_buf_local;
jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
size_t jmp_buf_size; /* size of the above, if allocated */
#endif
png_error_ptr error_fn; /* function for printing errors and aborting */
#ifdef PNG_WARNINGS_SUPPORTED
png_error_ptr warning_fn; /* function for printing warnings */
#endif
png_voidp error_ptr; /* user supplied struct for error functions */
png_rw_ptr write_data_fn; /* function for writing output data */
png_rw_ptr read_data_fn; /* function for reading input data */
png_voidp io_ptr; /* ptr to application struct for I/O functions */
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
png_user_transform_ptr read_user_transform_fn; /* user read transform */
#endif
/* Next the frequently accessed fields. Many processors perform arithmetic
* in the address pipeline, but frequently the amount of addition or
* subtraction is limited. By putting these fields at the head of png_struct
* the hope is that such processors will generate code that is both smaller
* and faster.
*/
png_colorp palette; /* palette from the input file */
size_t rowbytes; /* size of row in bytes */
size_t info_rowbytes; /* cache of updated row bytes */
png_uint_32 width; /* width of image in pixels */
png_uint_32 height; /* height of image in pixels */
png_uint_32 num_rows; /* number of rows in current pass */
png_uint_32 usr_width; /* width of row at start of write */
png_uint_32 iwidth; /* width of current interlaced row in pixels */
png_uint_32 row_number; /* current row in interlace pass */
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
png_uint_32 crc; /* current chunk CRC value */
png_uint_32 mode; /* tells us where we are in the PNG file */
png_uint_32 flags; /* flags indicating various things to libpng */
png_uint_32 transformations;/* which transformations to perform */
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
png_uint_32 free_me; /* items libpng is responsible for freeing */
int maximum_pixel_depth; /* pixel depth used for the row buffers */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
int num_palette_max; /* maximum palette index found in IDAT */
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
png_user_transform_ptr write_user_transform_fn; /* user write transform */
#endif
/* These were added in libpng-1.0.2 */
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_voidp user_transform_ptr; /* user supplied struct for user transform */
png_byte user_transform_depth; /* bit depth of user transformed pixels */
png_byte user_transform_channels; /* channels in user transformed pixels */
#endif
#endif
png_uint_32 mode; /* tells us where we are in the PNG file */
png_uint_32 flags; /* flags indicating various things to libpng */
png_uint_32 transformations; /* which transformations to perform */
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
z_stream zstream; /* decompression structure */
#ifdef PNG_WRITE_SUPPORTED
png_compression_bufferp zbuffer_list; /* Created on demand during write */
uInt zbuffer_size; /* size of the actual buffer */
int zlib_level; /* holds zlib compression level */
int zlib_method; /* holds zlib compression method */
int zlib_window_bits; /* holds zlib compression window bits */
int zlib_mem_level; /* holds zlib compression memory level */
int zlib_strategy; /* holds zlib compression strategy */
#endif
/* Added at libpng 1.5.4 */
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
int zlib_text_level; /* holds zlib compression level */
int zlib_text_method; /* holds zlib compression method */
int zlib_text_window_bits; /* holds zlib compression window bits */
int zlib_text_mem_level; /* holds zlib compression memory level */
int zlib_text_strategy; /* holds zlib compression strategy */
#endif
/* End of material added at libpng 1.5.4 */
/* Added at libpng 1.6.0 */
#ifdef PNG_WRITE_SUPPORTED
int zlib_set_level; /* Actual values set into the zstream on write */
int zlib_set_method;
int zlib_set_window_bits;
int zlib_set_mem_level;
int zlib_set_strategy;
#endif
png_uint_32 width; /* width of image in pixels */
png_uint_32 height; /* height of image in pixels */
png_uint_32 num_rows; /* number of rows in current pass */
png_uint_32 usr_width; /* width of row at start of write */
png_size_t rowbytes; /* size of row in bytes */
png_uint_32 iwidth; /* width of current interlaced row in pixels */
png_uint_32 row_number; /* current row in interlace pass */
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
* This is a pointer into big_prev_row
*/
png_bytep row_buf; /* buffer to save current (unfiltered) row.
* This is a pointer into big_row_buf
*/
#ifdef PNG_WRITE_SUPPORTED
png_bytep sub_row; /* buffer to save "sub" row when filtering */
png_bytep up_row; /* buffer to save "up" row when filtering */
png_bytep avg_row; /* buffer to save "avg" row when filtering */
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
#endif
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
png_uint_32 idat_size; /* current IDAT size for read */
png_uint_32 crc; /* current chunk CRC value */
png_colorp palette; /* palette from the input file */
png_uint_16 num_palette; /* number of color entries in palette */
png_uint_16 num_trans; /* number of transparency values */
/* Single byte values, typically used either to save space or to hold 1-byte
* values from the PNG chunk specifications.
*/
png_byte compression_type; /* file compression type (always 0) */
/* Added at libpng-1.5.10 */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
int num_palette_max; /* maximum palette index found in IDAT */
#endif
png_uint_16 num_trans; /* number of transparency values */
png_byte compression; /* file compression type (always 0) */
png_byte filter; /* file filter type (always 0) */
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
png_byte pass; /* current interlace pass (0 - 6) */
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
png_byte color_type; /* color type of file */
png_byte bit_depth; /* bit depth of file */
png_byte usr_bit_depth; /* bit depth of users row: write only */
png_byte pixel_depth; /* number of bits per pixel */
png_byte channels; /* number of channels in file */
#ifdef PNG_WRITE_SUPPORTED
png_byte usr_channels; /* channels at start of write: write only */
#endif
png_byte sig_bytes; /* magic bytes read/written from start of file */
png_byte maximum_pixel_depth;
/* pixel depth used for the row buffers */
png_byte transformed_pixel_depth;
/* pixel depth after read/write transforms */
/* ERROR HANDLING */
#ifdef PNG_SETJMP_SUPPORTED
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
png_longjmp_ptr longjmp_fn; /* setjmp non-local goto function. */
size_t jmp_buf_size; /* size of *jmp_buf_ptr, if allocated */
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
png_uint_16 filler; /* filler bytes for pixel expansion */
#endif
/* Error/warning callbacks */
png_error_ptr error_fn; /* print an error message and abort */
#ifdef PNG_WARNINGS_SUPPORTED
png_error_ptr warning_fn; /* print a warning and continue */
#endif
png_voidp error_ptr; /* user supplied data for the above */
/* MEMORY ALLOCATION */
#ifdef PNG_USER_MEM_SUPPORTED
png_malloc_ptr malloc_fn; /* allocate memory */
png_free_ptr free_fn; /* free memory */
png_voidp mem_ptr; /* user supplied data for the above */
#endif
/* IO and BASIC READ/WRITE SUPPORT */
png_voidp io_ptr; /* user supplied data for IO callbacks */
#ifdef PNG_READ_SUPPORTED
png_rw_ptr read_data_fn; /* read some bytes (must succeed) */
png_read_status_ptr read_row_fn; /* called after each row is decoded */
png_bytep read_buffer; /* buffer for reading chunk data */
/* During read the following array is set up to point to the appropriate
* un-filter function, this allows per-image and per-processor optimization.
*/
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row);
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
/* The png_struct colorspace structure is only required on read - on write it
* is in (just) the info_struct.
*/
png_colorspace colorspace;
#endif
#endif /* PNG_READ_SUPPORTED */
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
png_uint_32 user_width_max; /* Maximum width on read */
png_uint_32 user_height_max; /* Maximum height on read */
/* Total memory that a single zTXt, sPLT, iTXt, iCCP, or unknown chunk
* can occupy when decompressed. 0 means unlimited. This field is a counter
* - it is decremented as memory is allocated.
*/
png_alloc_size_t user_chunk_malloc_max;
#endif
#ifdef PNG_USER_LIMITS_SUPPORTED
/* limit on total *number* of sPLT, text and unknown chunks that can be
* stored. 0 means unlimited. This field is a counter - it is decremented
* as chunks are encountered.
*/
png_uint_32 user_chunk_cache_max;
#endif
/* The progressive reader gets passed data and calls application handling
* functions when appropriate.
*/
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
png_progressive_info_ptr info_fn; /* called after header data fully read */
png_progressive_row_ptr row_fn; /* called after a row is decoded */
png_progressive_end_ptr end_fn; /* called after image is complete */
/* Progressive read control data */
png_bytep save_buffer_ptr; /* current location in save_buffer */
png_bytep save_buffer; /* buffer for previously read data */
png_bytep current_buffer_ptr; /* current location in current_buffer */
png_bytep current_buffer; /* buffer for recently used data */
size_t save_buffer_size; /* amount of data now in save_buffer */
size_t save_buffer_max; /* total size of save_buffer */
size_t buffer_size; /* total amount of available input data */
size_t current_buffer_size; /* amount of data now in current_buffer */
png_uint_32 push_length; /* size of current input chunk */
png_uint_32 skip_length; /* bytes to skip in input data */
int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */
#endif
#ifdef PNG_WRITE_SUPPORTED
png_rw_ptr write_data_fn;/* write some bytes (must succeed) */
png_write_status_ptr write_row_fn; /* called after each row is encoded */
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
png_byte background_gamma_type;
png_fixed_point background_gamma;
png_color_16 background; /* background color in screen gamma space */
#ifdef PNG_READ_GAMMA_SUPPORTED
png_color_16 background_1; /* background normalized to gamma 1.0 */
#endif
#endif /* PNG_bKGD_SUPPORTED */
#ifdef PNG_WRITE_FLUSH_SUPPORTED
png_flush_ptr output_flush_fn; /* Function for flushing output */
png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
png_uint_32 flush_rows; /* number of rows written since last flush */
png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
png_uint_32 flush_rows; /* number of rows written since last flush */
#endif
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
png_bytep prev_filters; /* filter type(s) of previous row(s) */
png_uint_16p filter_weights; /* weight(s) for previous line(s) */
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
png_uint_16p filter_costs; /* relative filter calculation cost */
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
png_byte heuristic_method; /* heuristic for row filter selection */
png_byte num_prev_filters; /* number of weights for previous rows */
#endif
#ifdef PNG_WRITE_SUPPORTED
png_byte usr_bit_depth; /* bit depth of users row */
png_byte usr_channels; /* channels at start of write */
#endif
#ifdef PNG_IO_STATE_SUPPORTED
png_uint_32 io_state; /* tells the app read/write progress */
#endif
/* ROW BUFFERS
*
* Members that hold pointers to the decompressed image rows.
*/
png_bytep row_buf; /* buffer for the current (unfiltered) row */
#if defined(PNG_WRITE_FILTER_SUPPORTED) || defined(PNG_READ_SUPPORTED)
png_bytep prev_row; /* buffer to save the previous (unfiltered) row */
#endif
#ifdef PNG_READ_SUPPORTED
/* The row_buf and prev_row pointers are misaligned so that the start of the
* row - after the filter byte - is aligned, the 'big_' pointers record the
* original allocated pointer.
*/
png_bytep big_row_buf;
png_bytep big_prev_row;
size_t big_row_buf_size; /* Actual size of both */
#endif
#ifdef PNG_WRITE_SUPPORTED
/* This is somewhat excessive, there is no obvious reason on write to
* allocate a buffer for each possible filtered row, only for the one being
* tested and the current best.
*
* TODO: fix this
*/
png_bytep sub_row; /* buffer to save "sub" row when filtering */
png_bytep up_row; /* buffer to save "up" row when filtering */
png_bytep avg_row; /* buffer to save "avg" row when filtering */
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
#endif
/* UNKNOWN CHUNK HANDLING */
/* TODO: this is excessively complicated, there are multiple ways of doing
* the same thing. It should be cleaned up, possibly by finding out which
* APIs applications really use.
*/
#ifdef PNG_USER_CHUNKS_SUPPORTED
/* General purpose pointer for all user/unknown chunk handling; points to
* application supplied data for use in the read_user_chunk_fn callback
* (currently there is no write side support - the write side must use the
* set_unknown_chunks interface.)
*/
png_voidp user_chunk_ptr;
#endif
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
/* This is called back from the unknown chunk handling */
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
#endif
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
/* Temporary storage for unknown chunk that the library doesn't recognize,
* used while reading the chunk.
*/
png_unknown_chunk unknown_chunk;
#endif
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
* followed by a PNG_HANDLE_* byte */
int unknown_default; /* As PNG_HANDLE_* */
unsigned int num_chunk_list; /* Number of entries in the list */
#endif
/* USER TRANSFORM SUPPORT */
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
png_user_transform_ptr read_user_transform_fn; /* user read transform */
#endif
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
png_user_transform_ptr write_user_transform_fn; /* user write transform */
#endif
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
png_voidp user_transform_ptr; /* user supplied data for the above */
png_byte user_transform_depth; /* bit depth of user transformed pixels */
png_byte user_transform_channels; /* channels in user transformed pixels */
#endif
/* READ TRANSFORM SUPPORT
*
* Quite a lot of things can be done to the original image data on read, and
* most of these are configurable. The data required by the configurable
* read transforms should be stored here. The png_color_16 and png_color_8
* structures have low alignment requirements and odd sizes, so may cause
* misalignment when present. Member alignment is as follows:
*
* png_color_16 png_uint_16
* png_color_8 png_byte
*/
/* GAMMA/BACKGROUND/ALPHA-MODE/RGB-TO-GRAY/tRNS/sBIT
*
* These things are all interrelated because they need some or all of the
* gamma tables. Some attempt has been made below to order these members by
* size, so that as little padding as possible is required.
*/
#ifdef PNG_READ_GAMMA_SUPPORTED
png_bytep gamma_table; /* gamma table for 8-bit depth files */
png_uint_16p gamma_16_table; /* gamma table for 16-bit depth files */
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
defined(PNG_READ_ALPHA_MODE_SUPPORTED) ||\
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_bytep gamma_from_1; /* converts from 1.0 to screen */
png_uint_16p gamma_to_1; /* converts from file to 1.0 */
png_uint_16p gamma_16_from_1; /* converts from 1.0 to screen */
png_uint_16p gamma_16_to_1; /* converts from file to 1.0 */
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
#endif /* PNG_READ_GAMMA_SUPPORTED */
#if defined(PNG_READ_tRNS_SUPPORTED) || \
defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_EXPAND_SUPPORTED)
png_bytep trans_alpha; /* alpha values for paletted files */
#endif
/* Integer values */
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
png_fixed_point background_gamma;
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
png_bytep gamma_table; /* gamma table for 8-bit depth files */
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_bytep gamma_from_1; /* converts from 1.0 to screen */
png_bytep gamma_to_1; /* converts from file to 1.0 */
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
#endif
/* png_color_16 */
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
png_color_16 background; /* background color in screen gamma space */
png_color_16 background_1; /* background normalized to gamma 1.0 */
#endif
#if defined(PNG_READ_tRNS_SUPPORTED) || \
defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_EXPAND_SUPPORTED)
png_color_16 trans_color; /* transparent color for non-paletted files */
#endif
/* png_uint_16 */
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
png_uint_16 rgb_to_gray_red_coeff;
png_uint_16 rgb_to_gray_green_coeff;
/* The blue coefficient is calculated from the above */
#endif
/* png_color_8 */
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_sBIT_SUPPORTED)
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
png_color_8 sig_bit; /* significant bits in each available channel */
#endif
/* png_byte */
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
png_byte background_gamma_type;
#endif
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
png_byte rgb_to_gray_status;
#endif
/* SHIFT - both READ_SHIFT and WRITE_SHIFT */
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
png_color_8 shift; /* shift for significant bit tranformation */
#endif
/* FILLER SUPPORT (pixel expansion or read, contraction on write) */
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
png_uint_16 filler; /* filler bytes for pixel expansion */
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
|| defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep trans_alpha; /* alpha values for paletted files */
png_color_16 trans_color; /* transparent color for non-paletted files */
#endif
png_read_status_ptr read_row_fn; /* called after each row is decoded */
png_write_status_ptr write_row_fn; /* called after each row is encoded */
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
png_progressive_info_ptr info_fn; /* called after header data fully read */
png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */
png_progressive_end_ptr end_fn; /* called after image is complete */
png_bytep save_buffer_ptr; /* current location in save_buffer */
png_bytep save_buffer; /* buffer for previously read data */
png_bytep current_buffer_ptr; /* current location in current_buffer */
png_bytep current_buffer; /* buffer for recently used data */
png_uint_32 push_length; /* size of current input chunk */
png_uint_32 skip_length; /* bytes to skip in input data */
png_size_t save_buffer_size; /* amount of data now in save_buffer */
png_size_t save_buffer_max; /* total size of save_buffer */
png_size_t buffer_size; /* total amount of available input data */
png_size_t current_buffer_size; /* amount of data now in current_buffer */
int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
/* For the Borland special 64K segment handler */
png_bytepp offset_table_ptr;
png_bytep offset_table;
png_uint_16 offset_table_number;
png_uint_16 offset_table_count;
png_uint_16 offset_table_count_free;
#endif
/* QUANTIZE (convert to color-mapped) */
#ifdef PNG_READ_QUANTIZE_SUPPORTED
png_bytep palette_lookup; /* lookup table for quantizing */
png_bytep quantize_index; /* index translation for palette files */
png_bytep quantize_sort; /* working sort array */
png_bytep index_to_palette; /* where the original index currently is in the
* palette
*/
png_bytep palette_to_index; /* which original index points to this palette
* color
*/
png_bytep palette_lookup; /* lookup table for quantizing */
png_bytep quantize_index; /* index translation for palette files */
#endif
/* MNG SUPPORT */
#ifdef PNG_MNG_FEATURES_SUPPORTED
png_uint_32 mng_features_permitted;
png_byte filter_type;
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
png_byte heuristic_method; /* heuristic for row filter selection */
png_byte num_prev_filters; /* number of weights for previous rows */
png_bytep prev_filters; /* filter type(s) of previous row(s) */
png_uint_16p filter_weights; /* weight(s) for previous line(s) */
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
png_uint_16p filter_costs; /* relative filter calculation cost */
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
#endif
/* Options */
@@ -513,48 +362,128 @@ struct png_struct_def
png_byte options; /* On/off state (up to 4 options) */
#endif
/* COMPRESSION AND DECOMPRESSION SUPPORT.
*
* zlib expects a 'zstream' as the fundamental control structure, it allows
* all the parameters to be passed as one pointer.
#if PNG_LIBPNG_VER < 10700
/* To do: remove this from libpng-1.7 */
#ifdef PNG_TIME_RFC1123_SUPPORTED
char time_buffer[29]; /* String to hold RFC 1123 time text */
#endif
#endif
/* New members added in libpng-1.0.6 */
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
#ifdef PNG_USER_CHUNKS_SUPPORTED
png_voidp user_chunk_ptr;
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
#endif
#endif
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
int unknown_default; /* As PNG_HANDLE_* */
unsigned int num_chunk_list; /* Number of entries in the list */
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
* followed by a PNG_HANDLE_* byte */
#endif
/* New members added in libpng-1.0.3 */
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
png_byte rgb_to_gray_status;
/* Added in libpng 1.5.5 to record setting of coefficients: */
png_byte rgb_to_gray_coefficients_set;
/* These were changed from png_byte in libpng-1.0.6 */
png_uint_16 rgb_to_gray_red_coeff;
png_uint_16 rgb_to_gray_green_coeff;
/* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
#endif
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
#if defined(PNG_MNG_FEATURES_SUPPORTED)
/* Changed from png_byte to png_uint_32 at version 1.2.0 */
png_uint_32 mng_features_permitted;
#endif
/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
#ifdef PNG_MNG_FEATURES_SUPPORTED
png_byte filter_type;
#endif
/* New members added in libpng-1.2.0 */
/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
#ifdef PNG_USER_MEM_SUPPORTED
png_voidp mem_ptr; /* user supplied struct for mem functions */
png_malloc_ptr malloc_fn; /* function for allocating memory */
png_free_ptr free_fn; /* function for freeing memory */
#endif
/* New member added in libpng-1.0.13 and 1.2.0 */
png_bytep big_row_buf; /* buffer to save current (unfiltered) row */
#ifdef PNG_READ_QUANTIZE_SUPPORTED
/* The following three members were added at version 1.0.14 and 1.2.4 */
png_bytep quantize_sort; /* working sort array */
png_bytep index_to_palette; /* where the original index currently is
in the palette */
png_bytep palette_to_index; /* which original index points to this
palette color */
#endif
/* New members added in libpng-1.0.16 and 1.2.6 */
png_byte compression_type;
#ifdef PNG_USER_LIMITS_SUPPORTED
png_uint_32 user_width_max;
png_uint_32 user_height_max;
/* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
* chunks that can be stored (0 means unlimited).
*/
z_stream zstream; /* decompression structure */
png_uint_32 user_chunk_cache_max;
/* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
* can occupy when decompressed. 0 means unlimited.
*/
png_alloc_size_t user_chunk_malloc_max;
#endif
/* New member added in libpng-1.0.25 and 1.2.17 */
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
/* Temporary storage for unknown chunk that the library doesn't recognize,
* used while reading the chunk.
*/
png_unknown_chunk unknown_chunk;
#endif
/* New member added in libpng-1.2.26 */
png_size_t old_big_row_buf_size;
#ifdef PNG_READ_SUPPORTED
/* These, and IDAT_read_size below, control how much input and output (at
* most) is available to zlib.
*/
png_uint_32 idat_size; /* current IDAT size for read */
png_alloc_size_t read_buffer_size; /* current size of the buffer */
/* New member added in libpng-1.2.30 */
png_bytep read_buffer; /* buffer for reading chunk data */
png_alloc_size_t read_buffer_size; /* current size of the buffer */
#endif
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
int zlib_text_level; /* holds zlib compression level */
int zlib_text_method; /* holds zlib compression method */
int zlib_text_window_bits; /* holds zlib compression window bits */
int zlib_text_mem_level; /* holds zlib compression memory level */
int zlib_text_strategy; /* holds zlib compression strategy */
#endif
#ifdef PNG_WRITE_SUPPORTED
int zlib_level; /* holds zlib compression level */
int zlib_method; /* holds zlib compression method */
int zlib_window_bits; /* holds zlib compression window bits */
int zlib_mem_level; /* holds zlib compression memory level */
int zlib_strategy; /* holds zlib compression strategy */
int zlib_set_level; /* Actual values set into the zstream on write */
int zlib_set_method;
int zlib_set_window_bits;
int zlib_set_mem_level;
int zlib_set_strategy;
png_compression_bufferp zbuffer_list; /* Created on demand during write */
uInt zbuffer_size; /* size of the actual zlib buffer */
#endif
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
#endif
#ifdef PNG_IO_STATE_SUPPORTED
/* New member added in libpng-1.4.0 */
png_uint_32 io_state;
#endif
/* New member added in libpng-1.5.6 */
png_bytep big_prev_row;
/* New member added in libpng-1.5.7 */
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row);
#ifdef PNG_READ_SUPPORTED
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
png_colorspace colorspace;
#endif
#endif
};
#endif /* PNGSTRUCT_H */

View File

@@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.2 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -43,8 +43,24 @@
#include "png.h"
#ifdef PNG_READ_SUPPORTED /* else nothing can be done */
#include PNG_ZLIB_HEADER /* defined by pnglibconf.h */
/* Known chunks that exist in pngtest.png must be supported or pngtest will fail
* simply as a result of re-ordering them. This may be fixed in 1.7
*/
#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
defined PNG_READ_bKGD_SUPPORTED &&\
defined PNG_READ_cHRM_SUPPORTED &&\
defined PNG_READ_gAMA_SUPPORTED &&\
defined PNG_READ_oFFs_SUPPORTED &&\
defined PNG_READ_pCAL_SUPPORTED &&\
defined PNG_READ_pHYs_SUPPORTED &&\
defined PNG_READ_sBIT_SUPPORTED &&\
defined PNG_READ_sCAL_SUPPORTED &&\
defined PNG_READ_sRGB_SUPPORTED &&\
defined PNG_READ_tEXt_SUPPORTED &&\
defined PNG_READ_tIME_SUPPORTED &&\
defined PNG_READ_zTXt_SUPPORTED
#include "zlib.h"
/* Copied from pngpriv.h but only used in error messages below. */
#ifndef PNG_ZBUF_SIZE
# define PNG_ZBUF_SIZE 8192
@@ -100,6 +116,10 @@ static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */
static int error_count = 0; /* count calls to png_error */
static int warning_count = 0; /* count calls to png_warning */
#ifdef __TURBOC__
#include <mem.h>
#endif
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
#ifndef png_jmpbuf
# define png_jmpbuf(png_ptr) png_ptr->jmpbuf
@@ -1942,9 +1962,10 @@ main(void)
{
fprintf(STDERR,
" test ignored because libpng was not built with read support\n");
return 0;
/* And skip this test */
return 77;
}
#endif
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_7_0beta07 Your_png_h_is_not_version_1_7_0beta07;
typedef png_libpng_version_1_6_2rc05 Your_png_h_is_not_version_1_6_2rc05;

View File

@@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.2 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -57,9 +57,7 @@ png_set_packing(png_structrp png_ptr)
if (png_ptr->bit_depth < 8)
{
png_ptr->transformations |= PNG_PACK;
# ifdef PNG_WRITE_SUPPORTED
png_ptr->usr_bit_depth = 8;
# endif
png_ptr->usr_bit_depth = 8;
}
}
#endif

View File

@@ -1,7 +1,7 @@
/* pngwio.c - functions for data output
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.0 [February 14, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -151,7 +151,6 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
# endif
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
#ifdef PNG_READ_SUPPORTED
/* It is an error to read while writing a png file */
if (png_ptr->read_data_fn != NULL)
{
@@ -161,6 +160,5 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
"Can't set both read_data_fn and write_data_fn in the"
" same structure");
}
#endif
}
#endif /* PNG_WRITE_SUPPORTED */

View File

@@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.2 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -216,13 +216,8 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
int j, jend;
jend = info_ptr->num_trans;
if (jend > PNG_MAX_PALETTE_LENGTH)
jend = PNG_MAX_PALETTE_LENGTH;
for (j = 0; j<jend; ++j)
int j;
for (j = 0; j<(int)info_ptr->num_trans; j++)
info_ptr->trans_alpha[j] =
(png_byte)(255 - info_ptr->trans_alpha[j]);
}
@@ -935,52 +930,42 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(method == PNG_INTRAPIXEL_DIFFERENCING))
method = PNG_FILTER_TYPE_BASE;
#endif
/* The only supported method, except for the check above, is
* PNG_FILTER_TYPE_BASE. The code below does not use 'method' other than
* for the check, so just keep going if png_app_error returns.
*/
if (method != PNG_FILTER_TYPE_BASE)
png_app_error(png_ptr, "Unknown custom filter method");
/* If filter writing is not supported the 'filters' value must be zero,
* otherwise the value must be a single, valid, filter value or a set of the
* mask values. The defines in png.h are such that the filter masks used in
* this API and internally are 1<<(3+value), value is in the range 0..4, so
* this fits in a byte.
*/
# ifdef PNG_WRITE_FILTER_SUPPORTED
/* Notice that PNG_NO_FILTERS is 0 and passes this test; this is OK
* because filters then gets set to PNG_FILTER_NONE, as is required.
*/
if (filters < PNG_FILTER_VALUE_LAST)
filters = 0x08 << filters;
else if ((filters & ~PNG_ALL_FILTERS) != 0)
if (method == PNG_FILTER_TYPE_BASE)
{
switch (filters & (PNG_ALL_FILTERS | 0x07))
{
png_app_error(png_ptr, "png_set_filter: invalid filters mask/value");
#ifdef PNG_WRITE_FILTER_SUPPORTED
case 5:
case 6:
case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
/* FALL THROUGH */
#endif /* PNG_WRITE_FILTER_SUPPORTED */
case PNG_FILTER_VALUE_NONE:
png_ptr->do_filter = PNG_FILTER_NONE; break;
/* For compatibility with the previous behavior assume a mask value was
* passed and ignore the non-mask bits.
*/
filters &= PNG_ALL_FILTERS;
#ifdef PNG_WRITE_FILTER_SUPPORTED
case PNG_FILTER_VALUE_SUB:
png_ptr->do_filter = PNG_FILTER_SUB; break;
/* For a possibly foolish consistency (it shouldn't matter) set
* PNG_FILTER_NONE rather than 0.
*/
if (filters == 0)
filters = PNG_FILTER_NONE;
case PNG_FILTER_VALUE_UP:
png_ptr->do_filter = PNG_FILTER_UP; break;
case PNG_FILTER_VALUE_AVG:
png_ptr->do_filter = PNG_FILTER_AVG; break;
case PNG_FILTER_VALUE_PAETH:
png_ptr->do_filter = PNG_FILTER_PAETH; break;
default:
png_ptr->do_filter = (png_byte)filters; break;
#else
default:
png_app_error(png_ptr, "Unknown row filter for method 0");
#endif /* PNG_WRITE_FILTER_SUPPORTED */
}
# else
/* PNG_FILTER_VALUE_NONE and PNG_NO_FILTERS are both 0. */
if (filters != 0 && filters != PNG_FILTER_NONE)
png_app_error(png_ptr, "png_set_filter: no filters supported");
filters = PNG_FILTER_NONE;
# endif
# ifdef PNG_WRITE_FILTER_SUPPORTED
/* If we have allocated the row_buf, this means we have already started
* with the image and we should have allocated all of the filter buffers
* that have been selected. If prev_row isn't already allocated, then
@@ -989,45 +974,75 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
* wants to start and stop using particular filters during compression,
* it should start out with all of the filters, and then add and
* remove them after the start of compression.
*
* NOTE: this is a nasty constraint on the code, because it means that the
* prev_row buffer must be maintained even if there are currently no
* 'prev_row' requiring filters active.
*/
if (png_ptr->row_buf != NULL)
{
/* Repeat the checks in png_write_start_row; 1 pixel high or wide
* images cannot benefit from certain filters. If this isn't done here
* the check below will fire on 1 pixel high images.
*/
if (png_ptr->height == 1)
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
if (png_ptr->width == 1)
filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0
&& png_ptr->prev_row == NULL)
#ifdef PNG_WRITE_FILTER_SUPPORTED
if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
{
/* This is the error case, however it is benign - the previous row
* is not available so the filter can't be used. Just warn here.
*/
png_app_warning(png_ptr,
"png_set_filter: UP/AVG/PAETH cannot be added after start");
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
}
/* Allocate any required buffers that have not already been allocated.
*/
png_write_alloc_filter_row_buffers(png_ptr, filters);
}
# endif /* PNG_WRITE_FILTER_SUPPORTED */
if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL)
{
if (png_ptr->prev_row == NULL)
{
png_warning(png_ptr, "Can't add Up filter after starting");
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
~PNG_FILTER_UP);
}
/* Finally store the value.
* TODO: this field could probably be removed if neither READ nor
* WRITE_FILTER are supported.
*/
png_ptr->do_filter = (png_byte)filters; /* SAFE: checked above */
else
{
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
}
}
if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL)
{
if (png_ptr->prev_row == NULL)
{
png_warning(png_ptr, "Can't add Average filter after starting");
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
~PNG_FILTER_AVG);
}
else
{
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
}
}
if ((png_ptr->do_filter & PNG_FILTER_PAETH) &&
png_ptr->paeth_row == NULL)
{
if (png_ptr->prev_row == NULL)
{
png_warning(png_ptr, "Can't add Paeth filter after starting");
png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
}
else
{
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
}
}
if (png_ptr->do_filter == PNG_NO_FILTERS)
#endif /* PNG_WRITE_FILTER_SUPPORTED */
png_ptr->do_filter = PNG_FILTER_NONE;
}
}
else
png_error(png_ptr, "Unknown custom filter method");
}
/* This allows us to influence the way in which libpng chooses the "best"

View File

@@ -1,7 +1,7 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.0 [February 14, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)

View File

@@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.2 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -1425,11 +1425,10 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
if (num_trans <= 0 || num_trans > png_ptr->num_palette)
if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
{
/* This is an error which can only be reliably detected late. */
png_app_error(png_ptr,
"Invalid number of transparent colors specified");
png_app_warning(png_ptr,
"Invalid number of transparent colors specified");
return;
}
@@ -1443,8 +1442,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
/* One 16 bit value */
if (tran->gray >= (1 << png_ptr->bit_depth))
{
/* This can no longer happen because it is checked in png_set_tRNS */
png_app_error(png_ptr,
png_app_warning(png_ptr,
"Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
return;
@@ -1466,8 +1464,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
if (buf[0] | buf[2] | buf[4])
#endif
{
/* Also checked in png_set_tRNS */
png_app_error(png_ptr,
png_app_warning(png_ptr,
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
return;
}
@@ -1477,8 +1474,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
else
{
/* Checked in png_set_tRNS */
png_app_error(png_ptr, "Can't write tRNS with an alpha channel");
png_app_warning(png_ptr, "Can't write tRNS with an alpha channel");
}
}
#endif
@@ -1765,7 +1761,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
png_write_compressed_data_out(png_ptr, &comp);
else
png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len);
png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.input_len);
png_write_chunk_end(png_ptr);
}
@@ -1938,47 +1934,6 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
}
#endif
#ifdef PNG_WRITE_FILTER_SUPPORTED
void /* PRIVATE */
png_write_alloc_filter_row_buffers(png_structrp png_ptr, int filters)
/* Allocate row buffers for any filters that need them, this is also called
* from png_set_filter if the filters are changed during write to ensure that
* the required buffers exist. png_set_filter ensures that up/avg/paeth are
* only set if png_ptr->prev_row is allocated.
*/
{
/* The buffer size is determined just by the output row size, not any
* processing requirements.
*/
png_alloc_size_t buf_size = png_ptr->rowbytes + 1;
if ((filters & PNG_FILTER_SUB) != 0 && png_ptr->sub_row == NULL)
{
png_ptr->sub_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
}
if ((filters & PNG_FILTER_UP) != 0 && png_ptr->up_row == NULL)
{
png_ptr->up_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
}
if ((filters & PNG_FILTER_AVG) != 0 && png_ptr->avg_row == NULL)
{
png_ptr->avg_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
}
if ((filters & PNG_FILTER_PAETH) != 0 && png_ptr->paeth_row == NULL)
{
png_ptr->paeth_row = png_voidcast(png_bytep, png_malloc(png_ptr,
buf_size));
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
}
}
#endif /* PNG_WRITE_FILTER_SUPPORTED */
/* Initializes the row writing capability of libpng */
void /* PRIVATE */
png_write_start_row(png_structrp png_ptr)
@@ -1999,18 +1954,11 @@ png_write_start_row(png_structrp png_ptr)
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
#ifdef PNG_WRITE_FILTER_SUPPORTED
int filters;
#endif
png_alloc_size_t buf_size;
int usr_pixel_depth;
png_debug(1, "in png_write_start_row");
if (png_ptr == NULL)
return;
usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth;
buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1;
@@ -2019,34 +1967,49 @@ png_write_start_row(png_structrp png_ptr)
png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
/* Set up row buffer */
png_ptr->row_buf = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);
png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
#ifdef PNG_WRITE_FILTER_SUPPORTED
filters = png_ptr->do_filter;
/* Set up filtering buffer, if using this filter */
if (png_ptr->do_filter & PNG_FILTER_SUB)
{
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);
if (png_ptr->height == 1)
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
}
if (png_ptr->width == 1)
filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
/* We only need to keep the previous row if we are using one of these. */
if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
{
/* Set up previous row buffer */
png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size);
if (filters == 0)
filters = PNG_FILTER_NONE;
if (png_ptr->do_filter & PNG_FILTER_UP)
{
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
/* 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))
png_ptr->prev_row = png_voidcast(png_bytep, png_calloc(png_ptr,
buf_size));
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
}
png_write_alloc_filter_row_buffers(png_ptr, filters);
if (png_ptr->do_filter & PNG_FILTER_AVG)
{
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
png_ptr->do_filter = (png_byte)filters; /* in case it was changed above */
#else
png_ptr->do_filter = PNG_FILTER_NONE;
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
}
if (png_ptr->do_filter & PNG_FILTER_PAETH)
{
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
}
}
#endif /* PNG_WRITE_FILTER_SUPPORTED */
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
@@ -3034,7 +2997,6 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);
#ifdef PNG_WRITE_FILTER_SUPPORTED
/* Swap the current and previous rows */
if (png_ptr->prev_row != NULL)
{
@@ -3044,7 +3006,6 @@ 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 */
/* Finish row - updates counters and flushes zlib if last row */
png_write_finish_row(png_ptr);

View File

@@ -30,7 +30,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/libpng17.dll"
OutputFile="$(OutDir)/libpng16.dll"
LinkIncremental="1"/>
<Tool
Name="VCMIDLTool"/>
@@ -78,7 +78,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/libpng17d.dll"
OutputFile="$(OutDir)/libpng16d.dll"
GenerateDebugInformation="TRUE"/>
<Tool
Name="VCMIDLTool"/>
@@ -126,7 +126,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/libpng17vb.dll"
OutputFile="$(OutDir)/libpng16vb.dll"
LinkIncremental="1"/>
<Tool
Name="VCMIDLTool"/>

View File

@@ -130,7 +130,7 @@ $(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png"
Name="VCLinkerTool"
OutputFile="$(OutDir)/pngtest.exe"
LinkIncremental="1"
IgnoreDefaultLibraryNames="$(IntDir)\libpng17b.lib"
IgnoreDefaultLibraryNames="$(IntDir)\libpng16b.lib"
SubSystem="1"
TargetMachine="1"/>
<Tool

View File

@@ -63,23 +63,23 @@
<LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets>
</CustomBuildBeforeTargets>
<TargetName>$(ProjectName)17</TargetName>
<TargetName>$(ProjectName)16</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
<LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets />
<TargetName>$(ProjectName)17</TargetName>
<TargetName>$(ProjectName)16</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets>
</CustomBuildBeforeTargets>
<TargetName>$(ProjectName)17</TargetName>
<TargetName>$(ProjectName)16</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'">
<LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets />
<TargetName>$(ProjectName)17</TargetName>
<TargetName>$(ProjectName)16</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -107,7 +107,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>zlib.lib</AdditionalDependencies>
<Version>17</Version>
<Version>16</Version>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
@@ -164,7 +164,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>zlib.lib</AdditionalDependencies>
<Version>17</Version>
<Version>16</Version>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>

View File

@@ -96,7 +96,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
@@ -129,7 +129,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
@@ -163,7 +163,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
@@ -199,7 +199,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>

View File

@@ -96,7 +96,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
@@ -129,7 +129,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
@@ -164,7 +164,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
@@ -199,7 +199,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>

View File

@@ -96,7 +96,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
@@ -129,7 +129,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
@@ -163,7 +163,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
@@ -199,7 +199,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>

View File

@@ -96,7 +96,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
@@ -129,7 +129,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
@@ -163,7 +163,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
@@ -199,7 +199,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>

View File

@@ -1,7 +1,7 @@
VisualStudio instructions
libpng version 1.7.0beta07 - April 14, 2013
libpng version 1.6.2rc05 - April 23, 2013
Copyright (c) 1998-2010 Glenn Randers-Pehrson
@@ -40,7 +40,7 @@ problems.
If you don't use the Visual Studio defaults your application must still be built
with the default runtime option (/MD). If, for some reason, it is not then your
application will crash inside libpng17.dll as soon as libpng tries to read
application will crash inside libpng16.dll as soon as libpng tries to read
from a file handle you pass in.
If you do not want to use the DLL, for example for a very small application,

View File

@@ -2,7 +2,7 @@
<!--
* zlib.props - location of zlib source
*
* libpng version 1.7.0beta07 - April 14, 2013
* libpng version 1.6.2rc05 - April 23, 2013
*
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
*

View File

@@ -1,9 +1,9 @@
Makefiles for libpng version 1.7.0beta07 - April 14, 2013
Makefiles for libpng version 1.6.2rc05 - April 23, 2013
pnglibconf.h.prebuilt => Stores configuration settings
makefile.linux => Linux/ELF makefile
(gcc, creates libpng17.so.17.1.7.0beta07)
(gcc, creates libpng16.so.16.1.6.2rc05)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
@@ -20,7 +20,7 @@ pnglibconf.h.prebuilt => Stores configuration settings
makefile.dec => DEC Alpha UNIX makefile
makefile.dj2 => DJGPP 2 makefile
makefile.elf => Linux/ELF makefile symbol versioning,
(gcc, creates libpng17.so.17.1.7.0beta07)
(gcc, creates libpng16.so.16.1.6.2rc05)
makefile.freebsd => FreeBSD makefile
makefile.gcc => Generic gcc makefile
makefile.hpgcc => HPUX makefile using gcc
@@ -35,12 +35,12 @@ pnglibconf.h.prebuilt => Stores configuration settings
makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.sggcc => Silicon Graphics (gcc,
creates libpng17.so.17.1.7.0beta07)
creates libpng16.so.16.1.6.2rc05)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng17.so.17.1.7.0beta07)
creates libpng16.so.16.1.6.2rc05)
makefile.so9 => Solaris 9 makefile (gcc,
creates libpng17.so.17.1.7.0beta07)
creates libpng16.so.16.1.6.2rc05)
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit makefile

View File

@@ -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.0beta07"
PNG_DFN ";Version 1.6.2rc05"
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"

View File

@@ -11,7 +11,7 @@
# Modeled after libxml-config.
version=1.7.0beta07
version=1.6.2rc05
prefix=""
libdir=""
libs=""

View File

@@ -1,10 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/libpng17
includedir=@includedir@/libpng16
Name: libpng
Description: Loads and saves PNG files
Version: 1.7.0beta07
Libs: -L${libdir} -lpng17
Version: 1.6.2rc05
Libs: -L${libdir} -lpng16
Cflags: -I${includedir}

View File

@@ -9,8 +9,8 @@
# and license in png.h
# Library name:
LIBNAME=libpng17
PNGMAJ = 17
LIBNAME=libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -29,7 +29,7 @@ RM_F=/bin/rm -f
SUN_CC_FLAGS=-fast -xtarget=ultra
SUN_LD_FLAGS=-fast -xtarget=ultra
# where make install puts libpng.a, libpng17.so and libpng17/png.h
# where make install puts libpng.a, libpng16.so and libpng16/png.h
prefix=/a
exec_prefix=$(prefix)
@@ -95,7 +95,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -106,7 +106,7 @@ libpng-config:
echo R_opts=\"-R$(LIBPATH)\"; \
echo ccopts=\"-xtarget=ultra\"; \
echo ldopts=\"-xtarget=ultra\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -9,8 +9,8 @@
# and license in png.h
# Library name:
LIBNAME=libpng17
PNGMAJ = 17
LIBNAME=libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -29,7 +29,7 @@ RM_F=/bin/rm -f
SUN_CC_FLAGS=-fast -xtarget=ultra -xarch=v9
SUN_LD_FLAGS=-fast -xtarget=ultra -xarch=v9
# where make install puts libpng.a, libpng17.so and libpng17/png.h
# where make install puts libpng.a, libpng16.so and libpng16/png.h
prefix=/a
exec_prefix=$(prefix)
@@ -47,7 +47,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \
# $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng17 -lz -lm
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib
@@ -95,7 +95,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -106,7 +106,7 @@ libpng-config:
echo R_opts=\"-R$(LIBPATH)\"; \
echo ccopts=\"-xtarget=ultra -xarch=v9\"; \
echo ldopts=\"-xtarget=ultra -xarch=v9\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -21,8 +21,8 @@ RANLIB = ranlib
RM_F = rm -f
LN_SF = ln -f -s
LIBNAME=libpng17
PNGMAJ = 17
LIBNAME=libpng16
PNGMAJ = 16
prefix=/usr/local
INCPATH=$(prefix)/include
@@ -47,7 +47,7 @@ CRELEASE = -O2
LDRELEASE = -s
WARNMORE=-W -Wall
CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE)
LDFLAGS = -L. -L$(ZLIBLIB) -lpng17 -lz -lm $(LDRELEASE)
LDFLAGS = -L. -L$(ZLIBLIB) -lpng16 -lz -lm $(LDRELEASE)
# File extensions
O=.o

View File

@@ -9,8 +9,8 @@
# and license in png.h
# Library name:
LIBNAME=libpng17
PNGMAJ = 17
LIBNAME=libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -45,7 +45,7 @@ CFLAGS=-I$(ZLIBINC) -W -Wall -O1 -funroll-loops \
# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz
LDFLAGS=-L. -Wl,-soname=$(LIBSOMAJ) -L$(ZLIBLIB) -lz
# where make install puts libpng.a, libpng17.so*, and png.h
# where make install puts libpng.a, libpng16.so*, and png.h
prefix=/usr/local
exec_prefix=$(prefix)
INCPATH=$(prefix)/include
@@ -91,13 +91,13 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo libs=\"-lpng17 -lz \"; \
echo libs=\"-lpng16 -lz \"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
@@ -110,7 +110,7 @@ $(LIBSOMAJ): $(OBJSDLL)
$(LIBSOMAJ) $(OBJSDLL) $(LDFLAGS)
pngtest: pngtest.o $(LIBSO)
$(CC) -L$(ZLIBLIB) -L. -lz -lpng17 -o pngtest pngtest.o
$(CC) -L$(ZLIBLIB) -L. -lz -lpng16 -o pngtest pngtest.o
test: pngtest
./pngtest

View File

@@ -22,16 +22,16 @@
# make clean
VERMAJ = 1
VERMIN = 7
VERMIC = 0
VERMIN = 6
VERMIC = 2
VER = $(VERMAJ).$(VERMIN).$(VERMIC)
NAME = libpng
PACKAGE = $(NAME)-$(VER)
BIN = libpng17-0.dll
LIB = libpng17.a libpng17.dll.a libpng.a libpng.dll.a
BIN = libpng16-0.dll
LIB = libpng16.a libpng16.dll.a libpng.a libpng.dll.a
INCLUDE = png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
PC = libpng17.pc libpng.pc
PC = libpng16.pc libpng.pc
MANIFESTVERBIN = "Libpng-$(VER): Binary files"
MANIFESTVERDEV = "Libpng-$(VER): Developer files"

View File

@@ -9,7 +9,7 @@
# For conditions of distribution and use, see the disclaimer
# and license in png.h
# where "make install" puts libpng.a, libpng17.dylib, png.h, pngconf.h,
# where "make install" puts libpng.a, libpng16.dylib, png.h, pngconf.h,
# and pnglibconf.h
prefix=/usr/local
exec_prefix=$(prefix)
@@ -19,8 +19,8 @@ ZLIBLIB=/usr/lib
ZLIBINC=/usr/include
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
LIBNAME = libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).dylib
@@ -39,7 +39,7 @@ ARCH=-arch ppc -arch i386 -arch x86_64
# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops
CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops $(ARCH)
LDFLAGS=-L. -L$(ZLIBLIB) -lpng17 -lz $(ARCH)
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz $(ARCH)
INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib
@@ -87,14 +87,14 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz! > libpng.pc
-e s!-lpng16!-lpng16\ -lz! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz\"; \
echo libs=\"-lpng16 -lz\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
@@ -104,7 +104,7 @@ $(LIBSO): $(LIBSOMAJ)
$(LIBSOMAJ): $(OBJSDLL)
$(CC) -dynamiclib \
-install_name $(LIBPATH)/$(LIBSOMAJ) \
-current_version 17 -compatibility_version 17 \
-current_version 16 -compatibility_version 16 \
$(ARCH) -o $(LIBSOMAJ) \
$(OBJSDLL) -L$(ZLIBLIB) -lz

View File

@@ -7,8 +7,8 @@
# and license in png.h
# Library name:
PNGMAJ = 17
LIBNAME = libpng17
PNGMAJ = 16
LIBNAME = libpng16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -75,7 +75,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -83,7 +83,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo ccopts=\"-std\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -1,4 +1,4 @@
# makefile for libpng.a and libpng17.so on Linux ELF with gcc
# makefile for libpng.a and libpng16.so on Linux ELF with gcc
# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs
# and Glenn Randers-Pehrson
# Copyright (C) 1996, 1997 Andreas Dilger
@@ -10,19 +10,19 @@
# Modified for Debian by Junichi Uekawa and Josselin Mouette
# Major modifications are:
# * link libpng explicitly with libz and libm
# * $(OLDSO).17 is a symlink rather than a different library
# * $(OLDSO).16 is a symlink rather than a different library
# * versioned symbols
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
LIBNAME = libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).so
LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
LIBSOREL=$(LIBSOMAJ).$(RELEASE)
OLDSO=libpng.so
OLDSOMAJ=libpng.so.17
OLDSOMAJ=libpng.so.16
# Utilities:
AR_RC=ar rc
@@ -32,8 +32,8 @@ LN_SF=ln -sf
RANLIB=ranlib
RM_F=/bin/rm -f
# where "make install" puts libpng17.a, libpng17.so*,
# libpng17/png.h, libpng17/pngconf.h, and libpng17/pnglibconf.h
# where "make install" puts libpng16.a, libpng16.so*,
# libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h
# Prefix must be a full pathname.
prefix=/usr/local
exec_prefix=$(prefix)
@@ -57,7 +57,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
CFLAGS=-W -Wall -D_REENTRANT -O2 \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -lpng17
LDFLAGS=-L. -lpng16
LDFLAGS_A=libpng.a -lz -lm
LIBADDFLAGS=-lz -lm
@@ -108,11 +108,11 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng.syms: png.h pngconf.h pnglibconf.h
$(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG17_%s {global:\n",PNGMAJ)}\
awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG16_%s {global:\n",PNGMAJ)}\
{ for (i=1;i+2<=NF;++i)\
if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
print $$(i+1) ";";\
@@ -129,8 +129,8 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo L_opts=\"\"; \
echo R_opts=\"\"; \
echo libs=\"-lpng17\"; \
echo all_libs=\"-lpng17 $(LIBADDFLAGS)\"; \
echo libs=\"-lpng16\"; \
echo all_libs=\"-lpng16 $(LIBADDFLAGS)\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -6,7 +6,7 @@
# and license in png.h
PREFIX?= /usr/local
SHLIB_VER?= 17
SHLIB_VER?= 16
LIB= png
SHLIB_MAJOR= ${SHLIB_VER}

View File

@@ -19,8 +19,8 @@ ZLIBINC=/opt/zlib/include
# SHAREDLIB=libz.sl
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
LIBNAME = libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).sl
@@ -44,7 +44,7 @@ CCFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
# where make install puts libpng.a, libpng17.sl, and png.h
# where make install puts libpng.a, libpng16.sl, and png.h
prefix=/opt/libpng
exec_prefix=$(prefix)
INCPATH=$(prefix)/include
@@ -93,7 +93,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -101,7 +101,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -9,8 +9,8 @@
# and license in png.h
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
LIBNAME = libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).sl
@@ -55,8 +55,8 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng17 -lz -lm
LDFLAGS=-L. -L$(ZLIBLIB) -lpng17 -lz -lm
#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz -lm
INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib
@@ -100,13 +100,13 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -19,8 +19,8 @@ ZLIBINC=/opt/zlib/include
# SHAREDLIB=libz.sl
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
LIBNAME = libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).sl
@@ -36,7 +36,7 @@ LN_SF=ln -sf
RANLIB=ranlib
RM_F=/bin/rm -f
# where make install puts libpng.a, libpng17.sl, and png.h
# where make install puts libpng.a, libpng16.sl, and png.h
prefix=/opt/libpng
exec_prefix=$(prefix)
INCPATH=$(prefix)/include
@@ -90,7 +90,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -98,7 +98,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -1,4 +1,4 @@
# makefile for libpng.a and libpng17.so on Linux ELF with gcc
# makefile for libpng.a and libpng16.so on Linux ELF with gcc
# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs and
# Glenn Randers-Pehrson
# Copyright (C) 1996, 1997 Andreas Dilger
@@ -8,9 +8,9 @@
# and license in png.h
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
RELEASE = 0
LIBNAME = libpng16
PNGMAJ = 16
RELEASE = 2
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -26,8 +26,8 @@ LN_SF=ln -sf
RANLIB=ranlib
RM_F=/bin/rm -f
# where "make install" puts libpng17.a, libpng17.so*,
# libpng17/png.h, libpng17/pngconf.h, and libpng17/pnglibconf.h
# where "make install" puts libpng16.a, libpng16.so*,
# libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h
# Prefix must be a full pathname.
prefix=/usr/local
exec_prefix=$(prefix)
@@ -51,7 +51,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng17 -lz -lm
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm
LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
INCPATH=$(prefix)/include
@@ -100,7 +100,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -108,7 +108,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -16,9 +16,9 @@ prefix=/usr/local
exec_prefix=$(prefix)
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
RELEASE = 0
LIBNAME = libpng16
PNGMAJ = 16
RELEASE = 2
# Shared library names:
LIBSO=$(LIBNAME).dll
@@ -129,7 +129,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -137,7 +137,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
install-shared: install-headers $(LIBSOMAJ) libpng.pc
@@ -185,20 +185,20 @@ clean:
$(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png pnglibconf.h $(LIBSO) \
$(LIBSOMAJ) libpng-config
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.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngerror$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngget$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngmem$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngpread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngrio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngrtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngrutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngset$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngtrans$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwrite$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngtest.o: png.h pngconf.h pnglibconf.h
pngtest$(O): png.h pngconf.h pnglibconf.h

View File

@@ -13,11 +13,11 @@
LOCALBASE?=/usr/local
LIBDIR= ${LOCALBASE}/lib
MANDIR= ${LOCALBASE}/man
INCSDIR=${LOCALBASE}/include/libpng17
INCSDIR=${LOCALBASE}/include/libpng16
LIB= png17
LIB= png16
SHLIB_MAJOR= 0
SHLIB_MINOR= 1.7.0beta07
SHLIB_MINOR= 1.6.2rc05
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c

View File

@@ -8,7 +8,7 @@
# For conditions of distribution and use, see the disclaimer
# and license in png.h
# You should also run makefile.ne17bsd
# You should also run makefile.ne16bsd
LOCALBASE?=/usr/local
LIBDIR= ${LOCALBASE}/lib
@@ -16,8 +16,8 @@ MANDIR= ${LOCALBASE}/man
INCSDIR=${LOCALBASE}/include
LIB= png
SHLIB_MAJOR= 17
SHLIB_MINOR= 1.7.0beta07
SHLIB_MAJOR= 16
SHLIB_MINOR= 1.6.2rc05
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c

View File

@@ -10,8 +10,8 @@ PREFIX?= /usr/local
LIBDIR= ${PREFIX}/lib
MANDIR= ${PREFIX}/man/cat
SHLIB_MAJOR= 17
SHLIB_MINOR= 1.7.0beta07
SHLIB_MAJOR= 16
SHLIB_MINOR= 1.6.2rc05
LIB= png
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \

View File

@@ -10,8 +10,8 @@
# and license in png.h
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
LIBNAME = libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -38,7 +38,7 @@ ZLIBLIB=../zlib
ZLIBINC=../zlib
CFLAGS= -dy -belf -I$(ZLIBINC) -O3
LDFLAGS=-L. -L$(ZLIBLIB) -lpng17 -lz -lm
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz -lm
INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib
@@ -86,7 +86,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -94,7 +94,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo ccopts=\"-belf\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -1,4 +1,4 @@
# makefile for libpng.a and libpng17.so, SGI IRIX with 'cc'
# makefile for libpng.a and libpng16.so, SGI IRIX with 'cc'
# Copyright (C) 2001-2002, 2006, 2010-2011 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@@ -7,8 +7,8 @@
# and license in png.h
# Library name:
LIBNAME=libpng17
PNGMAJ = 17
LIBNAME=libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -24,7 +24,7 @@ LN_SF=ln -sf
RANLIB=echo
RM_F=/bin/rm -f
# Where make install puts libpng.a, libpng17.so, and libpng17/png.h
# Where make install puts libpng.a, libpng16.so, and libpng16/png.h
# Prefix must be a full pathname.
prefix=/usr/local
@@ -91,7 +91,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -102,7 +102,7 @@ libpng-config:
echo ldopts=\"$(ABI)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo libdir=\"$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -1,4 +1,4 @@
# makefile for libpng.a and libpng17.so, SGI IRIX with 'cc'
# makefile for libpng.a and libpng16.so, SGI IRIX with 'cc'
# Copyright (C) 2001-2002, 2006, 2007, 2010-2011 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@@ -7,8 +7,8 @@
# and license in png.h
# Library name:
LIBNAME=libpng17
PNGMAJ = 17
LIBNAME=libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -24,7 +24,7 @@ LN_SF=ln -sf
RANLIB=echo
RM_F=/bin/rm -f
# Where make install puts libpng.a, libpng17.so, and libpng17/png.h
# Where make install puts libpng.a, libpng16.so, and libpng16/png.h
# Prefix must be a full pathname.
prefix=/usr/local
@@ -46,7 +46,7 @@ WARNMORE=-fullwarn
# Note: -KPIC is the default anyhow
#CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC # -g -DPNG_DEBUG=5
CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE)
LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng17 -lz -lm
LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng16 -lz -lm
LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm
LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \
-set_version sgi$(PNGMAJ).0
@@ -92,7 +92,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -102,7 +102,7 @@ libpng-config:
echo ldopts=\"$(ABI)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo libdir=\"$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -10,8 +10,8 @@
# and license in png.h
# Library name:
PNGMAJ = 17
LIBNAME = libpng17
PNGMAJ = 16
LIBNAME = libpng16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -48,7 +48,7 @@ ZLIBINC=/usr/include
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
#CFLAGS=-I$(ZLIBINC) -W -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE
CFLAGS=-I$(ZLIBINC) -O3 -DPNG_NO_MMX_CODE
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng17 -lz -lm
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib
@@ -96,7 +96,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -104,7 +104,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo R_opts=\"-R$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -9,8 +9,8 @@
# and license in png.h
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
LIBNAME = libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -26,7 +26,7 @@ LN_SF=ln -f -s
RANLIB=echo
RM_F=/bin/rm -f
# Where make install puts libpng.a, libpng17.so*, and png.h
# Where make install puts libpng.a, libpng16.so*, and png.h
prefix=/usr/local
exec_prefix=$(prefix)
@@ -44,7 +44,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) -W -Wall -O \
# $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng17 -lz -lm
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib
@@ -92,7 +92,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -101,7 +101,7 @@ libpng-config:
echo cppflags=\"\"; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo R_opts=\"-R$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

View File

@@ -9,8 +9,8 @@
# and license in png.h
# Library name:
LIBNAME = libpng17
PNGMAJ = 17
LIBNAME = libpng16
PNGMAJ = 16
# Shared library names:
LIBSO=$(LIBNAME).so
@@ -26,7 +26,7 @@ LN_SF=ln -f -s
RANLIB=echo
RM_F=/bin/rm -f
# Where make install puts libpng.a, libpng17.so*, and png.h
# Where make install puts libpng.a, libpng16.so*, and png.h
prefix=/usr/local
exec_prefix=$(prefix)
@@ -44,7 +44,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) -W -Wall -O \
# $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng17 -lz -lm
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib
@@ -92,7 +92,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
@@ -101,7 +101,7 @@ libpng-config:
echo cppflags=\""; \
echo L_opts=\"-L$(LIBPATH)\"; \
echo R_opts=\"-R$(LIBPATH)\"; \
echo libs=\"-lpng17 -lz -lm\"; \
echo libs=\"-lpng16 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config

102
scripts/pnglibconf.dfa Normal file → Executable file
View File

@@ -8,7 +8,7 @@ com pnglibconf.h - library build configuration
com
version
com
com Copyright (c) 1998-2013 Glenn Randers-Pehrson
com Copyright (c) 1998-2012 Glenn Randers-Pehrson
com
com This code is released under the libpng license.
com For conditions of distribution and use, see the disclaimer
@@ -114,13 +114,6 @@ file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H
logunsupported = 1
# The following allows the output from configure to modify the contents of
# pnglibconf.h
@#ifdef HAVE_CONFIG_H
@# include "config.h"
@#endif
# PNG_USER_CONFIG has to be defined on the compiler command line
# to cause pngusr.h to be read while constructing pnglibconf.h
#
@@ -202,25 +195,9 @@ setting API_RULE default 0
setting PREFIX
# This says that a prefix has been added to zlib API function names; at present
# it is informational, the builder of zlib must ensure that zlib.h contains the
# appropriate renames
# Default to using the read macros
setting ZLIB_PREFIX
# This is used to select an alternative zlib header file - it must look pretty
# much like the standard zlib.h, but this makes it easier to ensure the correct
# header file is used. Set it to the "" or <> quoted file name (a full file
# name is acceptable). Prior to 1.7.0 this used "zlib.h", so it would use a
# zlib.h in the same directory as the libpng source, from 1.7.0 it defaults to
# just searching the -I directories. Prior to 1.6.0 the #include appeared in
# the exported header files - so it was quite important to use "zlib.h" to
# ensure that applications always got the zlib.h from the same directory as
# png.h.
setting ZLIB_HEADER default <zlib.h>
# include the file too, so that the defaults below are known
@# include <zlib.h>
setting DEFAULT_READ_MACROS default 1
# This setting allows a hardware or configuration specific filter optimization
# function to be specified, the argument is the name of the filter initializaion
@@ -253,29 +230,18 @@ option ARM_NEON_CHECK disabled enables ARM_NEON
# because the name of the setting is prefixed by PNG_
#
# The TEXT values are the defaults when writing compressed text (all forms)
#
# Include the zlib header too, so that the defaults below are known
@# include <zlib.h>
# The '@' here means to substitute the value when pnglibconf.h is built
setting Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION
# TODO: why aren't these Z_RLE; zlib.h says that Z_RLE, specifically, is
# appropriate for PNG images, maybe it doesn't exist in all versions?
setting Z_DEFAULT_STRATEGY default @Z_FILTERED
setting Z_DEFAULT_NOFILTER_STRATEGY default @Z_DEFAULT_STRATEGY
setting TEXT_Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION
setting TEXT_Z_DEFAULT_STRATEGY default @Z_DEFAULT_STRATEGY
# Define this to something that will stop, at least, the current thread; control
# cannot proceed beyond the PNG_ABORT operation and compilation of pngerror.c is
# likely to fail if the operation implemented does not clearly terminate the
# thread or process. The default implementation is the ANSI-C abort function,
# but any manner of C code may be used.
setting ABORT default { (abort()); }
# Default to using the read macros
setting DEFAULT_READ_MACROS default 1
# The alternative is to call functions to read PNG values, if
# the functions are turned *off* the read macros must always
# be enabled, so turning this off will actually force the
@@ -370,28 +336,40 @@ option USER_MEM
option IO_STATE
# Libpng limits: limit the size of images and data on read.
# This is only for PowerPC big-endian and 680x0 systems
# some testing, not enabled by default.
# NO LONGER USED
#option READ_BIG_ENDIAN disabled
# Allow users to control limits on what the READ code will
# read:
# Added at libpng-1.2.43; adds limit fields to png_struct,
# allows some usages of these fields
option USER_LIMITS
# Added at libpng-1.2.6; adds setting APIs, allows additional
# usage of this field (UTSL)
option SET_USER_LIMITS requires USER_LIMITS
# Feature added at libpng-1.4.0, this flag added at 1.4.1
option SET_USER_LIMITS enables SET_CHUNK_CACHE_LIMIT
# Feature added at libpng-1.4.1, this flag added at 1.4.1
option SET_USER_LIMITS enables SET_CHUNK_MALLOC_LIMIT
# Libpng limits.
#
# If this option is disabled all the limit checking code will be disabled:
option USER_LIMITS requires READ
# If the following settings are *not* set libpng will not limit the size of
# If these settings are *not* set libpng will not limit the size of
# images or the size of data in ancilliary chunks. This does lead to
# security issues if PNG files come from untrusted sources. Settings have the
# following interpretations:
#
# USER_WIDTH_MAX: maximum width of an image that will be read
# USER_HEIGHT_MAX: maximum height
# USER_CHUNK_MALLOC_MAX: maximum in-memory (decompressed) size of a single chunk
# USER_CHUNK_CACHE_MAX: maximum number of chunks to be cached
#
# Only chunks that are variable in number are counted towards the
# USER_CHUNK_CACHE_MAX limit
# security issues if PNG files come from untrusted sources.
setting USER_WIDTH_MAX
setting USER_HEIGHT_MAX
setting USER_CHUNK_MALLOC_MAX
setting USER_CHUNK_CACHE_MAX
setting USER_CHUNK_MALLOC_MAX
# To default all these settings to values that are large but probably
# safe turn the SAFE_LIMITS option on; this will cause the value in
@@ -400,10 +378,6 @@ setting USER_CHUNK_CACHE_MAX
option SAFE_LIMITS enables USER_LIMITS disabled
= SAFE_LIMITS SAFE_LIMITS
# If this option is enabled APIs to set the above limits at run time are added;
# without these the hardwired (compile time) limits will be used.
option SET_USER_LIMITS requires USER_LIMITS
# All of the following options relate to code capabilities for
# processing image data before creating a PNG or after reading one.
# You can remove these capabilities safely and still be PNG
@@ -844,11 +818,11 @@ option INFO_IMAGE
option CHECK_FOR_INVALID_INDEX enables READ_CHECK_FOR_INVALID_INDEX
option CHECK_FOR_INVALID_INDEX enables WRITE_CHECK_FOR_INVALID_INDEX
option READ_CHECK_FOR_INVALID_INDEX requires READ disabled
option WRITE_CHECK_FOR_INVALID_INDEX requires WRITE disabled
option READ_CHECK_FOR_INVALID_INDEX requires READ, CHECK_FOR_INVALID_INDEX
option WRITE_CHECK_FOR_INVALID_INDEX requires WRITE, CHECK_FOR_INVALID_INDEX
# added at libpng-1.5.15
option GET_PALETTE_MAX enables READ_GET_PALETTE_MAX, WRITE_GET_PALETTE_MAX
option GET_PALETTE_MAX enables READ_GET_PALETTE_MAX WRITE_GET_PALETTE_MAX
option READ_GET_PALETTE_MAX requires READ_CHECK_FOR_INVALID_INDEX disabled
option WRITE_GET_PALETTE_MAX requires WRITE_CHECK_FOR_INVALID_INDEX disabled

View File

@@ -1,8 +1,8 @@
/* libpng 1.7.0beta07 STANDARD API DEFINITION */
/* libpng 1.6.2rc05 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */
/* Libpng version 1.7.0beta07 - April 14, 2013 */
/* Libpng version 1.6.2rc05 - April 23, 2013 */
/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */
@@ -103,6 +103,8 @@
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_SEQUENTIAL_READ_SUPPORTED
#define PNG_SETJMP_SUPPORTED
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
/*#undef PNG_SET_OPTION_SUPPORTED*/
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_SET_USER_LIMITS_SUPPORTED
@@ -185,7 +187,6 @@
#define PNG_zTXt_SUPPORTED
/* end of options */
/* settings */
#define PNG_ABORT { (abort()); }
#define PNG_API_RULE 0
#define PNG_CALLOC_SUPPORTED
#define PNG_COST_SHIFT 3
@@ -201,7 +202,6 @@
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
#define PNG_WEIGHT_SHIFT 8
#define PNG_ZBUF_SIZE 8192
#define PNG_ZLIB_HEADER <zlib.h>
#define PNG_Z_DEFAULT_COMPRESSION (-1)
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
#define PNG_Z_DEFAULT_STRATEGY 1

View File

@@ -1,4 +1,4 @@
;Version 1.7.0beta07
;Version 1.6.2rc05
;--------------------------------------------------------------
; LIBPNG symbol list as a Win32 DEF file
; Contains all the symbols that can be exported from libpng
@@ -15,6 +15,7 @@ EXPORTS
png_set_compression_buffer_size @7
png_set_longjmp_fn @8
png_longjmp @9
png_reset_zstream @10
png_create_read_struct_2 @11
png_create_write_struct_2 @12
png_write_sig @13
@@ -23,9 +24,11 @@ EXPORTS
png_write_chunk_data @16
png_write_chunk_end @17
png_create_info_struct @18
png_info_init_3 @19
png_write_info_before_PLTE @20
png_write_info @21
png_read_info @22
png_convert_to_rfc1123 @23
png_convert_from_struct_tm @24
png_convert_from_time_t @25
png_set_expand @26
@@ -101,6 +104,9 @@ EXPORTS
png_malloc_warn @96
png_free @97
png_free_data @98
png_data_freer @99
png_malloc_default @100
png_free_default @101
png_error @102
png_chunk_error @103
png_err @104