mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
78 Commits
v1.5.4beta
...
v1.5.5beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec3ff78f70 | ||
|
|
6d62ef108a | ||
|
|
b6874f8062 | ||
|
|
8b8aacde83 | ||
|
|
bbd17bd7c4 | ||
|
|
b5cebba675 | ||
|
|
736f40f459 | ||
|
|
0c03fc6f75 | ||
|
|
e61e403d20 | ||
|
|
9d824eb166 | ||
|
|
75d5bfda5b | ||
|
|
9b979b177b | ||
|
|
7b9796539d | ||
|
|
0bc79772c8 | ||
|
|
a45ffbefb9 | ||
|
|
99ffac0838 | ||
|
|
6c98897a64 | ||
|
|
b17c75b222 | ||
|
|
d4e1ddb631 | ||
|
|
aab2aa196d | ||
|
|
03d6b482b5 | ||
|
|
4dcce66295 | ||
|
|
7a28724e6b | ||
|
|
a5bcab7854 | ||
|
|
0a007b743e | ||
|
|
e9ef47f69e | ||
|
|
0532aca928 | ||
|
|
5a77e672e1 | ||
|
|
c2891d0011 | ||
|
|
25e0f55586 | ||
|
|
ce775cc851 | ||
|
|
d0797f5b53 | ||
|
|
a5e5547679 | ||
|
|
4164c6f949 | ||
|
|
4b2237a6a4 | ||
|
|
cb47e20509 | ||
|
|
d3a0b23c1b | ||
|
|
ab38979670 | ||
|
|
628b632419 | ||
|
|
d404b6d488 | ||
|
|
38404a5996 | ||
|
|
05fc4ccd30 | ||
|
|
78bb9dafe1 | ||
|
|
4fca25504e | ||
|
|
9daf91ed5c | ||
|
|
fcd7c13ffd | ||
|
|
5bcd0a8c14 | ||
|
|
8d261262d9 | ||
|
|
c4a8214b77 | ||
|
|
4e47be74e9 | ||
|
|
314ef3e72b | ||
|
|
aee83b43d6 | ||
|
|
9a1e2232ba | ||
|
|
6da2f2d92a | ||
|
|
24145c8869 | ||
|
|
e6a8060a71 | ||
|
|
98f053edbd | ||
|
|
581d29d4c9 | ||
|
|
66b942ce16 | ||
|
|
86cf9b2e89 | ||
|
|
fb29e51dbd | ||
|
|
ab63dd0892 | ||
|
|
a7428d443c | ||
|
|
857dbbe7cc | ||
|
|
3fb7c07ea5 | ||
|
|
60d7c022e5 | ||
|
|
850769f787 | ||
|
|
5f0b9276ec | ||
|
|
733b131545 | ||
|
|
ef217b76a3 | ||
|
|
b0791f75ad | ||
|
|
039ad872fe | ||
|
|
903c64dce8 | ||
|
|
8f4edd07be | ||
|
|
be720edba7 | ||
|
|
140504b11a | ||
|
|
cd3b0cc4d9 | ||
|
|
06a9684cfa |
236
ANNOUNCE
236
ANNOUNCE
@@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.5.4beta02 - June 14, 2011
|
||||
Libpng 1.5.5beta06 - August 25, 2011
|
||||
|
||||
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,199 +9,75 @@ Files available for download:
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
1.5.4beta02.tar.xz (LZMA-compressed, recommended)
|
||||
1.5.4beta02.tar.gz
|
||||
1.5.4beta02.tar.bz2
|
||||
1.5.5beta06.tar.xz (LZMA-compressed, recommended)
|
||||
1.5.5beta06.tar.gz
|
||||
1.5.5beta06.tar.bz2
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
lp154b02.7z (LZMA-compressed, recommended)
|
||||
lp154b02.zip
|
||||
lp155b06.7z (LZMA-compressed, recommended)
|
||||
lp155b06.zip
|
||||
|
||||
Other information:
|
||||
|
||||
1.5.4beta02-README.txt
|
||||
1.5.4beta02-LICENSE.txt
|
||||
1.5.5beta06-README.txt
|
||||
1.5.5beta06-LICENSE.txt
|
||||
|
||||
Changes since the last public release (1.5.2):
|
||||
Changes since the last public release (1.5.4):
|
||||
|
||||
Version 1.5.3beta01 [April 1, 2011]
|
||||
Re-initialize the zlib compressor before compressing non-IDAT chunks.
|
||||
Added API functions to set parameters for zlib compression of non-IDAT
|
||||
chunks.
|
||||
Version 1.5.5beta01 [July 13, 2011]
|
||||
Fixed some typos and made other minor changes in the manual.
|
||||
Updated contrib/pngminus/makefile.std (Samuli Souminen)
|
||||
|
||||
Version 1.5.3beta02 [April 3, 2011]
|
||||
Updated scripts/symbols.def with new API functions.
|
||||
Only compile the new zlib re-initializing code when text or iCCP is
|
||||
supported, using PNG_WRITE_COMPRESSED_TEXT_SUPPORTED macro.
|
||||
Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03).
|
||||
Optimize the zlib CMF byte in non-IDAT compressed chunks
|
||||
Version 1.5.5beta02 [July 14, 2011]
|
||||
Revised Makefile.am and Makefile.in to look in the right directory for
|
||||
pnglibconf.h.prebuilt
|
||||
|
||||
Version 1.5.3beta03 [April 16, 2011]
|
||||
Fixed gcc -ansi -pedantic compile. A strict ANSI system does not have
|
||||
snprintf, and the "__STRICT_ANSI__" detects that condition more reliably
|
||||
than __STDC__ (John Bowler).
|
||||
Removed the PNG_PTR_NORETURN attribute because it too dangerous. It tells
|
||||
the compiler that a user supplied callback (the error handler) does not
|
||||
return, yet there is no guarantee in practice that the application code
|
||||
will correctly implement the error handler because the compiler only
|
||||
issues a warning if there is a mistake (John Bowler).
|
||||
Removed the no-longer-used PNG_DEPSTRUCT macro.
|
||||
Updated the zlib version to 1.2.5 in the VStudio project.
|
||||
Fixed 64-bit builds where png_uint_32 is smaller than png_size_t in
|
||||
pngwutil.c (John Bowler).
|
||||
Fixed bug with stripping the filler or alpha channel when writing, that
|
||||
was introduced in libpng-1.5.2beta01 (bug report by Andrew Church).
|
||||
Version 1.5.5beta03 [July 27, 2011]
|
||||
Enabled compilation with g++ compiler. This compiler does not recognize
|
||||
the file extension, so it always compiles with C++ rules. Made minor
|
||||
changes to pngrutil.c to cast results where C++ expects it but C does not.
|
||||
Minor editing of libpng.3 and libpng-manual.txt.
|
||||
|
||||
Version 1.5.3beta04 [April 27, 2011]
|
||||
Updated pngtest.png with the new zlib CMF optimization.
|
||||
Cleaned up conditional compilation code and of background/gamma handling
|
||||
Internal changes only except a new option to avoid compiling the
|
||||
png_build_grayscale_palette API (which is not used at all internally.)
|
||||
The main change is to move the transform tests (READ_TRANSFORMS,
|
||||
WRITE_TRANSFORMS) up one level to the caller of the APIs. This avoids
|
||||
calls to spurious functions if all transforms are disabled and slightly
|
||||
simplifies those functions. Pngvalid modified to handle this.
|
||||
A minor change is to stop the strip_16 and expand_16 interfaces from
|
||||
disabling each other; this allows the future alpha premultiplication
|
||||
code to use 16-bit intermediate values while still producing 8-bit output.
|
||||
png_do_background and png_do_gamma have been simplified to take a single
|
||||
pointer to the png_struct rather than pointers to every item required
|
||||
from the png_struct. This makes no practical difference to the internal
|
||||
code.
|
||||
A serious bug in the pngvalid internal routine 'standard_display_init' has
|
||||
been fixed - this failed to initialize the red channel and accidentally
|
||||
initialized the alpha channel twice.
|
||||
Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to
|
||||
avoid a clash with the png_jmpbuf macro on some platforms.
|
||||
Version 1.5.5beta04 [July 29, 2011]
|
||||
Revised CMakeLists.txt (Clifford Yapp)
|
||||
Updated commentary about the png_rgb_to_gray() default coefficients
|
||||
in the manual and in pngrtran.c
|
||||
|
||||
Version 1.5.3beta05 [May 6, 2011]
|
||||
Added appropriate feature test macros to ensure libpng sees the correct API
|
||||
_POSIX_SOURCE is defined in pngpriv.h, pngtest.c and pngvalid.c to ensure
|
||||
that POSIX conformant systems disable non-POSIX APIs. _ISOC99_SOURCE is
|
||||
defined in pngpriv.h to obtain the ISO C99 snprintf definition, when
|
||||
available.
|
||||
Removed png_snprintf and added formatted warning messages. This change adds
|
||||
internal APIs to allow png_warning messages to have parameters without
|
||||
requiring the host OS to implement snprintf. As a side effect the
|
||||
dependency of the tIME-supporting RFC1132 code on stdio is removed and
|
||||
PNG_NO_WARNINGS does actually work now.
|
||||
Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte
|
||||
optimization configureable.
|
||||
IDAT compression failed if preceded by a compressed text chunk (bug
|
||||
introduced in libpng-1.5.3beta01-02). This was because the attempt to
|
||||
reset the zlib stream in png_write_IDAT happened after the first IDAT
|
||||
chunk had been deflated - much too late. In this change internal
|
||||
functions were added to claim/release the z_stream and, hopefully, make
|
||||
the code more robust. Also deflateEnd checking is added - previously
|
||||
libpng would ignore an error at the end of the stream.
|
||||
|
||||
Version 1.5.3beta06 [May 8, 2011]
|
||||
Removed the -D_ALL_SOURCE from definitions for AIX in CMakeLists.txt
|
||||
Implemented premultiplied alpha support: png_set_alpha_mode API
|
||||
|
||||
Version 1.5.3beta07 [May 11, 2011]
|
||||
Added expand_16 support to the high level interface.
|
||||
Added named value and 'flag' gamma support to png_set_gamma. Made a minor
|
||||
change from the previous (unreleased) ABI/API to hide the exact value used
|
||||
for Macs - it's not a good idea to embed this in the ABI!
|
||||
Moved macro definitions for PNG_HAVE_IHDR, PNG_HAVE_PLTE, and PNG_AFTER_IDAT
|
||||
from pngpriv.h to png.h because they must be visible to applications
|
||||
that call png_set_unknown_chunks().
|
||||
Check for up->location !PNG_AFTER_IDAT when writing unknown chunks
|
||||
before IDAT.
|
||||
|
||||
Version 1.5.3beta08 [May 16, 2011]
|
||||
Improved "pngvalid --speed" to exclude more of pngvalid from the time.
|
||||
Documented png_set_alpha_mode(), other changes in libpng.3/libpng-manual.txt
|
||||
The cHRM chunk now sets the defaults for png_set_rgb_to_gray() (when negative
|
||||
parameters are supplied by the caller), while in the absence of cHRM
|
||||
sRGB/Rec 709 values are still used.
|
||||
The bKGD chunk no longer overwrites the background value set by
|
||||
png_set_background(), allowing the latter to be used before the file
|
||||
header is read. It never performed any useful function to override
|
||||
the default anyway.
|
||||
Added memory overwrite and palette image checks to pngvalid.c
|
||||
Previously palette image code was poorly checked. Since the transformation
|
||||
code has a special palette path in most cases this was a severe weakness.
|
||||
Minor cleanup and some extra checking in pngrutil.c and pngrtran.c. When
|
||||
expanding an indexed image, always expand to RGBA if transparency is
|
||||
present.
|
||||
|
||||
Version 1.5.3beta09 [May 17, 2011]
|
||||
Reversed earlier 1.5.3 change of transformation order; move png_expand_16 back.
|
||||
The change doesn't work because it requires 16-bit gamma tables when the code
|
||||
only generates 8-bit ones. This fails silently; the libpng code just doesn't
|
||||
do any gamma correction. Moving the tests back leaves the old, inaccurate,
|
||||
8-bit gamma calculations, but these are clearly better than none!
|
||||
|
||||
Version 1.5.3beta10 [May 20, 2011]
|
||||
png_set_background() and png_expand_16() did not work together correctly.
|
||||
This problem is present in 1.5.2; if png_set_background is called with
|
||||
need_expand false and the matching 16 bit color libpng erroneously just
|
||||
treats it as an 8-bit color because of where png_do_expand_16 is in the
|
||||
transform list. This simple fix reduces the supplied colour to 8-bits,
|
||||
so it gets smashed, but this is better than the current behavior.
|
||||
Added tests for expand16, more fixes for palette image tests to pngvalid.
|
||||
Corrects the code for palette image tests and disables attempts to
|
||||
validate palette colors.
|
||||
|
||||
Version 1.5.3rc01 [June 3, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.3rc02 [June 8, 2011]
|
||||
Fixed uninitialized memory read in png_format_buffer() (Bug report by
|
||||
Frank Busse, related to CVE-2004-0421).
|
||||
|
||||
Version 1.5.3beta11 [June 11, 2011]
|
||||
Fixed png_handle_sCAL which is broken in 1.5; added sCAL to pngtest.png
|
||||
Revised documentation about png_set_user_limits() to say that it also affects
|
||||
png writing.
|
||||
Revised handling of png_set_user_limits() so that it can increase the
|
||||
limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only
|
||||
reduce it.
|
||||
Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is
|
||||
wrong (high by one) 25% of the time. Dividing by 257 with rounding is
|
||||
wrong in 128 out of 65536 cases. Getting the right answer all the time
|
||||
without division is easy.
|
||||
Added "_SUPPORTED" to the PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION macro.
|
||||
Added projects/owatcom, an IDE project for OpenWatcom to replace
|
||||
scripts/makefile.watcom. This project works with OpenWatcom 1.9. The
|
||||
IDE autogenerates appropriate makefiles (libpng.mk) for batch processing.
|
||||
The project is configurable, unlike the Visual Studio project, so long
|
||||
as the developer has an awk.
|
||||
Changed png_set_gAMA to limit the gamma value range so that the inverse
|
||||
of the stored value cannot overflow the fixed point representation,
|
||||
and changed other things OpenWatcom warns about.
|
||||
Revised pngvalid.c to test PNG_ALPHA_MODE_SUPPORTED correctly. This allows
|
||||
pngvalid to build when ALPHA_MODE is not supported, which is required if
|
||||
it is to build on libpng 1.4.
|
||||
Removed string/memory macros that are no longer used and are not
|
||||
necessarily fully supportable, particularly png_strncpy and png_snprintf.
|
||||
Added log option to pngvalid.c and attempted to improve gamma messages.
|
||||
|
||||
Version 1.5.3 [omitted]
|
||||
People found the presence of a beta release following an rc release
|
||||
to be confusing; therefore we bump the version to libpng-1.5.4beta01
|
||||
and there will be no libpng-1.5.3 release.
|
||||
|
||||
Version 1.5.4beta01 [June 14, 2011]
|
||||
Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
to get the same (inaccurate) output as libpng-1.5.2 and earlier.
|
||||
Moved definitions of PNG_HAVE_IHDR, PNG_AFTER_IDAT, and PNG_HAVE_PLTE
|
||||
outside of an unknown-chunk block in png.h because they are also
|
||||
needed for other uses.
|
||||
|
||||
Version 1.5.4beta02 [June 14, 2011]
|
||||
Fixed and clarified LEGACY 16-to-8 scaling code.
|
||||
Added png_set_chop_16() API, to match inaccurate results from previous
|
||||
libpng versions.
|
||||
Removed the ACCURATE and LEGACY options (they are no longer useable)
|
||||
Use the old scaling method for background if png_set_chop_16() was
|
||||
called.
|
||||
Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
|
||||
Version 1.5.5beta05 [August 17, 2011]
|
||||
Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL"
|
||||
is removed from the test of whether a DLL is being built (this erroneously
|
||||
caused the libpng APIs to be marked as DLL exports in static builds under
|
||||
Microsoft Visual Studio). Almost all of the libpng building configuration
|
||||
is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in
|
||||
pngconf.h, though, so that it is colocated with the import definition (it
|
||||
is no longer used anywhere in the installed headers). The VStudio project
|
||||
definitions have been cleaned up: "_USRDLL" has been removed from the
|
||||
static library builds (this was incorrect), and PNG_USE_DLL has been added
|
||||
to pngvalid to test the functionality (pngtest does not supply it,
|
||||
deliberately). The spurious "_EXPORTS" has been removed from the
|
||||
libpng build (all these errors were a result of copy/paste between project
|
||||
configurations.)
|
||||
Added new types and internal functions for CIE RGB end point handling to
|
||||
pngpriv.h (functions yet to be implemented).
|
||||
|
||||
Version 1.5.5beta06 [August 25, 2011]
|
||||
Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt
|
||||
(Clifford Yap)
|
||||
Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler):
|
||||
The rgb_to_gray code had errors when combined with gamma correction.
|
||||
Some pixels were treated as true grey when they weren't and such pixels
|
||||
and true grey ones were not gamma corrected (the original value of the
|
||||
red component was used instead). APIs to get and set cHRM using color
|
||||
space end points have been added and the rgb_to_gray code that defaults
|
||||
based on cHRM (introduced in 1.5.4) has been corrected. A considerable
|
||||
number of tests has been added to pngvalid for the rgb_to_gray transform.
|
||||
Arithmetic errors in rgb_to_gray whereby the calculated gray value was
|
||||
truncated to the bit depth rather than rounded have been fixed except in
|
||||
the 8-bit non-gamma-corrected case (where consistency seems more important
|
||||
than correctness.) The code still has considerable inaccuracies in the
|
||||
8-bit case because 8-bit linear arithmetic is used.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
|
||||
(subscription required; visit
|
||||
|
||||
128
CHANGES
128
CHANGES
@@ -180,7 +180,7 @@ Version 0.96 [May, 1997]
|
||||
Fixed serious bug with < 8bpp images introduced in 0.95
|
||||
Fixed 256-color transparency bug (Greg Roelofs)
|
||||
Fixed up documentation (Greg Roelofs, Laszlo Nyul)
|
||||
Fixed "error" in pngconf.h for Linux setjmp() behaviour
|
||||
Fixed "error" in pngconf.h for Linux setjmp() behavior
|
||||
Fixed DOS medium model support (Tim Wegner)
|
||||
Fixed png_check_keyword() for case with error in static string text
|
||||
Added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul)
|
||||
@@ -204,8 +204,8 @@ Version 0.97 [January, 1998]
|
||||
Added more conditions for png_do_background, to avoid changing
|
||||
black pixels to background when a background is supplied and
|
||||
no pixels are transparent
|
||||
Repaired PNG_NO_STDIO behaviour
|
||||
Tested NODIV support and made it default behaviour (Greg Roelofs)
|
||||
Repaired PNG_NO_STDIO behavior
|
||||
Tested NODIV support and made it default behavior (Greg Roelofs)
|
||||
Added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler)
|
||||
Regularized version numbering scheme and bumped shared-library major
|
||||
version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs)
|
||||
@@ -1778,7 +1778,7 @@ Version 1.2.13beta1 [October 2, 2006]
|
||||
Removed AC_FUNC_MALLOC from configure.ac
|
||||
Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h
|
||||
Change "logical" to "bitwise" throughout documentation.
|
||||
Detect and fix attempt to write wrong iCCP profile length.
|
||||
Detect and fix attempt to write wrong iCCP profile length (CVE-2006-7244)
|
||||
|
||||
Version 1.0.21, 1.2.13 [November 14, 2006]
|
||||
Fix potential buffer overflow in sPLT chunk handler.
|
||||
@@ -2361,7 +2361,7 @@ Version 1.4.0beta72 [August 1, 2009]
|
||||
|
||||
Version 1.4.0beta73 [August 1, 2009]
|
||||
Reject attempt to write iCCP chunk with negative embedded profile length
|
||||
(JD Chen)
|
||||
(JD Chen) (CVE-2009-5063).
|
||||
|
||||
Version 1.4.0beta74 [August 8, 2009]
|
||||
Changed png_ptr and info_ptr member "trans" to "trans_alpha".
|
||||
@@ -3149,8 +3149,8 @@ version 1.5.1beta01 [January 8, 2011]
|
||||
in version 1.5.0beta36 but is not noted in the CHANGES. Similarly,
|
||||
it was changed from png_charpp to png_const_bytepp in png_set_iCCP().
|
||||
Ensure that png_rgb_to_gray ignores palette mapped images, if libpng
|
||||
internally happens to call it with one.
|
||||
Fixed a failure to handle palette mapped images correctly.
|
||||
internally happens to call it with one, and fixed a failure to handle
|
||||
palette mapped images correctly. This fixes CVE-2690.
|
||||
|
||||
Version 1.5.1beta02 [January 14, 2011]
|
||||
Fixed a bug in handling of interlaced images (bero at arklinux.org).
|
||||
@@ -3208,9 +3208,9 @@ Version 1.5.1beta09 [January 24, 2011]
|
||||
pngvalid contains tests of transforms, which tests are currently disabled
|
||||
because they are incompletely tested. gray_to_rgb was failing to expand
|
||||
the bit depth for smaller bit depth images; this seems to be a long
|
||||
standing error and resulted, apparently, in invalid output. The
|
||||
documentation did not accurately describe what libpng really does when
|
||||
converting RGB to gray.
|
||||
standing error and resulted, apparently, in invalid output
|
||||
(CVE-2011-0408, CERT VU#643140). The documentation did not accurately
|
||||
describe what libpng really does when converting RGB to gray.
|
||||
|
||||
Version 1.5.1beta10 [January 27, 2010]
|
||||
Fixed incorrect examples of callback prototypes in the manual, that were
|
||||
@@ -3289,8 +3289,8 @@ Version 1.5.2 [March 31, 2011]
|
||||
|
||||
Version 1.5.3beta01 [April 1, 2011]
|
||||
Re-initialize the zlib compressor before compressing non-IDAT chunks.
|
||||
Added API functions to set parameters for zlib compression of non-IDAT
|
||||
chunks.
|
||||
Added API functions (png_set_text_compression_level() and four others) to
|
||||
set parameters for zlib compression of non-IDAT chunks.
|
||||
|
||||
Version 1.5.3beta02 [April 3, 2011]
|
||||
Updated scripts/symbols.def with new API functions.
|
||||
@@ -3347,7 +3347,7 @@ Version 1.5.3beta05 [May 6, 2011]
|
||||
dependency of the tIME-supporting RFC1132 code on stdio is removed and
|
||||
PNG_NO_WARNINGS does actually work now.
|
||||
Pass "" instead of '\0' to png_default_error() in png_err(). This mistake
|
||||
was introduced in libpng-1.2.20beta01.
|
||||
was introduced in libpng-1.2.20beta01. This fixes CVE-2011-2691.
|
||||
Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte
|
||||
optimization configureable.
|
||||
IDAT compression failed if preceded by a compressed text chunk (bug
|
||||
@@ -3415,10 +3415,11 @@ Version 1.5.3rc01 [June 3, 2011]
|
||||
|
||||
Version 1.5.3rc02 [June 8, 2011]
|
||||
Fixed uninitialized memory read in png_format_buffer() (Bug report by
|
||||
Frank Busse, related to CVE-2004-0421).
|
||||
Frank Busse, CVE-2011-2501, related to CVE-2004-0421).
|
||||
|
||||
Version 1.5.3beta11 [June 11, 2011]
|
||||
Fixed png_handle_sCAL which is broken in 1.5; added sCAL to pngtest.png
|
||||
Fixed png_handle_sCAL which is broken in 1.5. This fixes CVE 2011-2692.
|
||||
Added sCAL to pngtest.png
|
||||
Revised documentation about png_set_user_limits() to say that it also affects
|
||||
png writing.
|
||||
Revised handling of png_set_user_limits() so that it can increase the
|
||||
@@ -3465,6 +3466,103 @@ Version 1.5.4beta02 [June 14, 2011]
|
||||
called.
|
||||
Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
|
||||
|
||||
Version 1.5.4beta03 [June 15, 2011]
|
||||
Fixed a problem in png_do_expand_palette() exposed by optimization in
|
||||
1.5.3beta06
|
||||
Also removed a spurious and confusing "trans" member ("trans") from png_info.
|
||||
The palette expand optimization prevented expansion to an intermediate RGBA
|
||||
form if tRNS was present but alpha was marked to be stripped; this exposed
|
||||
a check for tRNS in png_do_expand_palette() which is inconsistent with the
|
||||
code elsewhere in libpng.
|
||||
Correction to the expand_16 code; removed extra instance of
|
||||
png_set_scale_16_to_8 from pngpriv.h
|
||||
|
||||
Version 1.5.4beta04 [June 16, 2011]
|
||||
Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c
|
||||
Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms.
|
||||
Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again. If this is
|
||||
not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built.
|
||||
Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8
|
||||
|
||||
Version 1.5.4beta05 [June 16, 2011]
|
||||
Renamed png_set_strip_16() to png_set_scale_16() and renamed
|
||||
png_set_chop_16() to png_set_strip(16) in an attempt to minimize the
|
||||
behavior changes between libpng14 and libpng15.
|
||||
|
||||
Version 1.5.4beta06 [June 18, 2011]
|
||||
Fixed new bug that was causing both strip_16 and scale_16 to be applied.
|
||||
|
||||
Version 1.5.4beta07 [June 19, 2011]
|
||||
Fixed pngvalid, simplified macros, added checking for 0 in sCAL.
|
||||
The ACCURATE scale macro is no longer defined in 1.5 - call the
|
||||
png_scale_16_to_8 API. Made sure that PNG_READ_16_TO_8 is still defined
|
||||
if the png_strip_16_to_8 API is present. png_check_fp_number now
|
||||
maintains some state so that positive, negative and zero values are
|
||||
identified. sCAL uses these to be strictly spec conformant.
|
||||
|
||||
Version 1.5.4beta08 [June 23, 2011]
|
||||
Fixed pngvalid if ACCURATE_SCALE is defined.
|
||||
Updated scripts/pnglibconf.h.prebuilt.
|
||||
|
||||
Version 1.5.4rc01 [June 30, 2011]
|
||||
Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400.
|
||||
|
||||
Version 1.5.4 [July 7, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.5beta01 [July 13, 2011]
|
||||
Fixed some typos and made other minor changes in the manual.
|
||||
Updated contrib/pngminus/makefile.std (Samuli Souminen)
|
||||
|
||||
Version 1.5.5beta02 [July 14, 2011]
|
||||
Revised Makefile.am and Makefile.in to look in the right directory for
|
||||
pnglibconf.h.prebuilt
|
||||
|
||||
Version 1.5.5beta03 [July 27, 2011]
|
||||
Enabled compilation with g++ compiler. This compiler does not recognize
|
||||
the file extension, so it always compiles with C++ rules. Made minor
|
||||
changes to pngrutil.c to cast results where C++ expects it but C does not.
|
||||
Minor editing of libpng.3 and libpng-manual.txt.
|
||||
|
||||
Version 1.5.5beta04 [July 29, 2011]
|
||||
Revised CMakeLists.txt (Clifford Yapp)
|
||||
Updated commentary about the png_rgb_to_gray() default coefficients
|
||||
in the manual and in pngrtran.c
|
||||
|
||||
Version 1.5.5beta05 [August 17, 2011]
|
||||
Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL"
|
||||
is removed from the test of whether a DLL is being built (this erroneously
|
||||
caused the libpng APIs to be marked as DLL exports in static builds under
|
||||
Microsoft Visual Studio). Almost all of the libpng building configuration
|
||||
is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in
|
||||
pngconf.h, though, so that it is colocated with the import definition (it
|
||||
is no longer used anywhere in the installed headers). The VStudio project
|
||||
definitions have been cleaned up: "_USRDLL" has been removed from the
|
||||
static library builds (this was incorrect), and PNG_USE_DLL has been added
|
||||
to pngvalid to test the functionality (pngtest does not supply it,
|
||||
deliberately). The spurious "_EXPORTS" has been removed from the
|
||||
libpng build (all these errors were a result of copy/paste between project
|
||||
configurations.)
|
||||
Added new types and internal functions for CIE RGB end point handling to
|
||||
pngpriv.h (functions yet to be implemented).
|
||||
|
||||
Version 1.5.5beta06 [August 25, 2011]
|
||||
Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt
|
||||
(Clifford Yap)
|
||||
Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler):
|
||||
The rgb_to_gray code had errors when combined with gamma correction.
|
||||
Some pixels were treated as true grey when they weren't and such pixels
|
||||
and true grey ones were not gamma corrected (the original value of the
|
||||
red component was used instead). APIs to get and set cHRM using color
|
||||
space end points have been added and the rgb_to_gray code that defaults
|
||||
based on cHRM (introduced in 1.5.4) has been corrected. A considerable
|
||||
number of tests has been added to pngvalid for the rgb_to_gray transform.
|
||||
Arithmetic errors in rgb_to_gray whereby the calculated gray value was
|
||||
truncated to the bit depth rather than rounded have been fixed except in
|
||||
the 8-bit non-gamma-corrected case (where consistency seems more important
|
||||
than correctness.) The code still has considerable inaccuracies in the
|
||||
8-bit case because 8-bit linear arithmetic is used.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
138
CMakeLists.txt
138
CMakeLists.txt
@@ -1,3 +1,11 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
# Copyright (C) 2007-2011 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
|
||||
|
||||
cmake_minimum_required(VERSION 2.4.4)
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||
|
||||
@@ -25,15 +33,9 @@ endif()
|
||||
project(libpng C)
|
||||
enable_testing()
|
||||
|
||||
# Copyright (C) 2007-2011 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
|
||||
|
||||
set(PNGLIB_MAJOR 1)
|
||||
set(PNGLIB_MINOR 5)
|
||||
set(PNGLIB_RELEASE 4)
|
||||
set(PNGLIB_RELEASE 5)
|
||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||
|
||||
@@ -156,7 +158,6 @@ if(PNG_SHARED OR NOT MSVC)
|
||||
add_definitions(-DZLIB_DLL)
|
||||
endif()
|
||||
|
||||
|
||||
if(PNG_CONSOLE_IO_SUPPORTED)
|
||||
add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
|
||||
endif()
|
||||
@@ -201,7 +202,6 @@ if(PNG_STATIC)
|
||||
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
|
||||
if(PNG_SHARED AND WIN32)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
||||
endif()
|
||||
@@ -213,24 +213,32 @@ if(PNG_TESTS AND PNG_SHARED)
|
||||
add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
|
||||
IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
IF(WIN32)
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "bin")
|
||||
ELSE(WIN32)
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
|
||||
ENDIF(WIN32)
|
||||
ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
|
||||
# Set a variable with CMake code which:
|
||||
# Creates a symlink from src to dest (if possible) or alternatively
|
||||
# copies if different.
|
||||
macro(_png_generate_symlink_code CODE SRC DEST)
|
||||
macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||
FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(_png_gsc_message "Copying ${SRC} to ${DEST} if needed")
|
||||
set(_png_gsc_operation "copy_if_different")
|
||||
else()
|
||||
set(_png_gsc_message "Symlinking ${SRC} to ${DEST}")
|
||||
set(_png_gsc_operation "create_symlink")
|
||||
endif()
|
||||
|
||||
set(${CODE} "
|
||||
message(STATUS \"${_png_gsc_message}\")
|
||||
execute_process(COMMAND \${CMAKE_COMMAND} -E ${_png_gsc_operation}
|
||||
\"${SRC}\" \"${DEST}\")
|
||||
")
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC}
|
||||
)
|
||||
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
else(WIN32 AND NOT CYGWIN)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif(WIN32 AND NOT CYGWIN)
|
||||
endmacro()
|
||||
|
||||
# CREATE PKGCONFIG FILES
|
||||
@@ -245,22 +253,16 @@ set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
||||
set(LIBS "-lz -lm")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
||||
_png_generate_symlink_code(PNG_PC_INSTALL_CODE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng.pc)
|
||||
install(CODE ${PNG_PC_INSTALL_CODE})
|
||||
CREATE_SYMLINK(${PNGLIB_NAME}.pc libpng.pc)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
||||
_png_generate_symlink_code(PNG_CONFIG_INSTALL_CODE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng-config)
|
||||
install(CODE ${PNG_CONFIG_INSTALL_CODE})
|
||||
CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config)
|
||||
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||
# VERSION 15.${PNGLIB_RELEASE}.1.5.4beta02
|
||||
# VERSION 15.${PNGLIB_RELEASE}.1.5.5beta06
|
||||
VERSION 15.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 15
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
@@ -296,61 +298,35 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
|
||||
# Create a symlink for libpng.dll.a => libpng15.dll.a on Cygwin
|
||||
if(CYGWIN)
|
||||
_png_generate_symlink_code(PNG_SHARED_IMPLIB_INSTALL_CODE
|
||||
${PNGLIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_SHARED_IMPLIB_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(CYGWIN)
|
||||
|
||||
if(NOT WIN32)
|
||||
IF(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
_png_generate_symlink_code(PNG_SHARED_INSTALL_CODE
|
||||
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PNGLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_SHARED_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ELSE(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
_png_generate_symlink_code(PNG_SHARED_INSTALL_CODE
|
||||
${PNGLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_SHARED_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ENDIF(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
endif()
|
||||
endif()
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32)
|
||||
endif(PNG_SHARED)
|
||||
|
||||
if(PNG_STATIC)
|
||||
install(TARGETS ${PNG_LIB_NAME_STATIC}
|
||||
${PNG_EXPORT_RULE}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
if(NOT WIN32 OR CYGWIN)
|
||||
IF(CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
_png_generate_symlink_code(PNG_STATIC_INSTALL_CODE
|
||||
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${PNGLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_STATIC_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ELSE(CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
_png_generate_symlink_code(PNG_STATIC_INSTALL_CODE
|
||||
${PNGLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
install(CODE ${PNG_STATIC_INSTALL_CODE})
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ENDIF(CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
endif()
|
||||
endif()
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32 OR CYGWIN)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
||||
@@ -388,11 +364,9 @@ endif()
|
||||
|
||||
# what's with libpng-$VER%.txt and all the extra files?
|
||||
|
||||
|
||||
# UNINSTALL
|
||||
# do we need this?
|
||||
|
||||
|
||||
# DIST
|
||||
# do we need this?
|
||||
|
||||
|
||||
4
LICENSE
4
LICENSE
@@ -10,7 +10,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.5.4beta02, June 14, 2011, are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.5.5beta06, August 25, 2011, are
|
||||
Copyright (c) 2004, 2006-2011 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
|
||||
June 14, 2011
|
||||
August 25, 2011
|
||||
|
||||
@@ -97,7 +97,7 @@ $(PNGLIB_BASENAME)-config: libpng-config
|
||||
cp libpng-config $@
|
||||
|
||||
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
|
||||
scripts/symbols.out: png.h pngconf.h scripts/pnglibconf.h.prebuilt
|
||||
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
|
||||
|
||||
libpng.sym: scripts/sym.out
|
||||
rm -f $@
|
||||
@@ -108,7 +108,8 @@ libpng.vers: scripts/vers.out
|
||||
pnglibconf.h: pnglibconf.out
|
||||
rm -f $@
|
||||
cp $? $@
|
||||
scripts/pnglibconf.h.prebuilt:
|
||||
$(srcdir)/scripts/pnglibconf.h.prebuilt:
|
||||
@echo "Attempting to build $@" >&2
|
||||
@echo "This is a machine generated file, but if you want to make" >&2
|
||||
@echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2
|
||||
@exit 1
|
||||
@@ -162,7 +163,7 @@ scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk
|
||||
test -z "$(CPPFLAGS)"
|
||||
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out\
|
||||
logunsupported=4 - ${srcdir}/scripts/pnglibconf.dfa 1>&2
|
||||
logunsupported=1 - ${srcdir}/scripts/pnglibconf.dfa 1>&2
|
||||
$(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2
|
||||
rm dfn1.out
|
||||
mv dfn2.out $@
|
||||
|
||||
@@ -1265,7 +1265,7 @@ $(PNGLIB_BASENAME)-config: libpng-config
|
||||
cp libpng-config $@
|
||||
|
||||
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
|
||||
scripts/symbols.out: png.h pngconf.h scripts/pnglibconf.h.prebuilt
|
||||
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
|
||||
|
||||
libpng.sym: scripts/sym.out
|
||||
rm -f $@
|
||||
@@ -1276,7 +1276,8 @@ libpng.vers: scripts/vers.out
|
||||
pnglibconf.h: pnglibconf.out
|
||||
rm -f $@
|
||||
cp $? $@
|
||||
scripts/pnglibconf.h.prebuilt:
|
||||
$(srcdir)/scripts/pnglibconf.h.prebuilt:
|
||||
@echo "Attempting to build $@" >&2
|
||||
@echo "This is a machine generated file, but if you want to make" >&2
|
||||
@echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2
|
||||
@exit 1
|
||||
|
||||
2
README
2
README
@@ -1,4 +1,4 @@
|
||||
README for libpng version 1.5.4beta02 - June 14, 2011 (shared library 15.0)
|
||||
README for libpng version 1.5.5beta06 - August 25, 2011 (shared library 15.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
24
configure
vendored
24
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.68 for libpng 1.5.4beta02.
|
||||
# Generated by GNU Autoconf 2.68 for libpng 1.5.5beta06.
|
||||
#
|
||||
# Report bugs to <png-mng-implement@lists.sourceforge.net>.
|
||||
#
|
||||
@@ -570,8 +570,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='libpng'
|
||||
PACKAGE_TARNAME='libpng'
|
||||
PACKAGE_VERSION='1.5.4beta02'
|
||||
PACKAGE_STRING='libpng 1.5.4beta02'
|
||||
PACKAGE_VERSION='1.5.5beta06'
|
||||
PACKAGE_STRING='libpng 1.5.5beta06'
|
||||
PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net'
|
||||
PACKAGE_URL=''
|
||||
|
||||
@@ -1307,7 +1307,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures libpng 1.5.4beta02 to adapt to many kinds of systems.
|
||||
\`configure' configures libpng 1.5.5beta06 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -1377,7 +1377,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of libpng 1.5.4beta02:";;
|
||||
short | recursive ) echo "Configuration of libpng 1.5.5beta06:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@@ -1485,7 +1485,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
libpng configure 1.5.4beta02
|
||||
libpng configure 1.5.5beta06
|
||||
generated by GNU Autoconf 2.68
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
@@ -1908,7 +1908,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by libpng $as_me 1.5.4beta02, which was
|
||||
It was created by libpng $as_me 1.5.5beta06, which was
|
||||
generated by GNU Autoconf 2.68. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@@ -2723,7 +2723,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='libpng'
|
||||
VERSION='1.5.4beta02'
|
||||
VERSION='1.5.5beta06'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@@ -2787,10 +2787,10 @@ fi
|
||||
|
||||
|
||||
|
||||
PNGLIB_VERSION=1.5.4beta02
|
||||
PNGLIB_VERSION=1.5.5beta06
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=5
|
||||
PNGLIB_RELEASE=4
|
||||
PNGLIB_RELEASE=5
|
||||
|
||||
|
||||
|
||||
@@ -13040,7 +13040,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by libpng $as_me 1.5.4beta02, which was
|
||||
This file was extended by libpng $as_me 1.5.5beta06, which was
|
||||
generated by GNU Autoconf 2.68. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -13106,7 +13106,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
libpng config.status 1.5.4beta02
|
||||
libpng config.status 1.5.5beta06
|
||||
configured by $0, generated by GNU Autoconf 2.68,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
||||
@@ -18,15 +18,15 @@ AC_PREREQ(2.59)
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng], [1.5.4beta02], [png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng], [1.5.5beta06], [png-mng-implement@lists.sourceforge.net])
|
||||
AM_INIT_AUTOMAKE
|
||||
dnl stop configure from automagically running automake
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
PNGLIB_VERSION=1.5.4beta02
|
||||
PNGLIB_VERSION=1.5.5beta06
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=5
|
||||
PNGLIB_RELEASE=4
|
||||
PNGLIB_RELEASE=5
|
||||
|
||||
dnl End of version number stuff
|
||||
|
||||
|
||||
@@ -229,8 +229,14 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
png_set_expand(png_ptr);
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||
png_set_expand(png_ptr);
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
if (bit_depth == 16)
|
||||
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
png_set_scale_16(png_ptr);
|
||||
# else
|
||||
png_set_strip_16(png_ptr);
|
||||
# endif
|
||||
#endif
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
@@ -311,8 +311,14 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
png_set_expand(png_ptr);
|
||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||
png_set_expand(png_ptr);
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
if (bit_depth == 16)
|
||||
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
png_set_scale_16(png_ptr);
|
||||
# else
|
||||
png_set_strip_16(png_ptr);
|
||||
# endif
|
||||
#endif
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
@@ -36,4 +36,4 @@ option FLOATING_ARITHMETIC off
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option READ_EXPAND on
|
||||
option READ_16_TO_8 on
|
||||
option READ_STRIP_16_TO_8 on
|
||||
|
||||
@@ -36,5 +36,5 @@ option STDIO on
|
||||
option READ_bKGD on
|
||||
option READ_GAMMA on
|
||||
option READ_EXPAND on
|
||||
option READ_16_TO_8 on
|
||||
option READ_STRIP_16_TO_8 on
|
||||
option READ_GRAY_TO_RGB on
|
||||
|
||||
@@ -8,9 +8,9 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
|
||||
#PNGPATH = /usr/local
|
||||
#PNGINC = -I$(PNGPATH)/include/libpng12
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng12
|
||||
#PNGLIBS = $(PNGPATH)/lib/libpng12.a
|
||||
#PNGINC = -I$(PNGPATH)/include/libpng15
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng15
|
||||
#PNGLIBS = $(PNGPATH)/lib/libpng15.a
|
||||
PNGINC = -I../..
|
||||
PNGLIB = -L../.. -lpng
|
||||
PNGLIBS = ../../libpng.a
|
||||
@@ -23,9 +23,9 @@ ZINC = -I../../../zlib
|
||||
ZLIB = -L../../../zlib -lz
|
||||
ZLIBS = ../../../zlib/libz.a
|
||||
|
||||
CFLAGS=-O3 $(PNGINC) $(ZINC)
|
||||
LDFLAGS=$(PNGLIB) $(ZLIB)
|
||||
LDFLAGSS=$(PNGLIBS) $(ZLIBS)
|
||||
CFLAGS=$(PNGINC) $(ZINC)
|
||||
LDLIBS=$(PNGLIB) $(ZLIB)
|
||||
LDLIBSS=$(PNGLIBS) $(ZLIBS)
|
||||
C=.c
|
||||
O=.o
|
||||
L=.a
|
||||
@@ -40,19 +40,19 @@ png2pnm$(O): png2pnm$(C)
|
||||
$(CC) -c $(CFLAGS) png2pnm$(C)
|
||||
|
||||
png2pnm$(E): png2pnm$(O)
|
||||
$(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lm
|
||||
$(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
|
||||
|
||||
png2pnm-static$(E): png2pnm$(O)
|
||||
$(LD) -o png2pnm-static$(E) png2pnm$(O) $(LDFLAGSS) -lm
|
||||
$(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
|
||||
|
||||
pnm2png$(O): pnm2png$(C)
|
||||
$(CC) -c $(CFLAGS) pnm2png$(C)
|
||||
|
||||
pnm2png$(E): pnm2png$(O)
|
||||
$(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lm
|
||||
$(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
|
||||
|
||||
pnm2png-static$(E): pnm2png$(O)
|
||||
$(LD) -o pnm2png-static$(E) pnm2png$(O) $(LDFLAGSS) -lm
|
||||
$(LD) $(LDFLAGS) -o pnm2png-static$(E) pnm2png$(O) $(LDLIBSS) -lm
|
||||
|
||||
clean:
|
||||
$(RM) png2pnm$(O)
|
||||
|
||||
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
|
||||
if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n");
|
||||
fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -175,8 +175,14 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
|
||||
// expand images of all color-type and bit-depth to 3x8 bit RGB images
|
||||
// let the library process things like alpha, transparency, background
|
||||
|
||||
if (iBitDepth == 16)
|
||||
png_set_strip_16(png_ptr);
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
if (iBitDepth == 16)
|
||||
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
png_set_scale_16(png_ptr);
|
||||
# else
|
||||
png_set_strip_16(png_ptr);
|
||||
# endif
|
||||
#endif
|
||||
if (iColorType == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_expand(png_ptr);
|
||||
if (iBitDepth < 8)
|
||||
|
||||
11
example.c
11
example.c
@@ -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.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* This file has been placed in the public domain by the authors.
|
||||
* Maintained 1998-2011 Glenn Randers-Pehrson
|
||||
* Maintained 1996, 1997 Andreas Dilger)
|
||||
@@ -187,8 +187,15 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
|
||||
* are mutually exclusive.
|
||||
*/
|
||||
|
||||
/* Tell libpng to strip 16 bit/color files down to 8 bits/color */
|
||||
/* Tell libpng to strip 16 bit/color files down to 8 bits/color.
|
||||
* Use accurate scaling if it's available, otherwise just chop off the
|
||||
* low byte.
|
||||
*/
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
png_set_scale_16(png_ptr);
|
||||
#else
|
||||
png_set_strip_16(png_ptr);
|
||||
#endif
|
||||
|
||||
/* Strip alpha bytes from the input data without combining with the
|
||||
* background (not recommended).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.5.4beta02 - June 14, 2011
|
||||
libpng version 1.5.5beta06 - August 25, 2011
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2011 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.5.4beta02 - June 14, 2011
|
||||
libpng versions 0.97, January 1998, through 1.5.5beta06 - August 25, 2011
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
|
||||
@@ -107,7 +107,8 @@ PNG file. At one time, the fields of png_info were intended to be
|
||||
directly accessible to the user. However, this tended to cause problems
|
||||
with applications using dynamically loaded libraries, and as a result
|
||||
a set of interface functions for png_info (the png_get_*() and png_set_*()
|
||||
functions) was developed.
|
||||
functions) was developed, and direct access to the png_info fields was
|
||||
deprecated..
|
||||
|
||||
The png_struct structure is the object used by the library to decode a
|
||||
single image. As of 1.5.0 this structure is also not exposed.
|
||||
@@ -116,14 +117,23 @@ Almost all libpng APIs require a pointer to a png_struct as the first argument.
|
||||
Many (in particular the png_set and png_get APIs) also require a pointer
|
||||
to png_info as the second argument. Some application visible macros
|
||||
defined in png.h designed for basic data access (reading and writing
|
||||
integers in the PNG format) break this rule, but it's almost always safe
|
||||
to assume that a (png_struct*) has to be passed to call an API function.
|
||||
integers in the PNG format) don't take a png_info pointer, but it's almost
|
||||
always safe to assume that a (png_struct*) has to be passed to call an API
|
||||
function.
|
||||
|
||||
You can have more than one png_info structure associated with an image,
|
||||
as illustrated in pngtest.c, one for information valid prior to the
|
||||
IDAT chunks and another (called "end_info" below) for things after them.
|
||||
|
||||
The png.h header file is an invaluable reference for programming with libpng.
|
||||
And while I'm on the topic, make sure you include the libpng header file:
|
||||
|
||||
#include <png.h>
|
||||
|
||||
and also (as of libpng-1.5.0) the zlib header file, if you need it:
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
Types
|
||||
|
||||
The png.h header file defines a number of integral types used by the
|
||||
@@ -137,9 +147,9 @@ the value by multiplying by 100,000. As of libpng 1.5.0 a convenience
|
||||
macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point)
|
||||
which is simply (png_int_32).
|
||||
|
||||
All APIs that take (double) arguments also have an matching API that
|
||||
All APIs that take (double) arguments also have a matching API that
|
||||
takes the corresponding fixed point integer arguments. The fixed point
|
||||
API has the same name as the floating point one with _fixed appended.
|
||||
API has the same name as the floating point one with "_fixed" appended.
|
||||
The actual range of values permitted in the APIs is frequently less than
|
||||
the full range of (png_fixed_point) (-21474 to +21474). When APIs require
|
||||
a non-negative argument the type is recorded as png_uint_32 above. Consult
|
||||
@@ -157,6 +167,10 @@ preprocessing directives of the form:
|
||||
#ifdef PNG_feature_SUPPORTED
|
||||
declare-function
|
||||
#endif
|
||||
...
|
||||
#ifdef PNG_feature_SUPPORTED
|
||||
use-function
|
||||
#endif
|
||||
|
||||
The library can be built without support for these APIs, although a
|
||||
standard build will have all implemented APIs. Application programs
|
||||
@@ -165,7 +179,7 @@ portability. From libpng 1.5.0 the feature macros set during the build
|
||||
of libpng are recorded in the header file "pnglibconf.h" and this file
|
||||
is always included by png.h.
|
||||
|
||||
If you don't need to change the library configuration from the default skip to
|
||||
If you don't need to change the library configuration from the default, skip to
|
||||
the next section ("Reading").
|
||||
|
||||
Notice that some of the makefiles in the 'scripts' directory and (in 1.5.0) all
|
||||
@@ -197,24 +211,25 @@ A variety of methods exist to build libpng. Not all of these support
|
||||
reconfiguration of pnglibconf.h. To reconfigure pnglibconf.h it must either be
|
||||
rebuilt from scripts/pnglibconf.dfa using awk or it must be edited by hand.
|
||||
|
||||
Hand editing is achieved by copying scripts/pnglibconf.h.prebuilt and changing
|
||||
the lines defining the supported features, paying very close attention to the
|
||||
'option' information in scripts/pnglibconf.dfa that describes those features and
|
||||
their requirements. This is easy to get wrong.
|
||||
Hand editing is achieved by copying scripts/pnglibconf.h.prebuilt to
|
||||
pnglibconf.h and changing the lines defining the supported features, paying
|
||||
very close attention to the 'option' information in scripts/pnglibconf.dfa
|
||||
that describes those features and their requirements. This is easy to get
|
||||
wrong.
|
||||
|
||||
B. Configuration using DFA_XTRA
|
||||
|
||||
Rebuilding from pnglibconf.dfa is easy if a functioning 'awk', or a later
|
||||
variant such as 'nawk' or 'gawk', is available. The configure build will
|
||||
automatically find an appropriate awk and build pnglibconf.h.
|
||||
scripts/pnglibconf.mak contains a set of make rules for doing the same thing if
|
||||
configure is not used, and many of the makefiles in the scripts directory use
|
||||
this approach.
|
||||
The scripts/pnglibconf.mak file contains a set of make rules for doing the
|
||||
same thing if configure is not used, and many of the makefiles in the scripts
|
||||
directory use this approach.
|
||||
|
||||
When rebuilding simply write new file containing changed options and set
|
||||
When rebuilding simply write a new file containing changed options and set
|
||||
DFA_XTRA to the name of this file. This causes the build to append the new file
|
||||
to the end of scripts/pnglibconf.dfa. pngusr.dfa should contain lines of the
|
||||
following forms:
|
||||
to the end of scripts/pnglibconf.dfa. The pngusr.dfa file should contain lines
|
||||
of the following forms:
|
||||
|
||||
everything = off
|
||||
|
||||
@@ -238,12 +253,16 @@ source code. Most of these values have performance implications for the library
|
||||
but most of them have no visible effect on the API. Some can also be overridden
|
||||
from the API.
|
||||
|
||||
This method of building a customized pnglibconf.h is illustrated in
|
||||
contrib/pngminim/*. See the "$(PNGCONF):" target in the makefile and
|
||||
pngusr.dfa in these directories.
|
||||
|
||||
C. Configuration using PNG_USR_CONFIG
|
||||
|
||||
If -DPNG_USR_CONFIG is added to the CFLAGS when pnglibconf.h is built the file
|
||||
pngusr.h will automatically be included before the options in
|
||||
scripts/pnglibconf.dfa are processed. pngusr.h should contain only macro
|
||||
definitions turning features on or off or setting settings.
|
||||
scripts/pnglibconf.dfa are processed. Your pngusr.h file should contain only
|
||||
macro definitions turning features on or off or setting settings.
|
||||
|
||||
Apart from the global setting "everything = off" all the options listed above
|
||||
can be set using macros in pngusr.h:
|
||||
@@ -274,6 +293,9 @@ examine the intermediate file pnglibconf.dfn to find the full set of
|
||||
dependency information for each setting and option. Simply locate the
|
||||
feature in the file and read the C comments that precede it.
|
||||
|
||||
This method is also illustrated in the contrib/pngminim/* makefiles and
|
||||
pngusr.h.
|
||||
|
||||
III. Reading
|
||||
|
||||
We'll now walk you through the possible functions to call when reading
|
||||
@@ -557,6 +579,8 @@ according to the "keep" directive. If a chunk is named in successive
|
||||
instances of png_set_keep_unknown_chunks(), the final instance will
|
||||
take precedence. The IHDR and IEND chunks should not be named in
|
||||
chunk_list; if they are, libpng will process them normally anyway.
|
||||
If you know that your application will never make use of some particular
|
||||
chunks, use PNG_HANDLE_CHUNK_NEVER (or 1) as demonstrated below.
|
||||
|
||||
Here is an example of the usage of png_set_keep_unknown_chunks(),
|
||||
where the private "vpAg" chunk will later be processed by a user chunk
|
||||
@@ -647,13 +671,14 @@ If you intend to display the PNG or to incorporate it in other image data you
|
||||
need to tell libpng information about your display or drawing surface so that
|
||||
libpng can convert the values in the image to match the display.
|
||||
|
||||
From libpng-1.5.3 this information can be set before reading the PNG file
|
||||
From libpng-1.5.4 this information can be set before reading the PNG file
|
||||
header. In earlier versions png_set_gamma() existed but behaved incorrectly if
|
||||
called before the PNG file header had been read and png_set_alpha_mode() did not
|
||||
exist.
|
||||
|
||||
If you need to support versions prior to libpng-1.5.3 test the version number
|
||||
and follow the procedures described in the appropriate manual page.
|
||||
If you need to support versions prior to libpng-1.5.4 test the version number
|
||||
as illustrated below using "PNG_LIBPNG_VER >= 10504" and follow the procedures
|
||||
described in the appropriate manual page.
|
||||
|
||||
You give libpng the encoding expected by your system expressed as a 'gamma'
|
||||
value. You can also specify a default encoding for the PNG file in
|
||||
@@ -673,7 +698,7 @@ documentation!
|
||||
|
||||
Many systems permit the system gamma to be changed via a lookup table in the
|
||||
display driver, a few systems, including older Macs, change the response by
|
||||
default. As of 1.5.3 three special values are available to handle common
|
||||
default. As of 1.5.4 three special values are available to handle common
|
||||
situations:
|
||||
|
||||
PNG_DEFAULT_sRGB: Indicates that the system conforms to the IEC 61966-2-1
|
||||
@@ -698,7 +723,9 @@ Libpng only supports composing onto a single color (using png_set_background;
|
||||
see below.) Otherwise you must do the composition yourself and, in this case,
|
||||
you may need to call png_set_alpha_mode:
|
||||
|
||||
#if PNG_LIBPNG_VER >= 10504
|
||||
png_set_alpha_mode(png_ptr, mode, screen_gamma);
|
||||
#endif
|
||||
|
||||
The screen_gamma value is the same as the argument to png_set_gamma, however how
|
||||
it affects the output depends on the mode. png_set_alpha_mode() sets the file
|
||||
@@ -838,17 +865,22 @@ format produced by libpng to always have 8-bit or 16-bit components and then
|
||||
store the color as an 8-bit or 16-bit color as appropriate. The color contains
|
||||
separate gray and RGB component values, so you can let libpng produce gray or
|
||||
RGB output according to the input format, but low bit depth grayscale images
|
||||
must always be converted to at least 8-bit format. (Even low low bit depth
|
||||
must always be converted to at least 8-bit format. (Even though low bit depth
|
||||
grayscale images can't have an alpha channel they can have a transparent
|
||||
color!)
|
||||
|
||||
You set the transforms you need later, either as flags to the high level
|
||||
interface or libpng API calls for the low level interface. For reference the
|
||||
settings required are:
|
||||
settings and API calls required are:
|
||||
|
||||
8-bit values:
|
||||
PNG_TRANSFORM_STRIP_16 | PNG_EXPAND
|
||||
png_set_expand(png_ptr); png_set_strip_16(png_ptr);
|
||||
PNG_TRANSFORM_SCALE_16 | PNG_EXPAND
|
||||
png_set_expand(png_ptr); png_set_scale_16(png_ptr);
|
||||
|
||||
If you must get exactly the same inaccurate results
|
||||
produced by default in versions prior to libpng-1.5.4,
|
||||
use PNG_TRANSFORM_STRIP_16 and png_set_strip_16(png_ptr)
|
||||
instead.
|
||||
|
||||
16-bit values:
|
||||
PNG_TRANSFORM_EXPAND_16
|
||||
@@ -859,9 +891,9 @@ color data you can add PNG_TRANSFORM_GRAY_TO_RGB or png_set_gray_to_rgb(png_ptr)
|
||||
to the list.
|
||||
|
||||
Calling png_set_background before the PNG file header is read will not work
|
||||
prior to libpng-1.5.3. Because the failure may result in unexpected warnings or
|
||||
prior to libpng-1.5.4. Because the failure may result in unexpected warnings or
|
||||
errors it is therefore much safer to call png_set_background after the head has
|
||||
been read. Unfortunately this means that prior to libpng-1.5.3 it cannot be
|
||||
been read. Unfortunately this means that prior to libpng-1.5.4 it cannot be
|
||||
used with the high level interface.
|
||||
|
||||
The high-level read interface
|
||||
@@ -873,8 +905,10 @@ the entire image into memory, and (b) the input transformations
|
||||
you want to do are limited to the following set:
|
||||
|
||||
PNG_TRANSFORM_IDENTITY No transformation
|
||||
PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to
|
||||
8-bit
|
||||
PNG_TRANSFORM_SCALE_16 Strip 16-bit samples to
|
||||
8-bit accurately
|
||||
PNG_TRANSFORM_STRIP_16 Chop 16-bit samples to
|
||||
8-bit less accurately
|
||||
PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel
|
||||
PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit
|
||||
samples to bytes
|
||||
@@ -968,9 +1002,9 @@ for use in later transformations. Important information copied in is:
|
||||
1) The PNG file gamma from the gAMA chunk. This overwrites the default value
|
||||
provided by an earlier call to png_set_gamma or png_set_alpha_mode.
|
||||
|
||||
2) Prior to libpng-1.5.3 the background color from a bKGd chunk. This
|
||||
2) Prior to libpng-1.5.4 the background color from a bKGd chunk. This
|
||||
damages the information provided by an earlier call to png_set_background
|
||||
resulting in expected behavior. Libpng-1.5.3 no longer does this.
|
||||
resulting in unexpected behavior. Libpng-1.5.4 no longer does this.
|
||||
|
||||
3) The number of significant bits in each component value. Libpng uses this to
|
||||
optimize gamma handling by reducing the internal lookup table sizes.
|
||||
@@ -1108,6 +1142,28 @@ pointer into the info_ptr is returned for any complex types.
|
||||
int_file_gamma - 100,000 times the gamma at which the
|
||||
file is written
|
||||
|
||||
png_get_cHRM(png_ptr, info_ptr, &white_x, &white_y, &red_x, &red_y,
|
||||
&green_x, &green_y, &blue_x, &blue_y)
|
||||
png_get_cHRM_XYZ(png_ptr, info_ptr, &red_X, &red_Y, &red_Z, &green_X,
|
||||
&green_Y, &green_Z, &blue_X, &blue_Y, &blue_Z)
|
||||
png_get_cHRM_fixed(png_ptr, info_ptr, &int_white_x, &int_white_y,
|
||||
&int_red_x, &int_red_y, &int_green_x, &int_green_y,
|
||||
&int_blue_x, &int_blue_y)
|
||||
png_get_cHRM_XYZ_fixed(png_ptr, info_ptr, &int_red_X, &int_red_Y,
|
||||
&int_red_Z, &int_green_X, &int_green_Y, &int_green_Z,
|
||||
&int_blue_X, &int_blue_Y, &int_blue_Z)
|
||||
|
||||
{white,red,green,blue}_{x,y}
|
||||
A color space encoding specified using the chromaticities
|
||||
of the end points and the white point. (PNG_INFO_cHRM)
|
||||
|
||||
{red,green,blue}_{X,Y,Z}
|
||||
A color space encoding specified using the encoding end
|
||||
points - the CIE tristimulus specification of the intended
|
||||
color of the red, green and blue channels in the PNG RGB
|
||||
data. The white point is simply the sum of the three end
|
||||
points. (PNG_INFO_cHRM)
|
||||
|
||||
png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
|
||||
|
||||
file_srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
@@ -1166,7 +1222,8 @@ pointer into the info_ptr is returned for any complex types.
|
||||
|
||||
png_get_bKGD(png_ptr, info_ptr, &background);
|
||||
|
||||
background - background color (PNG_VALID_bKGD)
|
||||
background - background color (of type
|
||||
png_color_16p) (PNG_VALID_bKGD)
|
||||
valid 16-bit red, green and blue
|
||||
values, regardless of color_type
|
||||
|
||||
@@ -1205,6 +1262,8 @@ pointer into the info_ptr is returned for any complex types.
|
||||
Note that the itxt_length, lang, and lang_key
|
||||
members of the text_ptr structure only exist
|
||||
when the library is built with iTXt chunk support.
|
||||
Prior to libpng-1.4.0, the default build was
|
||||
without iTXt chunk support.
|
||||
|
||||
num_text - number of comments (same as
|
||||
num_comments; you can put NULL here
|
||||
@@ -1229,10 +1288,10 @@ pointer into the info_ptr is returned for any complex types.
|
||||
&unit_type);
|
||||
|
||||
offset_x - positive offset from the left edge
|
||||
of the screen
|
||||
of the screen (can be negative)
|
||||
|
||||
offset_y - positive offset from the top edge
|
||||
of the screen
|
||||
of the screen (can be negative)
|
||||
|
||||
unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
|
||||
|
||||
@@ -1264,6 +1323,7 @@ pointer into the info_ptr is returned for any complex types.
|
||||
unit - physical scale units (an integer)
|
||||
|
||||
width - width of a pixel in physical scale units
|
||||
(expressed as a string)
|
||||
|
||||
height - height of a pixel in physical scale units
|
||||
(width and height are strings like "2.54")
|
||||
@@ -1286,6 +1346,12 @@ pointer into the info_ptr is returned for any complex types.
|
||||
chunks were read from the PNG file or inserted with the
|
||||
png_set_unknown_chunks() function.
|
||||
|
||||
The value of "location" is a bitwise "or" of
|
||||
|
||||
PNG_HAVE_IHDR (0x01)
|
||||
PNG_HAVE_PLTE (0x02)
|
||||
PNG_AFTER_IDAT (0x08)
|
||||
|
||||
The data from the pHYs chunk can be retrieved in several convenient
|
||||
forms:
|
||||
|
||||
@@ -1399,12 +1465,12 @@ byte, unless png_set_packing() is called. 8-bit RGB data will be stored
|
||||
in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
|
||||
is called to insert filler bytes, either before or after each RGB triplet.
|
||||
16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
|
||||
byte of the color value first, unless png_set_strip_16() is called to
|
||||
byte of the color value first, unless png_set_scale_16() is called to
|
||||
transform it to regular RGB RGB triplets, or png_set_filler() or
|
||||
png_set_add alpha() is called to insert filler bytes, either before or
|
||||
after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can
|
||||
be modified with
|
||||
png_set_filler(), png_set_add_alpha(), or png_set_strip_16().
|
||||
be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(),
|
||||
or png_set_scale_16().
|
||||
|
||||
The following code transforms grayscale images of less than 8 to 8 bits,
|
||||
changes paletted images to RGB, and adds a full alpha channel if there is
|
||||
@@ -1430,7 +1496,7 @@ As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
|
||||
added. It expands the sample depth without changing tRNS to alpha.
|
||||
|
||||
As of libpng version 1.5.2, png_set_expand_16() was added. It behaves as
|
||||
png_set_expand(), however, the resultant channels have 16 bits rather than 8.
|
||||
png_set_expand(); however, the resultant channels have 16 bits rather than 8.
|
||||
Use this when the output color or gray channels are made linear to avoid fairly
|
||||
severe accuracy loss.
|
||||
|
||||
@@ -1441,7 +1507,14 @@ PNG can have files with 16 bits per channel. If you only can handle
|
||||
8 bits per channel, this will strip the pixels down to 8-bit.
|
||||
|
||||
if (bit_depth == 16)
|
||||
#if PNG_LIBPNG_VER >= 10504
|
||||
png_set_scale_16(png_ptr);
|
||||
#else
|
||||
png_set_strip_16(png_ptr);
|
||||
#endif
|
||||
|
||||
(The more accurate "png_set_scale_16()" API became available in libpng version
|
||||
1.5.4).
|
||||
|
||||
If you need to process the alpha channel on the image separately from the image
|
||||
data (for example if you convert it to a bitmap mask) it is possible to have
|
||||
@@ -1619,31 +1692,41 @@ It will return a png_byte that is zero if the image was gray or
|
||||
will be silently converted to grayscale, using the green channel
|
||||
data for sBIT, regardless of the error_action setting.
|
||||
|
||||
The default values come from the PNG file cHRM chunk if present, otherwise the
|
||||
The default values come from the PNG file cHRM chunk if present; otherwise, the
|
||||
defaults correspond to the ITU-R recommendation 709, and also the sRGB color
|
||||
space, as recommended in the Charles Poynton's Colour FAQ,
|
||||
<http://www.poynton.com/>, in section 9:
|
||||
|
||||
<http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC9>
|
||||
|
||||
Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
|
||||
|
||||
Previous versions of this document, 1998 through 2002, recommended a slightly
|
||||
different formula:
|
||||
|
||||
Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
|
||||
|
||||
Libpng uses an integer approximation:
|
||||
|
||||
Y = (6968 * R + 23434 * G + 2366 * B)/32768
|
||||
|
||||
The calculation is done in a linear colorspace, if the image gamma
|
||||
can be determined.
|
||||
|
||||
The png_set_background() function has been described already, it tells libpng to
|
||||
The png_set_background() function has been described already; it tells libpng to
|
||||
composite images with alpha or simple transparency against the supplied
|
||||
background color. For compatibility with versions of libpng earlier than
|
||||
libpng-1.5.3 it is recommended that you call the function after reading the file
|
||||
libpng-1.5.4 it is recommended that you call the function after reading the file
|
||||
header, even if you don't want to use the color in a bKGD chunk, if one exists.
|
||||
|
||||
If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
|
||||
you may use this color, or supply another color more suitable for
|
||||
the current display (e.g., the background color from a web page). You
|
||||
need to tell libpng how the color is represented, both the format of the
|
||||
component values in the color (the number of bits) and the gamme encoding of the
|
||||
component values in the color (the number of bits) and the gamma encoding of the
|
||||
color. The function takes two arguments, background_gamma_mode and need_expand
|
||||
to convey this information, however only two combinations are like to be useful:
|
||||
to convey this information, however only two combinations are likely to be
|
||||
useful:
|
||||
|
||||
png_color_16 my_background;
|
||||
png_color_16p image_background;
|
||||
@@ -1655,7 +1738,6 @@ to convey this information, however only two combinations are like to be useful:
|
||||
png_set_background(png_ptr, &my_background,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*do not expand*/, 1);
|
||||
|
||||
|
||||
The second call was described above - my_background is in the format of the
|
||||
final, display, output produced by libpng. Because you now know the format of
|
||||
the PNG it is possible to avoid the need to choose either 8-bit or 16-bit
|
||||
@@ -1671,7 +1753,7 @@ image_background->gray.
|
||||
|
||||
If you didn't call png_set_gamma() before reading the file header, for example
|
||||
if you need your code to remain compatible with older versions of libpng prior
|
||||
to libpng-1.5.3, this is the place to call it.
|
||||
to libpng-1.5.4, this is the place to call it.
|
||||
|
||||
Do not call it if you called png_set_alpha_mode(); doing so will damage the
|
||||
settings put in place by png_set_alpha_mode(). (If png_set_alpha_mode() is
|
||||
@@ -1694,9 +1776,9 @@ file has more entries then will fit on your screen, png_set_quantize()
|
||||
will do that. Note that this is a simple match quantization that merely
|
||||
finds the closest color available. This should work fairly well with
|
||||
optimized palettes, but fairly badly with linear color cubes. If you
|
||||
pass a palette that is larger then maximum_colors, the file will
|
||||
pass a palette that is larger than maximum_colors, the file will
|
||||
reduce the number of colors in the palette so it will fit into
|
||||
maximum_colors. If there is a histogram, it will use it to make
|
||||
maximum_colors. If there is a histogram, libpng will use it to make
|
||||
more intelligent choices when reducing the palette. If there is no
|
||||
histogram, it may not do as good a job.
|
||||
|
||||
@@ -1768,7 +1850,7 @@ after all of the other transformations have been processed. Take care with
|
||||
interlaced images if you do the interlace yourself - the width of the row is the
|
||||
width in 'row_info', not the overall image width.
|
||||
|
||||
If supported libpng provides two information routines that you can use to find
|
||||
If supported, libpng provides two information routines that you can use to find
|
||||
where you are in processing the image:
|
||||
|
||||
png_get_current_pass_number(png_structp png_ptr);
|
||||
@@ -2632,6 +2714,28 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
int_file_gamma - 100,000 times the gamma at which
|
||||
the image was created
|
||||
|
||||
png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y,
|
||||
green_x, green_y, blue_x, blue_y)
|
||||
png_set_cHRM_XYZ(png_ptr, info_ptr, red_X, red_Y, red_Z, green_X,
|
||||
green_Y, green_Z, blue_X, blue_Y, blue_Z)
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y,
|
||||
int_red_x, int_red_y, int_green_x, int_green_y,
|
||||
int_blue_x, int_blue_y)
|
||||
png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, int_red_X, int_red_Y,
|
||||
int_red_Z, int_green_X, int_green_Y, int_green_Z,
|
||||
int_blue_X, int_blue_Y, int_blue_Z)
|
||||
|
||||
{white,red,green,blue}_{x,y}
|
||||
A color space encoding specified using the chromaticities
|
||||
of the end points and the white point.
|
||||
|
||||
{red,green,blue}_{X,Y,Z}
|
||||
A color space encoding specified using the encoding end
|
||||
points - the CIE tristimulus specification of the intended
|
||||
color of the red, green and blue channels in the PNG RGB
|
||||
data. The white point is simply the sum of the three end
|
||||
points.
|
||||
|
||||
png_set_sRGB(png_ptr, info_ptr, srgb_intent);
|
||||
|
||||
srgb_intent - the rendering intent
|
||||
@@ -2692,14 +2796,14 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
trans_alpha - array of alpha (transparency)
|
||||
entries for palette (PNG_INFO_tRNS)
|
||||
|
||||
num_trans - number of transparent entries
|
||||
(PNG_INFO_tRNS)
|
||||
|
||||
trans_color - graylevel or color sample values
|
||||
(in order red, green, blue) of the
|
||||
single transparent color for
|
||||
non-paletted images (PNG_INFO_tRNS)
|
||||
|
||||
num_trans - number of transparent entries
|
||||
(PNG_INFO_tRNS)
|
||||
|
||||
png_set_hIST(png_ptr, info_ptr, hist);
|
||||
|
||||
hist - histogram of palette (array of
|
||||
@@ -2712,7 +2816,8 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
|
||||
png_set_bKGD(png_ptr, info_ptr, background);
|
||||
|
||||
background - background color (PNG_VALID_bKGD)
|
||||
background - background color (of type
|
||||
png_color_16p) (PNG_VALID_bKGD)
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, num_text);
|
||||
|
||||
@@ -2739,6 +2844,8 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
Note that the itxt_length, lang, and lang_key
|
||||
members of the text_ptr structure only exist
|
||||
when the library is built with iTXt chunk support.
|
||||
Prior to libpng-1.4.0 the library was built by default
|
||||
without iTXt support.
|
||||
|
||||
num_text - number of comments
|
||||
|
||||
@@ -2788,6 +2895,7 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
unit - physical scale units (an integer)
|
||||
|
||||
width - width of a pixel in physical scale units
|
||||
expressed as a string
|
||||
|
||||
height - height of a pixel in physical scale units
|
||||
(width and height are strings like "2.54")
|
||||
@@ -2829,7 +2937,7 @@ Because tEXt and zTXt chunks don't have a language field, if you
|
||||
specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
|
||||
any language code or translated keyword will not be written out.
|
||||
|
||||
Until text gets around 1000 bytes, it is not worth compressing it.
|
||||
Until text gets around a few hundred bytes, it is not worth compressing it.
|
||||
After the text has been written out to the file, the compression type
|
||||
is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
|
||||
so that it isn't written out again at the end (in case you are calling
|
||||
@@ -3439,7 +3547,8 @@ However, there are some uncertainties about the status of local variables
|
||||
after a longjmp, so the user may want to be careful about doing anything
|
||||
after setjmp returns non-zero besides returning itself. Consult your
|
||||
compiler documentation for more details. For an alternative approach, you
|
||||
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net).
|
||||
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net),
|
||||
which is illustrated in pngvalid.c and in contrib/visupng.
|
||||
|
||||
Custom chunks
|
||||
|
||||
@@ -3457,8 +3566,11 @@ and look at how other chunks were designed, so you can do things
|
||||
similarly. Second, check out the sections of libpng that read and
|
||||
write chunks. Try to find a chunk that is similar to yours and use
|
||||
it as a template. More details can be found in the comments inside
|
||||
the code. It is best to handle unknown chunks in a generic method,
|
||||
via callback functions, instead of by modifying libpng functions.
|
||||
the code. It is best to handle private or unknown chunks in a generic method,
|
||||
via callback functions, instead of by modifying libpng functions. This
|
||||
is illustrated in pngtest.c, which uses a callback function to handle a
|
||||
private "vpAg" chunk and the new "sTER" chunk, which are both unknown to
|
||||
libpng.
|
||||
|
||||
If you wish to write your own transformation for the data, look through
|
||||
the part of the code that does the transformations, and check out some of
|
||||
@@ -3486,8 +3598,8 @@ defined, and FAR gets defined to far in pngconf.h, and you should be
|
||||
all set. Everything in the library (except for zlib's structure) is
|
||||
expecting far data. You must use the typedefs with the p or pp on
|
||||
the end for pointers (or at least look at them and be careful). Make
|
||||
note that the rows of data are defined as png_bytepp, which is an
|
||||
unsigned char far * far *.
|
||||
note that the rows of data are defined as png_bytepp, which is
|
||||
an "unsigned char far * far *".
|
||||
|
||||
Configuring for gui/windowing platforms:
|
||||
|
||||
@@ -3505,7 +3617,10 @@ or delete an include, this is the place to do it.
|
||||
The includes that are not needed outside libpng are placed in pngpriv.h,
|
||||
which is only used by the routines inside libpng itself.
|
||||
The files in libpng proper only include pngpriv.h and png.h, which
|
||||
in turn includes pngconf.h.
|
||||
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
|
||||
As of libpng-1.5.0, pngpriv.h also includes three other private header
|
||||
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
|
||||
that previously appeared in the public headers.
|
||||
|
||||
Configuring zlib:
|
||||
|
||||
@@ -3547,8 +3662,28 @@ zlib.h for more information on what these mean.
|
||||
window_bits);
|
||||
|
||||
png_set_compression_method(png_ptr, method);
|
||||
|
||||
png_set_compression_buffer_size(png_ptr, size);
|
||||
|
||||
As of libpng version 1.5.4, additional APIs became
|
||||
available to set these separately for non-IDAT
|
||||
compressed chunks such as zTXt, iTXt, and iCCP:
|
||||
|
||||
#include zlib.h
|
||||
#if PNG_LIBPNG_VER <= 10504
|
||||
png_set_text_compression_level(png_ptr, level);
|
||||
|
||||
png_set_text_compression_mem_level(png_ptr, level);
|
||||
|
||||
png_set_text_compression_strategy(png_ptr,
|
||||
strategy);
|
||||
|
||||
png_set_text_compression_window_bits(png_ptr,
|
||||
window_bits);
|
||||
|
||||
png_set_text_compression_method(png_ptr, method);
|
||||
#endif
|
||||
|
||||
Controlling row filtering
|
||||
|
||||
If you want to control whether libpng uses filtering or not, which
|
||||
@@ -3654,8 +3789,8 @@ capability, which you'll still have).
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
make sure, or if you are building a stand alone library, all the
|
||||
reading files start with pngr and all the writing files start with
|
||||
pngw. The files that don't match either (like png.c, pngtrans.c, etc.)
|
||||
reading files start with "pngr" and all the writing files start with "pngw".
|
||||
The files that don't match either (like png.c, pngtrans.c, etc.)
|
||||
are used for both reading and writing, and always need to be included.
|
||||
The progressive reader is in pngpread.c
|
||||
|
||||
@@ -4033,7 +4168,6 @@ absolutely necessary) interlace an image.
|
||||
|
||||
libpng 1.5.0 adds an API png_longjmp(png_ptr, value). This API calls
|
||||
the application-provided png_longjmp_ptr on the internal, but application
|
||||
initialized, jmpbuf. It is provided as a convenience to avoid the need
|
||||
initialized, longjmp buffer. It is provided as a convenience to avoid
|
||||
the need to use the png_jmpbuf macro, which had the unnecessary side
|
||||
effect of resetting the internal png_longjmp_ptr value.
|
||||
@@ -4090,20 +4224,20 @@ PNG_NO_USE_READ_MACROS before including png.h. Notice that this is
|
||||
only supported from 1.5.0 -defining PNG_NO_USE_READ_MACROS prior to 1.5.0
|
||||
will lead to a link failure.
|
||||
|
||||
Prior to libpng-1.5.3, the zlib compressor used the same set of parameters
|
||||
Prior to libpng-1.5.4, the zlib compressor used the same set of parameters
|
||||
when compressing the IDAT data and textual data such as zTXt and iCCP.
|
||||
In libpng-1.5.3 we reinitialized the zlib stream for each type of data.
|
||||
In libpng-1.5.4 we reinitialized the zlib stream for each type of data.
|
||||
We added five png_set_text_*() functions for setting the parameters to
|
||||
use with textual data.
|
||||
|
||||
Prior to libpng-1.5.3, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
Prior to libpng-1.5.4, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
option was off by default, and slightly inaccurate scaling occurred.
|
||||
This option can no longer be turned off, and 16-to-8 scaling is always
|
||||
accurate. This change will result in some different results while
|
||||
reading 16-bit images, with none of the pixels being off-by-one any
|
||||
longer (see Clause 13.12 of the PNG specification).
|
||||
This option can no longer be turned off, and the choice of accurate
|
||||
or inaccurate 16-to-8 scaling is by using the new png_set_scale_16_to_8()
|
||||
API for accurate scaling or the old png_set_strip_16_to_8() API for simple
|
||||
chopping.
|
||||
|
||||
Prior to libpng-1.5.3, the png_set_user_limits() function could only be
|
||||
Prior to libpng-1.5.4, the png_set_user_limits() function could only be
|
||||
used to reduce the width and height limits from the value of
|
||||
PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said
|
||||
that it could be used to override them. Now this function will reduce or
|
||||
@@ -4112,9 +4246,9 @@ increase the limits.
|
||||
B. Changes to the build and configuration of libpng
|
||||
|
||||
Details of internal changes to the library code can be found in the CHANGES
|
||||
file. These will be of no concern to the vast majority of library users or
|
||||
builders, however the few who configure libpng to a non-default feature
|
||||
set may need to change how this is done.
|
||||
file and in the GIT repository logs. These will be of no concern to the vast
|
||||
majority of library users or builders, however the few who configure libpng
|
||||
to a non-default feature set may need to change how this is done.
|
||||
|
||||
There should be no need for library builders to alter build scripts if
|
||||
these use the distributed build support - configure or the makefiles -
|
||||
@@ -4123,14 +4257,14 @@ to build pnglibconf.h where the corresponding makefile does not do so.
|
||||
|
||||
Building libpng with a non-default configuration has changed completely.
|
||||
The old method using pngusr.h should still work correctly even though the
|
||||
way pngusr.h is used in the build has been changed, however library
|
||||
way pngusr.h is used in the build has been changed; however, library
|
||||
builders will probably want to examine the changes to take advantage of
|
||||
new capabilities and to simplify their build system.
|
||||
|
||||
B.1 Specific changes to library configuration capabilities
|
||||
|
||||
The library now supports a complete fixed point implementation and can
|
||||
thus be used on systems which have no floating point support or very
|
||||
thus be used on systems that have no floating point support or very
|
||||
limited or slow support. Previously gamma correction, an essential part
|
||||
of complete PNG support, required reasonably fast floating point.
|
||||
|
||||
@@ -4146,14 +4280,14 @@ pnglibconf.h
|
||||
As part of this the mechanism used to choose procedure call standards on
|
||||
those systems that allow a choice has been changed. At present this only
|
||||
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
|
||||
running on Intel processors. As before PNGAPI is defined where required
|
||||
running on Intel processors. As before, PNGAPI is defined where required
|
||||
to control the exported API functions; however, two new macros, PNGCBAPI
|
||||
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
|
||||
(PNGCAPI) for functions that must match a C library prototype (currently
|
||||
only png_longjmp_ptr, which must match the C longjmp function.) The new
|
||||
approach is documented in pngconf.h
|
||||
|
||||
Despite these changes libpng 1.5.0 only supports the native C function
|
||||
Despite these changes, libpng 1.5.0 only supports the native C function
|
||||
calling standard on those platforms tested so far (__cdecl on Microsoft
|
||||
Windows). This is because the support requirements for alternative
|
||||
calling conventions seem to no longer exist. Developers who find it
|
||||
@@ -4186,8 +4320,10 @@ if the feature is supported or:
|
||||
/*#undef PNG_feature_SUPPORTED*/
|
||||
|
||||
if it is not. Library code consistently checks for the 'SUPPORTED' macro.
|
||||
It does not, and should not, check for the 'NO' macro which will not
|
||||
normally be defined even if the feature is not supported.
|
||||
It does not, and libpng applications should not, check for the 'NO' macro
|
||||
which will not normally be defined even if the feature is not supported.
|
||||
The 'NO' macros are only used internally for setting or not setting the
|
||||
corresponding 'SUPPORTED' macros.
|
||||
|
||||
Compatibility with the old names is provided as follows:
|
||||
|
||||
@@ -4244,10 +4380,10 @@ application built without PNG_USER_CONFIG defined would see the
|
||||
unmodified, default, libpng API and thus would probably fail to link.
|
||||
|
||||
These mechanisms still work in the configure build and in any makefile
|
||||
build that builds pnglibconf.h although the feature selection macros
|
||||
build that builds pnglibconf.h, although the feature selection macros
|
||||
have changed somewhat as described above. In 1.5.0, however, pngusr.h is
|
||||
processed only once, when the exported header file pnglibconf.h is built.
|
||||
pngconf.h no longer includes pngusr.h, therefore it is ignored after the
|
||||
pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the
|
||||
build of pnglibconf.h and it is never included in an application build.
|
||||
|
||||
The rarely used alternative of adding a list of feature macros to the
|
||||
@@ -4261,7 +4397,7 @@ scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
|
||||
and all known later implementations (often called by subtly different
|
||||
names - nawk and gawk for example) are adequate to build pnglibconf.h.
|
||||
The Sun Microsystems (now Oracle) program 'awk' is an earlier version
|
||||
and does not work, this may also apply to other systems that have a
|
||||
and does not work; this may also apply to other systems that have a
|
||||
functioning awk called 'nawk'.
|
||||
|
||||
Configuration options are now documented in scripts/pnglibconf.dfa. This
|
||||
@@ -4303,8 +4439,8 @@ the libpng bug tracker at
|
||||
|
||||
We also accept patches built from the tar or zip distributions, and
|
||||
simple verbal discriptions of bug fixes, reported either to the
|
||||
SourceForge bug tracker or to the png-mng-implement at lists.sf.net
|
||||
mailing list.
|
||||
SourceForge bug tracker, to the png-mng-implement at lists.sf.net
|
||||
mailing list, or directly to glennrp.
|
||||
|
||||
XIII. Coding style
|
||||
|
||||
@@ -4417,13 +4553,13 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
XIV. Y2K Compliance in libpng
|
||||
|
||||
June 14, 2011
|
||||
August 25, 2011
|
||||
|
||||
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.5.4beta02 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.5.5beta06 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has three year fields. One is a 2-byte unsigned integer that
|
||||
|
||||
362
libpng.3
362
libpng.3
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNG 3 "June 14, 2011"
|
||||
.TH LIBPNG 3 "August 25, 2011"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta02
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.5beta06
|
||||
.SH SYNOPSIS
|
||||
\fI\fB
|
||||
|
||||
@@ -128,10 +128,22 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta02
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBpng_uint_32 png_get_chunk_cache_max (png_const_structp \fIpng_ptr\fP\fB);\fP
|
||||
\fBpng_uint_32 png_get_cHRM_XYZ (png_structp \fIpng_ptr,
|
||||
|
||||
\fBpng_const_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*red_X\fP\fB, double \fP\fI*red_Y\fP\fB, double \fI*red_Z,
|
||||
|
||||
\fBdouble \fP\fI*green_X\fP\fB, double \fP\fI*green_Y\fP\fB, double \fP\fI*green_Z\fP\fB, double \fI*blue_X,
|
||||
|
||||
\fBdouble \fP\fI*blue_Y\fP\fB, double \fI*blue_Z\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBpng_uint_32 png_get_cHRM_XYZ_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_fixed_point \fP\fI*int_red_X\fP\fB, png_fixed_point \fP\fI*int_red_Y\fP\fB, png_fixed_point \fP\fI*int_red_Z\fP\fB, png_fixed_point \fP\fI*int_green_X\fP\fB, png_fixed_point \fP\fI*int_green_Y\fP\fB, png_fixed_point \fP\fI*int_green_Z\fP\fB, png_fixed_point \fP\fI*int_blue_X\fP\fB, png_fixed_point \fP\fI*int_blue_Y\fP\fB, png_fixed_point \fI*int_blue_Z\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBpng_uint_32 png_get_chunk_cache_max (png_const_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBpng_alloc_size_t png_get_chunk_malloc_max (png_const_structp \fIpng_ptr\fP\fB);\fP
|
||||
@@ -548,6 +560,16 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta02
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_set_cHRM_XYZ (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIred_X\fP\fB, double \fP\fIred_Y\fP\fB, double \fP\fIred_Z\fP\fB, double \fP\fIgreen_X\fP\fB, double \fIgreen_Y,
|
||||
|
||||
\fBdouble \fP\fIgreen_Z\fP\fB, double \fP\fIblue_X\fP\fB, double \fP\fIblue_Y\fP\fB, double \fIblue_Z\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_set_cHRM_XYZ_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_fixed_point \fP\fIint_red_X\fP\fB, png_fixed_point \fP\fIint_red_Y\fP\fB, png_fixed_point \fP\fIint_red_Z\fP\fB, png_fixed_point \fP\fIint_green_X\fP\fB, png_fixed_point \fP\fIint_green_Y\fP\fB, png_fixed_point \fP\fIint_green_Z\fP\fB, png_fixed_point \fP\fIint_blue_X\fP\fB, png_fixed_point \fP\fIint_blue_Y\fP\fB, png_fixed_point \fIint_blue_Z\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_set_chunk_cache_max (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIuser_chunk_cache_max\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -672,10 +694,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta02
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_set_chunk_malloc_max (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIuser_chunk_cache_max\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -768,6 +786,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta02
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_set_scale_16 (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
@@ -955,7 +977,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.5.4beta02 - June 14, 2011
|
||||
libpng version 1.5.5beta06 - August 25, 2011
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
@@ -966,7 +988,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.5.4beta02 - June 14, 2011
|
||||
libpng versions 0.97, January 1998, through 1.5.5beta06 - August 25, 2011
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
|
||||
@@ -1062,7 +1084,8 @@ PNG file. At one time, the fields of png_info were intended to be
|
||||
directly accessible to the user. However, this tended to cause problems
|
||||
with applications using dynamically loaded libraries, and as a result
|
||||
a set of interface functions for png_info (the png_get_*() and png_set_*()
|
||||
functions) was developed.
|
||||
functions) was developed, and direct access to the png_info fields was
|
||||
deprecated..
|
||||
|
||||
The png_struct structure is the object used by the library to decode a
|
||||
single image. As of 1.5.0 this structure is also not exposed.
|
||||
@@ -1071,14 +1094,23 @@ Almost all libpng APIs require a pointer to a png_struct as the first argument.
|
||||
Many (in particular the png_set and png_get APIs) also require a pointer
|
||||
to png_info as the second argument. Some application visible macros
|
||||
defined in png.h designed for basic data access (reading and writing
|
||||
integers in the PNG format) break this rule, but it's almost always safe
|
||||
to assume that a (png_struct*) has to be passed to call an API function.
|
||||
integers in the PNG format) don't take a png_info pointer, but it's almost
|
||||
always safe to assume that a (png_struct*) has to be passed to call an API
|
||||
function.
|
||||
|
||||
You can have more than one png_info structure associated with an image,
|
||||
as illustrated in pngtest.c, one for information valid prior to the
|
||||
IDAT chunks and another (called "end_info" below) for things after them.
|
||||
|
||||
The png.h header file is an invaluable reference for programming with libpng.
|
||||
And while I'm on the topic, make sure you include the libpng header file:
|
||||
|
||||
#include <png.h>
|
||||
|
||||
and also (as of libpng-1.5.0) the zlib header file, if you need it:
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
.SS Types
|
||||
|
||||
The png.h header file defines a number of integral types used by the
|
||||
@@ -1092,9 +1124,9 @@ the value by multiplying by 100,000. As of libpng 1.5.0 a convenience
|
||||
macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point)
|
||||
which is simply (png_int_32).
|
||||
|
||||
All APIs that take (double) arguments also have an matching API that
|
||||
All APIs that take (double) arguments also have a matching API that
|
||||
takes the corresponding fixed point integer arguments. The fixed point
|
||||
API has the same name as the floating point one with _fixed appended.
|
||||
API has the same name as the floating point one with "_fixed" appended.
|
||||
The actual range of values permitted in the APIs is frequently less than
|
||||
the full range of (png_fixed_point) (-21474 to +21474). When APIs require
|
||||
a non-negative argument the type is recorded as png_uint_32 above. Consult
|
||||
@@ -1112,6 +1144,10 @@ preprocessing directives of the form:
|
||||
#ifdef PNG_feature_SUPPORTED
|
||||
declare-function
|
||||
#endif
|
||||
...
|
||||
#ifdef PNG_feature_SUPPORTED
|
||||
use-function
|
||||
#endif
|
||||
|
||||
The library can be built without support for these APIs, although a
|
||||
standard build will have all implemented APIs. Application programs
|
||||
@@ -1120,7 +1156,7 @@ portability. From libpng 1.5.0 the feature macros set during the build
|
||||
of libpng are recorded in the header file "pnglibconf.h" and this file
|
||||
is always included by png.h.
|
||||
|
||||
If you don't need to change the library configuration from the default skip to
|
||||
If you don't need to change the library configuration from the default, skip to
|
||||
the next section ("Reading").
|
||||
|
||||
Notice that some of the makefiles in the 'scripts' directory and (in 1.5.0) all
|
||||
@@ -1152,24 +1188,25 @@ A variety of methods exist to build libpng. Not all of these support
|
||||
reconfiguration of pnglibconf.h. To reconfigure pnglibconf.h it must either be
|
||||
rebuilt from scripts/pnglibconf.dfa using awk or it must be edited by hand.
|
||||
|
||||
Hand editing is achieved by copying scripts/pnglibconf.h.prebuilt and changing
|
||||
the lines defining the supported features, paying very close attention to the
|
||||
'option' information in scripts/pnglibconf.dfa that describes those features and
|
||||
their requirements. This is easy to get wrong.
|
||||
Hand editing is achieved by copying scripts/pnglibconf.h.prebuilt to
|
||||
pnglibconf.h and changing the lines defining the supported features, paying
|
||||
very close attention to the 'option' information in scripts/pnglibconf.dfa
|
||||
that describes those features and their requirements. This is easy to get
|
||||
wrong.
|
||||
|
||||
B. Configuration using DFA_XTRA
|
||||
|
||||
Rebuilding from pnglibconf.dfa is easy if a functioning 'awk', or a later
|
||||
variant such as 'nawk' or 'gawk', is available. The configure build will
|
||||
automatically find an appropriate awk and build pnglibconf.h.
|
||||
scripts/pnglibconf.mak contains a set of make rules for doing the same thing if
|
||||
configure is not used, and many of the makefiles in the scripts directory use
|
||||
this approach.
|
||||
The scripts/pnglibconf.mak file contains a set of make rules for doing the
|
||||
same thing if configure is not used, and many of the makefiles in the scripts
|
||||
directory use this approach.
|
||||
|
||||
When rebuilding simply write new file containing changed options and set
|
||||
When rebuilding simply write a new file containing changed options and set
|
||||
DFA_XTRA to the name of this file. This causes the build to append the new file
|
||||
to the end of scripts/pnglibconf.dfa. pngusr.dfa should contain lines of the
|
||||
following forms:
|
||||
to the end of scripts/pnglibconf.dfa. The pngusr.dfa file should contain lines
|
||||
of the following forms:
|
||||
|
||||
everything = off
|
||||
|
||||
@@ -1193,12 +1230,16 @@ source code. Most of these values have performance implications for the library
|
||||
but most of them have no visible effect on the API. Some can also be overridden
|
||||
from the API.
|
||||
|
||||
This method of building a customized pnglibconf.h is illustrated in
|
||||
contrib/pngminim/*. See the "$(PNGCONF):" target in the makefile and
|
||||
pngusr.dfa in these directories.
|
||||
|
||||
C. Configuration using PNG_USR_CONFIG
|
||||
|
||||
If -DPNG_USR_CONFIG is added to the CFLAGS when pnglibconf.h is built the file
|
||||
pngusr.h will automatically be included before the options in
|
||||
scripts/pnglibconf.dfa are processed. pngusr.h should contain only macro
|
||||
definitions turning features on or off or setting settings.
|
||||
scripts/pnglibconf.dfa are processed. Your pngusr.h file should contain only
|
||||
macro definitions turning features on or off or setting settings.
|
||||
|
||||
Apart from the global setting "everything = off" all the options listed above
|
||||
can be set using macros in pngusr.h:
|
||||
@@ -1229,6 +1270,9 @@ examine the intermediate file pnglibconf.dfn to find the full set of
|
||||
dependency information for each setting and option. Simply locate the
|
||||
feature in the file and read the C comments that precede it.
|
||||
|
||||
This method is also illustrated in the contrib/pngminim/* makefiles and
|
||||
pngusr.h.
|
||||
|
||||
.SH III. Reading
|
||||
|
||||
We'll now walk you through the possible functions to call when reading
|
||||
@@ -1512,6 +1556,8 @@ according to the "keep" directive. If a chunk is named in successive
|
||||
instances of png_set_keep_unknown_chunks(), the final instance will
|
||||
take precedence. The IHDR and IEND chunks should not be named in
|
||||
chunk_list; if they are, libpng will process them normally anyway.
|
||||
If you know that your application will never make use of some particular
|
||||
chunks, use PNG_HANDLE_CHUNK_NEVER (or 1) as demonstrated below.
|
||||
|
||||
Here is an example of the usage of png_set_keep_unknown_chunks(),
|
||||
where the private "vpAg" chunk will later be processed by a user chunk
|
||||
@@ -1602,13 +1648,14 @@ If you intend to display the PNG or to incorporate it in other image data you
|
||||
need to tell libpng information about your display or drawing surface so that
|
||||
libpng can convert the values in the image to match the display.
|
||||
|
||||
From libpng-1.5.3 this information can be set before reading the PNG file
|
||||
From libpng-1.5.4 this information can be set before reading the PNG file
|
||||
header. In earlier versions png_set_gamma() existed but behaved incorrectly if
|
||||
called before the PNG file header had been read and png_set_alpha_mode() did not
|
||||
exist.
|
||||
|
||||
If you need to support versions prior to libpng-1.5.3 test the version number
|
||||
and follow the procedures described in the appropriate manual page.
|
||||
If you need to support versions prior to libpng-1.5.4 test the version number
|
||||
as illustrated below using "PNG_LIBPNG_VER >= 10504" and follow the procedures
|
||||
described in the appropriate manual page.
|
||||
|
||||
You give libpng the encoding expected by your system expressed as a 'gamma'
|
||||
value. You can also specify a default encoding for the PNG file in
|
||||
@@ -1628,7 +1675,7 @@ documentation!
|
||||
|
||||
Many systems permit the system gamma to be changed via a lookup table in the
|
||||
display driver, a few systems, including older Macs, change the response by
|
||||
default. As of 1.5.3 three special values are available to handle common
|
||||
default. As of 1.5.4 three special values are available to handle common
|
||||
situations:
|
||||
|
||||
PNG_DEFAULT_sRGB: Indicates that the system conforms to the IEC 61966-2-1
|
||||
@@ -1653,7 +1700,9 @@ Libpng only supports composing onto a single color (using png_set_background;
|
||||
see below.) Otherwise you must do the composition yourself and, in this case,
|
||||
you may need to call png_set_alpha_mode:
|
||||
|
||||
#if PNG_LIBPNG_VER >= 10504
|
||||
png_set_alpha_mode(png_ptr, mode, screen_gamma);
|
||||
#endif
|
||||
|
||||
The screen_gamma value is the same as the argument to png_set_gamma, however how
|
||||
it affects the output depends on the mode. png_set_alpha_mode() sets the file
|
||||
@@ -1793,17 +1842,22 @@ format produced by libpng to always have 8-bit or 16-bit components and then
|
||||
store the color as an 8-bit or 16-bit color as appropriate. The color contains
|
||||
separate gray and RGB component values, so you can let libpng produce gray or
|
||||
RGB output according to the input format, but low bit depth grayscale images
|
||||
must always be converted to at least 8-bit format. (Even low low bit depth
|
||||
must always be converted to at least 8-bit format. (Even though low bit depth
|
||||
grayscale images can't have an alpha channel they can have a transparent
|
||||
color!)
|
||||
|
||||
You set the transforms you need later, either as flags to the high level
|
||||
interface or libpng API calls for the low level interface. For reference the
|
||||
settings required are:
|
||||
settings and API calls required are:
|
||||
|
||||
8-bit values:
|
||||
PNG_TRANSFORM_STRIP_16 | PNG_EXPAND
|
||||
png_set_expand(png_ptr); png_set_strip_16(png_ptr);
|
||||
PNG_TRANSFORM_SCALE_16 | PNG_EXPAND
|
||||
png_set_expand(png_ptr); png_set_scale_16(png_ptr);
|
||||
|
||||
If you must get exactly the same inaccurate results
|
||||
produced by default in versions prior to libpng-1.5.4,
|
||||
use PNG_TRANSFORM_STRIP_16 and png_set_strip_16(png_ptr)
|
||||
instead.
|
||||
|
||||
16-bit values:
|
||||
PNG_TRANSFORM_EXPAND_16
|
||||
@@ -1814,9 +1868,9 @@ color data you can add PNG_TRANSFORM_GRAY_TO_RGB or png_set_gray_to_rgb(png_ptr)
|
||||
to the list.
|
||||
|
||||
Calling png_set_background before the PNG file header is read will not work
|
||||
prior to libpng-1.5.3. Because the failure may result in unexpected warnings or
|
||||
prior to libpng-1.5.4. Because the failure may result in unexpected warnings or
|
||||
errors it is therefore much safer to call png_set_background after the head has
|
||||
been read. Unfortunately this means that prior to libpng-1.5.3 it cannot be
|
||||
been read. Unfortunately this means that prior to libpng-1.5.4 it cannot be
|
||||
used with the high level interface.
|
||||
|
||||
.SS The high-level read interface
|
||||
@@ -1828,8 +1882,10 @@ the entire image into memory, and (b) the input transformations
|
||||
you want to do are limited to the following set:
|
||||
|
||||
PNG_TRANSFORM_IDENTITY No transformation
|
||||
PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to
|
||||
8-bit
|
||||
PNG_TRANSFORM_SCALE_16 Strip 16-bit samples to
|
||||
8-bit accurately
|
||||
PNG_TRANSFORM_STRIP_16 Chop 16-bit samples to
|
||||
8-bit less accurately
|
||||
PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel
|
||||
PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit
|
||||
samples to bytes
|
||||
@@ -1923,9 +1979,9 @@ for use in later transformations. Important information copied in is:
|
||||
1) The PNG file gamma from the gAMA chunk. This overwrites the default value
|
||||
provided by an earlier call to png_set_gamma or png_set_alpha_mode.
|
||||
|
||||
2) Prior to libpng-1.5.3 the background color from a bKGd chunk. This
|
||||
2) Prior to libpng-1.5.4 the background color from a bKGd chunk. This
|
||||
damages the information provided by an earlier call to png_set_background
|
||||
resulting in expected behavior. Libpng-1.5.3 no longer does this.
|
||||
resulting in unexpected behavior. Libpng-1.5.4 no longer does this.
|
||||
|
||||
3) The number of significant bits in each component value. Libpng uses this to
|
||||
optimize gamma handling by reducing the internal lookup table sizes.
|
||||
@@ -2063,6 +2119,28 @@ pointer into the info_ptr is returned for any complex types.
|
||||
int_file_gamma - 100,000 times the gamma at which the
|
||||
file is written
|
||||
|
||||
png_get_cHRM(png_ptr, info_ptr, &white_x, &white_y, &red_x, &red_y,
|
||||
&green_x, &green_y, &blue_x, &blue_y)
|
||||
png_get_cHRM_XYZ(png_ptr, info_ptr, &red_X, &red_Y, &red_Z, &green_X,
|
||||
&green_Y, &green_Z, &blue_X, &blue_Y, &blue_Z)
|
||||
png_get_cHRM_fixed(png_ptr, info_ptr, &int_white_x, &int_white_y,
|
||||
&int_red_x, &int_red_y, &int_green_x, &int_green_y,
|
||||
&int_blue_x, &int_blue_y)
|
||||
png_get_cHRM_XYZ_fixed(png_ptr, info_ptr, &int_red_X, &int_red_Y,
|
||||
&int_red_Z, &int_green_X, &int_green_Y, &int_green_Z,
|
||||
&int_blue_X, &int_blue_Y, &int_blue_Z)
|
||||
|
||||
{white,red,green,blue}_{x,y}
|
||||
A color space encoding specified using the chromaticities
|
||||
of the end points and the white point. (PNG_INFO_cHRM)
|
||||
|
||||
{red,green,blue}_{X,Y,Z}
|
||||
A color space encoding specified using the encoding end
|
||||
points - the CIE tristimulus specification of the intended
|
||||
color of the red, green and blue channels in the PNG RGB
|
||||
data. The white point is simply the sum of the three end
|
||||
points. (PNG_INFO_cHRM)
|
||||
|
||||
png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
|
||||
|
||||
file_srgb_intent - the rendering intent (PNG_INFO_sRGB)
|
||||
@@ -2121,7 +2199,8 @@ pointer into the info_ptr is returned for any complex types.
|
||||
|
||||
png_get_bKGD(png_ptr, info_ptr, &background);
|
||||
|
||||
background - background color (PNG_VALID_bKGD)
|
||||
background - background color (of type
|
||||
png_color_16p) (PNG_VALID_bKGD)
|
||||
valid 16-bit red, green and blue
|
||||
values, regardless of color_type
|
||||
|
||||
@@ -2160,6 +2239,8 @@ pointer into the info_ptr is returned for any complex types.
|
||||
Note that the itxt_length, lang, and lang_key
|
||||
members of the text_ptr structure only exist
|
||||
when the library is built with iTXt chunk support.
|
||||
Prior to libpng-1.4.0, the default build was
|
||||
without iTXt chunk support.
|
||||
|
||||
num_text - number of comments (same as
|
||||
num_comments; you can put NULL here
|
||||
@@ -2184,10 +2265,10 @@ pointer into the info_ptr is returned for any complex types.
|
||||
&unit_type);
|
||||
|
||||
offset_x - positive offset from the left edge
|
||||
of the screen
|
||||
of the screen (can be negative)
|
||||
|
||||
offset_y - positive offset from the top edge
|
||||
of the screen
|
||||
of the screen (can be negative)
|
||||
|
||||
unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
|
||||
|
||||
@@ -2219,6 +2300,7 @@ pointer into the info_ptr is returned for any complex types.
|
||||
unit - physical scale units (an integer)
|
||||
|
||||
width - width of a pixel in physical scale units
|
||||
(expressed as a string)
|
||||
|
||||
height - height of a pixel in physical scale units
|
||||
(width and height are strings like "2.54")
|
||||
@@ -2241,6 +2323,12 @@ pointer into the info_ptr is returned for any complex types.
|
||||
chunks were read from the PNG file or inserted with the
|
||||
png_set_unknown_chunks() function.
|
||||
|
||||
The value of "location" is a bitwise "or" of
|
||||
|
||||
PNG_HAVE_IHDR (0x01)
|
||||
PNG_HAVE_PLTE (0x02)
|
||||
PNG_AFTER_IDAT (0x08)
|
||||
|
||||
The data from the pHYs chunk can be retrieved in several convenient
|
||||
forms:
|
||||
|
||||
@@ -2354,12 +2442,12 @@ byte, unless png_set_packing() is called. 8-bit RGB data will be stored
|
||||
in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
|
||||
is called to insert filler bytes, either before or after each RGB triplet.
|
||||
16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
|
||||
byte of the color value first, unless png_set_strip_16() is called to
|
||||
byte of the color value first, unless png_set_scale_16() is called to
|
||||
transform it to regular RGB RGB triplets, or png_set_filler() or
|
||||
png_set_add alpha() is called to insert filler bytes, either before or
|
||||
after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can
|
||||
be modified with
|
||||
png_set_filler(), png_set_add_alpha(), or png_set_strip_16().
|
||||
be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(),
|
||||
or png_set_scale_16().
|
||||
|
||||
The following code transforms grayscale images of less than 8 to 8 bits,
|
||||
changes paletted images to RGB, and adds a full alpha channel if there is
|
||||
@@ -2385,7 +2473,7 @@ As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
|
||||
added. It expands the sample depth without changing tRNS to alpha.
|
||||
|
||||
As of libpng version 1.5.2, png_set_expand_16() was added. It behaves as
|
||||
png_set_expand(), however, the resultant channels have 16 bits rather than 8.
|
||||
png_set_expand(); however, the resultant channels have 16 bits rather than 8.
|
||||
Use this when the output color or gray channels are made linear to avoid fairly
|
||||
severe accuracy loss.
|
||||
|
||||
@@ -2396,7 +2484,14 @@ PNG can have files with 16 bits per channel. If you only can handle
|
||||
8 bits per channel, this will strip the pixels down to 8-bit.
|
||||
|
||||
if (bit_depth == 16)
|
||||
#if PNG_LIBPNG_VER >= 10504
|
||||
png_set_scale_16(png_ptr);
|
||||
#else
|
||||
png_set_strip_16(png_ptr);
|
||||
#endif
|
||||
|
||||
(The more accurate "png_set_scale_16()" API became available in libpng version
|
||||
1.5.4).
|
||||
|
||||
If you need to process the alpha channel on the image separately from the image
|
||||
data (for example if you convert it to a bitmap mask) it is possible to have
|
||||
@@ -2574,31 +2669,41 @@ It will return a png_byte that is zero if the image was gray or
|
||||
will be silently converted to grayscale, using the green channel
|
||||
data for sBIT, regardless of the error_action setting.
|
||||
|
||||
The default values come from the PNG file cHRM chunk if present, otherwise the
|
||||
The default values come from the PNG file cHRM chunk if present; otherwise, the
|
||||
defaults correspond to the ITU-R recommendation 709, and also the sRGB color
|
||||
space, as recommended in the Charles Poynton's Colour FAQ,
|
||||
<http://www.poynton.com/>, in section 9:
|
||||
|
||||
<http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC9>
|
||||
|
||||
Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
|
||||
|
||||
Previous versions of this document, 1998 through 2002, recommended a slightly
|
||||
different formula:
|
||||
|
||||
Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
|
||||
|
||||
Libpng uses an integer approximation:
|
||||
|
||||
Y = (6968 * R + 23434 * G + 2366 * B)/32768
|
||||
|
||||
The calculation is done in a linear colorspace, if the image gamma
|
||||
can be determined.
|
||||
|
||||
The png_set_background() function has been described already, it tells libpng to
|
||||
The png_set_background() function has been described already; it tells libpng to
|
||||
composite images with alpha or simple transparency against the supplied
|
||||
background color. For compatibility with versions of libpng earlier than
|
||||
libpng-1.5.3 it is recommended that you call the function after reading the file
|
||||
libpng-1.5.4 it is recommended that you call the function after reading the file
|
||||
header, even if you don't want to use the color in a bKGD chunk, if one exists.
|
||||
|
||||
If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
|
||||
you may use this color, or supply another color more suitable for
|
||||
the current display (e.g., the background color from a web page). You
|
||||
need to tell libpng how the color is represented, both the format of the
|
||||
component values in the color (the number of bits) and the gamme encoding of the
|
||||
component values in the color (the number of bits) and the gamma encoding of the
|
||||
color. The function takes two arguments, background_gamma_mode and need_expand
|
||||
to convey this information, however only two combinations are like to be useful:
|
||||
to convey this information, however only two combinations are likely to be
|
||||
useful:
|
||||
|
||||
png_color_16 my_background;
|
||||
png_color_16p image_background;
|
||||
@@ -2610,7 +2715,6 @@ to convey this information, however only two combinations are like to be useful:
|
||||
png_set_background(png_ptr, &my_background,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*do not expand*/, 1);
|
||||
|
||||
|
||||
The second call was described above - my_background is in the format of the
|
||||
final, display, output produced by libpng. Because you now know the format of
|
||||
the PNG it is possible to avoid the need to choose either 8-bit or 16-bit
|
||||
@@ -2626,7 +2730,7 @@ image_background->gray.
|
||||
|
||||
If you didn't call png_set_gamma() before reading the file header, for example
|
||||
if you need your code to remain compatible with older versions of libpng prior
|
||||
to libpng-1.5.3, this is the place to call it.
|
||||
to libpng-1.5.4, this is the place to call it.
|
||||
|
||||
Do not call it if you called png_set_alpha_mode(); doing so will damage the
|
||||
settings put in place by png_set_alpha_mode(). (If png_set_alpha_mode() is
|
||||
@@ -2649,9 +2753,9 @@ file has more entries then will fit on your screen, png_set_quantize()
|
||||
will do that. Note that this is a simple match quantization that merely
|
||||
finds the closest color available. This should work fairly well with
|
||||
optimized palettes, but fairly badly with linear color cubes. If you
|
||||
pass a palette that is larger then maximum_colors, the file will
|
||||
pass a palette that is larger than maximum_colors, the file will
|
||||
reduce the number of colors in the palette so it will fit into
|
||||
maximum_colors. If there is a histogram, it will use it to make
|
||||
maximum_colors. If there is a histogram, libpng will use it to make
|
||||
more intelligent choices when reducing the palette. If there is no
|
||||
histogram, it may not do as good a job.
|
||||
|
||||
@@ -2723,7 +2827,7 @@ after all of the other transformations have been processed. Take care with
|
||||
interlaced images if you do the interlace yourself - the width of the row is the
|
||||
width in 'row_info', not the overall image width.
|
||||
|
||||
If supported libpng provides two information routines that you can use to find
|
||||
If supported, libpng provides two information routines that you can use to find
|
||||
where you are in processing the image:
|
||||
|
||||
png_get_current_pass_number(png_structp png_ptr);
|
||||
@@ -3587,6 +3691,28 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
int_file_gamma - 100,000 times the gamma at which
|
||||
the image was created
|
||||
|
||||
png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y,
|
||||
green_x, green_y, blue_x, blue_y)
|
||||
png_set_cHRM_XYZ(png_ptr, info_ptr, red_X, red_Y, red_Z, green_X,
|
||||
green_Y, green_Z, blue_X, blue_Y, blue_Z)
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y,
|
||||
int_red_x, int_red_y, int_green_x, int_green_y,
|
||||
int_blue_x, int_blue_y)
|
||||
png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, int_red_X, int_red_Y,
|
||||
int_red_Z, int_green_X, int_green_Y, int_green_Z,
|
||||
int_blue_X, int_blue_Y, int_blue_Z)
|
||||
|
||||
{white,red,green,blue}_{x,y}
|
||||
A color space encoding specified using the chromaticities
|
||||
of the end points and the white point.
|
||||
|
||||
{red,green,blue}_{X,Y,Z}
|
||||
A color space encoding specified using the encoding end
|
||||
points - the CIE tristimulus specification of the intended
|
||||
color of the red, green and blue channels in the PNG RGB
|
||||
data. The white point is simply the sum of the three end
|
||||
points.
|
||||
|
||||
png_set_sRGB(png_ptr, info_ptr, srgb_intent);
|
||||
|
||||
srgb_intent - the rendering intent
|
||||
@@ -3647,14 +3773,14 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
trans_alpha - array of alpha (transparency)
|
||||
entries for palette (PNG_INFO_tRNS)
|
||||
|
||||
num_trans - number of transparent entries
|
||||
(PNG_INFO_tRNS)
|
||||
|
||||
trans_color - graylevel or color sample values
|
||||
(in order red, green, blue) of the
|
||||
single transparent color for
|
||||
non-paletted images (PNG_INFO_tRNS)
|
||||
|
||||
num_trans - number of transparent entries
|
||||
(PNG_INFO_tRNS)
|
||||
|
||||
png_set_hIST(png_ptr, info_ptr, hist);
|
||||
|
||||
hist - histogram of palette (array of
|
||||
@@ -3667,7 +3793,8 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
|
||||
png_set_bKGD(png_ptr, info_ptr, background);
|
||||
|
||||
background - background color (PNG_VALID_bKGD)
|
||||
background - background color (of type
|
||||
png_color_16p) (PNG_VALID_bKGD)
|
||||
|
||||
png_set_text(png_ptr, info_ptr, text_ptr, num_text);
|
||||
|
||||
@@ -3694,6 +3821,8 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
Note that the itxt_length, lang, and lang_key
|
||||
members of the text_ptr structure only exist
|
||||
when the library is built with iTXt chunk support.
|
||||
Prior to libpng-1.4.0 the library was built by default
|
||||
without iTXt support.
|
||||
|
||||
num_text - number of comments
|
||||
|
||||
@@ -3743,6 +3872,7 @@ width, height, bit_depth, and color_type must be the same in each call.
|
||||
unit - physical scale units (an integer)
|
||||
|
||||
width - width of a pixel in physical scale units
|
||||
expressed as a string
|
||||
|
||||
height - height of a pixel in physical scale units
|
||||
(width and height are strings like "2.54")
|
||||
@@ -3784,7 +3914,7 @@ Because tEXt and zTXt chunks don't have a language field, if you
|
||||
specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
|
||||
any language code or translated keyword will not be written out.
|
||||
|
||||
Until text gets around 1000 bytes, it is not worth compressing it.
|
||||
Until text gets around a few hundred bytes, it is not worth compressing it.
|
||||
After the text has been written out to the file, the compression type
|
||||
is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
|
||||
so that it isn't written out again at the end (in case you are calling
|
||||
@@ -4394,7 +4524,8 @@ However, there are some uncertainties about the status of local variables
|
||||
after a longjmp, so the user may want to be careful about doing anything
|
||||
after setjmp returns non-zero besides returning itself. Consult your
|
||||
compiler documentation for more details. For an alternative approach, you
|
||||
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net).
|
||||
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net),
|
||||
which is illustrated in pngvalid.c and in contrib/visupng.
|
||||
|
||||
.SS Custom chunks
|
||||
|
||||
@@ -4412,8 +4543,11 @@ and look at how other chunks were designed, so you can do things
|
||||
similarly. Second, check out the sections of libpng that read and
|
||||
write chunks. Try to find a chunk that is similar to yours and use
|
||||
it as a template. More details can be found in the comments inside
|
||||
the code. It is best to handle unknown chunks in a generic method,
|
||||
via callback functions, instead of by modifying libpng functions.
|
||||
the code. It is best to handle private or unknown chunks in a generic method,
|
||||
via callback functions, instead of by modifying libpng functions. This
|
||||
is illustrated in pngtest.c, which uses a callback function to handle a
|
||||
private "vpAg" chunk and the new "sTER" chunk, which are both unknown to
|
||||
libpng.
|
||||
|
||||
If you wish to write your own transformation for the data, look through
|
||||
the part of the code that does the transformations, and check out some of
|
||||
@@ -4441,8 +4575,8 @@ defined, and FAR gets defined to far in pngconf.h, and you should be
|
||||
all set. Everything in the library (except for zlib's structure) is
|
||||
expecting far data. You must use the typedefs with the p or pp on
|
||||
the end for pointers (or at least look at them and be careful). Make
|
||||
note that the rows of data are defined as png_bytepp, which is an
|
||||
unsigned char far * far *.
|
||||
note that the rows of data are defined as png_bytepp, which is
|
||||
an "unsigned char far * far *".
|
||||
|
||||
.SS Configuring for gui/windowing platforms:
|
||||
|
||||
@@ -4460,7 +4594,11 @@ or delete an include, this is the place to do it.
|
||||
The includes that are not needed outside libpng are placed in pngpriv.h,
|
||||
which is only used by the routines inside libpng itself.
|
||||
The files in libpng proper only include pngpriv.h and png.h, which
|
||||
in turn includes pngconf.h.
|
||||
%14%in turn includes pngconf.h.
|
||||
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
|
||||
As of libpng-1.5.0, pngpriv.h also includes three other private header
|
||||
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
|
||||
that previously appeared in the public headers.
|
||||
|
||||
.SS Configuring zlib:
|
||||
|
||||
@@ -4502,8 +4640,28 @@ zlib.h for more information on what these mean.
|
||||
window_bits);
|
||||
|
||||
png_set_compression_method(png_ptr, method);
|
||||
|
||||
png_set_compression_buffer_size(png_ptr, size);
|
||||
|
||||
As of libpng version 1.5.4, additional APIs became
|
||||
available to set these separately for non-IDAT
|
||||
compressed chunks such as zTXt, iTXt, and iCCP:
|
||||
|
||||
#include zlib.h
|
||||
#if PNG_LIBPNG_VER <= 10504
|
||||
png_set_text_compression_level(png_ptr, level);
|
||||
|
||||
png_set_text_compression_mem_level(png_ptr, level);
|
||||
|
||||
png_set_text_compression_strategy(png_ptr,
|
||||
strategy);
|
||||
|
||||
png_set_text_compression_window_bits(png_ptr,
|
||||
window_bits);
|
||||
|
||||
png_set_text_compression_method(png_ptr, method);
|
||||
#endif
|
||||
|
||||
.SS Controlling row filtering
|
||||
|
||||
If you want to control whether libpng uses filtering or not, which
|
||||
@@ -4609,8 +4767,8 @@ capability, which you'll still have).
|
||||
All the reading and writing specific code are in separate files, so the
|
||||
linker should only grab the files it needs. However, if you want to
|
||||
make sure, or if you are building a stand alone library, all the
|
||||
reading files start with pngr and all the writing files start with
|
||||
pngw. The files that don't match either (like png.c, pngtrans.c, etc.)
|
||||
reading files start with "pngr" and all the writing files start with "pngw".
|
||||
The files that don't match either (like png.c, pngtrans.c, etc.)
|
||||
are used for both reading and writing, and always need to be included.
|
||||
The progressive reader is in pngpread.c
|
||||
|
||||
@@ -4988,7 +5146,6 @@ absolutely necessary) interlace an image.
|
||||
|
||||
libpng 1.5.0 adds an API png_longjmp(png_ptr, value). This API calls
|
||||
the application-provided png_longjmp_ptr on the internal, but application
|
||||
initialized, jmpbuf. It is provided as a convenience to avoid the need
|
||||
initialized, longjmp buffer. It is provided as a convenience to avoid
|
||||
the need to use the png_jmpbuf macro, which had the unnecessary side
|
||||
effect of resetting the internal png_longjmp_ptr value.
|
||||
@@ -5045,20 +5202,20 @@ PNG_NO_USE_READ_MACROS before including png.h. Notice that this is
|
||||
only supported from 1.5.0 -defining PNG_NO_USE_READ_MACROS prior to 1.5.0
|
||||
will lead to a link failure.
|
||||
|
||||
Prior to libpng-1.5.3, the zlib compressor used the same set of parameters
|
||||
Prior to libpng-1.5.4, the zlib compressor used the same set of parameters
|
||||
when compressing the IDAT data and textual data such as zTXt and iCCP.
|
||||
In libpng-1.5.3 we reinitialized the zlib stream for each type of data.
|
||||
In libpng-1.5.4 we reinitialized the zlib stream for each type of data.
|
||||
We added five png_set_text_*() functions for setting the parameters to
|
||||
use with textual data.
|
||||
|
||||
Prior to libpng-1.5.3, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
Prior to libpng-1.5.4, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
option was off by default, and slightly inaccurate scaling occurred.
|
||||
This option can no longer be turned off, and 16-to-8 scaling is always
|
||||
accurate. This change will result in some different results while
|
||||
reading 16-bit images, with none of the pixels being off-by-one any
|
||||
longer (see Clause 13.12 of the PNG specification).
|
||||
This option can no longer be turned off, and the choice of accurate
|
||||
or inaccurate 16-to-8 scaling is by using the new png_set_scale_16_to_8()
|
||||
API for accurate scaling or the old png_set_strip_16_to_8() API for simple
|
||||
chopping.
|
||||
|
||||
Prior to libpng-1.5.3, the png_set_user_limits() function could only be
|
||||
Prior to libpng-1.5.4, the png_set_user_limits() function could only be
|
||||
used to reduce the width and height limits from the value of
|
||||
PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said
|
||||
that it could be used to override them. Now this function will reduce or
|
||||
@@ -5067,9 +5224,9 @@ increase the limits.
|
||||
B. Changes to the build and configuration of libpng
|
||||
|
||||
Details of internal changes to the library code can be found in the CHANGES
|
||||
file. These will be of no concern to the vast majority of library users or
|
||||
builders, however the few who configure libpng to a non-default feature
|
||||
set may need to change how this is done.
|
||||
file and in the GIT repository logs. These will be of no concern to the vast
|
||||
majority of library users or builders, however the few who configure libpng
|
||||
to a non-default feature set may need to change how this is done.
|
||||
|
||||
There should be no need for library builders to alter build scripts if
|
||||
these use the distributed build support - configure or the makefiles -
|
||||
@@ -5078,14 +5235,14 @@ to build pnglibconf.h where the corresponding makefile does not do so.
|
||||
|
||||
Building libpng with a non-default configuration has changed completely.
|
||||
The old method using pngusr.h should still work correctly even though the
|
||||
way pngusr.h is used in the build has been changed, however library
|
||||
way pngusr.h is used in the build has been changed; however, library
|
||||
builders will probably want to examine the changes to take advantage of
|
||||
new capabilities and to simplify their build system.
|
||||
|
||||
B.1 Specific changes to library configuration capabilities
|
||||
|
||||
The library now supports a complete fixed point implementation and can
|
||||
thus be used on systems which have no floating point support or very
|
||||
thus be used on systems that have no floating point support or very
|
||||
limited or slow support. Previously gamma correction, an essential part
|
||||
of complete PNG support, required reasonably fast floating point.
|
||||
|
||||
@@ -5101,14 +5258,14 @@ pnglibconf.h
|
||||
As part of this the mechanism used to choose procedure call standards on
|
||||
those systems that allow a choice has been changed. At present this only
|
||||
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
|
||||
running on Intel processors. As before PNGAPI is defined where required
|
||||
running on Intel processors. As before, PNGAPI is defined where required
|
||||
to control the exported API functions; however, two new macros, PNGCBAPI
|
||||
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
|
||||
(PNGCAPI) for functions that must match a C library prototype (currently
|
||||
only png_longjmp_ptr, which must match the C longjmp function.) The new
|
||||
approach is documented in pngconf.h
|
||||
|
||||
Despite these changes libpng 1.5.0 only supports the native C function
|
||||
Despite these changes, libpng 1.5.0 only supports the native C function
|
||||
calling standard on those platforms tested so far (__cdecl on Microsoft
|
||||
Windows). This is because the support requirements for alternative
|
||||
calling conventions seem to no longer exist. Developers who find it
|
||||
@@ -5141,8 +5298,10 @@ if the feature is supported or:
|
||||
/*#undef PNG_feature_SUPPORTED*/
|
||||
|
||||
if it is not. Library code consistently checks for the 'SUPPORTED' macro.
|
||||
It does not, and should not, check for the 'NO' macro which will not
|
||||
normally be defined even if the feature is not supported.
|
||||
It does not, and libpng applications should not, check for the 'NO' macro
|
||||
which will not normally be defined even if the feature is not supported.
|
||||
The 'NO' macros are only used internally for setting or not setting the
|
||||
corresponding 'SUPPORTED' macros.
|
||||
|
||||
Compatibility with the old names is provided as follows:
|
||||
|
||||
@@ -5199,10 +5358,10 @@ application built without PNG_USER_CONFIG defined would see the
|
||||
unmodified, default, libpng API and thus would probably fail to link.
|
||||
|
||||
These mechanisms still work in the configure build and in any makefile
|
||||
build that builds pnglibconf.h although the feature selection macros
|
||||
build that builds pnglibconf.h, although the feature selection macros
|
||||
have changed somewhat as described above. In 1.5.0, however, pngusr.h is
|
||||
processed only once, when the exported header file pnglibconf.h is built.
|
||||
pngconf.h no longer includes pngusr.h, therefore it is ignored after the
|
||||
pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the
|
||||
build of pnglibconf.h and it is never included in an application build.
|
||||
|
||||
The rarely used alternative of adding a list of feature macros to the
|
||||
@@ -5216,7 +5375,7 @@ scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
|
||||
and all known later implementations (often called by subtly different
|
||||
names - nawk and gawk for example) are adequate to build pnglibconf.h.
|
||||
The Sun Microsystems (now Oracle) program 'awk' is an earlier version
|
||||
and does not work, this may also apply to other systems that have a
|
||||
and does not work; this may also apply to other systems that have a
|
||||
functioning awk called 'nawk'.
|
||||
|
||||
Configuration options are now documented in scripts/pnglibconf.dfa. This
|
||||
@@ -5258,8 +5417,8 @@ the libpng bug tracker at
|
||||
|
||||
We also accept patches built from the tar or zip distributions, and
|
||||
simple verbal discriptions of bug fixes, reported either to the
|
||||
SourceForge bug tracker or to the png-mng-implement at lists.sf.net
|
||||
mailing list.
|
||||
SourceForge bug tracker, to the png-mng-implement at lists.sf.net
|
||||
mailing list, or directly to glennrp.
|
||||
|
||||
.SH XIII. Coding style
|
||||
|
||||
@@ -5372,13 +5531,13 @@ Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
.SH XIV. Y2K Compliance in libpng
|
||||
|
||||
June 14, 2011
|
||||
August 25, 2011
|
||||
|
||||
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.5.4beta02 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.5.5beta06 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has three year fields. One is a 2-byte unsigned integer that
|
||||
@@ -5571,7 +5730,10 @@ the first widely used release:
|
||||
1.5.3rc01-02 15 10503 15.so.15.3[.0]
|
||||
1.5.3beta11 15 10503 15.so.15.3[.0]
|
||||
1.5.3 [omitted]
|
||||
1.5.4beta01-02 15 10504 15.so.15.4[.0]
|
||||
1.5.4beta01-08 15 10504 15.so.15.4[.0]
|
||||
1.5.4rc01 15 10504 15.so.15.4[.0]
|
||||
1.5.4 15 10504 15.so.15.4[.0]
|
||||
1.5.5beta01-06 15 10505 15.so.15.5[.0]
|
||||
|
||||
Henceforth the source version will match the shared-library minor
|
||||
and patch numbers; the shared-library major version number will be
|
||||
@@ -5628,7 +5790,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.5.4beta02 - June 14, 2011:
|
||||
Libpng version 1.5.5beta06 - August 25, 2011:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
||||
|
||||
@@ -5651,7 +5813,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.5.4beta02, June 14, 2011, are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.5.5beta06, August 25, 2011, 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
|
||||
@@ -5750,7 +5912,7 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
June 14, 2011
|
||||
August 25, 2011
|
||||
|
||||
.\" end of man page
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 "June 14, 2011"
|
||||
.TH LIBPNGPF 3 "August 25, 2011"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.4beta02
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.5beta06
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
|
||||
2
png.5
2
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "June 14, 2011"
|
||||
.TH PNG 5 "August 25, 2011"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
||||
447
png.c
447
png.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.5 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2011 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_5_4beta02 Your_png_h_is_not_version_1_5_4beta02;
|
||||
typedef png_libpng_version_1_5_5beta06 Your_png_h_is_not_version_1_5_5beta06;
|
||||
|
||||
/* 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
|
||||
@@ -43,7 +43,7 @@ png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||
* can simply check the remaining bytes for extra assurance. Returns
|
||||
* an integer less than, equal to, or greater than zero if sig is found,
|
||||
* respectively, to be less than, to match, or be greater than the correct
|
||||
* PNG signature (this is the same behaviour as strcmp, memcmp, etc).
|
||||
* PNG signature (this is the same behavior as strcmp, memcmp, etc).
|
||||
*/
|
||||
int PNGAPI
|
||||
png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
@@ -542,8 +542,8 @@ png_get_io_ptr(png_structp png_ptr)
|
||||
/* Initialize the default input/output functions for the PNG file. If you
|
||||
* use your own read or write routines, you can call either png_set_read_fn()
|
||||
* or png_set_write_fn() instead of png_init_io(). If you have defined
|
||||
* PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't
|
||||
* necessarily available.
|
||||
* PNG_NO_STDIO or otherwise disabled PNG_STDIO_SUPPORTED, you must use a
|
||||
* function of your own because "FILE *" isn't necessarily available.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_init_io(png_structp png_ptr, png_FILE_p fp)
|
||||
@@ -617,13 +617,13 @@ png_get_copyright(png_const_structp png_ptr)
|
||||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.5.4beta02 - June 14, 2011" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.5.5beta06 - August 25, 2011" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2011 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.5.4beta02 - June 14, 2011\
|
||||
return "libpng version 1.5.5beta06 - August 25, 2011\
|
||||
Copyright (c) 1998-2011 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
@@ -713,18 +713,9 @@ png_access_version_number(void)
|
||||
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
# ifdef PNG_SIZE_T
|
||||
/* Added at libpng version 1.2.6 */
|
||||
PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
|
||||
png_size_t PNGAPI
|
||||
png_convert_size(size_t size)
|
||||
{
|
||||
if (size > (png_size_t)-1)
|
||||
PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */
|
||||
|
||||
return ((png_size_t)size);
|
||||
}
|
||||
# endif /* PNG_SIZE_T */
|
||||
/* png_convert_size: a PNGAPI but no longer in png.h, so deleted
|
||||
* at libpng 1.5.5!
|
||||
*/
|
||||
|
||||
/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
|
||||
# ifdef PNG_CHECK_cHRM_SUPPORTED
|
||||
@@ -798,6 +789,326 @@ png_check_cHRM_fixed(png_structp png_ptr,
|
||||
}
|
||||
# endif /* PNG_CHECK_cHRM_SUPPORTED */
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
|
||||
* cHRM, as opposed to using chromaticities. These internal APIs return
|
||||
* non-zero on a parameter error. The X, Y and Z values are required to be
|
||||
* positive and less than 1.0.
|
||||
*/
|
||||
int png_xy_from_XYZ(png_xy *xy, png_XYZ XYZ)
|
||||
{
|
||||
png_int_32 d, dwhite, whiteX, whiteY;
|
||||
|
||||
d = XYZ.redX + XYZ.redY + XYZ.redZ;
|
||||
if (!png_muldiv(&xy->redx, XYZ.redX, PNG_FP_1, d)) return 1;
|
||||
if (!png_muldiv(&xy->redy, XYZ.redY, PNG_FP_1, d)) return 1;
|
||||
dwhite = d;
|
||||
whiteX = XYZ.redX;
|
||||
whiteY = XYZ.redY;
|
||||
|
||||
d = XYZ.greenX + XYZ.greenY + XYZ.greenZ;
|
||||
if (!png_muldiv(&xy->greenx, XYZ.greenX, PNG_FP_1, d)) return 1;
|
||||
if (!png_muldiv(&xy->greeny, XYZ.greenY, PNG_FP_1, d)) return 1;
|
||||
dwhite += d;
|
||||
whiteX += XYZ.greenX;
|
||||
whiteY += XYZ.greenY;
|
||||
|
||||
d = XYZ.blueX + XYZ.blueY + XYZ.blueZ;
|
||||
if (!png_muldiv(&xy->bluex, XYZ.blueX, PNG_FP_1, d)) return 1;
|
||||
if (!png_muldiv(&xy->bluey, XYZ.blueY, PNG_FP_1, d)) return 1;
|
||||
dwhite += d;
|
||||
whiteX += XYZ.blueX;
|
||||
whiteY += XYZ.blueY;
|
||||
|
||||
/* The reference white is simply the same of the end-point (X,Y,Z) vectors,
|
||||
* thus:
|
||||
*/
|
||||
if (!png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite)) return 1;
|
||||
if (!png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite)) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int png_XYZ_from_xy(png_XYZ *XYZ, png_xy xy)
|
||||
{
|
||||
png_fixed_point red_inverse, green_inverse, blue_scale;
|
||||
png_fixed_point left, right, denominator;
|
||||
|
||||
/* Check xy and, implicitly, z. Note that wide gamut color spaces typically
|
||||
* have end points with 0 tristimulus values (these are impossible end
|
||||
* points, but they are used to cover the possible colors.)
|
||||
*/
|
||||
if (xy.redx < 0 || xy.redx > PNG_FP_1) return 1;
|
||||
if (xy.redy < 0 || xy.redy > PNG_FP_1-xy.redx) return 1;
|
||||
if (xy.greenx < 0 || xy.greenx > PNG_FP_1) return 1;
|
||||
if (xy.greeny < 0 || xy.greeny > PNG_FP_1-xy.greenx) return 1;
|
||||
if (xy.bluex < 0 || xy.bluex > PNG_FP_1) return 1;
|
||||
if (xy.bluey < 0 || xy.bluey > PNG_FP_1-xy.bluex) return 1;
|
||||
if (xy.whitex < 0 || xy.whitex > PNG_FP_1) return 1;
|
||||
if (xy.whitey < 0 || xy.whitey > PNG_FP_1-xy.whitex) return 1;
|
||||
|
||||
/* The reverse calculation is more difficult because the original tristimulus
|
||||
* value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
|
||||
* derived values were recorded in the cHRM chunk;
|
||||
* (red,green,blue,white)x(x,y). This loses one degree of freedom and
|
||||
* therefore an arbitrary ninth value has to be introduced to undo the
|
||||
* original transformations.
|
||||
*
|
||||
* Think of the original end-points as points in (X,Y,Z) space. The
|
||||
* chromaticity values (c) have the property:
|
||||
*
|
||||
* C
|
||||
* c = ---------
|
||||
* X + Y + Z
|
||||
*
|
||||
* For each c (x,y,z) from the corresponding original C (X,Y,Z). Thus the
|
||||
* three chromaticity values (x,y,z) for each end-point obey the
|
||||
* relationship:
|
||||
*
|
||||
* x + y + z = 1
|
||||
*
|
||||
* This describes the plane in (X,Y,Z) space that intersects each axis at the
|
||||
* value 1.0; call this the chromaticity plane. Thus the chromaticity
|
||||
* calculation has scaled each end-point so that it is on the x+y+z=1 plane
|
||||
* and chromaticity is the intersection of the vector from the origin to the
|
||||
* (X,Y,Z) value with the chromaticity plane.
|
||||
*
|
||||
* To fully invert the chromaticity calculation we would need the three
|
||||
* end-point scale factors, (red-scale, green-scale, blue-scale), but these
|
||||
* were not recorded. Instead we calculated the reference white (X,Y,Z) and
|
||||
* recorded the chromaticity of this. The reference white (X,Y,Z) would have
|
||||
* given all three of the scale factors since:
|
||||
*
|
||||
* color-C = color-c * color-scale
|
||||
* white-C = red-C + green-C + blue-C
|
||||
* = red-c*red-scale + green-c*green-scale + blue-c*blue-scale
|
||||
*
|
||||
* But cHRM records only white-x and white-y, so we have lost the white scale
|
||||
* factor:
|
||||
*
|
||||
* white-C = white-c*white-scale
|
||||
*
|
||||
* To handle this the inverse transformation makes an arbitrary assumption
|
||||
* about white-scale:
|
||||
*
|
||||
* Assume: white-Y = 1.0
|
||||
* Hence: white-scale = 1/white-y
|
||||
* Or: red-Y + green-Y + blue-Y = 1.0
|
||||
*
|
||||
* Notice the last statement of the assumption gives an equation in three of
|
||||
* the nine values we want to calculate. 8 more equations come from the
|
||||
* above routine as summarised at the top above (the chromaticity
|
||||
* calculation):
|
||||
*
|
||||
* Given: color-x = color-X / (color-X + color-Y + color-Z)
|
||||
* Hence: (color-x - 1)*color-X + color.x*color-Y + color.x*color-Z = 0
|
||||
*
|
||||
* This is 9 simultaneous equations in the 9 variables "color-C" and can be
|
||||
* solved by Cramer's rule. Cramer's rule requires calculating 10 9x9 matrix
|
||||
* determinants, however this is not as bad as it seems because only 28 of
|
||||
* the total of 90 terms in the various matrices are non-zero. Nevertheless
|
||||
* Cramer's rule is notoriously numerically unstable because the determinant
|
||||
* calculation involves the difference of large, but similar, numbers. It is
|
||||
* difficult to be sure that the calculation is stable for real world values
|
||||
* and it is certain that it becomes unstable where the end points are close
|
||||
* together.
|
||||
*
|
||||
* So this code uses the perhaps slighly less optimal but more understandable
|
||||
* and totally obvious approach of calculating color-scale.
|
||||
*
|
||||
* This algorithm depends on the precision in white-scale and that is
|
||||
* (1/white-y), so we can immediately see that as white-y approaches 0 the
|
||||
* accuracy inherent in the cHRM chunk drops off substantially.
|
||||
*
|
||||
* libpng arithmetic: a simple invertion of the above equations
|
||||
* ------------------------------------------------------------
|
||||
*
|
||||
* white_scale = 1/white-y
|
||||
* white-X = white-x * white-scale
|
||||
* white-Y = 1.0
|
||||
* white-Z = (1 - white-x - white-y) * white_scale
|
||||
*
|
||||
* white-C = red-C + green-C + blue-C
|
||||
* = red-c*red-scale + green-c*green-scale + blue-c*blue-scale
|
||||
*
|
||||
* This gives us three equations in (red-scale,green-scale,blue-scale) where
|
||||
* all the coefficients are now known:
|
||||
*
|
||||
* red-x*red-scale + green-x*green-scale + blue-x*blue-scale
|
||||
* = white-x/white-y
|
||||
* red-y*red-scale + green-y*green-scale + blue-y*blue-scale = 1
|
||||
* red-z*red-scale + green-z*green-scale + blue-z*blue-scale
|
||||
* = (1 - white-x - white-y)/white-y
|
||||
*
|
||||
* In the last equation color-z is (1 - color-x - color-y) so we can add all
|
||||
* three equations together to get an alternative third:
|
||||
*
|
||||
* red-scale + green-scale + blue-scale = 1/white-y = white-scale
|
||||
*
|
||||
* So now we have a Cramer's rule solution where the determinants are just
|
||||
* 3x3 - far more tractible. Unfortunately 3x3 determinants still involve
|
||||
* multiplication of three coefficients so we can't guarantee to avoid
|
||||
* overflow in the libpng fixed point representation. Using Cramer's rule in
|
||||
* floating point is probably a good choice here, but it's not an option for
|
||||
* fixed point. Instead proceed to simplify the first two equations by
|
||||
* eliminating what is likely to be the largest value, blue-scale:
|
||||
*
|
||||
* blue-scale = white-scale - red-scale - green-scale
|
||||
*
|
||||
* Hence:
|
||||
*
|
||||
* (red-x - blue-x)*red-scale + (green-x - blue-x)*green-scale =
|
||||
* (white-x - blue-x)*white-scale
|
||||
*
|
||||
* (red-y - blue-y)*red-scale + (green-y - blue-y)*green-scale =
|
||||
* 1 - blue-y*white-scale
|
||||
*
|
||||
* And now we can trivially solve for (red-scale,green-scale):
|
||||
*
|
||||
* green-scale =
|
||||
* (white-x - blue-x)*white-scale - (red-x - blue-x)*red-scale
|
||||
* -----------------------------------------------------------
|
||||
* green-x - blue-x
|
||||
*
|
||||
* red-scale =
|
||||
* 1 - blue-y*white-scale - (green-y - blue-y) * green-scale
|
||||
* ---------------------------------------------------------
|
||||
* red-y - blue-y
|
||||
*
|
||||
* Hence:
|
||||
*
|
||||
* red-scale =
|
||||
* ( (green-x - blue-x) * (white-y - blue-y) -
|
||||
* (green-y - blue-y) * (white-x - blue-x) ) / white-y
|
||||
* -------------------------------------------------------------------------
|
||||
* (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)
|
||||
*
|
||||
* green-scale =
|
||||
* ( (red-y - blue-y) * (white-x - blue-x) -
|
||||
* (red-x - blue-x) * (white-y - blue-y) ) / white-y
|
||||
* -------------------------------------------------------------------------
|
||||
* (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)
|
||||
*
|
||||
* Accuracy:
|
||||
* The input values have 5 decimal digits of accuracy. The values are all in
|
||||
* the range 0 < value < 1, so simple products are in the same range but may
|
||||
* need up to 10 decimal digits to preserve the original precision and avoid
|
||||
* underflow. Because we are using a 32-bit signed representation we cannot
|
||||
* match this; the best is a little over 9 decimal digits, less than 10.
|
||||
*
|
||||
* The approach used here is to preserve the maximum precision within the
|
||||
* signed representation. Because the red-scale calculation above uses the
|
||||
* difference between two products of values that must be in the range -1..+1
|
||||
* it is sufficient to divide the product by 7; ceil(100,000/32767*2). The
|
||||
* factor is irrelevant in the calculation because it is applied to both
|
||||
* numerator and denominator.
|
||||
*
|
||||
* Note that the values of the differences of the products of the
|
||||
* chromaticities in the above equations tend to be small, for example for
|
||||
* the sRGB chromaticities they are:
|
||||
*
|
||||
* red numerator: -0.04751
|
||||
* green numerator: -0.08788
|
||||
* denominator: -0.2241 (without white-y multiplication)
|
||||
*
|
||||
* The resultant Y coefficients from the chromaticities of some widely used
|
||||
* color space definitions are (to 15 decimal places):
|
||||
*
|
||||
* sRGB
|
||||
* 0.212639005871510 0.715168678767756 0.072192315360734
|
||||
* Kodak ProPhoto
|
||||
* 0.288071128229293 0.711843217810102 0.000085653960605
|
||||
* Adobe RGB
|
||||
* 0.297344975250536 0.627363566255466 0.075291458493998
|
||||
* Adobe Wide Gamut RGB
|
||||
* 0.258728243040113 0.724682314948566 0.016589442011321
|
||||
*/
|
||||
/* By the argument, above overflow should be impossible here. The return
|
||||
* value of 2 indicates an internal error to the caller.
|
||||
*/
|
||||
if (!png_muldiv(&left, xy.greenx-xy.bluex, xy.redy - xy.bluey, 7)) return 2;
|
||||
if (!png_muldiv(&right, xy.greeny-xy.bluey, xy.redx - xy.bluex, 7)) return 2;
|
||||
denominator = left - right;
|
||||
|
||||
/* Now find the red numerator. */
|
||||
if (!png_muldiv(&left, xy.greenx-xy.bluex, xy.whitey-xy.bluey, 7)) return 2;
|
||||
if (!png_muldiv(&right, xy.greeny-xy.bluey, xy.whitex-xy.bluex, 7)) return 2;
|
||||
|
||||
/* Overflow is possible here and it indicates an extreme set of PNG cHRM
|
||||
* chunk values. This calculation actually returns the reciprocal of the
|
||||
* scale value because this allows us to delay the multiplication of white-y
|
||||
* into the denominator, which tends to produce a small number.
|
||||
*/
|
||||
if (!png_muldiv(&red_inverse, xy.whitey, denominator, left-right) ||
|
||||
red_inverse <= xy.whitey /* r+g+b scales = white scale */)
|
||||
return 1;
|
||||
|
||||
/* Similarly for green_inverse: */
|
||||
if (!png_muldiv(&left, xy.redy-xy.bluey, xy.whitex-xy.bluex, 7)) return 2;
|
||||
if (!png_muldiv(&right, xy.redx-xy.bluex, xy.whitey-xy.bluey, 7)) return 2;
|
||||
if (!png_muldiv(&green_inverse, xy.whitey, denominator, left-right) ||
|
||||
green_inverse <= xy.whitey)
|
||||
return 1;
|
||||
|
||||
/* And the blue scale, the checks above guarantee this can't overflow but it
|
||||
* can still produce 0 for extreme cHRM values.
|
||||
*/
|
||||
blue_scale = png_reciprocal(xy.whitey) - png_reciprocal(red_inverse) -
|
||||
png_reciprocal(green_inverse);
|
||||
if (blue_scale <= 0) return 1;
|
||||
|
||||
|
||||
/* And fill in the png_XYZ: */
|
||||
if (!png_muldiv(&XYZ->redX, xy.redx, PNG_FP_1, red_inverse)) return 1;
|
||||
if (!png_muldiv(&XYZ->redY, xy.redy, PNG_FP_1, red_inverse)) return 1;
|
||||
if (!png_muldiv(&XYZ->redZ, PNG_FP_1 - xy.redx - xy.redy, PNG_FP_1,
|
||||
red_inverse))
|
||||
return 1;
|
||||
|
||||
if (!png_muldiv(&XYZ->greenX, xy.greenx, PNG_FP_1, green_inverse)) return 1;
|
||||
if (!png_muldiv(&XYZ->greenY, xy.greeny, PNG_FP_1, green_inverse)) return 1;
|
||||
if (!png_muldiv(&XYZ->greenZ, PNG_FP_1 - xy.greenx - xy.greeny, PNG_FP_1,
|
||||
green_inverse))
|
||||
return 1;
|
||||
|
||||
if (!png_muldiv(&XYZ->blueX, xy.bluex, blue_scale, PNG_FP_1)) return 1;
|
||||
if (!png_muldiv(&XYZ->blueY, xy.bluey, blue_scale, PNG_FP_1)) return 1;
|
||||
if (!png_muldiv(&XYZ->blueZ, PNG_FP_1 - xy.bluex - xy.bluey, blue_scale,
|
||||
PNG_FP_1))
|
||||
return 1;
|
||||
|
||||
return 0; /*success*/
|
||||
}
|
||||
|
||||
int png_XYZ_from_xy_checked(png_structp png_ptr, png_XYZ *XYZ, png_xy xy)
|
||||
{
|
||||
switch (png_XYZ_from_xy(XYZ, xy))
|
||||
{
|
||||
case 0: /* success */
|
||||
return 1;
|
||||
|
||||
case 1:
|
||||
/* The chunk may be technically valid, but we got png_fixed_point
|
||||
* overflow while trying to get XYZ values out of it. This is
|
||||
* entirely benign - the cHRM chunk is pretty extreme.
|
||||
*/
|
||||
png_chunk_benign_error(png_ptr,
|
||||
"extreme cHRM chunk cannot be converted to tristimulus values");
|
||||
break;
|
||||
|
||||
default:
|
||||
/* libpng is broken; this should be a warning but if it happens we
|
||||
* want error reports so for the moment it is an error.
|
||||
*/
|
||||
png_error(png_ptr, "internal error in png_XYZ_from_xy");
|
||||
break;
|
||||
}
|
||||
|
||||
/* ERROR RETURN */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_IHDR(png_structp png_ptr,
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
@@ -946,16 +1257,9 @@ png_check_IHDR(png_structp png_ptr,
|
||||
/* Check an ASCII formated floating point value, see the more detailed
|
||||
* comments in pngpriv.h
|
||||
*/
|
||||
/* The following is used internally to preserve the 'valid' flag */
|
||||
/* The following is used internally to preserve the sticky flags */
|
||||
#define png_fp_add(state, flags) ((state) |= (flags))
|
||||
#define png_fp_set(state, value)\
|
||||
((state) = (value) | ((state) & PNG_FP_WAS_VALID))
|
||||
|
||||
/* Internal type codes: bits above the base state! */
|
||||
#define PNG_FP_SIGN 0 /* [+-] */
|
||||
#define PNG_FP_DOT 4 /* . */
|
||||
#define PNG_FP_DIGIT 8 /* [0123456789] */
|
||||
#define PNG_FP_E 12 /* [Ee] */
|
||||
#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY))
|
||||
|
||||
int /* PRIVATE */
|
||||
png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
|
||||
@@ -968,55 +1272,55 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
|
||||
{
|
||||
int type;
|
||||
/* First find the type of the next character */
|
||||
switch (string[i])
|
||||
{
|
||||
char ch = string[i];
|
||||
|
||||
if (ch >= 48 && ch <= 57)
|
||||
type = PNG_FP_DIGIT;
|
||||
|
||||
else switch (ch)
|
||||
{
|
||||
case 43: case 45: type = PNG_FP_SIGN; break;
|
||||
case 46: type = PNG_FP_DOT; break;
|
||||
case 69: case 101: type = PNG_FP_E; break;
|
||||
default: goto PNG_FP_End;
|
||||
}
|
||||
case 43: type = PNG_FP_SAW_SIGN; break;
|
||||
case 45: type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break;
|
||||
case 46: type = PNG_FP_SAW_DOT; break;
|
||||
case 48: type = PNG_FP_SAW_DIGIT; break;
|
||||
case 49: case 50: case 51: case 52:
|
||||
case 53: case 54: case 55: case 56:
|
||||
case 57: type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break;
|
||||
case 69:
|
||||
case 101: type = PNG_FP_SAW_E; break;
|
||||
default: goto PNG_FP_End;
|
||||
}
|
||||
|
||||
/* Now deal with this type according to the current
|
||||
* state, the type is arranged to not overlap the
|
||||
* bits of the PNG_FP_STATE.
|
||||
*/
|
||||
switch ((state & PNG_FP_STATE) + type)
|
||||
switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY))
|
||||
{
|
||||
case PNG_FP_INTEGER + PNG_FP_SIGN:
|
||||
case PNG_FP_INTEGER + PNG_FP_SAW_SIGN:
|
||||
if (state & PNG_FP_SAW_ANY)
|
||||
goto PNG_FP_End; /* not a part of the number */
|
||||
|
||||
png_fp_add(state, PNG_FP_SAW_SIGN);
|
||||
png_fp_add(state, type);
|
||||
break;
|
||||
|
||||
case PNG_FP_INTEGER + PNG_FP_DOT:
|
||||
case PNG_FP_INTEGER + PNG_FP_SAW_DOT:
|
||||
/* Ok as trailer, ok as lead of fraction. */
|
||||
if (state & PNG_FP_SAW_DOT) /* two dots */
|
||||
goto PNG_FP_End;
|
||||
|
||||
else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */
|
||||
png_fp_add(state, PNG_FP_SAW_DOT);
|
||||
png_fp_add(state, type);
|
||||
|
||||
else
|
||||
png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);
|
||||
png_fp_set(state, PNG_FP_FRACTION | type);
|
||||
|
||||
break;
|
||||
|
||||
case PNG_FP_INTEGER + PNG_FP_DIGIT:
|
||||
case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT:
|
||||
if (state & PNG_FP_SAW_DOT) /* delayed fraction */
|
||||
png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);
|
||||
|
||||
png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID);
|
||||
png_fp_add(state, type | PNG_FP_WAS_VALID);
|
||||
|
||||
break;
|
||||
case PNG_FP_INTEGER + PNG_FP_E:
|
||||
|
||||
case PNG_FP_INTEGER + PNG_FP_SAW_E:
|
||||
if ((state & PNG_FP_SAW_DIGIT) == 0)
|
||||
goto PNG_FP_End;
|
||||
|
||||
@@ -1024,17 +1328,17 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
|
||||
|
||||
break;
|
||||
|
||||
/* case PNG_FP_FRACTION + PNG_FP_SIGN:
|
||||
goto PNG_FP_End; ** no sign in exponent */
|
||||
/* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN:
|
||||
goto PNG_FP_End; ** no sign in fraction */
|
||||
|
||||
/* case PNG_FP_FRACTION + PNG_FP_DOT:
|
||||
/* case PNG_FP_FRACTION + PNG_FP_SAW_DOT:
|
||||
goto PNG_FP_End; ** Because SAW_DOT is always set */
|
||||
|
||||
case PNG_FP_FRACTION + PNG_FP_DIGIT:
|
||||
png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID);
|
||||
case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT:
|
||||
png_fp_add(state, type | PNG_FP_WAS_VALID);
|
||||
break;
|
||||
|
||||
case PNG_FP_FRACTION + PNG_FP_E:
|
||||
case PNG_FP_FRACTION + PNG_FP_SAW_E:
|
||||
/* This is correct because the trailing '.' on an
|
||||
* integer is handled above - so we can only get here
|
||||
* with the sequence ".E" (with no preceding digits).
|
||||
@@ -1046,7 +1350,7 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
|
||||
|
||||
break;
|
||||
|
||||
case PNG_FP_EXPONENT + PNG_FP_SIGN:
|
||||
case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN:
|
||||
if (state & PNG_FP_SAW_ANY)
|
||||
goto PNG_FP_End; /* not a part of the number */
|
||||
|
||||
@@ -1054,15 +1358,15 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
|
||||
|
||||
break;
|
||||
|
||||
/* case PNG_FP_EXPONENT + PNG_FP_DOT:
|
||||
/* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT:
|
||||
goto PNG_FP_End; */
|
||||
|
||||
case PNG_FP_EXPONENT + PNG_FP_DIGIT:
|
||||
png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID);
|
||||
case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT:
|
||||
png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID);
|
||||
|
||||
break;
|
||||
|
||||
/* case PNG_FP_EXPONEXT + PNG_FP_E:
|
||||
/* case PNG_FP_EXPONEXT + PNG_FP_SAW_E:
|
||||
goto PNG_FP_End; */
|
||||
|
||||
default: goto PNG_FP_End; /* I.e. break 2 */
|
||||
@@ -1090,8 +1394,11 @@ png_check_fp_string(png_const_charp string, png_size_t size)
|
||||
int state=0;
|
||||
png_size_t char_index=0;
|
||||
|
||||
return png_check_fp_number(string, size, &state, &char_index) &&
|
||||
(char_index == size || string[char_index] == 0);
|
||||
if (png_check_fp_number(string, size, &state, &char_index) &&
|
||||
(char_index == size || string[char_index] == 0))
|
||||
return state /* must be non-zero - see above */;
|
||||
|
||||
return 0; /* i.e. fail */
|
||||
}
|
||||
#endif /* pCAL or sCAL */
|
||||
|
||||
@@ -1845,7 +2152,7 @@ png_8bit_l2[128] =
|
||||
#endif
|
||||
};
|
||||
|
||||
static png_int_32
|
||||
PNG_STATIC png_int_32
|
||||
png_log8bit(unsigned int x)
|
||||
{
|
||||
unsigned int lg2 = 0;
|
||||
@@ -1901,7 +2208,7 @@ png_log8bit(unsigned int x)
|
||||
* Zero (257): 0
|
||||
* End (258): 23499
|
||||
*/
|
||||
static png_int_32
|
||||
PNG_STATIC png_int_32
|
||||
png_log16bit(png_uint_32 x)
|
||||
{
|
||||
unsigned int lg2 = 0;
|
||||
@@ -1995,7 +2302,7 @@ for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"}
|
||||
0 45425.85339951654943850496
|
||||
#endif
|
||||
|
||||
static png_uint_32
|
||||
PNG_STATIC png_uint_32
|
||||
png_exp(png_fixed_point x)
|
||||
{
|
||||
if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */
|
||||
@@ -2043,7 +2350,7 @@ png_exp(png_fixed_point x)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static png_byte
|
||||
PNG_STATIC png_byte
|
||||
png_exp8bit(png_fixed_point lg2)
|
||||
{
|
||||
/* Get a 32-bit value: */
|
||||
@@ -2057,7 +2364,7 @@ png_exp8bit(png_fixed_point lg2)
|
||||
return (png_byte)((x + 0x7fffffU) >> 24);
|
||||
}
|
||||
|
||||
static png_uint_16
|
||||
PNG_STATIC png_uint_16
|
||||
png_exp16bit(png_fixed_point lg2)
|
||||
{
|
||||
/* Get a 32-bit value: */
|
||||
@@ -2369,7 +2676,7 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
|
||||
else
|
||||
shift = 0; /* keep all 16 bits */
|
||||
|
||||
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_CHOP_16_TO_8))
|
||||
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))
|
||||
{
|
||||
/* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively
|
||||
* the significant bits in the *input* when the output will
|
||||
@@ -2385,12 +2692,12 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
|
||||
png_ptr->gamma_shift = shift;
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
/* NOTE: prior to 1.5.3 this test used to include PNG_BACKGROUND (now
|
||||
/* 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_CHOP_16_TO_8))
|
||||
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->gamma,
|
||||
|
||||
73
png.h
73
png.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.5.4beta02 - June 14, 2011
|
||||
* libpng version 1.5.5beta06 - August 25, 2011
|
||||
* Copyright (c) 1998-2011 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.5.4beta02 - June 14, 2011: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.5.5beta06 - August 25, 2011: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
@@ -154,7 +154,10 @@
|
||||
* 1.5.3rc01-02 15 10503 15.so.15.3[.0]
|
||||
* 1.5.3beta11 15 10503 15.so.15.3[.0]
|
||||
* 1.5.3 [omitted]
|
||||
* 1.5.4beta01-02 15 10504 15.so.15.4[.0]
|
||||
* 1.5.4beta01-08 15 10504 15.so.15.4[.0]
|
||||
* 1.5.4rc01 15 10504 15.so.15.4[.0]
|
||||
* 1.5.4 15 10504 15.so.15.4[.0]
|
||||
* 1.5.5beta01-06 15 10505 15.so.15.5[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
@@ -186,7 +189,7 @@
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.5.4beta02, June 14, 2011, are
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.5.5beta06, August 25, 2011, are
|
||||
* Copyright (c) 2004, 2006-2011 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:
|
||||
@@ -298,13 +301,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* June 14, 2011
|
||||
* August 25, 2011
|
||||
*
|
||||
* 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.5.4beta02 are Y2K compliant. It is my belief that
|
||||
* upward through 1.5.5beta06 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
|
||||
@@ -359,9 +362,9 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.5.4beta02"
|
||||
#define PNG_LIBPNG_VER_STRING "1.5.5beta06"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.5.4beta02 - June 14, 2011\n"
|
||||
" libpng version 1.5.5beta06 - August 25, 2011\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 15
|
||||
#define PNG_LIBPNG_VER_DLLNUM 15
|
||||
@@ -369,12 +372,12 @@
|
||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 5
|
||||
#define PNG_LIBPNG_VER_RELEASE 4
|
||||
#define PNG_LIBPNG_VER_RELEASE 5
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
*/
|
||||
|
||||
#define PNG_LIBPNG_VER_BUILD 02
|
||||
#define PNG_LIBPNG_VER_BUILD 06
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@@ -399,7 +402,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 10504 /* 1.5.4 */
|
||||
#define PNG_LIBPNG_VER 10505 /* 1.5.5 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
@@ -521,7 +524,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_5_4beta02;
|
||||
typedef char* png_libpng_version_1_5_5beta06;
|
||||
|
||||
/* Three color definitions. The order of the red, green, and blue, (and the
|
||||
* exact size) is not important, although the size of the fields need to
|
||||
@@ -598,7 +601,7 @@ typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
|
||||
* and whether that contents is compressed or not. The "key" field
|
||||
* points to a regular zero-terminated C string. The "text", "lang", and
|
||||
* "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
|
||||
* However, the * structure returned by png_get_text() will always contain
|
||||
* However, the structure returned by png_get_text() will always contain
|
||||
* regular zero-terminated C strings (possibly empty), never NULL pointers,
|
||||
* so they can be safely used in printf() and other string-handling functions.
|
||||
*/
|
||||
@@ -900,8 +903,9 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
|
||||
#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
|
||||
/* Added to libpng-1.4.0 */
|
||||
#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
|
||||
/* Added to libpng-1.5.3 */
|
||||
/* Added to libpng-1.5.4 */
|
||||
#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
|
||||
#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
|
||||
|
||||
/* Flags for MNG supported features */
|
||||
#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
|
||||
@@ -1404,7 +1408,7 @@ PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr));
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
/* Handle alpha and tRNS by replacing with a background color. Prior to
|
||||
* libpng-1.5.3 this API must not be called before the PNG file header has been
|
||||
* libpng-1.5.4 this API must not be called before the PNG file header has been
|
||||
* read. Doing so will result in unexpected behavior and possible warnings or
|
||||
* errors if the PNG file contains a bKGD chunk.
|
||||
*/
|
||||
@@ -1422,15 +1426,15 @@ PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr,
|
||||
# define PNG_BACKGROUND_GAMMA_UNIQUE 3
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
/* The following is always done from 1.5.4: */
|
||||
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
/* Scale a 16-bit depth file down to 8-bit, accurately. */
|
||||
PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr));
|
||||
# ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
|
||||
PNG_EXPORT(229, void, png_set_scale_16, (png_structp png_ptr));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
|
||||
/* Strip the second byte of information from a 16-bit depth file. */
|
||||
PNG_EXPORT(229, void, png_set_chop_16, (png_structp png_ptr));
|
||||
# endif
|
||||
PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
@@ -2044,6 +2048,10 @@ PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr,
|
||||
png_const_infop info_ptr, double *white_x, double *white_y, double *red_x,
|
||||
double *red_y, double *green_x, double *green_y, double *blue_x,
|
||||
double *blue_y));
|
||||
PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_structp png_ptr,
|
||||
png_const_infop info_ptr, double *red_X, double *red_Y, double *red_Z,
|
||||
double *green_X, double *green_Y, double *green_Z, double *blue_X,
|
||||
double *blue_Y, double *blue_Z));
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */
|
||||
PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
|
||||
(png_const_structp png_ptr,
|
||||
@@ -2053,6 +2061,13 @@ PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
|
||||
png_fixed_point *int_green_y, png_fixed_point *int_blue_x,
|
||||
png_fixed_point *int_blue_y));
|
||||
#endif
|
||||
PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,
|
||||
(png_structp png_ptr, png_const_infop info_ptr,
|
||||
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
||||
png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
|
||||
png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
|
||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||
png_fixed_point *int_blue_Z));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
@@ -2060,12 +2075,22 @@ PNG_FP_EXPORT(135, void, png_set_cHRM,
|
||||
(png_structp png_ptr, png_infop info_ptr,
|
||||
double white_x, double white_y, double red_x, double red_y, double green_x,
|
||||
double green_y, double blue_x, double blue_y));
|
||||
PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_structp png_ptr,
|
||||
png_infop info_ptr, double red_X, double red_Y, double red_Z,
|
||||
double green_X, double green_Y, double green_Z, double blue_X,
|
||||
double blue_Y, double blue_Z));
|
||||
PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structp png_ptr,
|
||||
png_infop info_ptr, png_fixed_point int_white_x,
|
||||
png_fixed_point int_white_y, png_fixed_point int_red_x,
|
||||
png_fixed_point int_red_y, png_fixed_point int_green_x,
|
||||
png_fixed_point int_green_y, png_fixed_point int_blue_x,
|
||||
png_fixed_point int_blue_y));
|
||||
PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_structp png_ptr,
|
||||
png_infop info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,
|
||||
png_fixed_point int_red_Z, png_fixed_point int_green_X,
|
||||
png_fixed_point int_green_Y, png_fixed_point int_green_Z,
|
||||
png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
|
||||
png_fixed_point int_blue_Z));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
@@ -2279,7 +2304,7 @@ PNG_EXPORT(171, void, png_set_sCAL_s,
|
||||
handling or default unknown chunk handling is not desired. Any chunks not
|
||||
listed will be handled in the default manner. The IHDR and IEND chunks
|
||||
must not be listed.
|
||||
keep = 0: follow default behaviour
|
||||
keep = 0: follow default behavior
|
||||
= 1: do not keep
|
||||
= 2: keep only if safe-to-copy
|
||||
= 3: keep even if unsafe-to-copy
|
||||
@@ -2573,7 +2598,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
||||
* scripts/symbols.def as well.
|
||||
*/
|
||||
#ifdef PNG_EXPORT_LAST_ORDINAL
|
||||
PNG_EXPORT_LAST_ORDINAL(229);
|
||||
PNG_EXPORT_LAST_ORDINAL(233);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
81
pngconf.h
81
pngconf.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.5.4beta02 - June 14, 2011
|
||||
* libpng version 1.5.5beta06 - August 25, 2011
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -164,7 +164,9 @@
|
||||
* 'type', compiler specific.
|
||||
*
|
||||
* PNG_DLL_EXPORT Set to the magic to use during a libpng build to
|
||||
* make a symbol exported from the DLL.
|
||||
* make a symbol exported from the DLL. Not used in the
|
||||
* public header files; see pngpriv.h for how it is used
|
||||
* in the libpng build.
|
||||
*
|
||||
* PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
|
||||
* from a DLL - used to define PNG_IMPEXP when
|
||||
@@ -258,25 +260,14 @@
|
||||
# define PNGAPI PNGCAPI
|
||||
#endif
|
||||
|
||||
/* The default for PNG_IMPEXP depends on whether the library is
|
||||
* being built or used.
|
||||
/* PNG_IMPEXP may be set on the compilation system command line or (if not set)
|
||||
* then in an internal header file when building the library, otherwise (when
|
||||
* using the library) it is set here.
|
||||
*/
|
||||
#ifndef PNG_IMPEXP
|
||||
# ifdef PNGLIB_BUILD
|
||||
/* Building the library */
|
||||
# if (defined(DLL_EXPORT)/*from libtool*/ ||\
|
||||
defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\
|
||||
defined(_USRDLL) ||\
|
||||
defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT)
|
||||
/* Building a DLL. */
|
||||
# define PNG_IMPEXP PNG_DLL_EXPORT
|
||||
# endif /* DLL */
|
||||
# else
|
||||
/* Using the library */
|
||||
# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
|
||||
/* This forces use of a DLL, disallowing static linking */
|
||||
# define PNG_IMPEXP PNG_DLL_IMPORT
|
||||
# endif
|
||||
# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
|
||||
/* This forces use of a DLL, disallowing static linking */
|
||||
# define PNG_IMPEXP PNG_DLL_IMPORT
|
||||
# endif
|
||||
|
||||
# ifndef PNG_IMPEXP
|
||||
@@ -356,25 +347,18 @@
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
|
||||
/* This specifically protects structure members that should only be
|
||||
* accessed from within the library, therefore should be empty during
|
||||
* a library build.
|
||||
*/
|
||||
# ifndef PNGLIB_BUILD
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((warning("This function is not exported by libpng.")))
|
||||
# else
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((warning("This function is not exported by libpng.")))
|
||||
# else
|
||||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# endif
|
||||
# endif
|
||||
# endif /* PNGLIB_BUILD */
|
||||
# endif
|
||||
# endif /* __GNUC__ */
|
||||
|
||||
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
@@ -385,21 +369,16 @@
|
||||
# define PNG_NORETURN __declspec(noreturn)
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __declspec(restrict)
|
||||
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# define PNG_ALLOCATED __declspec(restrict)
|
||||
# endif
|
||||
# endif
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __declspec(deprecated)
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE __declspec(deprecated)
|
||||
# endif
|
||||
|
||||
/* This specifically protects structure members that should only be
|
||||
* accessed from within the library, therefore should be empty during
|
||||
* a library build.
|
||||
*/
|
||||
# ifndef PNGLIB_BUILD
|
||||
# ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED __declspec(deprecated)
|
||||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE __declspec(deprecated)
|
||||
# endif
|
||||
# endif /* PNGLIB_BUILD */
|
||||
# endif /* _MSC_VER */
|
||||
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
@@ -507,7 +507,7 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
/* Check on NULL only added in 1.5.3 */
|
||||
/* Check on NULL only added in 1.5.4 */
|
||||
if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of error message. */
|
||||
|
||||
95
pngget.c
95
pngget.c
@@ -459,6 +459,65 @@ png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
|
||||
* same time to correct the rgb grayscale coefficient defaults obtained from the
|
||||
* cHRM chunk in 1.5.4
|
||||
*/
|
||||
png_uint_32 PNGFAPI
|
||||
png_get_cHRM_XYZ_fixed(png_structp png_ptr, png_const_infop info_ptr,
|
||||
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
||||
png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
|
||||
png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
|
||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
{
|
||||
png_xy xy;
|
||||
png_XYZ XYZ;
|
||||
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
xy.whitex = info_ptr->x_white;
|
||||
xy.whitey = info_ptr->y_white;
|
||||
xy.redx = info_ptr->x_red;
|
||||
xy.redy = info_ptr->y_red;
|
||||
xy.greenx = info_ptr->x_green;
|
||||
xy.greeny = info_ptr->y_green;
|
||||
xy.bluex = info_ptr->x_blue;
|
||||
xy.bluey = info_ptr->y_blue;
|
||||
|
||||
/* The *_checked function handles error reporting, so just return 0 if
|
||||
* there is a failure here.
|
||||
*/
|
||||
if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
|
||||
{
|
||||
if (int_red_X != NULL)
|
||||
*int_red_X = XYZ.redX;
|
||||
if (int_red_Y != NULL)
|
||||
*int_red_Y = XYZ.redY;
|
||||
if (int_red_Z != NULL)
|
||||
*int_red_Z = XYZ.redZ;
|
||||
if (int_green_X != NULL)
|
||||
*int_green_X = XYZ.greenX;
|
||||
if (int_green_Y != NULL)
|
||||
*int_green_Y = XYZ.greenY;
|
||||
if (int_green_Z != NULL)
|
||||
*int_green_Z = XYZ.greenZ;
|
||||
if (int_blue_X != NULL)
|
||||
*int_blue_X = XYZ.blueX;
|
||||
if (int_blue_Y != NULL)
|
||||
*int_blue_Y = XYZ.blueY;
|
||||
if (int_blue_Z != NULL)
|
||||
*int_blue_Z = XYZ.blueZ;
|
||||
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
@@ -490,6 +549,42 @@ png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_XYZ(png_structp png_ptr, png_const_infop info_ptr,
|
||||
double *red_X, double *red_Y, double *red_Z, double *green_X,
|
||||
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
||||
double *blue_Z)
|
||||
{
|
||||
png_XYZ XYZ;
|
||||
|
||||
if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,
|
||||
&XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,
|
||||
&XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)
|
||||
{
|
||||
if (red_X != NULL)
|
||||
*red_X = png_float(png_ptr, XYZ.redX, "cHRM red X");
|
||||
if (red_Y != NULL)
|
||||
*red_Y = png_float(png_ptr, XYZ.redY, "cHRM red Y");
|
||||
if (red_Z != NULL)
|
||||
*red_Z = png_float(png_ptr, XYZ.redZ, "cHRM red Z");
|
||||
if (green_X != NULL)
|
||||
*green_X = png_float(png_ptr, XYZ.greenX, "cHRM green X");
|
||||
if (green_Y != NULL)
|
||||
*green_Y = png_float(png_ptr, XYZ.greenY, "cHRM green Y");
|
||||
if (green_Z != NULL)
|
||||
*green_Z = png_float(png_ptr, XYZ.greenZ, "cHRM green Z");
|
||||
if (blue_X != NULL)
|
||||
*blue_X = png_float(png_ptr, XYZ.blueX, "cHRM blue X");
|
||||
if (blue_Y != NULL)
|
||||
*blue_Y = png_float(png_ptr, XYZ.blueY, "cHRM blue Y");
|
||||
if (blue_Z != NULL)
|
||||
*blue_Z = png_float(png_ptr, XYZ.blueZ, "cHRM blue Z");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
|
||||
@@ -138,7 +138,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
* single color specified that should be treated as fully transparent.
|
||||
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
|
||||
*/
|
||||
png_bytep trans; /* alpha values for paletted image */
|
||||
png_bytep trans_alpha; /* alpha values for paletted image */
|
||||
png_color_16 trans_color; /* transparent color for non-palette image */
|
||||
#endif
|
||||
|
||||
2
pngmem.c
2
pngmem.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
|
||||
172
pngpriv.h
172
pngpriv.h
@@ -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.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.5 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -44,7 +44,8 @@
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#define PNGLIB_BUILD
|
||||
#define PNGLIB_BUILD /*libpng is being built, not used*/
|
||||
|
||||
#ifdef PNG_USER_CONFIG
|
||||
# include "pngusr.h"
|
||||
/* These should have been defined in pngusr.h */
|
||||
@@ -55,10 +56,80 @@
|
||||
# define PNG_USER_DLLFNAME_POSTFIX "Cb"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Is this a build of a DLL where compilation of the object modules requires
|
||||
* different preprocessor settings to those required for a simple library? If
|
||||
* so PNG_BUILD_DLL must be set.
|
||||
*
|
||||
* If libpng is used inside a DLL but that DLL does not export the libpng APIs
|
||||
* PNG_BUILD_DLL must not be set. To avoid the code below kicking in build a
|
||||
* static library of libpng then link the DLL against that.
|
||||
*/
|
||||
#ifndef PNG_BUILD_DLL
|
||||
# ifdef DLL_EXPORT
|
||||
/* This is set by libtool when files are compiled for a DLL; libtool
|
||||
* always compiles twice, even on systems where it isn't necessary. Set
|
||||
* PNG_BUILD_DLL in case it is necessary:
|
||||
*/
|
||||
# define PNG_BUILD_DLL
|
||||
# else
|
||||
# ifdef _WINDLL
|
||||
/* This is set by the Microsoft Visual Studio IDE in projects that
|
||||
* build a DLL. It can't easily be removed from those projects (it
|
||||
* isn't visible in the Visual Studio UI) so it is a fairly reliable
|
||||
* indication that PNG_IMPEXP needs to be set to the DLL export
|
||||
* attributes.
|
||||
*/
|
||||
# define PNG_BUILD_DLL
|
||||
# else
|
||||
# ifdef __DLL__
|
||||
/* This is set by the Borland C system when compiling for a DLL
|
||||
* (as above.)
|
||||
*/
|
||||
# define PNG_BUILD_DLL
|
||||
# else
|
||||
/* Add additional compiler cases here. */
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif /* Setting PNG_BUILD_DLL if required */
|
||||
|
||||
/* See pngconf.h for more details: the builder of the library may set this on
|
||||
* the command line to the right thing for the specific compilation system or it
|
||||
* may be automagically set above (at present we know of no system where it does
|
||||
* need to be set on the command line.)
|
||||
*
|
||||
* PNG_IMPEXP must be set here when building the library to prevent pngconf.h
|
||||
* setting it to the "import" setting for a DLL build.
|
||||
*/
|
||||
#ifndef PNG_IMPEXP
|
||||
# ifdef PNG_BUILD_DLL
|
||||
# define PNG_IMPEXP PNG_DLL_EXPORT
|
||||
# else
|
||||
/* Not building a DLL, or the DLL doesn't require specific export
|
||||
* definitions.
|
||||
*/
|
||||
# define PNG_IMPEXP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* No warnings for private or deprecated functions in the build: */
|
||||
#ifndef PNG_DEPRECATED
|
||||
# define PNG_DEPRECATED
|
||||
#endif
|
||||
#ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE
|
||||
#endif
|
||||
|
||||
#include "png.h"
|
||||
#include "pnginfo.h"
|
||||
#include "pngstruct.h"
|
||||
|
||||
/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */
|
||||
#ifndef PNG_DLL_EXPORT
|
||||
# define PNG_DLL_EXPORT
|
||||
#endif
|
||||
|
||||
/* This is used for 16 bit gamma tables - only the top level pointers are const,
|
||||
* this could be changed:
|
||||
*/
|
||||
@@ -115,8 +186,15 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
# define PNG_ZBUF_SIZE 65536L
|
||||
#endif
|
||||
|
||||
/* PNG_STATIC is used to mark internal file scope functions if they need to be
|
||||
* accessed for implementation tests (see the code in tests/?*).
|
||||
*/
|
||||
#ifndef PNG_STATIC
|
||||
# define PNG_STATIC static
|
||||
#endif
|
||||
|
||||
/* If warnings or errors are turned off the code is disabled or redirected here.
|
||||
* From 1.5.3 functions have been added to allow very limited formatting of
|
||||
* From 1.5.4 functions have been added to allow very limited formatting of
|
||||
* error and warning messages - this code will also be disabled here.
|
||||
*/
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
@@ -281,7 +359,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
#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
|
||||
#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
|
||||
#define PNG_RGBA 0x0800
|
||||
#define PNG_EXPAND 0x1000
|
||||
#define PNG_GAMMA 0x2000
|
||||
@@ -295,10 +373,10 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
#define PNG_RGB_TO_GRAY_ERR 0x200000L
|
||||
#define PNG_RGB_TO_GRAY_WARN 0x400000L
|
||||
#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
|
||||
#define PNG_ENCODE_ALPHA 0x800000L /* Added to libpng-1.5.3 */
|
||||
#define PNG_ENCODE_ALPHA 0x800000L /* Added to libpng-1.5.4 */
|
||||
#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */
|
||||
#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */
|
||||
#define PNG_CHOP_16_TO_8 0x4000000L
|
||||
#define PNG_SCALE_16_TO_8 0x4000000L /* Added to libpng-1.5.4 */
|
||||
/* 0x8000000L unused */
|
||||
/* 0x10000000L unused */
|
||||
/* 0x20000000L unused */
|
||||
@@ -325,9 +403,9 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
|
||||
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
|
||||
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
|
||||
#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.3 */
|
||||
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.3 */
|
||||
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.3 */
|
||||
#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */
|
||||
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */
|
||||
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */
|
||||
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
|
||||
#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
|
||||
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L
|
||||
@@ -338,7 +416,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
/* 0x400000L unused */
|
||||
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */
|
||||
#define PNG_FLAG_ZTXT_CUSTOM_STRATEGY 0x1000000L /* 5 lines added */
|
||||
#define PNG_FLAG_ZTXT_CUSTOM_LEVEL 0x2000000L /* to libpng-1.5.3 */
|
||||
#define PNG_FLAG_ZTXT_CUSTOM_LEVEL 0x2000000L /* to libpng-1.5.4 */
|
||||
#define PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL 0x4000000L
|
||||
#define PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS 0x8000000L
|
||||
#define PNG_FLAG_ZTXT_CUSTOM_METHOD 0x10000000L
|
||||
@@ -452,7 +530,7 @@ PNG_EXTERN png_fixed_point png_fixed PNGARG((png_structp png_ptr, double fp,
|
||||
#define PNG_tRNS PNG_CONST png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
|
||||
#define PNG_zTXt PNG_CONST png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
|
||||
|
||||
/* Gamma values (new at libpng-1.5.3): */
|
||||
/* Gamma values (new at libpng-1.5.4): */
|
||||
#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */
|
||||
#define PNG_GAMMA_MAC_INVERSE 65909
|
||||
#define PNG_GAMMA_sRGB_INVERSE 45455
|
||||
@@ -819,15 +897,13 @@ PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
PNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
|
||||
#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
|
||||
PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
PNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info,
|
||||
|
||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
@@ -1073,6 +1149,35 @@ PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
|
||||
unsigned long *hi_product, unsigned long *lo_product));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* Added at libpng version 1.5.5 */
|
||||
typedef struct png_xy
|
||||
{
|
||||
png_fixed_point redx, redy;
|
||||
png_fixed_point greenx, greeny;
|
||||
png_fixed_point bluex, bluey;
|
||||
png_fixed_point whitex, whitey;
|
||||
} png_xy;
|
||||
|
||||
typedef struct png_XYZ
|
||||
{
|
||||
png_fixed_point redX, redY, redZ;
|
||||
png_fixed_point greenX, greenY, greenZ;
|
||||
png_fixed_point blueX, blueY, blueZ;
|
||||
} png_XYZ;
|
||||
|
||||
/* The conversion APIs return 0 on success, non-zero on a parameter error. They
|
||||
* allow conversion between the above representations of a color encoding. When
|
||||
* converting from XYZ end points to chromaticities the absolute magnitude of
|
||||
* the end points is lost, when converting back the sum of the Y values of the
|
||||
* three end points will be 1.0
|
||||
*/
|
||||
PNG_EXTERN int png_xy_from_XYZ PNGARG((png_xy *xy, png_XYZ XYZ));
|
||||
PNG_EXTERN int png_XYZ_from_xy PNGARG((png_XYZ *XYZ, png_xy xy));
|
||||
PNG_EXTERN int png_XYZ_from_xy_checked PNGARG((png_structp png_ptr,
|
||||
png_XYZ *XYZ, png_xy xy));
|
||||
#endif
|
||||
|
||||
/* Added at libpng version 1.4.0 */
|
||||
PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
@@ -1135,7 +1240,7 @@ PNG_EXTERN png_charp png_format_number(png_const_charp start, png_charp end,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
/* New defines and members adding in libpng-1.5.3 */
|
||||
/* New defines and members adding in libpng-1.5.4 */
|
||||
# define PNG_WARNING_PARAMETER_SIZE 32
|
||||
# define PNG_WARNING_PARAMETER_COUNT 8
|
||||
|
||||
@@ -1228,8 +1333,18 @@ PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr,
|
||||
#define PNG_FP_SAW_DOT 16 /* Saw a dot in current state */
|
||||
#define PNG_FP_SAW_E 32 /* Saw an E (or e) in current state */
|
||||
#define PNG_FP_SAW_ANY 60 /* Saw any of the above 4 */
|
||||
|
||||
/* These three values don't affect the parser. They are set but not used.
|
||||
*/
|
||||
#define PNG_FP_WAS_VALID 64 /* Preceding substring is a valid fp number */
|
||||
#define PNG_FP_INVALID 128 /* Available for callers as a distinct value */
|
||||
#define PNG_FP_NEGATIVE 128 /* A negative number, including "-0" */
|
||||
#define PNG_FP_NONZERO 256 /* A non-zero value */
|
||||
#define PNG_FP_STICKY 448 /* The above three flags */
|
||||
|
||||
/* This is available for the caller to store in 'state' if required. Do not
|
||||
* call the parser after setting it (the parser sometimes clears it.)
|
||||
*/
|
||||
#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */
|
||||
|
||||
/* Result codes for the parser (boolean - true meants ok, false means
|
||||
* not ok yet.)
|
||||
@@ -1237,6 +1352,20 @@ PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr,
|
||||
#define PNG_FP_MAYBE 0 /* The number may be valid in the future */
|
||||
#define PNG_FP_OK 1 /* The number is valid */
|
||||
|
||||
/* Tests on the sticky non-zero and negative flags. To pass these checks
|
||||
* the state must also indicate that the whole number is valid - this is
|
||||
* achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this
|
||||
* is equivalent to PNG_FP_OK above.)
|
||||
*/
|
||||
#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)
|
||||
/* NZ_MASK: the string is valid and a non-zero negative value */
|
||||
#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)
|
||||
/* Z MASK: the string is valid and a non-zero value. */
|
||||
/* PNG_FP_SAW_DIGIT: the string is valid. */
|
||||
#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)
|
||||
#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)
|
||||
#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)
|
||||
|
||||
/* The actual parser. This can be called repeatedly, it updates
|
||||
* the index into the string and the state variable (which must
|
||||
* be initialzed to 0). It returns a result code, as above. There
|
||||
@@ -1256,7 +1385,10 @@ PNG_EXTERN int png_check_fp_number PNGARG((png_const_charp string,
|
||||
png_size_t size, int *statep, png_size_tp whereami));
|
||||
|
||||
/* This is the same but it checks a complete string and returns true
|
||||
* only if it just contains a floating point number.
|
||||
* only if it just contains a floating point number. As of 1.5.4 this
|
||||
* function also returns the state at the end of parsing the number if
|
||||
* it was valid (otherwise it returns 0.) This can be used for testing
|
||||
* for negative or zero values using the sticky flag.
|
||||
*/
|
||||
PNG_EXTERN int png_check_fp_string PNGARG((png_const_charp string,
|
||||
png_size_t size));
|
||||
|
||||
20
pngread.c
20
pngread.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
@@ -1286,9 +1286,23 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
/* -------------- image transformations start here ------------------- */
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
/* Tell libpng to strip 16-bit/color files down to 8 bits per color.
|
||||
*/
|
||||
if (transforms & PNG_TRANSFORM_SCALE_16)
|
||||
{
|
||||
/* Added at libpng-1.5.4. "strip_16" produces the same result that it
|
||||
* did in earlier versions, while "scale_16" is now more accurate.
|
||||
*/
|
||||
png_set_scale_16(png_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
/* If both SCALE and STRIP are required pngrtran will effectively cancel the
|
||||
* latter by doing SCALE first. This is ok and allows apps not to check for
|
||||
* which is supported to get the right answer.
|
||||
*/
|
||||
if (transforms & PNG_TRANSFORM_STRIP_16)
|
||||
png_set_strip_16(png_ptr);
|
||||
#endif
|
||||
@@ -1387,7 +1401,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
#endif
|
||||
|
||||
/* Added at libpng-1.5.3 */
|
||||
/* Added at libpng-1.5.4 */
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
if (transforms & PNG_TRANSFORM_EXPAND_16)
|
||||
png_set_expand_16(png_ptr);
|
||||
|
||||
641
pngrtran.c
641
pngrtran.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.5 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
@@ -132,8 +132,25 @@ png_set_background(png_structp png_ptr,
|
||||
# endif /* FLOATING_POINT */
|
||||
#endif /* READ_BACKGROUND */
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
/* Scale 16-bit depth files to 8-bit depth */
|
||||
/* Scale 16-bit depth files to 8-bit depth. If both of these are set then the
|
||||
* one that pngrtran does first (scale) happens. This is necessary to allow the
|
||||
* TRANSFORM and API behavior to be somewhat consistent, and it's simpler.
|
||||
*/
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_scale_16(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_scale_16");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_SCALE_16_TO_8;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
/* Chop 16-bit depth files to 8-bit depth */
|
||||
void PNGAPI
|
||||
png_set_strip_16(png_structp png_ptr)
|
||||
{
|
||||
@@ -143,26 +160,8 @@ png_set_strip_16(png_structp png_ptr)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_16_TO_8;
|
||||
#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
|
||||
png_ptr->transformations &= ~PNG_CHOP_16_TO_8;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
|
||||
/* Chop 16-bit depth files to 8-bit depth */
|
||||
void PNGAPI
|
||||
png_set_chop_16(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_chop_16");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_CHOP_16_TO_8;
|
||||
png_ptr->transformations &= ~PNG_16_TO_8;
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_16_TO_8_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
void PNGAPI
|
||||
@@ -775,12 +774,12 @@ png_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma,
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* New in libpng-1.5.3 - reserve particular negative values as flags. */
|
||||
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
|
||||
scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);
|
||||
file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);
|
||||
|
||||
#if PNG_LIBPNG_VER >= 10600
|
||||
/* Checking the gamma values for being >0 was added in 1.5.3 along with the
|
||||
/* Checking the gamma values for being >0 was added in 1.5.4 along with the
|
||||
* premultiplied alpha support; this actually hides an undocumented feature
|
||||
* of the previous implementation which allowed gamma processing to be
|
||||
* disabled in background handling. There is no evidence (so far) that this
|
||||
@@ -969,13 +968,17 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
||||
{
|
||||
png_uint_16 red_int, green_int;
|
||||
|
||||
/* NOTE: this calculation does not round, but this behavior is retained
|
||||
* for consistency, the inaccuracy is very small. The code here always
|
||||
* overwrites the coefficients, regardless of whether they have been
|
||||
* defaulted or set already.
|
||||
*/
|
||||
red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L);
|
||||
green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L);
|
||||
|
||||
png_ptr->rgb_to_gray_red_coeff = red_int;
|
||||
png_ptr->rgb_to_gray_green_coeff = green_int;
|
||||
png_ptr->rgb_to_gray_blue_coeff =
|
||||
(png_uint_16)(32768 - red_int - green_int);
|
||||
png_ptr->rgb_to_gray_coefficients_set = 1;
|
||||
}
|
||||
|
||||
else
|
||||
@@ -984,17 +987,18 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
||||
png_warning(png_ptr,
|
||||
"ignoring out of range rgb_to_gray coefficients");
|
||||
|
||||
/* Use the defaults, from the cHRM chunk if set, else the built in Rec
|
||||
* 709 values (which correspond to sRGB, so we don't have to worry
|
||||
* about the sRGB chunk!)
|
||||
/* Use the defaults, from the cHRM chunk if set, else the historical
|
||||
* values which are close to the sRGB/HDTV/ITU-Rec 709 values. See
|
||||
* png_do_rgb_to_gray for more discussion of the values. In this case
|
||||
* the coefficients are not marked as 'set' and are not overwritten if
|
||||
* something has already provided a default.
|
||||
*/
|
||||
if (png_ptr->rgb_to_gray_red_coeff == 0 &&
|
||||
png_ptr->rgb_to_gray_green_coeff == 0 &&
|
||||
png_ptr->rgb_to_gray_blue_coeff == 0)
|
||||
png_ptr->rgb_to_gray_green_coeff == 0)
|
||||
{
|
||||
png_ptr->rgb_to_gray_red_coeff = 6968; /* .212671 * 32768 + .5 */
|
||||
png_ptr->rgb_to_gray_green_coeff = 23434; /* .715160 * 32768 + .5 */
|
||||
png_ptr->rgb_to_gray_blue_coeff = 2366;
|
||||
png_ptr->rgb_to_gray_red_coeff = 6968;
|
||||
png_ptr->rgb_to_gray_green_coeff = 23434;
|
||||
/* png_ptr->rgb_to_gray_blue_coeff = 2366; */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1155,7 +1159,7 @@ png_init_palette_transformations(png_structp png_ptr)
|
||||
static void /* PRIVATE */
|
||||
png_init_rgb_transformations(png_structp png_ptr)
|
||||
{
|
||||
/* Added to libpng-1.5.3: check the color type to determine whether there
|
||||
/* Added to libpng-1.5.4: check the color type to determine whether there
|
||||
* is any alpha or transparency in the image and simply cancel the
|
||||
* background and alpha mode stuff if there isn't.
|
||||
*/
|
||||
@@ -1260,9 +1264,9 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
*/
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
/* Prior to 1.5.3 these tests were performed from png_set_gamma, 1.5.3 adds
|
||||
/* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds
|
||||
* png_set_alpha_mode and this is another source for a default file gamma so
|
||||
* the test needs to be performed later - here. In addition prior to 1.5.3
|
||||
* the test needs to be performed later - here. In addition prior to 1.5.4
|
||||
* the tests were repeated for the PALETTE color type here - this is no
|
||||
* longer necessary (and doesn't seem to have been necessary before.)
|
||||
*/
|
||||
@@ -1287,7 +1291,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
|
||||
else if (png_ptr->screen_gamma != 0)
|
||||
/* The converse - assume the file matches the screen, note that this
|
||||
* perhaps undesireable default can (from 1.5.3) be changed by calling
|
||||
* perhaps undesireable default can (from 1.5.4) be changed by calling
|
||||
* png_set_alpha_mode (even if the alpha handling mode isn't required
|
||||
* or isn't changed from the default.)
|
||||
*/
|
||||
@@ -1297,7 +1301,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
/* Just in case the following prevents any processing - file and screen
|
||||
* are both assumed to be linear and there is no way to introduce a
|
||||
* third gamma value other than png_set_background with 'UNIQUE', and,
|
||||
* prior to 1.5.3
|
||||
* prior to 1.5.4
|
||||
*/
|
||||
png_ptr->screen_gamma = png_ptr->gamma = PNG_FP_1;
|
||||
|
||||
@@ -1330,20 +1334,21 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
* 6) PNG_GAMMA
|
||||
* 7) PNG_STRIP_ALPHA (if compose)
|
||||
* 8) PNG_ENCODE_ALPHA
|
||||
* 9) PNG_16_TO_8 or PNG_CHOP_16_TO_8 (strip16/chop16)
|
||||
* 10) PNG_QUANTIZE (converts to palette)
|
||||
* 11) PNG_EXPAND_16
|
||||
* 12) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY
|
||||
* 13) PNG_INVERT_MONO
|
||||
* 14) PNG_SHIFT
|
||||
* 15) PNG_PACK
|
||||
* 16) PNG_BGR
|
||||
* 17) PNG_PACKSWAP
|
||||
* 18) PNG_FILLER (includes PNG_ADD_ALPHA)
|
||||
* 19) PNG_INVERT_ALPHA
|
||||
* 20) PNG_SWAP_ALPHA
|
||||
* 21) PNG_SWAP_BYTES
|
||||
* 22) PNG_USER_TRANSFORM [must be last]
|
||||
* 9) PNG_SCALE_16_TO_8
|
||||
* 10) PNG_16_TO_8
|
||||
* 11) PNG_QUANTIZE (converts to palette)
|
||||
* 12) PNG_EXPAND_16
|
||||
* 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY
|
||||
* 14) PNG_INVERT_MONO
|
||||
* 15) PNG_SHIFT
|
||||
* 16) PNG_PACK
|
||||
* 17) PNG_BGR
|
||||
* 18) PNG_PACKSWAP
|
||||
* 19) PNG_FILLER (includes PNG_ADD_ALPHA)
|
||||
* 20) PNG_INVERT_ALPHA
|
||||
* 21) PNG_SWAP_ALPHA
|
||||
* 22) PNG_SWAP_BYTES
|
||||
* 23) PNG_USER_TRANSFORM [must be last]
|
||||
*/
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||
@@ -1358,12 +1363,12 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
PNG_EXPAND_tRNS);
|
||||
png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
|
||||
|
||||
/* Kill the tRNS chunk itself too. Prior to 1.5.3 this did not happen
|
||||
/* Kill the tRNS chunk itself too. Prior to 1.5.4 this did not happen
|
||||
* so transparency information would remain just so long as it wasn't
|
||||
* expanded. This produces unexpected API changes if the set of things
|
||||
* that do PNG_EXPAND_tRNS changes (perfectly possible given the
|
||||
* documentation - which says ask for what you want, accept what you
|
||||
* get.) This makes the behavior consistent from 1.5.3:
|
||||
* get.) This makes the behavior consistent from 1.5.4:
|
||||
*/
|
||||
png_ptr->num_trans = 0;
|
||||
}
|
||||
@@ -1401,7 +1406,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)
|
||||
{
|
||||
/* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if
|
||||
* the file was greyscale the background value is gray.
|
||||
* the file was grayscale the background value is gray.
|
||||
*/
|
||||
if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
|
||||
png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
|
||||
@@ -1456,28 +1461,16 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
*
|
||||
* The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at
|
||||
* present, so that case is ok (until do_expand_16 is moved.)
|
||||
*
|
||||
* NOTE: this discards the low 16 bits of the user supplied background
|
||||
* color, but until expand_16 works properly there is no choice!
|
||||
*/
|
||||
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
{
|
||||
# define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16))
|
||||
CHOP(png_ptr->background.red);
|
||||
CHOP(png_ptr->background.green);
|
||||
CHOP(png_ptr->background.blue);
|
||||
CHOP(png_ptr->background.gray);
|
||||
# undef CHOP
|
||||
}
|
||||
#ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
|
||||
else /* Use pre-libpng-1.5.4 inaccurate "ACCURATE" scaling */
|
||||
{
|
||||
# define CHOP(x) (x)=((png_uint_16)((2*(png_uint_32)(x) + 257)/514))
|
||||
CHOP(png_ptr->background.red);
|
||||
CHOP(png_ptr->background.green);
|
||||
CHOP(png_ptr->background.blue);
|
||||
CHOP(png_ptr->background.gray);
|
||||
# undef CHOP
|
||||
}
|
||||
#endif /* PNG_READ_CHOP_16_TO_8_SUPPORTED */
|
||||
}
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */
|
||||
|
||||
@@ -1485,7 +1478,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
* background support (see the comments in scripts/pnglibconf.dfa), this
|
||||
* allows pre-multiplication of the alpha channel to be implemented as
|
||||
* compositing on black. This is probably sub-optimal and has been done in
|
||||
* 1.5.3 betas simply to enable external critique and testing (i.e. to
|
||||
* 1.5.4 betas simply to enable external critique and testing (i.e. to
|
||||
* implement the new API quickly, without lots of internal changes.)
|
||||
*/
|
||||
|
||||
@@ -1504,7 +1497,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
* the gamma tables will not be built even if composition is required on a
|
||||
* gamma encoded value.
|
||||
*
|
||||
* In 1.5.3 this is addressed below by an additional check on the individual
|
||||
* In 1.5.4 this is addressed below by an additional check on the individual
|
||||
* file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the
|
||||
* tables.
|
||||
*/
|
||||
@@ -1515,9 +1508,11 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
|| ((png_ptr->transformations & PNG_COMPOSE)
|
||||
&& (png_gamma_significant(png_ptr->gamma)
|
||||
|| png_gamma_significant(png_ptr->screen_gamma)
|
||||
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
|
||||
&& png_gamma_significant(png_ptr->background_gamma))))
|
||||
|| ((png_ptr->transformations & PNG_ENCODE_ALPHA)
|
||||
&& png_gamma_significant(png_ptr->background_gamma))
|
||||
# endif
|
||||
)) || ((png_ptr->transformations & PNG_ENCODE_ALPHA)
|
||||
&& png_gamma_significant(png_ptr->screen_gamma))
|
||||
)
|
||||
{
|
||||
@@ -1870,7 +1865,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
/* The following used to be conditional on PNG_GAMMA (prior to 1.5.3),
|
||||
/* The following used to be conditional on PNG_GAMMA (prior to 1.5.4),
|
||||
* however it seems that the code in png_init_read_transformations, which has
|
||||
* been called before this from png_read_update_info->png_read_start_row
|
||||
* sometimes does the gamma transform and cancels the flag.
|
||||
@@ -1878,21 +1873,43 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
info_ptr->gamma = png_ptr->gamma;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
#ifdef PNG_READ_16BIT_SUPPORTED
|
||||
if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_CHOP_16_TO_8)) &&
|
||||
(info_ptr->bit_depth == 16))
|
||||
info_ptr->bit_depth = 8;
|
||||
#else
|
||||
/* Force chopping 16-bit input down to 8 */
|
||||
if (info_ptr->bit_depth == 16)
|
||||
{
|
||||
if (!(png_ptr->transformations & PNG_CHOP_16_TO_8))
|
||||
png_ptr->transformations |=PNG_16_TO_8;
|
||||
info_ptr->bit_depth = 8;
|
||||
# ifdef PNG_READ_16BIT_SUPPORTED
|
||||
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SCALE_16_TO_8)
|
||||
info_ptr->bit_depth = 8;
|
||||
# endif
|
||||
|
||||
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
info_ptr->bit_depth = 8;
|
||||
# endif
|
||||
|
||||
# else
|
||||
/* No 16 bit support: force chopping 16-bit input down to 8, in this case
|
||||
* the app program can chose if both APIs are available by setting the
|
||||
* correct scaling to use.
|
||||
*/
|
||||
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
/* For compatibility with previous versions use the strip method by
|
||||
* default. This code works because if PNG_SCALE_16_TO_8 is already
|
||||
* set the code below will do that in preference to the chop.
|
||||
*/
|
||||
png_ptr->transformations |= PNG_16_TO_8;
|
||||
info_ptr->bit_depth = 8;
|
||||
# else
|
||||
|
||||
# if PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
png_ptr->transformations |= PNG_SCALE_16_TO_8;
|
||||
info_ptr->bit_depth = 8;
|
||||
# else
|
||||
|
||||
CONFIGURATION ERROR: you must enable at least one 16 to 8 method
|
||||
# endif
|
||||
# endif
|
||||
#endif /* !READ_16BIT_SUPPORTED */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
|
||||
@@ -1979,7 +1996,7 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
|
||||
|
||||
/* Adding in 1.5.3: cache the above value in png_struct so that we can later
|
||||
/* Adding in 1.5.4: cache the above value in png_struct so that we can later
|
||||
* check in png_rowbytes that the user buffer won't get overwritten. Note
|
||||
* that the field is not always set - if png_read_update_info isn't called
|
||||
* the application has to either not do any transforms or get the calculation
|
||||
@@ -2004,15 +2021,15 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
|
||||
if (png_ptr->row_buf == NULL)
|
||||
{
|
||||
/* Prior to 1.5.3 this output row/pass where the NULL pointer is, but this
|
||||
/* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this
|
||||
* error is incredibly rare and incredibly easy to debug without this
|
||||
* information.
|
||||
*/
|
||||
png_error(png_ptr, "NULL row buffer");
|
||||
}
|
||||
|
||||
/* The following is debugging; prior to 1.5.3 the code was never compiled in;
|
||||
* in 1.5.3 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
|
||||
/* The following is debugging; prior to 1.5.4 the code was never compiled in;
|
||||
* in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
|
||||
* PNG_WARN_UNINITIALIZED_ROW removed. In 1.5 the new flag is set only for
|
||||
* selected new APIs to ensure that there is no API change.
|
||||
*/
|
||||
@@ -2021,7 +2038,7 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
/* Application has failed to call either png_read_start_image() or
|
||||
* png_read_update_info() after setting transforms that expand pixels.
|
||||
* This check added to libpng-1.2.19 (but not enabled until 1.5.3).
|
||||
* This check added to libpng-1.2.19 (but not enabled until 1.5.4).
|
||||
*/
|
||||
png_error(png_ptr, "Uninitialized row");
|
||||
}
|
||||
@@ -2152,13 +2169,18 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
png_do_encode_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SCALE_16_TO_8)
|
||||
png_do_scale_16_to_8(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
# ifdef PNG_READ_CHOP_16_TO_8_SUPPORTED
|
||||
else if (png_ptr->transformations & PNG_CHOP_16_TO_8)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
/* There is no harm in doing both of these because only one has any effect,
|
||||
* by putting the 'scale' option first if the app asks for scale (either by
|
||||
* calling the API or in a TRANSFORM flag) this is what happens.
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
@@ -2183,7 +2205,7 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
/*NOTE: moved here in 1.5.3 (from much later in this list.) */
|
||||
/*NOTE: moved here in 1.5.4 (from much later in this list.) */
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
@@ -2487,7 +2509,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
/* Scale rows of bit depth 16 down to 8 accurately */
|
||||
void /* PRIVATE */
|
||||
png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
|
||||
@@ -2544,7 +2566,9 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
|
||||
row_info->rowbytes = row_info->width * row_info->channels;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
/* Simply discard the low byte. This was the default behavior prior
|
||||
* to libpng-1.5.4.
|
||||
@@ -2561,8 +2585,8 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
|
||||
while (sp < ep)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
sp++;
|
||||
*dp++ = *sp;
|
||||
sp += 2; /* skip low byte */
|
||||
}
|
||||
|
||||
row_info->bit_depth = 8;
|
||||
@@ -2570,7 +2594,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
row_info->rowbytes = row_info->width * row_info->channels;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_16_TO_8_SUPPORTED */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
@@ -3047,33 +3071,61 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* Reduce RGB files to grayscale, with or without alpha
|
||||
* using the equation given in Poynton's ColorFAQ at
|
||||
* <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008)
|
||||
* New link:
|
||||
* <http://www.poynton.com/notes/colour_and_gamma/>
|
||||
* using the equation given in Poynton's ColorFAQ of 1998-01-04 at
|
||||
* <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008 but
|
||||
* versions dated 1998 through November 2002 have been archived at
|
||||
* http://web.archive.org/web/20000816232553/http://www.inforamp.net/
|
||||
* ~poynton/notes/colour_and_gamma/ColorFAQ.txt )
|
||||
* Charles Poynton poynton at poynton.com
|
||||
*
|
||||
* Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
|
||||
*
|
||||
* We approximate this with
|
||||
*
|
||||
* Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
|
||||
*
|
||||
* which can be expressed with integers as
|
||||
*
|
||||
* Y = (6969 * R + 23434 * G + 2365 * B)/32768
|
||||
*
|
||||
* The calculation is to be done in a linear colorspace.
|
||||
* Poynton's current link (as of January 2003 through July 2011):
|
||||
* <http://www.poynton.com/notes/colour_and_gamma/>
|
||||
* has changed the numbers slightly:
|
||||
*
|
||||
* Other integer coefficents can be used via png_set_rgb_to_gray().
|
||||
* Y = 0.2126*R + 0.7152*G + 0.0722*B
|
||||
*
|
||||
* which can be expressed with integers as
|
||||
*
|
||||
* Y = (6966 * R + 23436 * G + 2366 * B)/32768
|
||||
*
|
||||
* Historically, however, libpng uses numbers derived from the ITU-R Rec 709
|
||||
* end point chromaticities and the D65 white point. Depending on the
|
||||
* precision used for the D65 white point this produces a variety of different
|
||||
* numbers, however if the four decimal place value used in ITU-R Rec 709 is
|
||||
* used (0.3127,0.3290) the Y calculation would be:
|
||||
*
|
||||
* Y = (6968 * R + 23435 * G + 2366 * B)/32768
|
||||
*
|
||||
* While this is correct the rounding results in an overflow for white, because
|
||||
* the sum of the rounded coefficients is 32769, not 32768. Consequently
|
||||
* libpng uses, instead, the closest non-overflowing approximation:
|
||||
*
|
||||
* Y = (6968 * R + 23434 * G + 2366 * B)/32768
|
||||
*
|
||||
* Starting with libpng-1.5.5, if the image being converted has a cHRM chunk
|
||||
* (including an sRGB chunk) then the chromaticities are used to calculate the
|
||||
* coefficients. See the chunk handling in pngrutil.c for more information.
|
||||
*
|
||||
* In all cases the calculation is to be done in a linear colorspace. If no
|
||||
* gamma information is available to correct the encoding of the original RGB
|
||||
* values this results in an implicit assumption that the original PNG RGB
|
||||
* values were linear.
|
||||
*
|
||||
* Other integer coefficents can be used via png_set_rgb_to_gray(). Because
|
||||
* the API takes just red and green coefficients the blue coefficient is
|
||||
* calculated to make the sum 32768. This will result in different rounding
|
||||
* to that used above.
|
||||
*/
|
||||
int /* PRIVATE */
|
||||
png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
{
|
||||
png_uint_32 i;
|
||||
|
||||
png_uint_32 row_width = row_info->width;
|
||||
int rgb_error = 0;
|
||||
|
||||
png_debug(1, "in png_do_rgb_to_gray");
|
||||
@@ -3081,234 +3133,179 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff;
|
||||
PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
PNG_CONST png_uint_32 bc = 32768 - rc - gc;
|
||||
PNG_CONST png_uint_32 row_width = row_info->width;
|
||||
PNG_CONST int have_alpha =
|
||||
(row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
|
||||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)
|
||||
/* Notice that gamma to/from 1 are not necessarily inverses (if
|
||||
* there is an overall gamma correction). Prior to 1.5.5 this code
|
||||
* checked the linearized values for equality; this doesn't match
|
||||
* the documentation, the original values must be checked.
|
||||
*/
|
||||
if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
png_byte red = *(sp++);
|
||||
png_byte green = *(sp++);
|
||||
png_byte blue = *(sp++);
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
if (red != green || red != blue)
|
||||
{
|
||||
png_byte red = png_ptr->gamma_to_1[*(sp++)];
|
||||
png_byte green = png_ptr->gamma_to_1[*(sp++)];
|
||||
png_byte blue = png_ptr->gamma_to_1[*(sp++)];
|
||||
red = png_ptr->gamma_to_1[red];
|
||||
green = png_ptr->gamma_to_1[green];
|
||||
blue = png_ptr->gamma_to_1[blue];
|
||||
|
||||
if (red != green || red != blue)
|
||||
{
|
||||
rgb_error |= 1;
|
||||
*(dp++) = png_ptr->gamma_from_1[
|
||||
(rc*red + gc*green + bc*blue)>>15];
|
||||
}
|
||||
|
||||
else
|
||||
*(dp++) = *(sp - 1);
|
||||
rgb_error |= 1;
|
||||
*(dp++) = png_ptr->gamma_from_1[
|
||||
(rc*red + gc*green + bc*blue + 16384)>>15];
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
for (i = 0; i < row_width; i++)
|
||||
|
||||
else
|
||||
{
|
||||
png_byte red = *(sp++);
|
||||
png_byte green = *(sp++);
|
||||
png_byte blue = *(sp++);
|
||||
/* If there is no overall correction the table will not be
|
||||
* set.
|
||||
*/
|
||||
if (png_ptr->gamma_table != NULL)
|
||||
red = png_ptr->gamma_table[red];
|
||||
|
||||
if (red != green || red != blue)
|
||||
{
|
||||
rgb_error |= 1;
|
||||
*(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
|
||||
}
|
||||
|
||||
else
|
||||
*(dp++) = *(sp - 1);
|
||||
*(dp++) = red;
|
||||
}
|
||||
|
||||
if (have_alpha)
|
||||
*(dp++) = *(sp++);
|
||||
}
|
||||
}
|
||||
|
||||
else /* RGB bit_depth == 16 */
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->gamma_16_to_1 != NULL &&
|
||||
png_ptr->gamma_16_from_1 != NULL)
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
for (i = 0; i < row_width; i++)
|
||||
png_byte red = *(sp++);
|
||||
png_byte green = *(sp++);
|
||||
png_byte blue = *(sp++);
|
||||
|
||||
if (red != green || red != blue)
|
||||
{
|
||||
png_uint_16 red, green, blue, w;
|
||||
rgb_error |= 1;
|
||||
/*NOTE: this is the historical approach which simply
|
||||
* truncates the results.
|
||||
*/
|
||||
*(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
|
||||
}
|
||||
|
||||
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
else
|
||||
*(dp++) = red;
|
||||
|
||||
if (red == green && red == blue)
|
||||
w = red;
|
||||
if (have_alpha)
|
||||
*(dp++) = *(sp++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff)
|
||||
else /* RGB bit_depth == 16 */
|
||||
{
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL)
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_uint_16 red, green, blue, w;
|
||||
|
||||
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
|
||||
if (red == green && red == blue)
|
||||
{
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
w = png_ptr->gamma_16_table[(red&0xff)
|
||||
>> png_ptr->gamma_shift][red>>8];
|
||||
png_uint_16 green_1 =
|
||||
png_ptr->gamma_16_to_1[(green&0xff) >>
|
||||
png_ptr->gamma_shift][green>>8];
|
||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff)
|
||||
>> png_ptr->gamma_shift][blue>>8];
|
||||
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
|
||||
+ bc*blue_1)>>15);
|
||||
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
||||
png_ptr->gamma_shift][gray16 >> 8];
|
||||
rgb_error |= 1;
|
||||
}
|
||||
|
||||
*(dp++) = (png_byte)((w>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(w & 0xff);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_uint_16 red, green, blue, gray16;
|
||||
|
||||
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
|
||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(gray16 & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_byte red = png_ptr->gamma_to_1[*(sp++)];
|
||||
png_byte green = png_ptr->gamma_to_1[*(sp++)];
|
||||
png_byte blue = png_ptr->gamma_to_1[*(sp++)];
|
||||
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
|
||||
*(dp++) = png_ptr->gamma_from_1
|
||||
[(rc*red + gc*green + bc*blue)>>15];
|
||||
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_byte red = *(sp++);
|
||||
png_byte green = *(sp++);
|
||||
png_byte blue = *(sp++);
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
|
||||
*(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* RGBA bit_depth == 16 */
|
||||
{
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->gamma_16_to_1 != NULL &&
|
||||
png_ptr->gamma_16_from_1 != NULL)
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_uint_16 red, green, blue, w;
|
||||
|
||||
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
|
||||
if (red == green && red == blue)
|
||||
w = red;
|
||||
|
||||
else
|
||||
{
|
||||
png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >>
|
||||
png_ptr->gamma_shift][red>>8];
|
||||
w = red;
|
||||
}
|
||||
|
||||
png_uint_16 green_1 =
|
||||
png_ptr->gamma_16_to_1[(green&0xff) >>
|
||||
png_ptr->gamma_shift][green>>8];
|
||||
else
|
||||
{
|
||||
png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff)
|
||||
>> png_ptr->gamma_shift][red>>8];
|
||||
png_uint_16 green_1 =
|
||||
png_ptr->gamma_16_to_1[(green&0xff) >>
|
||||
png_ptr->gamma_shift][green>>8];
|
||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff)
|
||||
>> png_ptr->gamma_shift][blue>>8];
|
||||
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
|
||||
+ bc*blue_1 + 16384)>>15);
|
||||
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
||||
png_ptr->gamma_shift][gray16 >> 8];
|
||||
rgb_error |= 1;
|
||||
}
|
||||
|
||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
|
||||
png_ptr->gamma_shift][blue>>8];
|
||||
*(dp++) = (png_byte)((w>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(w & 0xff);
|
||||
|
||||
png_uint_16 gray16 = (png_uint_16)((rc * red_1
|
||||
+ gc * green_1 + bc * blue_1)>>15);
|
||||
|
||||
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
||||
png_ptr->gamma_shift][gray16 >> 8];
|
||||
|
||||
rgb_error |= 1;
|
||||
}
|
||||
|
||||
*(dp++) = (png_byte)((w>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(w & 0xff);
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
if (have_alpha)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
for (i = 0; i < row_width; i++)
|
||||
png_uint_16 red, green, blue, gray16;
|
||||
|
||||
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
|
||||
/* From 1.5.5 in the 16 bit case do the accurate convertion even
|
||||
* in the 'fast' case - this is because this is where the code
|
||||
* ends up when handling linear 16 bit data.
|
||||
*/
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>
|
||||
15);
|
||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(gray16 & 0xff);
|
||||
|
||||
if (have_alpha)
|
||||
{
|
||||
png_uint_16 red, green, blue, gray16;
|
||||
red = (png_uint_16)((*(sp)<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)((*(sp)<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)((*(sp)<<8) | *(sp + 1)); sp += 2;
|
||||
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
|
||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(gray16 & 0xff);
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
row_info->channels -= 2;
|
||||
row_info->color_type = (png_byte)(row_info->color_type &
|
||||
~PNG_COLOR_MASK_COLOR);
|
||||
@@ -4464,7 +4461,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
{
|
||||
if (trans_alpha != NULL)
|
||||
if (num_trans > 0)
|
||||
{
|
||||
sp = row + (png_size_t)row_width - 1;
|
||||
dp = row + (png_size_t)(row_width << 2) - 1;
|
||||
@@ -4518,7 +4515,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
png_const_color_16p trans_value)
|
||||
png_const_color_16p trans_color)
|
||||
{
|
||||
int shift, value;
|
||||
png_bytep sp, dp;
|
||||
@@ -4530,7 +4527,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0);
|
||||
png_uint_16 gray = (png_uint_16)(trans_color ? trans_color->gray : 0);
|
||||
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
@@ -4622,7 +4619,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
row_info->rowbytes = row_width;
|
||||
}
|
||||
|
||||
if (trans_value != NULL)
|
||||
if (trans_color != NULL)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
@@ -4674,13 +4671,13 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
row_width);
|
||||
}
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value)
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_byte red = (png_byte)(trans_value->red & 0xff);
|
||||
png_byte green = (png_byte)(trans_value->green & 0xff);
|
||||
png_byte blue = (png_byte)(trans_value->blue & 0xff);
|
||||
png_byte red = (png_byte)(trans_color->red & 0xff);
|
||||
png_byte green = (png_byte)(trans_color->green & 0xff);
|
||||
png_byte blue = (png_byte)(trans_color->blue & 0xff);
|
||||
sp = row + (png_size_t)row_info->rowbytes - 1;
|
||||
dp = row + (png_size_t)(row_width << 2) - 1;
|
||||
for (i = 0; i < row_width; i++)
|
||||
@@ -4698,12 +4695,12 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_byte red_high = (png_byte)((trans_value->red >> 8) & 0xff);
|
||||
png_byte green_high = (png_byte)((trans_value->green >> 8) & 0xff);
|
||||
png_byte blue_high = (png_byte)((trans_value->blue >> 8) & 0xff);
|
||||
png_byte red_low = (png_byte)(trans_value->red & 0xff);
|
||||
png_byte green_low = (png_byte)(trans_value->green & 0xff);
|
||||
png_byte blue_low = (png_byte)(trans_value->blue & 0xff);
|
||||
png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff);
|
||||
png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff);
|
||||
png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff);
|
||||
png_byte red_low = (png_byte)(trans_color->red & 0xff);
|
||||
png_byte green_low = (png_byte)(trans_color->green & 0xff);
|
||||
png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
|
||||
sp = row + row_info->rowbytes - 1;
|
||||
dp = row + (png_size_t)(row_width << 3) - 1;
|
||||
for (i = 0; i < row_width; i++)
|
||||
@@ -4743,7 +4740,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
/* If the bit depth is 8 and the colour type is not a palette type expand the
|
||||
/* If the bit depth is 8 and the color type is not a palette type expand the
|
||||
* whole row to 16 bits. Has no effect otherwise.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
|
||||
149
pngrutil.c
149
pngrutil.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.5 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
@@ -458,7 +458,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
||||
{
|
||||
/* Success (maybe) - really uncompress the chunk. */
|
||||
png_size_t new_size = 0;
|
||||
png_charp text = png_malloc_warn(png_ptr,
|
||||
png_charp text = (png_charp)png_malloc_warn(png_ptr,
|
||||
prefix_size + expanded_size + 1);
|
||||
|
||||
if (text != NULL)
|
||||
@@ -501,7 +501,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
||||
* amount of compressed data.
|
||||
*/
|
||||
{
|
||||
png_charp text = png_malloc_warn(png_ptr, prefix_size + 1);
|
||||
png_charp text = (png_charp)png_malloc_warn(png_ptr, prefix_size + 1);
|
||||
|
||||
if (text != NULL)
|
||||
{
|
||||
@@ -1022,27 +1022,80 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* Store the _white values as default coefficients for the rgb to gray
|
||||
* operation if it is supported.
|
||||
* operation if it is supported. Check if the transform is already set to
|
||||
* avoid destroying the transform values.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == 0)
|
||||
if (!png_ptr->rgb_to_gray_coefficients_set)
|
||||
{
|
||||
/* png_set_background has not been called, the coefficients must be in
|
||||
* range for the following to work without overflow.
|
||||
/* png_set_background has not been called and we haven't seen an sRGB
|
||||
* chunk yet. Find the XYZ of the three end points.
|
||||
*/
|
||||
if (y_red <= (1<<17) && y_green <= (1<<17) && y_blue <= (1<<17))
|
||||
{
|
||||
/* The y values are chromaticities: Y/X+Y+Z, the weights for the gray
|
||||
* transformation are simply the normalized Y values for red, green and
|
||||
* blue scaled by 32768.
|
||||
*/
|
||||
png_uint_32 w = y_red + y_green + y_blue;
|
||||
png_XYZ XYZ;
|
||||
png_xy xy;
|
||||
|
||||
png_ptr->rgb_to_gray_red_coeff = (png_uint_16)(((png_uint_32)y_red *
|
||||
32768)/w);
|
||||
png_ptr->rgb_to_gray_green_coeff = (png_uint_16)(((png_uint_32)y_green
|
||||
* 32768)/w);
|
||||
png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(((png_uint_32)y_blue *
|
||||
32768)/w);
|
||||
xy.redx = x_red;
|
||||
xy.redy = y_red;
|
||||
xy.greenx = x_green;
|
||||
xy.greeny = y_green;
|
||||
xy.bluex = x_blue;
|
||||
xy.bluey = y_blue;
|
||||
xy.whitex = x_white;
|
||||
xy.whitey = y_white;
|
||||
|
||||
if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
|
||||
{
|
||||
/* The success case, because XYZ_from_xy normalises to a reference
|
||||
* white Y of 1.0 we just need to scale the numbers. This should
|
||||
* always work just fine. It is an internal error if this overflows.
|
||||
*/
|
||||
{
|
||||
png_fixed_point r, g, b;
|
||||
if (png_muldiv(&r, XYZ.redY, 32768, PNG_FP_1) &&
|
||||
r >= 0 && r <= 32768 &&
|
||||
png_muldiv(&g, XYZ.greenY, 32768, PNG_FP_1) &&
|
||||
g >= 0 && g <= 32768 &&
|
||||
png_muldiv(&b, XYZ.blueY, 32768, PNG_FP_1) &&
|
||||
b >= 0 && b <= 32768 &&
|
||||
r+g+b <= 32769)
|
||||
{
|
||||
/* We allow 0 coefficients here. r+g+b may be 32769 if two or
|
||||
* all of the coefficients were rounded up. Handle this by
|
||||
* reducing the *largest* coefficient by 1; this matches the
|
||||
* approach used for the default coefficients in pngrtran.c
|
||||
*/
|
||||
int add = 0;
|
||||
|
||||
if (r+g+b > 32768)
|
||||
add = -1;
|
||||
else if (r+g+b < 32768)
|
||||
add = 1;
|
||||
|
||||
if (add != 0)
|
||||
{
|
||||
if (g >= r && g >= b)
|
||||
g += add;
|
||||
else if (r >= g && r >= b)
|
||||
r += add;
|
||||
else
|
||||
b += add;
|
||||
}
|
||||
|
||||
/* Check for an internal error. */
|
||||
if (r+g+b != 32768)
|
||||
png_error(png_ptr,
|
||||
"internal error handling cHRM coefficients");
|
||||
|
||||
png_ptr->rgb_to_gray_red_coeff = (png_uint_16)r;
|
||||
png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g;
|
||||
}
|
||||
|
||||
/* This is a png_error at present even though it could be ignored -
|
||||
* it should never happen, but it is important that if it does, the
|
||||
* bug is fixed.
|
||||
*/
|
||||
else
|
||||
png_error(png_ptr, "internal error handling cHRM->XYZ");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1135,6 +1188,47 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
}
|
||||
#endif /* PNG_READ_cHRM_SUPPORTED */
|
||||
|
||||
/* This is recorded for use when handling the cHRM chunk above. An sRGB
|
||||
* chunk unconditionally overwrites the coefficients for grayscale conversion
|
||||
* too.
|
||||
*/
|
||||
png_ptr->is_sRGB = 1;
|
||||
|
||||
# ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* Don't overwrite user supplied values: */
|
||||
if (!png_ptr->rgb_to_gray_coefficients_set)
|
||||
{
|
||||
/* These numbers come from the sRGB specification (or, since one has to
|
||||
* pay much money to get a copy, the wikipedia sRGB page) the
|
||||
* chromaticity values quoted have been inverted to get the reverse
|
||||
* transformation from RGB to XYZ and the 'Y' coefficients scaled by
|
||||
* 32768 (then rounded).
|
||||
*
|
||||
* sRGB and ITU Rec-709 both truncate the values for the D65 white
|
||||
* point to four digits and, even though it actually stores five
|
||||
* digits, the PNG spec gives the truncated value.
|
||||
*
|
||||
* This means that when the chromaticities are converted back to XYZ
|
||||
* end points we end up with (6968,23435,2366), which, as described in
|
||||
* pngrtran.c, would overflow. If the five digit precision and up is
|
||||
* used we get, instead:
|
||||
*
|
||||
* 6968*R + 23435*G + 2365*B
|
||||
*
|
||||
* (Notice that this rounds the blue coefficient down, rather than the
|
||||
* choice used in pngrtran.c which is to round the green one down.)
|
||||
*/
|
||||
png_ptr->rgb_to_gray_red_coeff = 6968; /* 0.212639005871510 */
|
||||
png_ptr->rgb_to_gray_green_coeff = 23434; /* 0.715168678767756 */
|
||||
/* png_ptr->rgb_to_gray_blue_coeff = 2366; 0.072192315360734 */
|
||||
|
||||
/* The following keeps the cHRM chunk from destroying the
|
||||
* coefficients again in the event that it follows the sRGB chunk.
|
||||
*/
|
||||
png_ptr->rgb_to_gray_coefficients_set = 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent);
|
||||
}
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
@@ -2038,21 +2132,26 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
i = 1;
|
||||
state = 0;
|
||||
|
||||
if (png_ptr->chunkdata[1] == 45 /* negative width */ ||
|
||||
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
|
||||
if (!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
|
||||
i >= slength || png_ptr->chunkdata[i++] != 0)
|
||||
png_warning(png_ptr, "Invalid sCAL chunk ignored: bad width format");
|
||||
|
||||
else if (!PNG_FP_IS_POSITIVE(state))
|
||||
png_warning(png_ptr, "Invalid sCAL chunk ignored: non-positive width");
|
||||
|
||||
else
|
||||
{
|
||||
png_size_t heighti = i;
|
||||
|
||||
state = 0;
|
||||
if (png_ptr->chunkdata[i] == 45 /* negative height */ ||
|
||||
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
|
||||
if (!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
|
||||
i != slength)
|
||||
png_warning(png_ptr, "Invalid sCAL chunk ignored: bad height format");
|
||||
|
||||
else if (!PNG_FP_IS_POSITIVE(state))
|
||||
png_warning(png_ptr,
|
||||
"Invalid sCAL chunk ignored: non-positive height");
|
||||
|
||||
else
|
||||
/* This is the (only) success case. */
|
||||
png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0],
|
||||
@@ -2679,7 +2778,7 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
||||
{
|
||||
png_debug(1, "in png_combine_row");
|
||||
|
||||
/* Added in 1.5.3: the row_info should match the information returned by any
|
||||
/* Added in 1.5.4: the row_info should match the information returned by any
|
||||
* call to png_read_update_info at this point. Do not continue if we got
|
||||
* this wrong.
|
||||
*/
|
||||
|
||||
54
pngset.c
54
pngset.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.5.1 [February 3, 2011]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
@@ -64,6 +64,39 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
void PNGFAPI
|
||||
png_set_cHRM_XYZ_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_fixed_point int_red_X, png_fixed_point int_red_Y,
|
||||
png_fixed_point int_red_Z, png_fixed_point int_green_X,
|
||||
png_fixed_point int_green_Y, png_fixed_point int_green_Z,
|
||||
png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
|
||||
png_fixed_point int_blue_Z)
|
||||
{
|
||||
png_XYZ XYZ;
|
||||
png_xy xy;
|
||||
|
||||
png_debug1(1, "in %s storage function", "cHRM XYZ fixed");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
XYZ.redX = int_red_X;
|
||||
XYZ.redY = int_red_Y;
|
||||
XYZ.redZ = int_red_Z;
|
||||
XYZ.greenX = int_green_X;
|
||||
XYZ.greenY = int_green_Y;
|
||||
XYZ.greenZ = int_green_Z;
|
||||
XYZ.blueX = int_blue_X;
|
||||
XYZ.blueY = int_blue_Y;
|
||||
XYZ.blueZ = int_blue_Z;
|
||||
|
||||
if (png_xy_from_XYZ(&xy, XYZ))
|
||||
png_error(png_ptr, "XYZ values out of representable range");
|
||||
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr, xy.whitex, xy.whitey, xy.redx, xy.redy,
|
||||
xy.greenx, xy.greeny, xy.bluex, xy.bluey);
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
@@ -80,6 +113,23 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
png_fixed(png_ptr, blue_x, "cHRM Blue X"),
|
||||
png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_cHRM_XYZ(png_structp png_ptr, png_infop info_ptr, double red_X,
|
||||
double red_Y, double red_Z, double green_X, double green_Y, double green_Z,
|
||||
double blue_X, double blue_Y, double blue_Z)
|
||||
{
|
||||
png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
|
||||
png_fixed(png_ptr, red_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, red_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, red_Z, "cHRM Red Z"),
|
||||
png_fixed(png_ptr, green_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, green_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, green_Z, "cHRM Red Z"),
|
||||
png_fixed(png_ptr, blue_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
|
||||
}
|
||||
# endif /* PNG_FLOATING_POINT_SUPPORTED */
|
||||
|
||||
#endif /* PNG_cHRM_SUPPORTED */
|
||||
@@ -99,7 +149,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
||||
* possible for 1/gamma to overflow the limit of 21474 and this means the
|
||||
* gamma value must be at least 5/100000 and hence at most 20000.0. For
|
||||
* safety the limits here are a little narrower. The values are 0.00016 to
|
||||
* 6250.0, which are truely ridiculous gammma values (and will produce
|
||||
* 6250.0, which are truly ridiculous gammma values (and will produce
|
||||
* displays that are all black or all white.)
|
||||
*/
|
||||
if (file_gamma < 16 || file_gamma > 625000000)
|
||||
|
||||
21
pngstruct.h
21
pngstruct.h
@@ -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.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -68,7 +68,7 @@ struct png_struct_def
|
||||
uInt zbuf_size; /* size of zbuf (typically 65536) */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Added in 1.5.3: state to keep track of whether the zstream has been
|
||||
/* Added in 1.5.4: state to keep track of whether the zstream has been
|
||||
* initialized and if so whether it is for IDAT or some other chunk.
|
||||
*/
|
||||
#define PNG_ZLIB_UNINITIALIZED 0
|
||||
@@ -78,7 +78,7 @@ struct png_struct_def
|
||||
#define PNG_ZLIB_IN_USE 4 /* a flag value */
|
||||
|
||||
png_uint_32 zlib_state; /* State of zlib initialization */
|
||||
/* End of material added at libpng 1.5.3 */
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
|
||||
int zlib_level; /* holds zlib compression level */
|
||||
int zlib_method; /* holds zlib compression method */
|
||||
@@ -86,7 +86,7 @@ struct png_struct_def
|
||||
int zlib_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* Added at libpng 1.5.3 */
|
||||
/* Added at libpng 1.5.4 */
|
||||
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
|
||||
int zlib_text_level; /* holds zlib compression level */
|
||||
@@ -95,7 +95,7 @@ struct png_struct_def
|
||||
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.3 */
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
@@ -111,7 +111,7 @@ struct png_struct_def
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
png_row_info row_info; /* used for transformation routines */
|
||||
png_size_t info_rowbytes; /* Added in 1.5.3: cache of updated row bytes */
|
||||
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 */
|
||||
@@ -255,13 +255,20 @@ struct png_struct_def
|
||||
png_bytep chunk_list;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
/* Added in 1.5.5 to record an sRGB chunk in the png. */
|
||||
png_byte is_sRGB;
|
||||
#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;
|
||||
png_uint_16 rgb_to_gray_blue_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) */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
@@ -918,7 +918,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
/* Normally one would use Z_DEFAULT_STRATEGY for text compression.
|
||||
* This is here just to make pngtest replicate the results from libpng
|
||||
* versions prior to 1.5.3, and to test this new API.
|
||||
* versions prior to 1.5.4, and to test this new API.
|
||||
*/
|
||||
png_set_text_compression_strategy(write_ptr, Z_FILTERED);
|
||||
#endif
|
||||
@@ -1794,4 +1794,4 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_5_4beta02 Your_png_h_is_not_version_1_5_4beta02;
|
||||
typedef png_libpng_version_1_5_5beta06 Your_png_h_is_not_version_1_5_5beta06;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
|
||||
1794
pngvalid.c
1794
pngvalid.c
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
@@ -1458,7 +1458,7 @@ png_set_compression_method(png_structp png_ptr, int method)
|
||||
png_ptr->zlib_method = method;
|
||||
}
|
||||
|
||||
/* The following were added to libpng-1.5.3 */
|
||||
/* The following were added to libpng-1.5.4 */
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_text_compression_level(png_structp png_ptr, int level)
|
||||
@@ -1539,7 +1539,7 @@ png_set_text_compression_method(png_structp png_ptr, int method)
|
||||
png_ptr->zlib_text_method = method;
|
||||
}
|
||||
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
|
||||
/* end of API added to libpng-1.5.3 */
|
||||
/* end of API added to libpng-1.5.4 */
|
||||
|
||||
void PNGAPI
|
||||
png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.5.4 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 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.)
|
||||
@@ -1017,7 +1017,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_write_chunk(png_ptr, png_IDAT, data, length);
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
|
||||
/* Prior to 1.5.3 this code was replicated in every caller (except at the
|
||||
/* Prior to 1.5.4 this code was replicated in every caller (except at the
|
||||
* end, where it isn't technically necessary). Since this function has
|
||||
* flushed the data we can safely reset the zlib output buffer here.
|
||||
*/
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
@@ -175,7 +175,7 @@
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
||||
<PrecompiledHeaderFile>pngpriv.h</PrecompiledHeaderFile>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
@@ -146,7 +146,7 @@
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4996;4127</DisableSpecificWarnings>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
VisualStudio instructions
|
||||
|
||||
libpng version 1.5.4beta02 - June 14, 2011
|
||||
libpng version 1.5.5beta06 - August 25, 2011
|
||||
|
||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
* zlib.props - location of zlib source
|
||||
*
|
||||
* libpng version 1.5.4beta02 - June 14, 2011
|
||||
* libpng version 1.5.5beta06 - August 25, 2011
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
*
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
@@ -99,7 +99,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
@@ -156,7 +156,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DEBUGZLIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Makefiles for libpng version 1.5.4beta02 - June 14, 2011
|
||||
Makefiles for libpng version 1.5.5beta06 - August 25, 2011
|
||||
|
||||
pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng15.so.15.1.5.4beta02)
|
||||
(gcc, creates libpng15.so.15.1.5.5beta06)
|
||||
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 libpng15.so.15.1.5.4beta02)
|
||||
(gcc, creates libpng15.so.15.1.5.5beta06)
|
||||
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 libpng15.so.15.1.5.4beta02)
|
||||
creates libpng15.so.15.1.5.5beta06)
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc,
|
||||
creates libpng15.so.15.1.5.4beta02)
|
||||
creates libpng15.so.15.1.5.5beta06)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng15.so.15.1.5.4beta02)
|
||||
creates libpng15.so.15.1.5.5beta06)
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
@@ -57,7 +57,7 @@ Other supporting scripts:
|
||||
libpng-config-body.in => used by several makefiles to create libpng-config
|
||||
libpng-config-head.in => used by several makefiles to create libpng-config
|
||||
libpng.pc.in => Used by several makefiles to create libpng.pc
|
||||
pngwin.rc => Used by the visualc6 and visualc71 projects.
|
||||
pngwin.rc => Used by the visualc71 project.
|
||||
pngwin.def => Used by makefile.os2
|
||||
pngwin.dfn => Used to maintain pngwin.def
|
||||
SCOPTIONS.ppc => Used with smakefile.ppc
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.5.4beta02
|
||||
version=1.5.5beta06
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
||||
@@ -5,6 +5,6 @@ includedir=@includedir@/libpng15
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.5.4beta02
|
||||
Version: 1.5.5beta06
|
||||
Libs: -L${libdir} -lpng15
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
VERMAJ = 1
|
||||
VERMIN = 5
|
||||
VERMIC = 4
|
||||
VERMIC = 5
|
||||
VER = $(VERMAJ).$(VERMIN).$(VERMIC)
|
||||
NAME = libpng
|
||||
PACKAGE = $(NAME)-$(VER)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# Library name:
|
||||
LIBNAME = libpng15
|
||||
PNGMAJ = 15
|
||||
RELEASE = 4
|
||||
RELEASE = 5
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng15
|
||||
|
||||
LIB= png15
|
||||
SHLIB_MAJOR= 0
|
||||
SHLIB_MINOR= 1.5.4beta02
|
||||
SHLIB_MINOR= 1.5.5beta06
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include
|
||||
|
||||
LIB= png
|
||||
SHLIB_MAJOR= 15
|
||||
SHLIB_MINOR= 1.5.4beta02
|
||||
SHLIB_MINOR= 1.5.5beta06
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -11,7 +11,7 @@ LIBDIR= ${PREFIX}/lib
|
||||
MANDIR= ${PREFIX}/man/cat
|
||||
|
||||
SHLIB_MAJOR= 15
|
||||
SHLIB_MINOR= 1.5.4beta02
|
||||
SHLIB_MINOR= 1.5.5beta06
|
||||
|
||||
LIB= png
|
||||
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#
|
||||
com pnglibconf.h - library build configuration
|
||||
com
|
||||
com libpng version 1.5.3 - (PENDING RELEASE)
|
||||
com libpng version 1.5.3 - July 7, 2011
|
||||
com
|
||||
com Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
com
|
||||
@@ -294,7 +294,9 @@ option READ enables READ_INTERLACING
|
||||
# Disabling READ_16BIT does not disable reading 16-bit PNG files, but it
|
||||
# forces them to be chopped down to 8-bit, and disables any 16-bit
|
||||
# processing after that has happened. You need to be sure to enable
|
||||
# READ_16_TO_8 when you disable READ_16BIT for this to work properly.
|
||||
# READ_SCALE_16_TO_8 or READ_STRIP_16_TO_8 when you disable READ_16BIT for
|
||||
# this to work properly. You should disable the other option if you need to
|
||||
# ensure a particular convertion (otherwise the app can chose.)
|
||||
|
||||
option READ_16BIT requires READ enables 16BIT
|
||||
|
||||
@@ -312,7 +314,8 @@ option READ_SWAP requires READ_TRANSFORMS READ_16BIT
|
||||
option READ_PACKSWAP requires READ_TRANSFORMS
|
||||
option READ_INVERT requires READ_TRANSFORMS
|
||||
option READ_BACKGROUND requires READ_TRANSFORMS enables READ_STRIP_ALPHA
|
||||
option READ_16_TO_8 requires READ_TRANSFORMS
|
||||
option READ_STRIP_16_TO_8 requires READ_TRANSFORMS
|
||||
option READ_SCALE_16_TO_8 requires READ_TRANSFORMS
|
||||
option READ_FILLER requires READ_TRANSFORMS
|
||||
option READ_GAMMA requires READ_TRANSFORMS enables READ_gAMA
|
||||
option READ_GRAY_TO_RGB requires READ_TRANSFORMS
|
||||
@@ -552,8 +555,6 @@ option SAVE_INT_32 requires WRITE
|
||||
|
||||
# added at libpng-1.5.4
|
||||
|
||||
option READ_CHOP_16_TO_8 requires READ_16_TO_8
|
||||
|
||||
option WRITE_OPTIMIZE_CMF requires WRITE
|
||||
|
||||
option READ_COMPRESSED_TEXT disabled
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* libpng version 1.5.0 - last changed on February 11, 2011 */
|
||||
/* libpng version 1.5.4 - last changed on June 22, 2011 */
|
||||
|
||||
/* Copyright (c) 1998-2011 Glenn Randers-Pehrson */
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#define PNG_CONSOLE_IO_SUPPORTED
|
||||
#define PNG_CONVERT_tIME_SUPPORTED
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||
#define PNG_ERROR_TEXT_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
@@ -68,16 +69,14 @@
|
||||
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_READ_16BIT_SUPPORTED
|
||||
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
#define PNG_READ_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||
#define PNG_READ_BGR_SUPPORTED
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_CHOP_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_READ_EXPAND_16_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_FILLER_SUPPORTED
|
||||
@@ -100,10 +99,12 @@
|
||||
#define PNG_READ_QUANTIZE_SUPPORTED
|
||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
#define PNG_READ_sBIT_SUPPORTED
|
||||
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_sCAL_SUPPORTED
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
#define PNG_READ_sPLT_SUPPORTED
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_SUPPORTED
|
||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
@@ -117,7 +118,6 @@
|
||||
#define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_SAVE_INT_32_SUPPORTED
|
||||
#define PNG_sBIT_SUPPORTED
|
||||
#define PNG_sCAL_SUPPORTED
|
||||
@@ -146,6 +146,8 @@
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
#define PNG_WRITE_bKGD_SUPPORTED
|
||||
#define PNG_WRITE_cHRM_SUPPORTED
|
||||
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_FILLER_SUPPORTED
|
||||
#define PNG_WRITE_FILTER_SUPPORTED
|
||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||
@@ -156,7 +158,6 @@
|
||||
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_iTXt_SUPPORTED
|
||||
#define PNG_WRITE_oFFs_SUPPORTED
|
||||
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
@@ -182,7 +183,5 @@
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#define PNG_zTXt_SUPPORTED
|
||||
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||
/* end of options */
|
||||
#endif /* PNGLCONF_H */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
LIBRARY
|
||||
|
||||
EXPORTS
|
||||
;Version 1.5.4beta02
|
||||
;Version 1.5.5beta06
|
||||
png_access_version_number @1
|
||||
png_set_sig_bytes @2
|
||||
png_sig_cmp @3
|
||||
@@ -234,4 +234,8 @@ EXPORTS
|
||||
png_set_text_compression_method @226
|
||||
png_set_alpha_mode @227
|
||||
png_set_alpha_mode_fixed @228
|
||||
png_set_chop_16 @229
|
||||
png_set_scale_16 @229
|
||||
png_get_cHRM_XYZ @230
|
||||
png_get_cHRM_XYZ_fixed @231
|
||||
png_set_cHRM_XYZ @232
|
||||
png_set_cHRM_XYZ_fixed @233
|
||||
|
||||
Reference in New Issue
Block a user