Upgrading libpng: Adding clean copy of libpng 1.5.10

This commit removes the previous version of the bundled libpng
(1.5.4), as well as all local modifications to it. It adds an
unmodified copy of the official libpng source distribution, except
that various extraneous files have been removed, as usual.

The patches required to build it in Qt will follow in separate
commit(s).

Change-Id: I90149f87fc889c44a3b60b21cdf755020f3a8e39
Reviewed-by: Kim M. Kalland <kim.kalland@nokia.com>
This commit is contained in:
aavit 2012-04-16 13:34:47 +02:00 committed by Qt by Nokia
parent 93055e81c8
commit 1fa1ce3628
38 changed files with 8059 additions and 22840 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.5.1 - February 3, 2011
Libpng 1.5.10 - March 29, 2012
This is a public release of libpng, intended for use in production codes.
@ -8,89 +8,57 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
libpng-1.5.1.tar.xz (LZMA-compressed, recommended)
libpng-1.5.1.tar.gz
libpng-1.5.1.tar.bz2
libpng-1.5.10.tar.xz (LZMA-compressed, recommended)
libpng-1.5.10.tar.gz
libpng-1.5.10.tar.bz2
Source files with CRLF line endings (for Windows), without the
"configure" script
lpng151.7z (LZMA-compressed, recommended)
lpng151.zip
lpng1510.7z (LZMA-compressed, recommended)
lpng1510.zip
Other information:
libpng-1.5.1-README.txt
libpng-1.5.1-LICENSE.txt
libpng-1.5.10-README.txt
libpng-1.5.10-LICENSE.txt
Changes since the last public release (1.5.0):
Changes since the last public release (1.5.9):
Added description of png_set_crc_action() to the manual.
Added a note in the manual that the type of the iCCP profile was changed
from png_charpp to png_bytepp in png_get_iCCP(). 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 the failure to handle palette mapped images correctly.
Fixed a bug in handling of interlaced images (bero at arklinux.org).
Updated CMakeLists.txt (Clifford Yapp)
Fixed typecasting of some png_debug() statements (Cosmin)
Updated documentation of png_set|get_tRNS() (Thomas Klausner).
Mentioned in the documentation that applications must #include "zlib.h"
if they need access to anything in zlib.h, and that a number of
macros such as png_memset() are no longer accessible by applications.
Corrected pngvalid gamma test "sample" function to access all of the color
samples of each pixel, instead of sampling the red channel three times.
Changed variable names index, div, exp, and gamma to char_index, divisor,
exp_b10, and gamma_val, respectively, to avoid "shadow" warnings.
Prevent png_push_crc_skip() from hanging while reading an unknown chunk
or an over-large compressed zTXt chunk with the progressive reader.
Eliminated more GCC "shadow" warnings.
Revised png_fixed() in png.c to avoid compiler warning about reaching the
end without returning anything.
In the manual, describe the png_get_IHDR() arguments in the correct order.
Added const_png_structp and const_png_infop types, and used them in
prototypes for most png_get_*() functions.
Added png_get_io_chunk_type() and deprecated png_get_io_chunk_name()
Added synopses for the IO_STATE functions and other missing synopses
to the manual. Removed the synopses from libpngpf.3 because they
were out of date and no longer useful. Better information can be
obtained by reading the prototypes and comments in pngpriv.h
Attempted to fix cpp on Solaris with S. Studio 12 cc, fix build
Added a make macro DFNCPP that is a CPP that will accept the tokens in
a .dfn file and adds configure stuff to test for such a CPP. ./configure
should fail if one is not available.
Corrected const_png_ in png.h to png_const_ to avoid polluting the namespace.
Added png_get_current_row_number and png_get_current_pass_number for the
benefit of the user transform callback.
Added png_process_data_pause and png_process_data_skip for the benefit of
progressive readers that need to stop data processing or want to optimize
skipping of unread data (e.g. if the reader marks a chunk to be skipped.)
Enhanced pngvalid, corrected an error in gray_to_rgb, corrected doc error.
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.
Fixed incorrect examples of callback prototypes in the manual, that were
introduced in libpng-1.0.0.
In addition the order of the png_get_uint macros with respect to the
relevant function definitions has been reversed. This helps the
preprocessing of the symbol files be more robust. Furthermore, the
symbol file preprocessing now uses -DPNG_NO_USE_READ_MACROS even when
the library may actually be built with PNG_USE_READ_MACROS; this stops
the read macros interfering with the symbol file format.
Made the manual, synopses, and function prototypes use the function
argument names file_gamma, int_file_gamma, and srgb_intent consistently.
Changed PNG_UNUSED from "param=param;" to "(void)param;".
Added transform tests to pngvalid and simplified the arguments.
Added a request in the manual that applications do not use "png_" or
"PNG_" to begin any of their own symbols.
Removed two useless #ifdef directives from pngread.c and one from pngrutil.c
Always put the CMAKE_LIBRARY in "lib" (removed special WIN32 case).
Removed empty vstudio/pngstest directory (Clifford Yapp).
Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from
pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c;
now that png_ptr->buffer is inaccessible to applications, the special
handling is no longer useful.
Fixed bug with png_handle_hIST with odd chunk length (Frank Busse).
Added PNG_SAFE_LIMITS feature to pnglibconf.dfa and code in pngconf.h
to reset the user limits to safe ones if PNG_SAFE_LIMITS is defined.
To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED" on the configure
command or put "#define PNG_SAFE_LIMITS_SUPPORTED" in pnglibconf.h.
Revised the SAFE_LIMITS feature to be the same as the feature in libpng16.
Added information about the new limits in the manual.
Updated Makefile.in
Removed unused "current_text" members of png_struct and the png_free()
of png_ptr->current_text from pngread.c
Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
Fixed CMF optimization of non-IDAT compressed chunks, which was added at
libpng-1.5.4. It sometimes produced too small of a window.
Reject all iCCP chunks after the first, even if the first one is invalid.
Added palette-index checking. Issue a png_benign_error() if an invalid
index is found.
Revised example.c to put text strings in a temporary character array
instead of directly assigning string constants to png_textp members.
This avoids compiler warnings when -Wwrite-strings is enabled.
Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice.
Revised png_set_text_2() to avoid potential memory corruption (fixes
CVE-2011-3048).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe) or to glennrp at users.sourceforge.net
to subscribe)
or to glennrp at users.sourceforge.net
Glenn R-P

View File

@ -1,5 +1,4 @@
#if 0
libpng_changes(){ /*
CHANGES - changes for libpng
Version 0.2
@ -15,7 +14,7 @@ Version 0.3
fixed some bugs in writer
interfaced with zlib 0.5
added K&R support
added check for 64 KB blocks for 16 bit machines
added check for 64 KB blocks for 16-bit machines
Version 0.4
cleaned up code and commented code
@ -74,7 +73,7 @@ Version 0.82 [September, 1995]
Version 0.85 [December, 1995]
added more medium model code (almost everything's a far)
added i/o, error, and memory callback functions
fixed some bugs (16 bit, 4 bit interlaced, etc.)
fixed some bugs (16-bit, 4-bit interlaced, etc.)
added first run progressive reader (barely tested)
Version 0.86 [January, 1996]
@ -180,7 +179,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)
@ -197,18 +196,20 @@ Version 0.97 [January, 1998]
Added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P)
Minor corrections in libpng.txt
Added simple sRGB support (Glenn R-P)
Easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
Easier conditional compiling, e.g.,
define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
all configurable options can be selected from command-line instead
of having to edit pngconf.h (Glenn R-P)
Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
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)
version number to 2 to avoid problems with libpng 0.89 apps
(Greg Roelofs)
Version 0.98 [January, 1998]
Cleaned up some typos in libpng.txt and in code documentation
@ -1778,7 +1779,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 +2362,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".
@ -2935,7 +2936,7 @@ Version 1.5.0beta36 [July 29, 2010]
PNG_INTERLACE transform and to get the number of rows in the current
pass.
A new test program, pngvalid.c, validates the gamma code.
Errors in the 16 bit gamma correction (overflows) have been corrected.
Errors in the 16-bit gamma correction (overflows) have been corrected.
cHRM chunk testing is done consistently (previously the floating point
API bypassed it, because the test really didn't work on FP, now the test
is performed on the actual values to be stored in the PNG file so it
@ -3149,8 +3150,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 +3209,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
@ -3227,7 +3228,7 @@ Version 1.5.1beta10 [January 27, 2010]
Version 1.5.1beta11 [January 28, 2011]
Changed PNG_UNUSED from "param=param;" to "{if(param){}}".
Corrected local variable type in new API png_process_data_skip()
The type was self-evidently incorrect but only causes problems on 64 bit
The type was self-evidently incorrect but only causes problems on 64-bit
architectures.
Added transform tests to pngvalid and simplified the arguments.
@ -3242,6 +3243,617 @@ Version 1.5.1rc02 [January 31, 2011]
Version 1.5.1 [February 3, 2011]
No changes.
Version 1.5.2beta01 [February 13, 2011]
More -Wshadow fixes for older gcc compilers. Older gcc versions apparently
check formal parameters names in function declarations (as well as
definitions) to see if they match a name in the global namespace.
Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the
old VisualC++ preprocessor.
Turned on interlace handling in png_read_png().
Fixed gcc pendantic warnings.
Handle longjmp in Cygwin.
Fixed png_get_current_row_number() in the interlaced case.
Cleaned up ALPHA flags and transformations.
Implemented expansion to 16 bits.
Version 1.5.2beta02 [February 19, 2011]
Fixed mistake in the descriptions of user read_transform and write_transform
function prototypes in the manual. The row_info struct is png_row_infop.
Reverted png_get_current_row_number() to previous (1.5.2beta01) behavior.
Corrected png_get_current_row_number documentation
Fixed the read/write row callback documentation.
This documents the current behavior, where the callback is called after
every row with information pertaining to the next row.
Version 1.5.2beta03 [March 3, 2011]
Fixed scripts/makefile.vcwin32
Updated contrib/pngsuite/README to add the word "modify".
Define PNG_ALLOCATED to blank when _MSC_VER<1300.
Version 1.5.2rc01 [March 19, 2011]
Define remaining attributes to blank when MSC_VER<1300.
ifdef out mask arrays in pngread.c when interlacing is not supported.
Version 1.5.2rc02 [March 22, 2011]
Added a hint to try CPP=/bin/cpp if "cpp -E" fails in scripts/pnglibconf.mak
and in contrib/pngminim/*/makefile, eg., on SunOS 5.10, and removed "strip"
from the makefiles.
Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail
to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill)
Version 1.5.2rc03 [March 24, 2011]
Don't include standard header files in png.h while building the symbol table,
to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro).
Version 1.5.2 [March 31, 2011]
No changes.
Version 1.5.3beta01 [April 1, 2011]
Re-initialize the zlib compressor before compressing 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.
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.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.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 possible clash with the png_jmpbuf macro on some platforms.
Version 1.5.3beta05 [May 6, 2011]
Added the "_POSIX_SOURCE" feature test macro 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.
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.
Pass "" instead of '\0' to png_default_error() in png_err(). This mistake
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
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. This introduced a divide-by-zero
bug in png_handle_cHRM().
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 where it was. 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, 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. 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
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.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 26, 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, and the divide-by-zero bug in png_handle_cHRM (CERT
VU#477046, CVE-2011-3328, introduced in 1.5.4) have 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.
Version 1.5.5beta07 [September 7, 2011]
Added "$(ARCH)" option to makefile.darwin
Added SunOS support to configure.ac and Makefile.am
Changed png_chunk_benign_error() to png_warning() in png.c, in
png_XYZ_from_xy_checked().
Version 1.5.5beta08 [September 10, 2011]
Fixed 64-bit compilation errors (gcc). The errors fixed relate
to conditions where types that are 32 bits in the GCC 32-bit
world (uLong and png_size_t) become 64 bits in the 64-bit
world. This produces potential truncation errors which the
compiler correctly flags.
Relocated new HAVE_SOLARIS_LD definition in configure.ac
Constant changes for 64-bit compatibility (removal of L suffixes). The
16-bit cases still use "L" as we don't have a 16-bit test system.
Version 1.5.5rc01 [September 15, 2011]
Removed "L" suffixes in pngpriv.h
Version 1.5.5 [September 22, 2011]
No changes.
Version 1.5.6beta01 [September 22, 2011]
Fixed some 64-bit type conversion warnings in pngrtran.c
Moved row_info from png_struct to a local variable.
The various interlace mask arrays have been made into arrays of
bytes and made PNG_CONST and static (previously some arrays were
marked PNG_CONST and some weren't).
Additional checks have been added to the transform code to validate the
pixel depths after the transforms on both read and write.
Removed some redundant code from pngwrite.c, in png_destroy_write_struct().
Changed chunk reading/writing code to use png_uint_32 instead of png_byte[4].
This removes the need to allocate temporary strings for chunk names on
the stack in the read/write code. Unknown chunk handling still uses the
string form because this is exposed in the API.
Version 1.5.6beta02 [September 26, 2011]
Added a note in the manual the png_read_update_info() must be called only
once with a particular info_ptr.
Fixed a typo in the definition of the new PNG_STRING_FROM_CHUNK(s,c) macro.
Version 1.5.6beta03 [September 28, 2011]
Revised test-pngtest.sh to report FAIL when pngtest fails.
Added "--strict" option to pngtest, to report FAIL when the failure is
only because the resulting valid files are different.
Revised CMakeLists.txt to work with mingw and removed some material from
CMakeLists.txt that is no longer useful in libpng-1.5.
Version 1.5.6beta04 [October 5, 2011]
Fixed typo in Makefile.in and Makefile.am ("-M Wl" should be "-M -Wl")."
Version 1.5.6beta05 [October 12, 2011]
Speed up png_combine_row() for interlaced images. This reduces the generality
of the code, allowing it to be optimized for Adam7 interlace. The masks
passed to png_combine_row() are now generated internally, avoiding
some code duplication and localizing the interlace handling somewhat.
Align png_struct::row_buf - previously it was always unaligned, caused by
a bug in the code that attempted to align it; the code needs to subtract
one from the pointer to take account of the filter byte prepended to
each row.
Optimized png_combine_row() when rows are aligned. This gains a small
percentage for 16-bit and 32-bit pixels in the typical case where the
output row buffers are appropriately aligned. The optimization was not
previously possible because the png_struct buffer was always misaligned.
Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01.
Version 1.5.6beta06 [October 17, 2011]
Removed two redundant tests for unitialized row.
Fixed a relatively harmless memory overwrite in compressed text writing
with a 1 byte zlib buffer.
Add ability to call png_read_update_info multiple times to pngvalid.c.
Fixes for multiple calls to png_read_update_info. These fixes attend to
most of the errors revealed in pngvalid, however doing the gamma work
twice results in inaccuracies that can't be easily fixed. There is now
a warning in the code if this is going to happen.
Turned on multiple png_read_update_info in pngvalid transform tests.
Prevent libpng from overwriting unused bits at the end of the image when
it is not byte aligned, while reading. Prior to libpng-1.5.6 libpng would
overwrite the partial byte at the end of each row if the row width was not
an exact multiple of 8 bits and the image is not interlaced.
Version 1.5.6beta07 [October 21, 2011]
Made png_ptr->prev_row an aligned pointer into png_ptr->big_prev_row
(Mans Rullgard).
Version 1.5.6rc01 [October 26, 2011]
Changed misleading "Missing PLTE before cHRM" warning to "Out of place cHRM"
Version 1.5.6rc02 [October 27, 2011]
Added LSR() macro to defend against buggy compilers that evaluate non-taken
code branches and complain about out-of-range shifts.
Version 1.5.6rc03 [October 28, 2011]
Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro.
Fixed compiler warnings with Intel and MSYS compilers. The logical shift
fix for Microsoft Visual C is required by other compilers, so this
enables that fix for all compilers when using compile-time constants.
Under MSYS 'byte' is a name declared in a system header file, so we
changed the name of a local variable to avoid the warnings that result.
Added #define PNG_ALIGN_TYPE PNG_ALIGN_NONE to contrib/pngminim/*/pngusr.h
Version 1.5.6 [November 3, 2011]
No changes.
Version 1.5.7beta01 [November 4, 2011]
Added support for ARM processor (Mans Rullgard)
Fixed bug in pngvalid on early allocation failure; fixed type cast in
pngmem.c; pngvalid would attempt to call png_error() if the allocation
of a png_struct or png_info failed. This would probably have led to a
crash. The pngmem.c implementation of png_malloc() included a cast
to png_size_t which would fail on large allocations on 16-bit systems.
Fix for the preprocessor of the Intel C compiler. The preprocessor
splits adjacent @ signs with a space; this changes the concatentation
token from @-@-@ to PNG_JOIN; that should work with all compiler
preprocessors.
Paeth filter speed improvements from work by Siarhei Siamashka. This
changes the 'Paeth' reconstruction function to improve the GCC code
generation on x86. The changes are only part of the suggested ones;
just the changes that definitely improve speed and remain simple.
The changes also slightly increase the clarity of the code.
Version 1.5.7beta02 [November 11, 2011]
Check compression_type parameter in png_get_iCCP and remove spurious
casts. The compression_type parameter is always assigned to, so must
be non-NULL. The cast of the profile length potentially truncated the
value unnecessarily on a 16-bit int system, so the cast of the (byte)
compression type to (int) is specified by ANSI-C anyway.
Fixed FP division by zero in pngvalid.c; the 'test_pixel' code left
the sBIT fields in the test pixel as 0, which resulted in a floating
point division by zero which was irrelevant but causes systems where
FP exceptions cause a crash. Added code to pngvalid to turn on FP
exceptions if the appropriate glibc support is there to ensure this is
tested in the future.
Updated scripts/pnglibconf.mak and scripts/makefile.std to handle the
new PNG_JOIN macro.
Added versioning to pnglibconf.h comments.
Simplified read/write API initial version; basic read/write tested on
a variety of images, limited documentation (in the header file.)
Installed more accurate linear to sRGB conversion tables. The slightly
modified tables reduce the number of 16-bit values that
convert to an off-by-one 8-bit value. The "makesRGB.c" code that was used
to generate the tables is now in a contrib/sRGBtables sub-directory.
Version 1.5.7beta03 [November 17, 2011]
Removed PNG_CONST from the sRGB table declarations in pngpriv.h and png.c
Added run-time detection of NEON support.
Added contrib/libtests; includes simplified API test and timing test and
a color conversion utility for rapid checking of failed 'pngstest' results.
Multiple transform bug fixes plus a work-round for double gamma correction.
libpng does not support more than one transform that requires linear data
at once - if this is tried typically the results is double gamma
correction. Since the simplified APIs can need rgb to gray combined with
a compose operation it is necessary to do one of these outside the main
libpng transform code. This check-in also contains fixes to various bugs
in the simplified APIs themselves and to some bugs in compose and rgb to
gray (on palette) itself.
Fixes for C++ compilation using g++ When libpng source is compiled
using g++. The compiler imposes C++ rules on the C source; thus it
is desireable to make the source work with either C or C++ rules
without throwing away useful error information. This change adds
png_voidcast to allow C semantic (void*) cases or the corresponding
C++ static_cast operation, as appropriate.
Added --noexecstack to assembler file compilation. GCC does not set
this on assembler compilation, even though it does on C compilation.
This creates security issues if assembler code is enabled; the
work-around is to set it by default in the flags for $(CCAS)
Work around compilers that don't support declaration of const data. Some
compilers fault 'extern const' data declarations (because the data is
not initialized); this turns on const-ness only for compilers where
this is known to work.
Version 1.5.7beta04 [November 17, 2011]
Since the gcc driver does not recognize the --noexecstack flag, we must
use the -Wa prefix to have it passed through to the assembler.
Also removed a duplicate setting of this flag.
Added files that were omitted from the libpng-1.5.7beta03 zip distribution.
Version 1.5.7beta05 [November 25, 2011]
Removed "zTXt" from warning in generic chunk decompression function.
Validate time settings passed to pngset() and png_convert_to_rfc1123()
(Frank Busse).
Added MINGW support to CMakeLists.txt
Reject invalid compression flag or method when reading the iTXt chunk.
Backed out 'simplified' API changes. The API seems too complex and there
is a lack of consensus or enthusiasm for the proposals. The API also
reveals significant bugs inside libpng (double gamma correction and the
known bug of being unable to retrieve a corrected palette). It seems
better to wait until the bugs, at least, are corrected.
Moved pngvalid.c into contrib/libtests
Rebuilt Makefile.in, configure, etc., with autoconf-2.68
Version 1.5.7rc01 [December 1, 2011]
Replaced an "#if" with "#ifdef" in pngrtran.c
Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else)
Version 1.5.7rc02 [December 5, 2011]
Revised project files and contrib/pngvalid/pngvalid.c to account for
the relocation of pngvalid into contrib/libtests.
Revised pngconf.h to use " __declspec(restrict)" only when MSC_VER >= 1400,
as in libpng-1.5.4.
Put CRLF line endings in the owatcom project files.
Version 1.5.7rc03 [December 7, 2011]
Updated CMakeLists.txt to account for the relocation of pngvalid.c
Version 1.5.7 [December 15, 2011]
Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings
reported by earlier versions.
Version 1.5.8beta01 [January 15, 2011]
Removed '#include config.h"' from contrib/libtests/pngvalid.c. It's not
needed and causes trouble for VPATH building.
Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper
location in configure.ac (Gilles Espinasse).
Fix bug in pngerror.c: some long warnings were being improperly truncated
(CVE-2011-3464, bug introduced in libpng-1.5.3beta05).
Version 1.5.8rc01 [January 21, 2012]
No changes.
Version 1.5.8rc02 [January 25, 2012]
Fixed Min/GW uninstall to remove libpng.dll.a
Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt
Version 1.5.8 [February 1, 2012]
No changes.
Version 1.5.9beta01 [February 3, 2012]
Rebuilt configure scripts in the tar distributions.
Version 1.5.9beta02 [February 16, 2012]
Removed two unused definitions from scripts/pnglibconf.h.prebuilt
Removed some unused arrays (with #ifdef) from png_read_push_finish_row().
Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h
Version 1.5.9rc01 [February 17, 2012]
Fixed CVE-2011-3026 buffer overrun bug. This bug was introduced when
iCCP chunk support was added at libpng-1.0.6. Deal more correctly with the
test on iCCP chunk length. Also removed spurious casts that may hide
problems on 16-bit systems.
Version 1.5.9 [February 18, 2012]
No changes.
Version 1.5.10beta01 [February 24, 2012]
Removed two useless #ifdef directives from pngread.c and one from pngrutil.c
Always put the CMAKE_LIBRARY in "lib" (removed special WIN32 case).
Removed empty vstudio/pngstest directory (Clifford Yapp).
Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from
pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c;
now that png_ptr->buffer is inaccessible to applications, the special
handling is no longer useful.
Fixed bug with png_handle_hIST with odd chunk length (Frank Busse).
Added PNG_SAFE_LIMITS feature to pnglibconf.dfa and code in pngconf.h
to reset the user limits to safe ones if PNG_SAFE_LIMITS is defined.
To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED" on the configure
command or put "#define PNG_SAFE_LIMITS_SUPPORTED" in pnglibconf.h.
Revised the SAFE_LIMITS feature to be the same as the feature in libpng16.
Added information about the new limits in the manual.
Version 1.5.10beta02 [February 27, 2012]
Updated Makefile.in
Version 1.5.10beta03 [March 6, 2012]
Removed unused "current_text" members of png_struct and the png_free()
of png_ptr->current_text from pngread.c
Added palette-index checking. Issue a png_warning() if an invalid index is
found.
Version 1.5.10beta04 [March 10, 2012]
Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
Fixed CMF optimization of non-IDAT compressed chunks, which was added at
libpng-1.5.4. It sometimes produced too small of a window.
Version 1.5.10beta05 [March 10, 2012]
Reject all iCCP chunks after the first, even if the first one is invalid.
Issue a png_benign_error() instead of png_warning() about bad palette index.
Fixed an off-by-one error in the palette index checking function.
Revised example.c to put text strings in a temporary character array
instead of directly assigning string constants to png_textp members.
This avoids compiler warnings when -Wwrite-strings is enabled.
Version 1.5.10 [March 29, 2012]
Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice.
Revised png_set_text_2() to avoid potential memory corruption (fixes
CVE-2011-3048).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
@ -3249,5 +3861,4 @@ to subscribe)
or to glennrp at users.sourceforge.net
Glenn R-P
*/ }
#endif

View File

@ -1,406 +0,0 @@
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE)
if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
# workaround CMake 2.4.x bug
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are:
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
Debug
Release
RelWithDebInfo
MinSizeRel.")
else()
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are:
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
Debug
Release
RelWithDebInfo
MinSizeRel.")
endif()
endif()
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 1)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
# needed packages
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
if(NOT WIN32)
find_library(M_LIBRARY
NAMES m
PATHS /usr/lib /usr/local/lib
)
if(NOT M_LIBRARY)
message(STATUS
"math library 'libm' not found - floating point support disabled")
endif()
else()
# not needed on windows
set(M_LIBRARY "")
endif()
# COMMAND LINE OPTIONS
if(DEFINED PNG_SHARED)
option(PNG_SHARED "Build shared lib" ${PNG_SHARED})
else()
option(PNG_SHARED "Build shared lib" ON)
endif()
if(DEFINED PNG_STATIC)
option(PNG_STATIC "Build static lib" ${PNG_STATIC})
else()
option(PNG_STATIC "Build static lib" ON)
endif()
if(MINGW)
option(PNG_TESTS "Build pngtest" NO)
else()
option(PNG_TESTS "Build pngtest" YES)
endif()
option(PNG_NO_CONSOLE_IO "FIXME" YES)
option(PNG_NO_STDIO "FIXME" YES)
option(PNG_DEBUG "Build with debug output" NO)
option(PNGARG "FIXME" YES)
#TODO:
# PNG_CONSOLE_IO_SUPPORTED
# maybe needs improving, but currently I don't know when we can enable what :)
set(png_asm_tmp "OFF")
if(NOT WIN32)
find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin)
if(uname_executable)
exec_program(${uname_executable}
ARGS --machine OUTPUT_VARIABLE uname_output)
if("uname_output" MATCHES "^.*i[1-9]86.*$")
set(png_asm_tmp "ON")
else("uname_output" MATCHES "^.*i[1-9]86.*$")
set(png_asm_tmp "OFF")
endif("uname_output" MATCHES "^.*i[1-9]86.*$")
endif(uname_executable)
else()
# this env var is normally only set on win64
set(TEXT "ProgramFiles(x86)")
if("$ENV{${TEXT}}" STREQUAL "")
set(png_asm_tmp "ON")
endif("$ENV{${TEXT}}" STREQUAL "")
endif()
# SET LIBNAME
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
# to distinguish between debug and release lib
set(CMAKE_DEBUG_POSTFIX "d")
# Use the prebuilt pnglibconf.h file from the scripts folder
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# OUR SOURCES
set(libpng_public_hdrs
png.h
pngconf.h
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
)
set(libpng_sources
${libpng_public_hdrs}
pngdebug.h
pnginfo.h
pngpriv.h
pngstruct.h
png.c
pngerror.c
pngget.c
pngmem.c
pngpread.c
pngread.c
pngrio.c
pngrtran.c
pngrutil.c
pngset.c
pngtrans.c
pngwio.c
pngwrite.c
pngwtran.c
pngwutil.c
)
set(pngtest_sources
pngtest.c
)
# SOME NEEDED DEFINITIONS
add_definitions(-DPNG_CONFIGURE_LIBPNG)
if(_AIX)
add_definitions(-D_ALL_SOURCE)
endif(_AIX)
if(MSVC)
add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE)
endif(MSVC)
if(PNG_SHARED OR NOT MSVC)
#if building msvc static this has NOT to be defined
add_definitions(-DZLIB_DLL)
endif()
if(PNG_CONSOLE_IO_SUPPORTED)
add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
endif()
if(PNG_NO_CONSOLE_IO)
add_definitions(-DPNG_NO_CONSOLE_IO)
endif()
if(PNG_NO_STDIO)
add_definitions(-DPNG_NO_STDIO)
endif()
if(PNG_DEBUG)
add_definitions(-DPNG_DEBUG)
endif()
if(NOT M_LIBRARY AND NOT WIN32)
add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
endif()
# NOW BUILD OUR TARGET
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
if(PNG_SHARED)
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
endif()
target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
endif()
if(PNG_STATIC)
# does not work without changing name
set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
endif()
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()
if(PNG_TESTS AND PNG_SHARED)
# does not work with msvc due to png_lib_ver issue
add_executable(pngtest ${pngtest_sources})
target_link_libraries(pngtest ${PNG_LIB_NAME})
add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
endif()
#
# 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)
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}\")
")
endmacro()
# CREATE PKGCONFIG FILES
# we use the same files like ./configure, so we have to set its vars
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
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})
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})
# SET UP LINKS
if(PNG_SHARED)
set_target_properties(${PNG_LIB_NAME} PROPERTIES
# VERSION 15.${PNGLIB_RELEASE}.1.5.1
VERSION 15.${PNGLIB_RELEASE}.0
SOVERSION 15
CLEAN_DIRECT_OUTPUT 1)
endif()
if(PNG_STATIC)
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
if(NOT MSVC)
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
OUTPUT_NAME ${PNG_LIB_NAME}
CLEAN_DIRECT_OUTPUT 1)
endif()
endif()
# If CMake > 2.4.x, we set a variable used below to export
# targets to an export file.
# TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2
if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4)
set(PNG_EXPORT_RULE EXPORT libpng)
elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof
set(PNG_EXPORT_RULE EXPORT libpng)
endif()
# INSTALL
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
if(PNG_SHARED)
install(TARGETS ${PNG_LIB_NAME}
${PNG_EXPORT_RULE}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
# 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()
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()
if(PNG_STATIC)
install(TARGETS ${PNG_LIB_NAME_STATIC}
${PNG_EXPORT_RULE}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(NOT WIN32 OR CYGWIN)
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()
endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
install(FILES ${libpng_public_hdrs} DESTINATION include)
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
endif()
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
DESTINATION bin)
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
# Install man pages
if(NOT PNG_MAN_DIR)
set(PNG_MAN_DIR "share/man")
endif()
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
# Install pkg-config files
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
DESTINATION bin)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
DESTINATION bin)
endif()
# On versions of CMake that support it, create an export file CMake
# users can include() to import our targets
if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
endif()
# what's with libpng-$VER%.txt and all the extra files?
# UNINSTALL
# do we need this?
# DIST
# do we need this?
# to create msvc import lib for mingw compiled shared lib
# pexports libpng.dll > libpng.def
# lib /def:libpng.def /machine:x86

View File

@ -133,3 +133,23 @@ run "make install".
Further information can be found in the README and libpng-manual.txt
files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5.
Using the ./configure script -- 16 December 2002.
=================================================
The ./configure script should work compatibly with what scripts/makefile.*
did, however there are some options you might need to add to configure
explicitly, which previously was done semi-automatically (if you didn't edit
scripts/makefile.* yourself, that is)
CFLAGS="-Wall -O -funroll-loops \
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
You can alternatively specify --includedir=/usr/include, /usr/local/include,
/usr/include/libpng%NN%, or whatever.
If you find that the configure script is out-of-date or is not supporting
your platform properly, try running autogen.sh to regenerate "configure",
"Makefile.in", and the other configuration files. Then try configure again.

View File

@ -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.1, February 3, 2011, are
libpng versions 1.2.6, August 15, 2004, through 1.5.10, March 29, 2012, 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
February 3, 2011
March 29, 2012

View File

@ -1,4 +1,4 @@
README for libpng version 1.5.1 - February 3, 2011 (shared library 15.0)
README for libpng version 1.5.10 - March 29, 2012 (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.
@ -114,19 +114,16 @@ given in previous versions of this document. He and Andreas will
read mail addressed to the png-implement list, however.
Please do not send general questions about PNG. Send them to
the (png-list at ccrc.wustl.edu, subscription required, write to
majordomo at ccrc.wustl.edu with "subscribe png-list" in your message).
On the other hand,
please do not send libpng questions to that address, send them to me
or to the png-implement list. I'll
get them in the end anyway. If you have a question about something
png-mng-misc at lists.sf.net (subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
subscribe). If you have a question about something
in the PNG specification that is related to using libpng, send it
to me. Send me any questions that start with "I was using libpng,
and ...". If in doubt, send questions to me. I'll bounce them
to others, if necessary.
Please do not send suggestions on how to change PNG. We have
been discussing PNG for nine years now, and it is official and
been discussing PNG for sixteen years now, and it is official and
finished. If you have suggestions for libpng, however, I'll
gladly listen. Even if your suggestion is not used immediately,
it may be used later.

View File

@ -1,27 +0,0 @@
/*
TODO - list of things to do for libpng:
Final bug fixes.
Better C++ wrapper/full C++ implementation?
Fix problem with C++ and EXTERN "C".
cHRM transformation.
Remove setjmp/longjmp usage in favor of returning error codes.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Improved dithering.
Multi-lingual error and warning message support.
Complete sRGB transformation (presently it simply uses gamma=0.45455).
Man pages for function calls.
Better documentation.
Better filter selection
(counting huffman bits/precompression? filter inertia? filter costs?).
Histogram creation.
Text conversion between different code pages (Latin-1 -> Mac and DOS).
Avoid building gamma tables whenever possible.
Use greater precision when changing to linear gamma for compositing against
background and doing rgb-to-gray transformation.
Investigate pre-incremented loop counters and other loop constructions.
Add interpolated method of handling interlacing.
Switch to the simpler zlib (zlib/libpng) license if legally possible.
Extend pngvalid.c to validate more of the libpng transformations.
*/

File diff suppressed because it is too large Load Diff

View File

@ -1,86 +0,0 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the `pow' function. */
#undef HAVE_POW
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
/* Version number of package */
#undef VERSION
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

File diff suppressed because it is too large Load Diff

View File

@ -1,167 +0,0 @@
# configure.ac
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Minor upgrades (compatible ABI): increment the package version
dnl (third field in two places below) and set the PNGLIB_RELEASE
dnl variable.
dnl
dnl Major upgrades (incompatible ABI): increment the package major
dnl version (second field, or first if desired), set the minor
dnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in
dnl Makefile.am to upgrade the package name.
dnl This is here to prevent earlier autoconf from being used, it
dnl should not be necessary to regenerate configure if the time
dnl stamps are correct
AC_PREREQ(2.59)
dnl Version number stuff here:
AC_INIT([libpng], [1.5.1], [png-mng-implement@lists.sourceforge.net])
AM_INIT_AUTOMAKE
dnl stop configure from automagically running automake
AM_MAINTAINER_MODE
PNGLIB_VERSION=1.5.1
PNGLIB_MAJOR=1
PNGLIB_MINOR=5
PNGLIB_RELEASE=1
dnl End of version number stuff
AC_CONFIG_SRCDIR([pngget.c])
AM_CONFIG_HEADER(config.h)
# Checks for programs.
AC_LANG([C])
AC_PROG_CC
AC_PROG_LD
AC_PROG_CPP
AC_CHECK_TOOL(SED, sed, :)
AC_CHECK_TOOL(AWK, awk, :)
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
LT_INIT([win32-dll])
# On Solaris 10 and 12 CPP gets set to cc -E, however this still
# does some input parsing. We need strict ANSI-C style tokenization,
# check this:
AC_REQUIRE_CPP
AC_MSG_CHECKING([for a C preprocessor that does not parse its input])
AC_TRY_CPP([1.5.0 16BIT],
[DFNCPP="$CPP"],
[DFNCPP=""
sav_CPP="$CPP"
for CPP in "${CC-cc} -E" "${CC-cc} -E -traditional-cpp" "/lib/cpp" "cpp"; do
AC_TRY_CPP([1.5.0 16BIT],
[DFNCPP="$CPP"]
[break],,)
done
CPP="$sav_CPP"])
if test -n "$DFNCPP"; then
AC_MSG_RESULT([$DFNCPP])
AC_SUBST(DFNCPP)
else
AC_MSG_FAILURE([not found], 1)
fi
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memset], , AC_ERROR([memset not found in libc]))
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_ERROR([cannot find pow])) )
AC_ARG_WITH(zlib-prefix,
AC_HELP_STRING([--with-zlib-prefix],
[prefix that may have been used in installed zlib]),
[ZPREFIX=${withval}],
[ZPREFIX='z_'])
AC_CHECK_LIB(z, zlibVersion, ,
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, ,
AC_ERROR([zlib not installed])))
LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG
LIBPNG_DEFINES=$LIBPNG_DEFINES
AC_SUBST(LIBPNG_DEFINES)
AC_MSG_CHECKING([if libraries can be versioned])
# Special case for PE/COFF platforms: ld reports
# support for version-script, but doesn't actually
# DO anything with it.
case $host in
*cygwin* | *mingw32* | *interix* )
have_ld_version_script=no
AC_MSG_RESULT(no)
;;
* )
GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
if test "$GLD"; then
have_ld_version_script=yes
AC_MSG_RESULT(yes)
else
have_ld_version_script=no
AC_MSG_RESULT(no)
AC_MSG_WARN(*** You have not enabled versioned symbols.)
fi
;;
esac
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
if test "$have_ld_version_script" = "yes"; then
AC_MSG_CHECKING([for symbol prefix])
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
| ${CPP-${CC-gcc} -E} - 2>&1 \
| ${EGREP-grep} "^PREFIX=" \
| ${SED-sed} "s:^PREFIX=::"`
AC_SUBST(SYMBOL_PREFIX)
AC_MSG_RESULT($SYMBOL_PREFIX)
fi
# Substitutions for .in files
AC_SUBST(PNGLIB_VERSION)
AC_SUBST(PNGLIB_MAJOR)
AC_SUBST(PNGLIB_MINOR)
AC_SUBST(PNGLIB_RELEASE)
# Additional arguments (and substitutions)
# Allow the pkg-config directory to be set
AC_ARG_WITH(pkgconfigdir,
AC_HELP_STRING([--with-pkgconfigdir],
[Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
[pkgconfigdir=${withval}],
[pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST([pkgconfigdir])
AC_MSG_NOTICE([pkgconfig directory is ${pkgconfigdir}])
# Make the *-config binary config scripts optional
AC_ARG_WITH(binconfigs,
AC_HELP_STRING([--with-binconfigs],
[Generate shell libpng-config scripts as well as pkg-config data]
[@<:@default=yes@:>@]),
[if test "${withval}" = no; then
binconfigs=
AC_MSG_NOTICE([libpng-config scripts will not be built])
else
binconfigs='${binconfigs}'
fi],
[binconfigs='${binconfigs}'])
AC_SUBST([binconfigs])
# Config files, substituting as above
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
AC_CONFIG_FILES([libpng-config:libpng-config.in],
[chmod +x libpng-config])
AC_OUTPUT

View File

@ -1,843 +0,0 @@
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
* Last changed in libpng 1.5.0 [January 6, 2011]
* This file has been placed in the public domain by the authors.
* Maintained 1998-2011 Glenn Randers-Pehrson
* Maintained 1996, 1997 Andreas Dilger)
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/
/* This is an example of how to use libpng to read and write PNG files.
* The file libpng-manual.txt is much more verbose then this. If you have not
* read it, do so first. This was designed to be a starting point of an
* implementation. This is not officially part of libpng, is hereby placed
* in the public domain, and therefore does not require a copyright notice.
*
* This file does not currently compile, because it is missing certain
* parts, like allocating memory to hold an image. You will have to
* supply these parts to get it to compile. For an example of a minimal
* working PNG reader/writer, see pngtest.c, included in this distribution;
* see also the programs in the contrib directory.
*/
#include "png.h"
/* The png_jmpbuf() macro, used in error handling, became available in
* libpng version 1.0.6. If you want to be able to run your code with older
* versions of libpng, you must define the macro yourself (but only if it
* is not already defined by libpng!).
*/
#ifndef png_jmpbuf
# define png_jmpbuf(png_ptr) ((png_ptr)->png_jmpbuf)
#endif
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
*
* The function check_if_png() shown here, but not used, returns nonzero (true)
* if the file can be opened and is a PNG, 0 (false) otherwise.
*
* If this call is successful, and you are going to keep the file open,
* you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once
* you have created the png_ptr, so that libpng knows your application
* has read that many bytes from the start of the file. Make sure you
* don't call png_set_sig_bytes() with more than 8 bytes read or give it
* an incorrect number of bytes read, or you will either have read too
* many bytes (your fault), or you are telling libpng to read the wrong
* number of magic bytes (also your fault).
*
* Many applications already read the first 2 or 4 bytes from the start
* of the image to determine the file type, so it would be easiest just
* to pass the bytes to png_sig_cmp() or even skip that if you know
* you have a PNG file, and call png_set_sig_bytes().
*/
#define PNG_BYTES_TO_CHECK 4
int check_if_png(char *file_name, FILE **fp)
{
char buf[PNG_BYTES_TO_CHECK];
/* Open the prospective PNG file. */
if ((*fp = fopen(file_name, "rb")) == NULL)
return 0;
/* Read in some of the signature bytes */
if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)
return 0;
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
Return nonzero (true) if they match */
return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK));
}
/* Read a PNG file. You may want to return an error code if the read
* fails (depending upon the failure). There are two "prototypes" given
* here - one where we are given the filename, and we need to open the
* file, and the other where we are given an open file (possibly with
* some or all of the magic bytes read - see comments above).
*/
#ifdef open_file /* prototype 1 */
void read_png(char *file_name) /* We need to open the file */
{
png_structp png_ptr;
png_infop info_ptr;
unsigned int sig_read = 0;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type;
FILE *fp;
if ((fp = fopen(file_name, "rb")) == NULL)
return (ERROR);
#else no_open_file /* prototype 2 */
void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
{
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type;
#endif no_open_file /* Only use one prototype! */
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also supply the
* the compiler header file version, so that we know if the application
* was compiled with a compatible version of the library. REQUIRED
*/
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
fclose(fp);
return (ERROR);
}
/* Allocate/initialize the memory for image information. REQUIRED. */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
fclose(fp);
png_destroy_read_struct(&png_ptr, NULL, NULL);
return (ERROR);
}
/* Set error handling if you are using the setjmp/longjmp method (this is
* the normal method of doing things with libpng). REQUIRED unless you
* set up your own error handlers in the png_create_read_struct() earlier.
*/
if (setjmp(png_jmpbuf(png_ptr)))
{
/* Free all of the memory associated with the png_ptr and info_ptr */
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
fclose(fp);
/* If we get here, we had a problem reading the file */
return (ERROR);
}
/* One of the following I/O initialization methods is REQUIRED */
#ifdef streams /* PNG file I/O method 1 */
/* Set up the input control if you are using standard C streams */
png_init_io(png_ptr, fp);
#else no_streams /* PNG file I/O method 2 */
/* If you are using replacement read functions, instead of calling
* png_init_io() here you would call:
*/
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
/* where user_io_ptr is a structure you want available to the callbacks */
#endif no_streams /* Use only one I/O method! */
/* If we have already read some of the signature */
png_set_sig_bytes(png_ptr, sig_read);
#ifdef hilevel
/*
* If you have enough memory to read in the entire image at once,
* and you need to specify only transforms that can be controlled
* with one of the PNG_TRANSFORM_* bits (this presently excludes
* quantizing, filling, setting background, and doing gamma
* adjustment), then you can read the entire image (including
* pixels) into the info structure with this call:
*/
png_read_png(png_ptr, info_ptr, png_transforms, NULL);
#else
/* OK, you're doing it the hard way, with the lower-level functions */
/* The call to png_read_info() gives us all of the information from the
* PNG file before the first IDAT (image data chunk). REQUIRED
*/
png_read_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
&interlace_type, NULL, NULL);
/* Set up the data transformations you want. Note that these are all
* optional. Only call them if you want/need them. Many of the
* transformations only work on specific types of images, and many
* are mutually exclusive.
*/
/* Tell libpng to strip 16 bit/color files down to 8 bits/color */
png_set_strip_16(png_ptr);
/* Strip alpha bytes from the input data without combining with the
* background (not recommended).
*/
png_set_strip_alpha(png_ptr);
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
* byte into separate bytes (useful for paletted and grayscale images).
*/
png_set_packing(png_ptr);
/* Change the order of packed pixels to least significant bit first
* (not useful if you are using png_set_packing). */
png_set_packswap(png_ptr);
/* Expand paletted colors into true RGB triplets */
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png_ptr);
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
png_set_expand_gray_1_2_4_to_8(png_ptr);
/* Expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets.
*/
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(png_ptr);
/* Set the background color to draw transparent and alpha images over.
* It is possible to set the red, green, and blue components directly
* for paletted images instead of supplying a palette index. Note that
* even if the PNG file supplies a background, you are not required to
* use it - you should use the (solid) application background if it has one.
*/
png_color_16 my_background, *image_background;
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
png_set_background(png_ptr, image_background,
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
else
png_set_background(png_ptr, &my_background,
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
/* Some suggestions as to how to get a screen gamma value
*
* Note that screen gamma is the display_exponent, which includes
* the CRT_exponent and any correction for viewing conditions
*/
if (/* We have a user-defined screen gamma value */)
{
screen_gamma = user-defined screen_gamma;
}
/* This is one way that applications share the same screen gamma value */
else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL)
{
screen_gamma = atof(gamma_str);
}
/* If we don't have another value */
else
{
screen_gamma = 2.2; /* A good guess for a PC monitor in a dimly
lit room */
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
}
/* Tell libpng to handle the gamma conversion for you. The final call
* is a good guess for PC generated images, but it should be configurable
* by the user at run time by the user. It is strongly suggested that
* your application support gamma correction.
*/
int intent;
if (png_get_sRGB(png_ptr, info_ptr, &intent))
png_set_gamma(png_ptr, screen_gamma, 0.45455);
else
{
double image_gamma;
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma))
png_set_gamma(png_ptr, screen_gamma, image_gamma);
else
png_set_gamma(png_ptr, screen_gamma, 0.45455);
}
#ifdef PNG_READ_QUANTIZE_SUPPORTED
/* Quantize RGB files down to 8 bit palette or reduce palettes
* to the number of colors available on your screen.
*/
if (color_type & PNG_COLOR_MASK_COLOR)
{
int num_palette;
png_colorp palette;
/* This reduces the image to the application supplied palette */
if (/* We have our own palette */)
{
/* An array of colors to which the image should be quantized */
png_color std_color_cube[MAX_SCREEN_COLORS];
png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
MAX_SCREEN_COLORS, NULL, 0);
}
/* This reduces the image to the palette supplied in the file */
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
{
png_uint_16p histogram = NULL;
png_get_hIST(png_ptr, info_ptr, &histogram);
png_set_quantize(png_ptr, palette, num_palette,
max_screen_colors, histogram, 0);
}
}
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
/* Invert monochrome files to have 0 as white and 1 as black */
png_set_invert_mono(png_ptr);
/* If you want to shift the pixel values from the range [0,255] or
* [0,65535] to the original [0,7] or [0,31], or whatever range the
* colors were originally in:
*/
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
{
png_color_8p sig_bit_p;
png_get_sBIT(png_ptr, info_ptr, &sig_bit_p);
png_set_shift(png_ptr, sig_bit_p);
}
/* Flip the RGB pixels to BGR (or RGBA to BGRA) */
if (color_type & PNG_COLOR_MASK_COLOR)
png_set_bgr(png_ptr);
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
png_set_swap_alpha(png_ptr);
/* Swap bytes of 16 bit files to least significant byte first */
png_set_swap(png_ptr);
/* Add filler (or alpha) byte (before/after each RGB triplet) */
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
/* Turn on interlace handling. REQUIRED if you are not using
* png_read_image(). To see how to handle interlacing passes,
* see the png_read_row() method below:
*/
number_passes = png_set_interlace_handling(png_ptr);
/* Optional call to gamma correct and add the background to the palette
* and update info structure. REQUIRED if you are expecting libpng to
* update the palette for you (ie you selected such a transform above).
*/
png_read_update_info(png_ptr, info_ptr);
/* Allocate the memory to hold the image using the fields of info_ptr. */
/* The easiest way to read the image: */
png_bytep row_pointers[height];
/* Clear the pointer array */
for (row = 0; row < height; row++)
row_pointers[row] = NULL;
for (row = 0; row < height; row++)
row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
info_ptr));
/* Now it's time to read the image. One of these methods is REQUIRED */
#ifdef entire /* Read the entire image in one go */
png_read_image(png_ptr, row_pointers);
#else no_entire /* Read the image one or more scanlines at a time */
/* The other way to read images - deal with interlacing: */
for (pass = 0; pass < number_passes; pass++)
{
#ifdef single /* Read the image a single row at a time */
for (y = 0; y < height; y++)
{
png_read_rows(png_ptr, &row_pointers[y], NULL, 1);
}
#else no_single /* Read the image several rows at a time */
for (y = 0; y < height; y += number_of_rows)
{
#ifdef sparkle /* Read the image using the "sparkle" effect. */
png_read_rows(png_ptr, &row_pointers[y], NULL,
number_of_rows);
#else no_sparkle /* Read the image using the "rectangle" effect */
png_read_rows(png_ptr, NULL, &row_pointers[y],
number_of_rows);
#endif no_sparkle /* Use only one of these two methods */
}
/* If you want to display the image after every pass, do so here */
#endif no_single /* Use only one of these two methods */
}
#endif no_entire /* Use only one of these two methods */
/* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr);
#endif hilevel
/* At this point you have read the entire image */
/* Clean up after the read, and free any memory allocated - REQUIRED */
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
/* Close the file */
fclose(fp);
/* That's it */
return (OK);
}
/* Progressively read a file */
int
initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
{
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also check that
* the library version is compatible in case we are using dynamically
* linked libraries.
*/
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (*png_ptr == NULL)
{
*info_ptr = NULL;
return (ERROR);
}
*info_ptr = png_create_info_struct(png_ptr);
if (*info_ptr == NULL)
{
png_destroy_read_struct(png_ptr, info_ptr, NULL);
return (ERROR);
}
if (setjmp(png_jmpbuf((*png_ptr))))
{
png_destroy_read_struct(png_ptr, info_ptr, NULL);
return (ERROR);
}
/* This one's new. You will need to provide all three
* function callbacks, even if you aren't using them all.
* If you aren't using all functions, you can specify NULL
* parameters. Even when all three functions are NULL,
* you need to call png_set_progressive_read_fn().
* These functions shouldn't be dependent on global or
* static variables if you are decoding several images
* simultaneously. You should store stream specific data
* in a separate struct, given as the second parameter,
* and retrieve the pointer from inside the callbacks using
* the function png_get_progressive_ptr(png_ptr).
*/
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
info_callback, row_callback, end_callback);
return (OK);
}
int
process_data(png_structp *png_ptr, png_infop *info_ptr,
png_bytep buffer, png_uint_32 length)
{
if (setjmp(png_jmpbuf((*png_ptr))))
{
/* Free the png_ptr and info_ptr memory on error */
png_destroy_read_struct(png_ptr, info_ptr, NULL);
return (ERROR);
}
/* This one's new also. Simply give it chunks of data as
* they arrive from the data stream (in order, of course).
* On segmented machines, don't give it any more than 64K.
* The library seems to run fine with sizes of 4K, although
* you can give it much less if necessary (I assume you can
* give it chunks of 1 byte, but I haven't tried with less
* than 256 bytes yet). When this function returns, you may
* want to display any rows that were generated in the row
* callback, if you aren't already displaying them there.
*/
png_process_data(*png_ptr, *info_ptr, buffer, length);
return (OK);
}
info_callback(png_structp png_ptr, png_infop info)
{
/* Do any setup here, including setting any of the transformations
* mentioned in the Reading PNG files section. For now, you _must_
* call either png_start_read_image() or png_read_update_info()
* after all the transformations are set (even if you don't set
* any). You may start getting rows before png_process_data()
* returns, so this is your last chance to prepare for that.
*/
}
row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass)
{
/*
* This function is called for every row in the image. If the
* image is interlaced, and you turned on the interlace handler,
* this function will be called for every row in every pass.
*
* In this function you will receive a pointer to new row data from
* libpng called new_row that is to replace a corresponding row (of
* the same data format) in a buffer allocated by your application.
*
* The new row data pointer "new_row" may be NULL, indicating there is
* no new data to be replaced (in cases of interlace loading).
*
* If new_row is not NULL then you need to call
* png_progressive_combine_row() to replace the corresponding row as
* shown below:
*/
/* Get pointer to corresponding row in our
* PNG read buffer.
*/
png_bytep old_row = ((png_bytep *)our_data)[row_num];
/* If both rows are allocated then copy the new row
* data to the corresponding row data.
*/
if ((old_row != NULL) && (new_row != NULL))
png_progressive_combine_row(png_ptr, old_row, new_row);
/*
* The rows and passes are called in order, so you don't really
* need the row_num and pass, but I'm supplying them because it
* may make your life easier.
*
* For the non-NULL rows of interlaced images, you must call
* png_progressive_combine_row() passing in the new row and the
* old row, as demonstrated above. You can call this function for
* NULL rows (it will just return) and for non-interlaced images
* (it just does the png_memcpy for you) if it will make the code
* easier. Thus, you can just do this for all cases:
*/
png_progressive_combine_row(png_ptr, old_row, new_row);
/* where old_row is what was displayed for previous rows. Note
* that the first pass (pass == 0 really) will completely cover
* the old row, so the rows do not have to be initialized. After
* the first pass (and only for interlaced images), you will have
* to pass the current row as new_row, and the function will combine
* the old row and the new row.
*/
}
end_callback(png_structp png_ptr, png_infop info)
{
/* This function is called when the whole image has been read,
* including any chunks after the image (up to and including
* the IEND). You will usually have the same info chunk as you
* had in the header, although some data may have been added
* to the comments and time fields.
*
* Most people won't do much here, perhaps setting a flag that
* marks the image as finished.
*/
}
/* Write a png file */
void write_png(char *file_name /* , ... other image information ... */)
{
FILE *fp;
png_structp png_ptr;
png_infop info_ptr;
png_colorp palette;
/* Open the file */
fp = fopen(file_name, "wb");
if (fp == NULL)
return (ERROR);
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
* you can supply NULL for the last three parameters. We also check that
* the library version is compatible with the one used at compile time,
* in case we are using dynamically linked libraries. REQUIRED.
*/
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
fclose(fp);
return (ERROR);
}
/* Allocate/initialize the image information data. REQUIRED */
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
{
fclose(fp);
png_destroy_write_struct(&png_ptr, NULL);
return (ERROR);
}
/* Set error handling. REQUIRED if you aren't supplying your own
* error handling functions in the png_create_write_struct() call.
*/
if (setjmp(png_jmpbuf(png_ptr)))
{
/* If we get here, we had a problem writing the file */
fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr);
return (ERROR);
}
/* One of the following I/O initialization functions is REQUIRED */
#ifdef streams /* I/O initialization method 1 */
/* Set up the output control if you are using standard C streams */
png_init_io(png_ptr, fp);
#else no_streams /* I/O initialization method 2 */
/* If you are using replacement write functions, instead of calling
* png_init_io() here you would call
*/
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
user_IO_flush_function);
/* where user_io_ptr is a structure you want available to the callbacks */
#endif no_streams /* Only use one initialization method */
#ifdef hilevel
/* This is the easy way. Use it if you already have all the
* image info living in the structure. You could "|" many
* PNG_TRANSFORM flags into the png_transforms integer here.
*/
png_write_png(png_ptr, info_ptr, png_transforms, NULL);
#else
/* This is the hard way */
/* Set the image information here. Width and height are up to 2^31,
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
*/
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
/* Set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
* png_sizeof(png_color));
/* ... Set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
/* You must not free palette here, because png_set_PLTE only makes a link to
* the palette that you malloced. Wait until you are about to destroy
* the png structure.
*/
/* Optional significant bit (sBIT) chunk */
png_color_8 sig_bit;
/* If we are dealing with a grayscale image then */
sig_bit.gray = true_bit_depth;
/* Otherwise, if we are dealing with a color image then */
sig_bit.red = true_red_bit_depth;
sig_bit.green = true_green_bit_depth;
sig_bit.blue = true_blue_bit_depth;
/* If the image has an alpha channel then */
sig_bit.alpha = true_alpha_bit_depth;
png_set_sBIT(png_ptr, info_ptr, &sig_bit);
/* Optional gamma chunk is strongly suggested if you have any guess
* as to the correct gamma of the image.
*/
png_set_gAMA(png_ptr, info_ptr, gamma);
/* Optionally write comments into the image */
text_ptr[0].key = "Title";
text_ptr[0].text = "Mona Lisa";
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr[0].itxt_length = 0;
text_ptr[0].lang = NULL;
text_ptr[0].lang_key = NULL;
text_ptr[1].key = "Author";
text_ptr[1].text = "Leonardo DaVinci";
text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr[1].itxt_length = 0;
text_ptr[1].lang = NULL;
text_ptr[1].lang_key = NULL;
text_ptr[2].key = "Description";
text_ptr[2].text = "<long text>";
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
text_ptr[2].itxt_length = 0;
text_ptr[2].lang = NULL;
text_ptr[2].lang_key = NULL;
png_set_text(png_ptr, info_ptr, text_ptr, 3);
/* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */
/* Note that if sRGB is present the gAMA and cHRM chunks must be ignored
* on read and, if your application chooses to write them, they must
* be written in accordance with the sRGB profile
*/
/* Write the file header information. REQUIRED */
png_write_info(png_ptr, info_ptr);
/* If you want, you can write the info in two steps, in case you need to
* write your private chunk ahead of PLTE:
*
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
* write_my_chunk();
* png_write_info(png_ptr, info_ptr);
*
* However, given the level of known- and unknown-chunk support in 1.2.0
* and up, this should no longer be necessary.
*/
/* Once we write out the header, the compression type on the text
* chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or
* PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again
* at the end.
*/
/* Set up the transformations you want. Note that these are
* all optional. Only call them if you want them.
*/
/* Invert monochrome pixels */
png_set_invert_mono(png_ptr);
/* Shift the pixels up to a legal bit depth and fill in
* as appropriate to correctly scale the image.
*/
png_set_shift(png_ptr, &sig_bit);
/* Pack pixels into bytes */
png_set_packing(png_ptr);
/* Swap location of alpha bytes from ARGB to RGBA */
png_set_swap_alpha(png_ptr);
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
* RGB (4 channels -> 3 channels). The second parameter is not used.
*/
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
/* Flip BGR pixels to RGB */
png_set_bgr(png_ptr);
/* Swap bytes of 16-bit files to most significant byte first */
png_set_swap(png_ptr);
/* Swap bits of 1, 2, 4 bit packed pixel formats */
png_set_packswap(png_ptr);
/* Turn on interlace handling if you are not using png_write_image() */
if (interlacing)
number_passes = png_set_interlace_handling(png_ptr);
else
number_passes = 1;
/* The easiest way to write the image (you may have a different memory
* layout, however, so choose what fits your needs best). You need to
* use the first method if you aren't handling interlacing yourself.
*/
png_uint_32 k, height, width;
png_byte image[height][width*bytes_per_pixel];
png_bytep row_pointers[height];
if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
png_error (png_ptr, "Image is too tall to process in memory");
for (k = 0; k < height; k++)
row_pointers[k] = image + k*width*bytes_per_pixel;
/* One of the following output methods is REQUIRED */
#ifdef entire /* Write out the entire image data in one call */
png_write_image(png_ptr, row_pointers);
/* The other way to write the image - deal with interlacing */
#else no_entire /* Write out the image data by one or more scanlines */
/* The number of passes is either 1 for non-interlaced images,
* or 7 for interlaced images.
*/
for (pass = 0; pass < number_passes; pass++)
{
/* Write a few rows at a time. */
png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows);
/* If you are only writing one row at a time, this works */
for (y = 0; y < height; y++)
png_write_rows(png_ptr, &row_pointers[y], 1);
}
#endif no_entire /* Use only one output method */
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
* as well. Shouldn't be necessary in 1.2.0 and up as all the public
* chunks are supported and you can use png_set_unknown_chunks() to
* register unknown chunks into the info structure to be written out.
*/
/* It is REQUIRED to call this to finish writing the rest of the file */
png_write_end(png_ptr, info_ptr);
#endif hilevel
/* If you png_malloced a palette, free it here (don't free info_ptr->palette,
* as recommended in versions 1.0.5m and earlier of this example; if
* libpng mallocs info_ptr->palette, libpng will free it). If you
* allocated it with malloc() instead of png_malloc(), use free() instead
* of png_free().
*/
png_free(png_ptr, palette);
palette = NULL;
/* Similarly, if you png_malloced any data that you passed in with
* png_set_something(), such as a hist or trans array, free it here,
* when you can be sure that libpng is through with it.
*/
png_free(png_ptr, trans);
trans = NULL;
/* Whenever you use png_free() it is a good idea to set the pointer to
* NULL in case your application inadvertently tries to png_free() it
* again. When png_free() sees a NULL it returns without action, thus
* avoiding the double-free security problem.
*/
/* Clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, &info_ptr);
/* Close the file */
fclose(fp);
/* That's it */
return (OK);
}
#endif /* if 0 */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
Name: libpng
Description: Loads and saves PNG files
Version: @PNGLIB_VERSION@
Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
Libs.private: @LIBS@
Cflags: -I${includedir}

View File

@ -1,30 +0,0 @@
.TH LIBPNGPF 3 "February 3, 2011"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1
(private functions)
.SH SYNOPSIS
\fB#include \fI"pngpriv.h"
\fI\fB
\fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer \fP\fImaintained\fP\fB, now \fIthat
\fBthe private function prototypes are hidden in pngpriv.h and not \fIaccessible
\fBto applications. Look in pngpriv.h for the prototypes and a short \fIdescription
\fBof each \fIfunction.
\fI\fB
.SH DESCRIPTION
The functions previously listed here are used privately by libpng
and are not recommended for use by applications. They are
not "exported" to applications using shared libraries. They
are listed alphabetically here as an aid to libpng maintainers.
See pngpriv.h for more information on these functions.
.SH SEE ALSO
.BR "png"(5), " libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
.SH AUTHOR
Glenn Randers-Pehrson

View File

@ -1,74 +0,0 @@
.TH PNG 5 "February 3, 2011"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
PNG (Portable Network Graphics) is an extensible file format for the
lossless, portable, well-compressed storage of raster images. PNG provides
a patent-free replacement for GIF and can also replace many
common uses of TIFF. Indexed-color, grayscale, and truecolor images are
supported, plus an optional alpha channel. Sample depths range from
1 to 16 bits.
.br
PNG is designed to work well in online viewing applications, such as the
World Wide Web, so it is fully streamable with a progressive display
option. PNG is robust, providing both full file integrity checking and
fast, simple detection of common transmission errors. Also, PNG can store
gamma and chromaticity data for improved color matching on heterogeneous
platforms.
.SH "SEE ALSO"
.BR "libpng"(3), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
.LP
PNG specification (second edition), November 2003:
.IP
.br
<http://www.w3.org/TR/2003/REC-PNG-20031110/
PNG 1.2 specification, July 1999:
.IP
.br
http://www.libpng.org/pub/png
.LP
PNG 1.0 specification, October 1996:
.IP
.br
RFC 2083
.IP
.br
ftp://ds.internic.net/rfc/rfc2083.txt
.br
or (as a W3C Recommendation) at
.br
http://www.w3.org/TR/REC-png.html
.SH AUTHORS
This man page: Glenn Randers-Pehrson
.LP
Portable Network Graphics (PNG) Specification (Second Edition)
Information technology - Computer graphics and image processing -
Portable Network Graphics (PNG): Functional specification.
ISO/IEC 15948:2003 (E) (November 10, 2003): David Duce and others.
.LP
Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999):
Glenn Randers-Pehrson and others (png-list).
.LP
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
Thomas Boutell and others (png-list).
.LP
.SH COPYRIGHT NOTICE
.LP
This man page is Copyright (c) 1998-2006 Glenn Randers-Pehrson. See png.h
for conditions of use and distribution.
.LP
The PNG Specification (Second Edition) is
Copyright (c) 2003 W3C. (MIT, ERCIM, Keio), All Rights Reserved.
.LP
The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson.
See the specification for conditions of use and distribution.
.LP
The PNG-1.0 specification is copyright (c) 1996 Massachusetts Institute of
Technology. See the specification for conditions of use and distribution.
.LP
.\" end of man page

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.5.1 - February 3, 2011
* libpng version 1.5.10 - March 29, 2012
*
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Copyright (c) 1998-2012 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.)
*
@ -22,35 +22,37 @@
#ifndef PNGCONF_H
#define PNGCONF_H
#ifndef PNG_BUILDING_SYMBOL_TABLE
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
* definition file for machine specific limits, this may impact the
* correctness of the definitons below (see uses of INT_MAX).
*/
#ifndef PNG_NO_LIMITS_H
# include <limits.h>
#endif
# ifndef PNG_NO_LIMITS_H
# include <limits.h>
# endif
/* For the memory copy APIs (i.e. the standard definitions of these),
* because this file defines png_memcpy and so on the base APIs must
* be defined here.
*/
#if defined(BSD) && !defined(VXWORKS)
# include <strings.h>
#else
# include <string.h>
#endif
# ifdef BSD
# include <strings.h>
# else
# include <string.h>
# endif
/* For png_FILE_p - this provides the standard definition of a
* FILE
*/
#ifdef PNG_STDIO_SUPPORTED
# include <stdio.h>
# ifdef PNG_STDIO_SUPPORTED
# include <stdio.h>
# endif
#endif
/* This controls optimization of the reading of 16 and 32 bit values
* from PNG files. It can be set on a per-app-file basis - it
* just changes whether a macro is used to the function is called.
* The library builder sets the default, if read functions are not
* just changes whether a macro is used when the function is called.
* The library builder sets the default; if read functions are not
* built into the library the macro implementation is forced on.
*/
#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
@ -162,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
@ -195,7 +199,7 @@
# define PNGCAPI __watcall
# endif
# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) || defined(__WINSCW__)
# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
# define PNGCAPI __cdecl
# if PNG_API_RULE == 1
# define PNGAPI __stdcall
@ -256,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
@ -282,23 +275,15 @@
# endif
#endif
/* THe following complexity is concerned with getting the 'attributes' of the
* declared function in the correct place. This potentially requires a separate
* PNG_EXPORT function for every compiler.
/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
* 'attributes' as a storage class - the attributes go at the start of the
* function definition, and attributes are always appended regardless of the
* compiler. This considerably simplifies these macros but may cause problems
* if any compilers both need function attributes and fail to handle them as
* a storage class (this is unlikely.)
*/
#ifndef PNG_FUNCTION
# ifdef __GNUC__
# define PNG_FUNCTION(type, name, args, attributes)\
attributes type name args
# else /* !GNUC */
# ifdef _MSC_VER
# define PNG_FUNCTION(type, name, args, attributes)\
attributes type name args
# else /* !MSC */
# define PNG_FUNCTION(type, name, args, attributes)\
type name args
# endif
# endif
# define PNG_FUNCTION(type, name, args, attributes) attributes type name args
#endif
#ifndef PNG_EXPORT_TYPE
@ -310,13 +295,19 @@
* scripts directory.
*/
#ifndef PNG_EXPORTA
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
extern PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args),\
attributes)
PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
extern attributes)
#endif
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
* so make something non-empty to satisfy the requirement:
*/
#define PNG_EMPTY /*empty list*/
#define PNG_EXPORT(ordinal, type, name, args)\
PNG_EXPORTA(ordinal, type, name, args, )
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
/* Use PNG_REMOVED to comment out a removed interface. */
#ifndef PNG_REMOVED
@ -324,8 +315,7 @@
#endif
#ifndef PNG_CALLBACK
# define PNG_CALLBACK(type, name, args, attributes)\
type (PNGCBAPI name) PNGARG(args) attributes
# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
#endif
/* Support for compiler specific function attributes. These are used
@ -347,72 +337,49 @@
* functions in png.h will generate compiler warnings. Added at libpng
* version 1.2.41.
*/
# ifdef __GNUC__
# if defined(__GNUC__)
# ifndef PNG_USE_RESULT
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
# endif
# ifndef PNG_NORETURN
# define PNG_NORETURN __attribute__((__noreturn__))
# endif
# ifndef PNG_PTR_NORETURN
# define PNG_PTR_NORETURN __attribute__((__noreturn__))
# endif
# 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_DEPSTRUCT
# define PNG_DEPSTRUCT __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 /* PNG_PRIVATE */
# endif /* PNGLIB_BUILD */
# endif
# endif /* __GNUC__ */
# ifdef _MSC_VER /* may need to check value */
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
# ifndef PNG_USE_RESULT
# define PNG_USE_RESULT /*not supported*/
# define PNG_USE_RESULT /* not supported */
# endif
# ifndef PNG_NORETURN
# define PNG_NORETURN __declspec(noreturn)
# endif
# ifndef PNG_PTR_NORETURN
# define PNG_PTR_NORETURN /*not supported*/
# define PNG_NORETURN __declspec(noreturn)
# endif
# ifndef PNG_ALLOCATED
# define PNG_ALLOCATED __declspec(restrict)
# if (_MSC_VER >= 1400)
# define PNG_ALLOCATED __declspec(restrict)
# endif
# 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_DEPSTRUCT
# define PNG_DEPSTRUCT __declspec(deprecated)
# endif
# ifndef PNG_PRIVATE
# define PNG_PRIVATE __declspec(deprecated)
# endif /* PNG_PRIVATE */
# endif /* PNGLIB_BUILD */
# endif /* __GNUC__ */
# ifndef PNG_DEPRECATED
# define PNG_DEPRECATED __declspec(deprecated)
# endif
# ifndef PNG_PRIVATE
# define PNG_PRIVATE __declspec(deprecated)
# endif
# endif /* _MSC_VER */
#endif /* PNG_PEDANTIC_WARNINGS */
#ifndef PNG_DEPRECATED
@ -427,9 +394,6 @@
#ifndef PNG_ALLOCATED
# define PNG_ALLOCATED /* The result of the function is new memory */
#endif
#ifndef PNG_DEPSTRUCT
# define PNG_DEPSTRUCT /* Access to this struct member is deprecated */
#endif
#ifndef PNG_PRIVATE
# define PNG_PRIVATE /* This is a private libpng function */
#endif

View File

@ -1,8 +1,8 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.8 [February 1, 2011]
* Copyright (c) 1998-2012 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.)
*
@ -89,15 +89,121 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
PNG_FUNCTION(void,PNGAPI
png_err,(png_structp png_ptr),PNG_NORETURN)
{
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
* erroneously as '\0', instead of the empty string "". This was
* apparently an error, introduced in libpng-1.2.20, and png_default_error
* will crash in this case.
*/
if (png_ptr != NULL && png_ptr->error_fn != NULL)
(*(png_ptr->error_fn))(png_ptr, '\0');
(*(png_ptr->error_fn))(png_ptr, "");
/* If the custom handler doesn't exist, or if it returns,
use the default handler, which will not return. */
png_default_error(png_ptr, '\0');
png_default_error(png_ptr, "");
}
#endif /* PNG_ERROR_TEXT_SUPPORTED */
/* Utility to safely appends strings to a buffer. This never errors out so
* error checking is not required in the caller.
*/
size_t
png_safecat(png_charp buffer, size_t bufsize, size_t pos,
png_const_charp string)
{
if (buffer != NULL && pos < bufsize)
{
if (string != NULL)
while (*string != '\0' && pos < bufsize-1)
buffer[pos++] = *string++;
buffer[pos] = '\0';
}
return pos;
}
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)
/* Utility to dump an unsigned value into a buffer, given a start pointer and
* and end pointer (which should point just *beyond* the end of the buffer!)
* Returns the pointer to the start of the formatted string.
*/
png_charp
png_format_number(png_const_charp start, png_charp end, int format,
png_alloc_size_t number)
{
int count = 0; /* number of digits output */
int mincount = 1; /* minimum number required */
int output = 0; /* digit output (for the fixed point format) */
*--end = '\0';
/* This is written so that the loop always runs at least once, even with
* number zero.
*/
while (end > start && (number != 0 || count < mincount))
{
static const char digits[] = "0123456789ABCDEF";
switch (format)
{
case PNG_NUMBER_FORMAT_fixed:
/* Needs five digits (the fraction) */
mincount = 5;
if (output || number % 10 != 0)
{
*--end = digits[number % 10];
output = 1;
}
number /= 10;
break;
case PNG_NUMBER_FORMAT_02u:
/* Expects at least 2 digits. */
mincount = 2;
/* fall through */
case PNG_NUMBER_FORMAT_u:
*--end = digits[number % 10];
number /= 10;
break;
case PNG_NUMBER_FORMAT_02x:
/* This format expects at least two digits */
mincount = 2;
/* fall through */
case PNG_NUMBER_FORMAT_x:
*--end = digits[number & 0xf];
number >>= 4;
break;
default: /* an error */
number = 0;
break;
}
/* Keep track of the number of digits added */
++count;
/* Float a fixed number here: */
if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
{
/* End of the fraction, but maybe nothing was output? In that case
* drop the decimal point. If the number is a true zero handle that
* here.
*/
if (output)
*--end = '.';
else if (number == 0) /* and !output */
*--end = '0';
}
}
return end;
}
#endif
#ifdef PNG_WARNINGS_SUPPORTED
/* This function is called whenever there is a non-fatal error. This function
* should not be changed. If there is a need to handle warnings differently,
@ -128,6 +234,124 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
else
png_default_warning(png_ptr, warning_message + offset);
}
/* These functions support 'formatted' warning messages with up to
* PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter
* is introduced by @<number>, where 'number' starts at 1. This follows the
* standard established by X/Open for internationalizable error messages.
*/
void
png_warning_parameter(png_warning_parameters p, int number,
png_const_charp string)
{
if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)
(void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);
}
void
png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
png_alloc_size_t value)
{
char buffer[PNG_NUMBER_BUFFER_SIZE];
png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
}
void
png_warning_parameter_signed(png_warning_parameters p, int number, int format,
png_int_32 value)
{
png_alloc_size_t u;
png_charp str;
char buffer[PNG_NUMBER_BUFFER_SIZE];
/* Avoid overflow by doing the negate in a png_alloc_size_t: */
u = (png_alloc_size_t)value;
if (value < 0)
u = ~u + 1;
str = PNG_FORMAT_NUMBER(buffer, format, u);
if (value < 0 && str > buffer)
*--str = '-';
png_warning_parameter(p, number, str);
}
void
png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
png_const_charp message)
{
/* The internal buffer is just 192 bytes - enough for all our messages,
* overflow doesn't happen because this code checks! If someone figures
* out how to send us a message longer than 192 bytes, all that will
* happen is that the message will be truncated appropriately.
*/
size_t i = 0; /* Index in the msg[] buffer: */
char msg[192];
/* Each iteration through the following loop writes at most one character
* to msg[i++] then returns here to validate that there is still space for
* the trailing '\0'. It may (in the case of a parameter) read more than
* one character from message[]; it must check for '\0' and continue to the
* test if it finds the end of string.
*/
while (i<(sizeof msg)-1 && *message != '\0')
{
/* '@' at end of string is now just printed (previously it was skipped);
* it is an error in the calling code to terminate the string with @.
*/
if (p != NULL && *message == '@' && message[1] != '\0')
{
int parameter_char = *++message; /* Consume the '@' */
static const char valid_parameters[] = "123456789";
int parameter = 0;
/* Search for the parameter digit, the index in the string is the
* parameter to use.
*/
while (valid_parameters[parameter] != parameter_char &&
valid_parameters[parameter] != '\0')
++parameter;
/* If the parameter digit is out of range it will just get printed. */
if (parameter < PNG_WARNING_PARAMETER_COUNT)
{
/* Append this parameter */
png_const_charp parm = p[parameter];
png_const_charp pend = p[parameter] + (sizeof p[parameter]);
/* No need to copy the trailing '\0' here, but there is no guarantee
* that parm[] has been initialized, so there is no guarantee of a
* trailing '\0':
*/
while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend)
msg[i++] = *parm++;
/* Consume the parameter digit too: */
++message;
continue;
}
/* else not a parameter and there is a character after the @ sign; just
* copy that. This is known not to be '\0' because of the test above.
*/
}
/* At this point *message can't be '\0', even in the bad parameter case
* above where there is a lone '@' at the end of the message string.
*/
msg[i++] = *message++;
}
/* i is always less than (sizeof msg), so: */
msg[i] = '\0';
/* And this is the formatted message, it may be larger than
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these are
* not (currently) formatted.
*/
png_warning(png_ptr, msg);
}
#endif /* PNG_WARNINGS_SUPPORTED */
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
@ -159,11 +383,14 @@ static void /* PRIVATE */
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
error_message)
{
int iout = 0, iin = 0;
png_uint_32 chunk_name = png_ptr->chunk_name;
int iout = 0, ishift = 24;
while (iin < 4)
while (ishift >= 0)
{
int c = png_ptr->chunk_name[iin++];
int c = (int)(chunk_name >> ishift) & 0xff;
ishift -= 8;
if (isnonalpha(c))
{
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
@ -174,7 +401,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
else
{
buffer[iout++] = (png_byte)c;
buffer[iout++] = (char)c;
}
}
@ -183,10 +410,16 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
else
{
int iin = 0;
buffer[iout++] = ':';
buffer[iout++] = ' ';
png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0')
buffer[iout++] = error_message[iin++];
/* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */
buffer[iout] = '\0';
}
}
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
@ -272,7 +505,7 @@ png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
return NULL;
png_ptr->longjmp_fn = longjmp_fn;
return &png_ptr->png_jmpbuf;
return &png_ptr->longjmp_buffer;
}
#endif
@ -287,7 +520,8 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
{
#ifdef PNG_CONSOLE_IO_SUPPORTED
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (*error_message == PNG_LITERAL_SHARP)
/* 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. */
int offset;
@ -317,11 +551,11 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
else
#endif
{
fprintf(stderr, "libpng error: %s", error_message);
fprintf(stderr, "libpng error: %s", error_message ? error_message :
"undefined");
fprintf(stderr, PNG_STRING_NEWLINE);
}
#endif
#ifndef PNG_CONSOLE_IO_SUPPORTED
#else
PNG_UNUSED(error_message) /* Make compiler happy */
#endif
png_longjmp(png_ptr, 1);
@ -335,13 +569,13 @@ png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
{
# ifdef USE_FAR_KEYWORD
{
jmp_buf png_jmpbuf;
png_memcpy(png_jmpbuf, png_ptr->png_jmpbuf, png_sizeof(jmp_buf));
png_ptr->longjmp_fn(png_jmpbuf, val);
jmp_buf tmp_jmpbuf;
png_memcpy(tmp_jmpbuf, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
png_ptr->longjmp_fn(tmp_jmpbuf, val);
}
# else
png_ptr->longjmp_fn(png_ptr->png_jmpbuf, val);
png_ptr->longjmp_fn(png_ptr->longjmp_buffer, val);
# endif
}
#endif
@ -403,7 +637,7 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
/* This function is called when the application wants to use another method
* of handling errors and warnings. Note that the error function MUST NOT
* return to the calling routine or serious problems will occur. The return
* method used in the default routine calls longjmp(png_ptr->png_jmpbuf, 1)
* method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1)
*/
void PNGAPI
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
@ -414,7 +648,11 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
png_ptr->error_ptr = error_ptr;
png_ptr->error_fn = error_fn;
#ifdef PNG_WARNINGS_SUPPORTED
png_ptr->warning_fn = warning_fn;
#else
PNG_UNUSED(warning_fn)
#endif
}

View File

@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct
*
* Last changed in libpng 1.5.1 [February 3, 2011]
* Last changed in libpng 1.5.7 [December 15, 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.)
@ -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
@ -587,15 +682,16 @@ png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
png_debug1(1, "in %s retrieval function", "iCCP");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
&& name != NULL && profile != NULL && proflen != NULL)
&& name != NULL && compression_type != NULL && profile != NULL &&
proflen != NULL)
{
*name = info_ptr->iccp_name;
*profile = info_ptr->iccp_profile;
/* Compression_type is a dummy so the API won't have to change
* if we introduce multiple compression types later.
*/
*proflen = (int)info_ptr->iccp_proflen;
*compression_type = (int)info_ptr->iccp_compression;
*proflen = info_ptr->iccp_proflen;
*compression_type = info_ptr->iccp_compression;
return (PNG_INFO_iCCP);
}
@ -855,9 +951,8 @@ png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{
png_debug1(1, "in %s retrieval function",
(png_ptr->chunk_name[0] == '\0' ? "text" :
(png_const_charp)png_ptr->chunk_name));
png_debug1(1, "in 0x%lx retrieval function",
(unsigned long)png_ptr->chunk_name);
if (text_ptr != NULL)
*text_ptr = info_ptr->text;
@ -971,10 +1066,9 @@ png_get_user_chunk_ptr(png_const_structp png_ptr)
png_size_t PNGAPI
png_get_compression_buffer_size(png_const_structp png_ptr)
{
return (png_ptr ? png_ptr->zbuf_size : 0L);
return (png_ptr ? png_ptr->zbuf_size : 0);
}
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* These functions were added to libpng 1.2.6 and were enabled
* by default in libpng-1.4.0 */
@ -1016,16 +1110,14 @@ png_get_io_state (png_structp png_ptr)
png_uint_32 PNGAPI
png_get_io_chunk_type (png_const_structp png_ptr)
{
return ((png_ptr->chunk_name[0] << 24) +
(png_ptr->chunk_name[1] << 16) +
(png_ptr->chunk_name[2] << 8) +
(png_ptr->chunk_name[3]));
return png_ptr->chunk_name;
}
png_const_bytep PNGAPI
png_get_io_chunk_name (png_structp png_ptr)
{
return png_ptr->chunk_name;
PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);
return png_ptr->io_chunk_string;
}
#endif /* ?PNG_IO_STATE_SUPPORTED */

View File

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

View File

@ -3,176 +3,184 @@
/* pnglibconf.h - library build configuration */
/* libpng version 1.5.0 - last changed on January 6, 2011 */
/* Libpng 1.5.10 - March 29, 2012 */
/* Copyright (c) 1998-2011 Glenn Randers-Pehrson */
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */
/* For conditions of distribution and use, see the disclaimer */
/* and license in png.h */
/* pnglibconf.h */
/* Machine generated file: DO NOT EDIT */
/* Derived from: scripts/pnglibconf.dfa */
/* If you edit this file by hand you must obey the rules expressed in */
/* pnglibconf.dfa with respect to the dependencies between the following */
/* symbols. It is much better to generate a new file using */
/* scripts/libpngconf.mak */
#ifndef PNGLCONF_H
#define PNGLCONF_H
/* settings */
#define PNG_MAX_GAMMA_8 11
#define PNG_CALLOC_SUPPORTED
#define PNG_QUANTIZE_RED_BITS 5
#define PNG_USER_WIDTH_MAX 1000000L
#define PNG_QUANTIZE_GREEN_BITS 5
#define PNG_API_RULE 0
#define PNG_QUANTIZE_BLUE_BITS 5
#define PNG_USER_CHUNK_CACHE_MAX 0
#define PNG_USER_HEIGHT_MAX 1000000L
#define PNG_sCAL_PRECISION 5
#define PNG_CALLOC_SUPPORTED
#define PNG_COST_SHIFT 3
#define PNG_WEIGHT_SHIFT 8
#define PNG_USER_CHUNK_MALLOC_MAX 0
#define PNG_DEFAULT_READ_MACROS 1
#define PNG_ZBUF_SIZE 8192
#define PNG_GAMMA_THRESHOLD_FIXED 5000
#define PNG_MAX_GAMMA_8 11
#define PNG_QUANTIZE_BLUE_BITS 5
#define PNG_QUANTIZE_GREEN_BITS 5
#define PNG_QUANTIZE_RED_BITS 5
#define PNG_sCAL_PRECISION 5
#define PNG_WEIGHT_SHIFT 8
#define PNG_ZBUF_SIZE 8192
/* end of settings */
/* options */
#define PNG_INFO_IMAGE_SUPPORTED
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
#define PNG_POINTER_INDEXING_SUPPORTED
#define PNG_WARNINGS_SUPPORTED
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
#define PNG_WRITE_SUPPORTED
#define PNG_WRITE_INTERLACING_SUPPORTED
#define PNG_WRITE_16BIT_SUPPORTED
#define PNG_EASY_ACCESS_SUPPORTED
#define PNG_16BIT_SUPPORTED
#define PNG_ALIGN_MEMORY_SUPPORTED
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_USER_LIMITS_SUPPORTED
#define PNG_FIXED_POINT_SUPPORTED
#define PNG_BENIGN_ERRORS_SUPPORTED
#define PNG_bKGD_SUPPORTED
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
#define PNG_CHECK_cHRM_SUPPORTED
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_cHRM_SUPPORTED
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_CONVERT_tIME_SUPPORTED
#define PNG_EASY_ACCESS_SUPPORTED
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
#define PNG_ERROR_TEXT_SUPPORTED
#define PNG_READ_SUPPORTED
/*#undef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED*/
#define PNG_BENIGN_ERRORS_SUPPORTED
#define PNG_SETJMP_SUPPORTED
#define PNG_WRITE_FLUSH_SUPPORTED
#define PNG_MNG_FEATURES_SUPPORTED
#define PNG_FIXED_POINT_SUPPORTED
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
#define PNG_FLOATING_POINT_SUPPORTED
#define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_STDIO_SUPPORTED
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_USER_MEM_SUPPORTED
#define PNG_IO_STATE_SUPPORTED
#define PNG_SET_USER_LIMITS_SUPPORTED
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_WRITE_FILTER_SUPPORTED
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
#define PNG_WRITE_iCCP_SUPPORTED
#define PNG_READ_TRANSFORMS_SUPPORTED
#define PNG_READ_GAMMA_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_READ_sCAL_SUPPORTED
#define PNG_WRITE_hIST_SUPPORTED
#define PNG_READ_OPT_PLTE_SUPPORTED
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
#define PNG_WRITE_gAMA_SUPPORTED
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
#define PNG_WRITE_pCAL_SUPPORTED
#define PNG_READ_INVERT_ALPHA_SUPPORTED
#define PNG_WRITE_TRANSFORMS_SUPPORTED
#define PNG_READ_sBIT_SUPPORTED
#define PNG_READ_PACK_SUPPORTED
#define PNG_WRITE_SWAP_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_WRITE_tIME_SUPPORTED
#define PNG_READ_INTERLACING_SUPPORTED
#define PNG_READ_tRNS_SUPPORTED
#define PNG_WRITE_pHYs_SUPPORTED
#define PNG_WRITE_INVERT_SUPPORTED
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
#define PNG_WRITE_sRGB_SUPPORTED
#define PNG_READ_oFFs_SUPPORTED
#define PNG_WRITE_FILLER_SUPPORTED
#define PNG_WRITE_TEXT_SUPPORTED
#define PNG_WRITE_SHIFT_SUPPORTED
#define PNG_PROGRESSIVE_READ_SUPPORTED
#define PNG_READ_SHIFT_SUPPORTED
#ifndef _WIN32_WCE
#define PNG_CONVERT_tIME_SUPPORTED
#endif
#define PNG_READ_USER_TRANSFORM_SUPPORTED
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
#define PNG_READ_USER_CHUNKS_SUPPORTED
#define PNG_READ_hIST_SUPPORTED
#define PNG_READ_16BIT_SUPPORTED
#define PNG_READ_SWAP_ALPHA_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
#define PNG_SEQUENTIAL_READ_SUPPORTED
#define PNG_READ_BACKGROUND_SUPPORTED
#define PNG_READ_QUANTIZE_SUPPORTED
#define PNG_READ_iCCP_SUPPORTED
#define PNG_READ_STRIP_ALPHA_SUPPORTED
#define PNG_READ_PACKSWAP_SUPPORTED
#define PNG_READ_sRGB_SUPPORTED
#define PNG_WRITE_tEXt_SUPPORTED
#define PNG_READ_gAMA_SUPPORTED
#define PNG_READ_pCAL_SUPPORTED
#define PNG_READ_EXPAND_SUPPORTED
#define PNG_WRITE_sPLT_SUPPORTED
#define PNG_READ_SWAP_SUPPORTED
#define PNG_READ_tIME_SUPPORTED
#define PNG_READ_pHYs_SUPPORTED
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
#define PNG_TIME_RFC1123_SUPPORTED
#define PNG_READ_TEXT_SUPPORTED
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_USER_CHUNKS_SUPPORTED
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_WRITE_PACK_SUPPORTED
#define PNG_READ_FILLER_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_tRNS_SUPPORTED
#define PNG_READ_sPLT_SUPPORTED
#define PNG_WRITE_sCAL_SUPPORTED
#define PNG_WRITE_oFFs_SUPPORTED
#define PNG_READ_tEXt_SUPPORTED
#define PNG_WRITE_sBIT_SUPPORTED
#define PNG_READ_INVERT_SUPPORTED
#define PNG_READ_16_TO_8_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_16BIT_SUPPORTED
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
#define PNG_READ_BGR_SUPPORTED
#define PNG_WRITE_PACKSWAP_SUPPORTED
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
#define PNG_sCAL_SUPPORTED
#define PNG_WRITE_zTXt_SUPPORTED
#define PNG_sBIT_SUPPORTED
#define PNG_cHRM_SUPPORTED
#define PNG_bKGD_SUPPORTED
#define PNG_tRNS_SUPPORTED
#define PNG_WRITE_iTXt_SUPPORTED
#define PNG_oFFs_SUPPORTED
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
#define PNG_gAMA_SUPPORTED
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
#define PNG_hIST_SUPPORTED
#define PNG_iCCP_SUPPORTED
#define PNG_sRGB_SUPPORTED
#define PNG_READ_zTXt_SUPPORTED
#define PNG_gAMA_SUPPORTED
#define PNG_pCAL_SUPPORTED
#define PNG_CHECK_cHRM_SUPPORTED
#define PNG_tIME_SUPPORTED
#define PNG_pHYs_SUPPORTED
#define PNG_READ_iTXt_SUPPORTED
#define PNG_TEXT_SUPPORTED
#define PNG_SAVE_INT_32_SUPPORTED
#define PNG_sPLT_SUPPORTED
#define PNG_tEXt_SUPPORTED
#define PNG_zTXt_SUPPORTED
#define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_INFO_IMAGE_SUPPORTED
#define PNG_IO_STATE_SUPPORTED
#define PNG_iTXt_SUPPORTED
#define PNG_MNG_FEATURES_SUPPORTED
#define PNG_oFFs_SUPPORTED
#define PNG_pCAL_SUPPORTED
#define PNG_pHYs_SUPPORTED
#define PNG_POINTER_INDEXING_SUPPORTED
#define PNG_PROGRESSIVE_READ_SUPPORTED
#define PNG_READ_16BIT_SUPPORTED
#define PNG_READ_ALPHA_MODE_SUPPORTED
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_READ_BACKGROUND_SUPPORTED
#define PNG_READ_BGR_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
#define PNG_READ_EXPAND_16_SUPPORTED
#define PNG_READ_EXPAND_SUPPORTED
#define PNG_READ_FILLER_SUPPORTED
#define PNG_READ_gAMA_SUPPORTED
#define PNG_READ_GAMMA_SUPPORTED
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
#define PNG_READ_hIST_SUPPORTED
#define PNG_READ_iCCP_SUPPORTED
#define PNG_READ_INTERLACING_SUPPORTED
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
#define PNG_READ_INVERT_ALPHA_SUPPORTED
#define PNG_READ_INVERT_SUPPORTED
#define PNG_READ_iTXt_SUPPORTED
#define PNG_READ_oFFs_SUPPORTED
#define PNG_READ_OPT_PLTE_SUPPORTED
#define PNG_READ_PACK_SUPPORTED
#define PNG_READ_PACKSWAP_SUPPORTED
#define PNG_READ_pCAL_SUPPORTED
#define PNG_READ_pHYs_SUPPORTED
#define PNG_READ_QUANTIZE_SUPPORTED
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
#define PNG_READ_sBIT_SUPPORTED
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
#define PNG_READ_sCAL_SUPPORTED
#define PNG_READ_SHIFT_SUPPORTED
#define PNG_READ_sPLT_SUPPORTED
#define PNG_READ_sRGB_SUPPORTED
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
#define PNG_READ_STRIP_ALPHA_SUPPORTED
#define PNG_READ_SUPPORTED
#define PNG_READ_SWAP_ALPHA_SUPPORTED
#define PNG_READ_SWAP_SUPPORTED
#define PNG_READ_tEXt_SUPPORTED
#define PNG_READ_TEXT_SUPPORTED
#define PNG_READ_tIME_SUPPORTED
#define PNG_READ_TRANSFORMS_SUPPORTED
#define PNG_READ_tRNS_SUPPORTED
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_READ_USER_CHUNKS_SUPPORTED
#define PNG_READ_USER_TRANSFORM_SUPPORTED
#define PNG_READ_zTXt_SUPPORTED
#define PNG_SAVE_INT_32_SUPPORTED
#define PNG_sBIT_SUPPORTED
#define PNG_sCAL_SUPPORTED
#define PNG_SEQUENTIAL_READ_SUPPORTED
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
#define PNG_SETJMP_SUPPORTED
#define PNG_SET_USER_LIMITS_SUPPORTED
#define PNG_sPLT_SUPPORTED
#define PNG_sRGB_SUPPORTED
#define PNG_STDIO_SUPPORTED
#define PNG_tEXt_SUPPORTED
#define PNG_TEXT_SUPPORTED
#define PNG_TIME_RFC1123_SUPPORTED
#define PNG_tIME_SUPPORTED
#define PNG_tRNS_SUPPORTED
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_USER_CHUNKS_SUPPORTED
#define PNG_USER_LIMITS_SUPPORTED
#define PNG_USER_MEM_SUPPORTED
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
#define PNG_WARNINGS_SUPPORTED
#define PNG_WRITE_16BIT_SUPPORTED
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
#define PNG_WRITE_FILLER_SUPPORTED
#define PNG_WRITE_FILTER_SUPPORTED
#define PNG_WRITE_FLUSH_SUPPORTED
#define PNG_WRITE_gAMA_SUPPORTED
#define PNG_WRITE_hIST_SUPPORTED
#define PNG_WRITE_iCCP_SUPPORTED
#define PNG_WRITE_INTERLACING_SUPPORTED
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
#define PNG_WRITE_INVERT_SUPPORTED
#define PNG_WRITE_iTXt_SUPPORTED
#define PNG_WRITE_oFFs_SUPPORTED
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
#define PNG_WRITE_PACK_SUPPORTED
#define PNG_WRITE_PACKSWAP_SUPPORTED
#define PNG_WRITE_pCAL_SUPPORTED
#define PNG_WRITE_pHYs_SUPPORTED
#define PNG_WRITE_sBIT_SUPPORTED
#define PNG_WRITE_sCAL_SUPPORTED
#define PNG_WRITE_SHIFT_SUPPORTED
#define PNG_WRITE_sPLT_SUPPORTED
#define PNG_WRITE_sRGB_SUPPORTED
#define PNG_WRITE_SUPPORTED
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
#define PNG_WRITE_SWAP_SUPPORTED
#define PNG_WRITE_tEXt_SUPPORTED
#define PNG_WRITE_TEXT_SUPPORTED
#define PNG_WRITE_tIME_SUPPORTED
#define PNG_WRITE_TRANSFORMS_SUPPORTED
#define PNG_WRITE_tRNS_SUPPORTED
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_zTXt_SUPPORTED
#define PNG_zTXt_SUPPORTED
/* end of options */
#endif /* PNGLCONF_H */

View File

@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation
*
* Last changed in libpng 1.5.1 [February 3, 2011]
* Last changed in libpng 1.5.7 [December 15, 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.)
@ -56,9 +56,9 @@ png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
if (malloc_fn != NULL)
{
png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
memset(&dummy_struct, 0, sizeof dummy_struct);
dummy_struct.mem_ptr=mem_ptr;
struct_ptr = (*(malloc_fn))(&dummy_struct, (png_alloc_size_t)size);
}
else
@ -90,9 +90,9 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
if (free_fn != NULL)
{
png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
(*(free_fn))(png_ptr, struct_ptr);
memset(&dummy_struct, 0, sizeof dummy_struct);
dummy_struct.mem_ptr=mem_ptr;
(*(free_fn))(&dummy_struct, struct_ptr);
return;
}
@ -143,7 +143,7 @@ png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
# ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr->malloc_fn != NULL)
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
else
ret = (png_malloc_default(png_ptr, size));
@ -187,8 +187,9 @@ png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
int num_blocks;
png_uint_32 total_size;
png_bytep table;
int i;
int i, mem_level, window_bits;
png_byte huge * hptr;
int window_bits
if (ret != NULL)
{
@ -196,14 +197,22 @@ png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
ret = NULL;
}
if (png_ptr->zlib_window_bits > 14)
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
window_bits =
png_ptr->zlib_window_bits >= png_ptr->zlib_text_window_bits ?
png_ptr->zlib_window_bits : png_ptr->zlib_text_window_bits;
if (window_bits > 14)
num_blocks = (int)(1 << (window_bits - 14));
else
num_blocks = 1;
if (png_ptr->zlib_mem_level >= 7)
num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
mem_level =
png_ptr->zlib_mem_level >= png_ptr->zlib_text_mem_level ?
png_ptr->zlib_mem_level : png_ptr->zlib_text_mem_level;
if (mem_level >= 7)
num_blocks += (int)(1 << (mem_level - 7));
else
num_blocks++;
@ -277,7 +286,7 @@ png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
{
# ifndef PNG_USER_MEM_SUPPORTED
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out of Memory"); /* Note "o" and "M" */
png_error(png_ptr, "Out of Memory"); /* Note "O" and "M" */
else
png_warning(png_ptr, "Out of Memory");

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.5.1 [$RDATE%]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.10 [March 8, 2012]
* Copyright (c) 1998-2012 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.)
*
@ -47,12 +47,10 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
#ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD
jmp_buf png_jmpbuf;
jmp_buf tmp_jmpbuf;
#endif
#endif
int i;
png_debug(1, "in png_create_read_struct");
#ifdef PNG_USER_MEM_SUPPORTED
@ -69,29 +67,26 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
png_ptr->user_width_max = PNG_USER_WIDTH_MAX;
png_ptr->user_height_max = PNG_USER_HEIGHT_MAX;
# ifdef PNG_USER_CHUNK_CACHE_MAX
/* Added at libpng-1.2.43 and 1.4.0 */
png_ptr->user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;
# endif
# ifdef PNG_SET_USER_CHUNK_MALLOC_MAX
/* Added at libpng-1.2.43 and 1.4.1 */
png_ptr->user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
# endif
#endif
#ifdef PNG_SETJMP_SUPPORTED
/* Applications that neglect to set up their own setjmp() and then
encounter a png_error() will longjmp here. Since the jmpbuf is
then meaningless we abort instead of returning. */
* encounter a png_error() will longjmp here. Since the jmpbuf is
* then meaningless we abort instead of returning.
*/
#ifdef USE_FAR_KEYWORD
if (setjmp(png_jmpbuf))
if (setjmp(tmp_jmpbuf))
#else
if (setjmp(png_jmpbuf(png_ptr))) /* Sets longjmp to match setjmp */
#endif
PNG_ABORT();
#ifdef USE_FAR_KEYWORD
png_memcpy(png_jmpbuf(png_ptr), png_jmpbuf, png_sizeof(jmp_buf));
png_memcpy(png_jmpbuf(png_ptr), tmp_jmpbuf, png_sizeof(jmp_buf));
#endif
#endif /* PNG_SETJMP_SUPPORTED */
@ -101,54 +96,9 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
if (user_png_ver)
{
i = 0;
do
{
if (user_png_ver[i] != png_libpng_ver[i])
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
}
else
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
{
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
* we must recompile any applications that use any older library version.
* For versions after libpng 1.0, we will be compatible, so we need
* only check the first digit.
*/
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{
#ifdef PNG_CONSOLE_IO_SUPPORTED
char msg[80];
if (user_png_ver)
{
png_snprintf2(msg, 80,
"Application built with libpng-%.20s"
" but running with %.20s",
user_png_ver,
png_libpng_ver);
png_warning(png_ptr, msg);
}
#else
png_warning(png_ptr,
"Incompatible libpng version in application and library");
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags = 0;
#endif
png_cleanup_needed = 1;
}
}
/* Call the general version checker (shared with read and write code): */
if (!png_user_version_check(png_ptr, user_png_ver))
png_cleanup_needed = 1;
if (!png_cleanup_needed)
{
@ -237,89 +187,35 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
for (;;)
{
PNG_IHDR;
PNG_IDAT;
PNG_IEND;
PNG_PLTE;
#ifdef PNG_READ_bKGD_SUPPORTED
PNG_bKGD;
#endif
#ifdef PNG_READ_cHRM_SUPPORTED
PNG_cHRM;
#endif
#ifdef PNG_READ_gAMA_SUPPORTED
PNG_gAMA;
#endif
#ifdef PNG_READ_hIST_SUPPORTED
PNG_hIST;
#endif
#ifdef PNG_READ_iCCP_SUPPORTED
PNG_iCCP;
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
PNG_iTXt;
#endif
#ifdef PNG_READ_oFFs_SUPPORTED
PNG_oFFs;
#endif
#ifdef PNG_READ_pCAL_SUPPORTED
PNG_pCAL;
#endif
#ifdef PNG_READ_pHYs_SUPPORTED
PNG_pHYs;
#endif
#ifdef PNG_READ_sBIT_SUPPORTED
PNG_sBIT;
#endif
#ifdef PNG_READ_sCAL_SUPPORTED
PNG_sCAL;
#endif
#ifdef PNG_READ_sPLT_SUPPORTED
PNG_sPLT;
#endif
#ifdef PNG_READ_sRGB_SUPPORTED
PNG_sRGB;
#endif
#ifdef PNG_READ_tEXt_SUPPORTED
PNG_tEXt;
#endif
#ifdef PNG_READ_tIME_SUPPORTED
PNG_tIME;
#endif
#ifdef PNG_READ_tRNS_SUPPORTED
PNG_tRNS;
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
PNG_zTXt;
#endif
png_uint_32 length = png_read_chunk_header(png_ptr);
PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
png_uint_32 chunk_name = png_ptr->chunk_name;
/* This should be a binary subdivision search or a hash for
* matching the chunk name rather than a linear search.
*/
if (!png_memcmp(chunk_name, png_IDAT, 4))
if (chunk_name == png_IDAT)
if (png_ptr->mode & PNG_AFTER_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
if (!png_memcmp(chunk_name, png_IHDR, 4))
if (chunk_name == png_IHDR)
png_handle_IHDR(png_ptr, info_ptr, length);
else if (!png_memcmp(chunk_name, png_IEND, 4))
else if (chunk_name == png_IEND)
png_handle_IEND(png_ptr, info_ptr, length);
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
else if (png_handle_as_unknown(png_ptr, chunk_name))
else if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
PNG_HANDLE_CHUNK_AS_DEFAULT)
{
if (!png_memcmp(chunk_name, png_IDAT, 4))
if (chunk_name == png_IDAT)
png_ptr->mode |= PNG_HAVE_IDAT;
png_handle_unknown(png_ptr, info_ptr, length);
if (!png_memcmp(chunk_name, png_PLTE, 4))
if (chunk_name == png_PLTE)
png_ptr->mode |= PNG_HAVE_PLTE;
else if (!png_memcmp(chunk_name, png_IDAT, 4))
else if (chunk_name == png_IDAT)
{
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before IDAT");
@ -332,10 +228,10 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
}
}
#endif
else if (!png_memcmp(chunk_name, png_PLTE, 4))
else if (chunk_name == png_PLTE)
png_handle_PLTE(png_ptr, info_ptr, length);
else if (!png_memcmp(chunk_name, png_IDAT, 4))
else if (chunk_name == png_IDAT)
{
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before IDAT");
@ -350,87 +246,87 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
}
#ifdef PNG_READ_bKGD_SUPPORTED
else if (!png_memcmp(chunk_name, png_bKGD, 4))
else if (chunk_name == png_bKGD)
png_handle_bKGD(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_cHRM_SUPPORTED
else if (!png_memcmp(chunk_name, png_cHRM, 4))
else if (chunk_name == png_cHRM)
png_handle_cHRM(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_gAMA_SUPPORTED
else if (!png_memcmp(chunk_name, png_gAMA, 4))
else if (chunk_name == png_gAMA)
png_handle_gAMA(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_hIST_SUPPORTED
else if (!png_memcmp(chunk_name, png_hIST, 4))
else if (chunk_name == png_hIST)
png_handle_hIST(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_oFFs_SUPPORTED
else if (!png_memcmp(chunk_name, png_oFFs, 4))
else if (chunk_name == png_oFFs)
png_handle_oFFs(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_pCAL_SUPPORTED
else if (!png_memcmp(chunk_name, png_pCAL, 4))
else if (chunk_name == png_pCAL)
png_handle_pCAL(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sCAL_SUPPORTED
else if (!png_memcmp(chunk_name, png_sCAL, 4))
else if (chunk_name == png_sCAL)
png_handle_sCAL(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_pHYs_SUPPORTED
else if (!png_memcmp(chunk_name, png_pHYs, 4))
else if (chunk_name == png_pHYs)
png_handle_pHYs(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sBIT_SUPPORTED
else if (!png_memcmp(chunk_name, png_sBIT, 4))
else if (chunk_name == png_sBIT)
png_handle_sBIT(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sRGB_SUPPORTED
else if (!png_memcmp(chunk_name, png_sRGB, 4))
else if (chunk_name == png_sRGB)
png_handle_sRGB(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_iCCP_SUPPORTED
else if (!png_memcmp(chunk_name, png_iCCP, 4))
else if (chunk_name == png_iCCP)
png_handle_iCCP(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sPLT_SUPPORTED
else if (!png_memcmp(chunk_name, png_sPLT, 4))
else if (chunk_name == png_sPLT)
png_handle_sPLT(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_tEXt_SUPPORTED
else if (!png_memcmp(chunk_name, png_tEXt, 4))
else if (chunk_name == png_tEXt)
png_handle_tEXt(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_tIME_SUPPORTED
else if (!png_memcmp(chunk_name, png_tIME, 4))
else if (chunk_name == png_tIME)
png_handle_tIME(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_tRNS_SUPPORTED
else if (!png_memcmp(chunk_name, png_tRNS, 4))
else if (chunk_name == png_tRNS)
png_handle_tRNS(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
else if (!png_memcmp(chunk_name, png_zTXt, 4))
else if (chunk_name == png_zTXt)
png_handle_zTXt(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
else if (!png_memcmp(chunk_name, png_iTXt, 4))
else if (chunk_name == png_iTXt)
png_handle_iTXt(png_ptr, info_ptr, length);
#endif
@ -449,15 +345,13 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
if (png_ptr == NULL)
return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
png_read_start_row(png_ptr);
else
png_warning(png_ptr,
"Ignoring extra png_read_update_info() call;"
" row buffer not reallocated");
png_read_start_row(png_ptr);
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
png_read_transform_info(png_ptr, info_ptr);
#else
PNG_UNUSED(info_ptr)
#endif
}
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
@ -471,15 +365,8 @@ png_start_read_image(png_structp png_ptr)
{
png_debug(1, "in png_start_read_image");
if (png_ptr == NULL)
return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
png_read_start_row(png_ptr);
else
png_warning(png_ptr,
"Ignoring extra png_start_read_image() call;"
" row buffer not reallocated");
if (png_ptr != NULL)
png_read_start_row(png_ptr);
}
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
@ -487,21 +374,30 @@ png_start_read_image(png_structp png_ptr)
void PNGAPI
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
{
PNG_IDAT;
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
0xff};
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
int ret;
png_row_info row_info;
if (png_ptr == NULL)
return;
png_debug2(1, "in png_read_row (row %lu, pass %d)",
(unsigned long)png_ptr->row_number, png_ptr->pass);
/* png_read_start_row sets the information (in particular iwidth) for this
* interlace pass.
*/
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
png_read_start_row(png_ptr);
/* 1.5.6: row_info moved out of png_struct to a local here. */
row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */
row_info.color_type = png_ptr->color_type;
row_info.bit_depth = png_ptr->bit_depth;
row_info.channels = png_ptr->channels;
row_info.pixel_depth = png_ptr->pixel_depth;
row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{
/* Check for transforms that have been set but were defined out */
@ -543,7 +439,12 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
}
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* If interlaced and we do not need a new row, combine row and return */
/* If interlaced and we do not need a new row, combine row and return.
* Notice that the pixels we have from previous rows have been transformed
* already; we can only combine like with like (transformed or
* untransformed) and, because of the libpng API for interlaced images, this
* means we must transform before de-interlacing.
*/
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
{
switch (png_ptr->pass)
@ -552,8 +453,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
if (png_ptr->row_number & 0x07)
{
if (dsp_row != NULL)
png_combine_row(png_ptr, dsp_row,
png_pass_dsp_mask[png_ptr->pass]);
png_combine_row(png_ptr, dsp_row, 1/*display*/);
png_read_finish_row(png_ptr);
return;
}
@ -563,8 +463,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
{
if (dsp_row != NULL)
png_combine_row(png_ptr, dsp_row,
png_pass_dsp_mask[png_ptr->pass]);
png_combine_row(png_ptr, dsp_row, 1/*display*/);
png_read_finish_row(png_ptr);
return;
@ -575,8 +474,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
if ((png_ptr->row_number & 0x07) != 4)
{
if (dsp_row != NULL && (png_ptr->row_number & 4))
png_combine_row(png_ptr, dsp_row,
png_pass_dsp_mask[png_ptr->pass]);
png_combine_row(png_ptr, dsp_row, 1/*display*/);
png_read_finish_row(png_ptr);
return;
@ -587,8 +485,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
if ((png_ptr->row_number & 3) || png_ptr->width < 3)
{
if (dsp_row != NULL)
png_combine_row(png_ptr, dsp_row,
png_pass_dsp_mask[png_ptr->pass]);
png_combine_row(png_ptr, dsp_row, 1/*display*/);
png_read_finish_row(png_ptr);
return;
@ -599,8 +496,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
if ((png_ptr->row_number & 3) != 2)
{
if (dsp_row != NULL && (png_ptr->row_number & 2))
png_combine_row(png_ptr, dsp_row,
png_pass_dsp_mask[png_ptr->pass]);
png_combine_row(png_ptr, dsp_row, 1/*display*/);
png_read_finish_row(png_ptr);
return;
@ -610,8 +506,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
if ((png_ptr->row_number & 1) || png_ptr->width < 2)
{
if (dsp_row != NULL)
png_combine_row(png_ptr, dsp_row,
png_pass_dsp_mask[png_ptr->pass]);
png_combine_row(png_ptr, dsp_row, 1/*display*/);
png_read_finish_row(png_ptr);
return;
@ -647,7 +542,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
png_crc_finish(png_ptr, 0);
png_ptr->idat_size = png_read_chunk_header(png_ptr);
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
if (png_ptr->chunk_name != png_IDAT)
png_error(png_ptr, "Not enough image data");
}
png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
@ -677,33 +572,47 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
} while (png_ptr->zstream.avail_out);
png_ptr->row_info.color_type = png_ptr->color_type;
png_ptr->row_info.width = png_ptr->iwidth;
png_ptr->row_info.channels = png_ptr->channels;
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
png_ptr->row_info.width);
if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
{
if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)
png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,
png_ptr->prev_row + 1, png_ptr->row_buf[0]);
else
png_error(png_ptr, "bad adaptive filter value");
}
if (png_ptr->row_buf[0])
png_read_filter_row(png_ptr, &(png_ptr->row_info),
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
(int)(png_ptr->row_buf[0]));
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
/* libpng 1.5.6: the following line was copying png_ptr->rowbytes before
* 1.5.6, while the buffer really is this big in current versions of libpng
* it may not be in the future, so this was changed just to copy the
* interlaced count:
*/
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
#ifdef PNG_MNG_FEATURES_SUPPORTED
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
{
/* Intrapixel differencing */
png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1);
}
#endif
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
png_do_read_transformations(png_ptr);
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
if (png_ptr->transformations)
png_do_read_transformations(png_ptr, &row_info);
#endif
/* The transformed pixel depth should match the depth now in row_info. */
if (png_ptr->transformed_pixel_depth == 0)
{
png_ptr->transformed_pixel_depth = row_info.pixel_depth;
if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)
png_error(png_ptr, "sequential row overflow");
}
else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)
png_error(png_ptr, "internal sequential row size calculation error");
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Blow up interlaced rows to full size */
@ -711,27 +620,24 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
(png_ptr->transformations & PNG_INTERLACE))
{
if (png_ptr->pass < 6)
/* Old interface (pre-1.0.9):
* png_do_read_interlace(&(png_ptr->row_info),
* png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
*/
png_do_read_interlace(png_ptr);
png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
png_ptr->transformations);
if (dsp_row != NULL)
png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]);
png_combine_row(png_ptr, dsp_row, 1/*display*/);
if (row != NULL)
png_combine_row(png_ptr, row, png_pass_mask[png_ptr->pass]);
png_combine_row(png_ptr, row, 0/*row*/);
}
else
#endif
{
if (row != NULL)
png_combine_row(png_ptr, row, 0xff);
png_combine_row(png_ptr, row, -1/*ignored*/);
if (dsp_row != NULL)
png_combine_row(png_ptr, dsp_row, 0xff);
png_combine_row(png_ptr, dsp_row, -1/*ignored*/);
}
png_read_finish_row(png_ptr);
@ -895,87 +801,40 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Report invalid palette index; added at libng-1.5.10 */
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
png_ptr->num_palette_max > png_ptr->num_palette)
png_benign_error(png_ptr, "Read palette index exceeding num_palette");
#endif
do
{
PNG_IHDR;
PNG_IDAT;
PNG_IEND;
PNG_PLTE;
#ifdef PNG_READ_bKGD_SUPPORTED
PNG_bKGD;
#endif
#ifdef PNG_READ_cHRM_SUPPORTED
PNG_cHRM;
#endif
#ifdef PNG_READ_gAMA_SUPPORTED
PNG_gAMA;
#endif
#ifdef PNG_READ_hIST_SUPPORTED
PNG_hIST;
#endif
#ifdef PNG_READ_iCCP_SUPPORTED
PNG_iCCP;
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
PNG_iTXt;
#endif
#ifdef PNG_READ_oFFs_SUPPORTED
PNG_oFFs;
#endif
#ifdef PNG_READ_pCAL_SUPPORTED
PNG_pCAL;
#endif
#ifdef PNG_READ_pHYs_SUPPORTED
PNG_pHYs;
#endif
#ifdef PNG_READ_sBIT_SUPPORTED
PNG_sBIT;
#endif
#ifdef PNG_READ_sCAL_SUPPORTED
PNG_sCAL;
#endif
#ifdef PNG_READ_sPLT_SUPPORTED
PNG_sPLT;
#endif
#ifdef PNG_READ_sRGB_SUPPORTED
PNG_sRGB;
#endif
#ifdef PNG_READ_tEXt_SUPPORTED
PNG_tEXt;
#endif
#ifdef PNG_READ_tIME_SUPPORTED
PNG_tIME;
#endif
#ifdef PNG_READ_tRNS_SUPPORTED
PNG_tRNS;
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
PNG_zTXt;
#endif
png_uint_32 length = png_read_chunk_header(png_ptr);
PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
png_uint_32 chunk_name = png_ptr->chunk_name;
if (!png_memcmp(chunk_name, png_IHDR, 4))
if (chunk_name == png_IHDR)
png_handle_IHDR(png_ptr, info_ptr, length);
else if (!png_memcmp(chunk_name, png_IEND, 4))
else if (chunk_name == png_IEND)
png_handle_IEND(png_ptr, info_ptr, length);
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
else if (png_handle_as_unknown(png_ptr, chunk_name))
else if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
PNG_HANDLE_CHUNK_AS_DEFAULT)
{
if (!png_memcmp(chunk_name, png_IDAT, 4))
if (chunk_name == png_IDAT)
{
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
png_benign_error(png_ptr, "Too many IDATs found");
}
png_handle_unknown(png_ptr, info_ptr, length);
if (!png_memcmp(chunk_name, png_PLTE, 4))
if (chunk_name == png_PLTE)
png_ptr->mode |= PNG_HAVE_PLTE;
}
#endif
else if (!png_memcmp(chunk_name, png_IDAT, 4))
else if (chunk_name == png_IDAT)
{
/* Zero length IDATs are legal after the last IDAT has been
* read, but not after other chunks have been read.
@ -985,91 +844,91 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
png_crc_finish(png_ptr, length);
}
else if (!png_memcmp(chunk_name, png_PLTE, 4))
else if (chunk_name == png_PLTE)
png_handle_PLTE(png_ptr, info_ptr, length);
#ifdef PNG_READ_bKGD_SUPPORTED
else if (!png_memcmp(chunk_name, png_bKGD, 4))
else if (chunk_name == png_bKGD)
png_handle_bKGD(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_cHRM_SUPPORTED
else if (!png_memcmp(chunk_name, png_cHRM, 4))
else if (chunk_name == png_cHRM)
png_handle_cHRM(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_gAMA_SUPPORTED
else if (!png_memcmp(chunk_name, png_gAMA, 4))
else if (chunk_name == png_gAMA)
png_handle_gAMA(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_hIST_SUPPORTED
else if (!png_memcmp(chunk_name, png_hIST, 4))
else if (chunk_name == png_hIST)
png_handle_hIST(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_oFFs_SUPPORTED
else if (!png_memcmp(chunk_name, png_oFFs, 4))
else if (chunk_name == png_oFFs)
png_handle_oFFs(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_pCAL_SUPPORTED
else if (!png_memcmp(chunk_name, png_pCAL, 4))
else if (chunk_name == png_pCAL)
png_handle_pCAL(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sCAL_SUPPORTED
else if (!png_memcmp(chunk_name, png_sCAL, 4))
else if (chunk_name == png_sCAL)
png_handle_sCAL(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_pHYs_SUPPORTED
else if (!png_memcmp(chunk_name, png_pHYs, 4))
else if (chunk_name == png_pHYs)
png_handle_pHYs(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sBIT_SUPPORTED
else if (!png_memcmp(chunk_name, png_sBIT, 4))
else if (chunk_name == png_sBIT)
png_handle_sBIT(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sRGB_SUPPORTED
else if (!png_memcmp(chunk_name, png_sRGB, 4))
else if (chunk_name == png_sRGB)
png_handle_sRGB(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_iCCP_SUPPORTED
else if (!png_memcmp(chunk_name, png_iCCP, 4))
else if (chunk_name == png_iCCP)
png_handle_iCCP(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_sPLT_SUPPORTED
else if (!png_memcmp(chunk_name, png_sPLT, 4))
else if (chunk_name == png_sPLT)
png_handle_sPLT(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_tEXt_SUPPORTED
else if (!png_memcmp(chunk_name, png_tEXt, 4))
else if (chunk_name == png_tEXt)
png_handle_tEXt(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_tIME_SUPPORTED
else if (!png_memcmp(chunk_name, png_tIME, 4))
else if (chunk_name == png_tIME)
png_handle_tIME(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_tRNS_SUPPORTED
else if (!png_memcmp(chunk_name, png_tRNS, 4))
else if (chunk_name == png_tRNS)
png_handle_tRNS(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
else if (!png_memcmp(chunk_name, png_zTXt, 4))
else if (chunk_name == png_zTXt)
png_handle_zTXt(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
else if (!png_memcmp(chunk_name, png_iTXt, 4))
else if (chunk_name == png_iTXt)
png_handle_iTXt(png_ptr, info_ptr, length);
#endif
@ -1161,7 +1020,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
jmp_buf tmp_jmp;
#endif
png_error_ptr error_fn;
#ifdef PNG_WARNINGS_SUPPORTED
png_error_ptr warning_fn;
#endif
png_voidp error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn;
@ -1175,9 +1036,13 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
if (end_info_ptr != NULL)
png_info_destroy(png_ptr, end_info_ptr);
#ifdef PNG_READ_GAMMA_SUPPORTED
png_destroy_gamma_table(png_ptr);
#endif
png_free(png_ptr, png_ptr->zbuf);
png_free(png_ptr, png_ptr->big_row_buf);
png_free(png_ptr, png_ptr->prev_row);
png_free(png_ptr, png_ptr->big_prev_row);
png_free(png_ptr, png_ptr->chunkdata);
#ifdef PNG_READ_QUANTIZE_SUPPORTED
@ -1185,15 +1050,6 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
png_free(png_ptr, png_ptr->quantize_index);
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
png_free(png_ptr, png_ptr->gamma_table);
#endif
#ifdef PNG_READ_BACKGROUND_SUPPORTED
png_free(png_ptr, png_ptr->gamma_from_1);
png_free(png_ptr, png_ptr->gamma_to_1);
#endif
if (png_ptr->free_me & PNG_FREE_PLTE)
png_zfree(png_ptr, png_ptr->palette);
png_ptr->free_me &= ~PNG_FREE_PLTE;
@ -1211,67 +1067,23 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
png_ptr->free_me &= ~PNG_FREE_HIST;
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
if (png_ptr->gamma_16_table != NULL)
{
int i;
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_table[i]);
}
png_free(png_ptr, png_ptr->gamma_16_table);
}
#ifdef PNG_READ_BACKGROUND_SUPPORTED
if (png_ptr->gamma_16_from_1 != NULL)
{
int i;
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
}
png_free(png_ptr, png_ptr->gamma_16_from_1);
}
if (png_ptr->gamma_16_to_1 != NULL)
{
int i;
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
}
png_free(png_ptr, png_ptr->gamma_16_to_1);
}
#endif
#endif
#ifdef PNG_TIME_RFC1123_SUPPORTED
png_free(png_ptr, png_ptr->time_buffer);
#endif
inflateEnd(&png_ptr->zstream);
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
png_free(png_ptr, png_ptr->save_buffer);
#endif
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
#ifdef PNG_TEXT_SUPPORTED
png_free(png_ptr, png_ptr->current_text);
#endif /* PNG_TEXT_SUPPORTED */
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
/* Save the important info out of the png_struct, in case it is
* being used again.
*/
#ifdef PNG_SETJMP_SUPPORTED
png_memcpy(tmp_jmp, png_ptr->png_jmpbuf, png_sizeof(jmp_buf));
png_memcpy(tmp_jmp, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
#endif
error_fn = png_ptr->error_fn;
#ifdef PNG_WARNINGS_SUPPORTED
warning_fn = png_ptr->warning_fn;
#endif
error_ptr = png_ptr->error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
@ -1280,14 +1092,16 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
png_memset(png_ptr, 0, png_sizeof(png_struct));
png_ptr->error_fn = error_fn;
#ifdef PNG_WARNINGS_SUPPORTED
png_ptr->warning_fn = warning_fn;
#endif
png_ptr->error_ptr = error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_ptr->free_fn = free_fn;
#endif
#ifdef PNG_SETJMP_SUPPORTED
png_memcpy(png_ptr->png_jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
png_memcpy(png_ptr->longjmp_buffer, tmp_jmp, png_sizeof(jmp_buf));
#endif
}
@ -1311,7 +1125,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
{
int row;
if (png_ptr == NULL)
if (png_ptr == NULL || info_ptr == NULL)
return;
/* png_read_info() gives us all of the information from the
@ -1323,8 +1137,22 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
/* -------------- image transformations start here ------------------- */
#ifdef PNG_READ_16_TO_8_SUPPORTED
/* Tell libpng to strip 16 bit/color files down to 8 bits per color.
#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);
@ -1405,7 +1233,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_READ_SWAP_SUPPORTED
/* Swap bytes of 16 bit files to least significant byte first */
/* Swap bytes of 16-bit files to least significant byte first */
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
png_set_swap(png_ptr);
#endif
@ -1424,8 +1252,19 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
png_set_gray_to_rgb(png_ptr);
#endif
/* Added at libpng-1.5.4 */
#ifdef PNG_READ_EXPAND_16_SUPPORTED
if (transforms & PNG_TRANSFORM_EXPAND_16)
png_set_expand_16(png_ptr);
#endif
/* We don't handle adding filler bytes */
/* We use png_read_image and rely on that for interlace handling, but we also
* call png_read_update_info therefore must turn on interlace handling now:
*/
(void)png_set_interlace_handling(png_ptr);
/* Optional call to gamma correct and add the background to the palette
* and update info structure. REQUIRED if you are expecting libpng to
* update the palette for you (i.e., you selected such a transform above).

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.10 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 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 */
@ -94,15 +144,16 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
if (png_ptr == NULL || info_ptr == NULL)
return;
/* Previously these values were limited, however they must be
* wrong, therefore storing them (and setting PNG_INFO_gAMA)
* must be wrong too.
/* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
* occur. Since the fixed point representation is assymetrical it is
* possible for 1/gamma to overflow the limit of 21474 and this means the
* gamma value must be at least 5/100000 and hence at most 20000.0. For
* safety the limits here are a little narrower. The values are 0.00016 to
* 6250.0, which are truly ridiculous gammma values (and will produce
* displays that are all black or all white.)
*/
if (file_gamma > (png_fixed_point)PNG_UINT_31_MAX)
png_warning(png_ptr, "Gamma too large, ignored");
else if (file_gamma <= 0)
png_warning(png_ptr, "Negative or zero gamma ignored");
if (file_gamma < 16 || file_gamma > 625000000)
png_warning(png_ptr, "Out of range gamma value ignored");
else
{
@ -340,12 +391,12 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
if (unit != 1 && unit != 2)
png_error(png_ptr, "Invalid sCAL unit");
if (swidth == NULL || (lengthw = png_strlen(swidth)) <= 0 ||
swidth[0] == 45 /*'-'*/ || !png_check_fp_string(swidth, lengthw))
if (swidth == NULL || (lengthw = png_strlen(swidth)) == 0 ||
swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw))
png_error(png_ptr, "Invalid sCAL width");
if (sheight == NULL || (lengthh = png_strlen(sheight)) <= 0 ||
sheight[0] == 45 /*'-'*/ || !png_check_fp_string(sheight, lengthh))
if (sheight == NULL || (lengthh = png_strlen(sheight)) == 0 ||
sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh))
png_error(png_ptr, "Invalid sCAL height");
info_ptr->scal_unit = (png_byte)unit;
@ -545,16 +596,16 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
png_set_sRGB(png_ptr, info_ptr, srgb_intent);
# ifdef PNG_gAMA_SUPPORTED
png_set_gAMA_fixed(png_ptr, info_ptr, 45455L);
png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE);
# endif
# ifdef PNG_cHRM_SUPPORTED
png_set_cHRM_fixed(png_ptr, info_ptr,
/* color x y */
/* white */ 31270L, 32900L,
/* red */ 64000L, 33000L,
/* green */ 30000L, 60000L,
/* blue */ 15000L, 6000L
/* white */ 31270, 32900,
/* red */ 64000, 33000,
/* green */ 30000, 60000,
/* blue */ 15000, 6000
);
# endif /* cHRM */
}
@ -569,7 +620,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
{
png_charp new_iccp_name;
png_bytep new_iccp_profile;
png_uint_32 length;
png_size_t length;
png_debug1(1, "in %s storage function", "iCCP");
@ -630,9 +681,8 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
{
int i;
png_debug1(1, "in %s storage function", ((png_ptr == NULL ||
png_ptr->chunk_name[0] == '\0') ?
"text" : (png_const_charp)png_ptr->chunk_name));
png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" :
(unsigned long)png_ptr->chunk_name);
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
return(0);
@ -642,24 +692,28 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
*/
if (info_ptr->num_text + num_text > info_ptr->max_text)
{
int old_max_text = info_ptr->max_text;
int old_num_text = info_ptr->num_text;
if (info_ptr->text != NULL)
{
png_textp old_text;
int old_max;
old_max = info_ptr->max_text;
info_ptr->max_text = info_ptr->num_text + num_text + 8;
old_text = info_ptr->text;
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
if (info_ptr->text == NULL)
{
png_free(png_ptr, old_text);
/* Restore to previous condition */
info_ptr->max_text = old_max_text;
info_ptr->text = old_text;
return(1);
}
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max_text *
png_sizeof(png_text)));
png_free(png_ptr, old_text);
}
@ -671,7 +725,12 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
if (info_ptr->text == NULL)
{
/* Restore to previous condition */
info_ptr->num_text = old_num_text;
info_ptr->max_text = old_max_text;
return(1);
}
info_ptr->free_me |= PNG_FREE_TEXT;
}
@ -814,6 +873,15 @@ png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time)
(png_ptr->mode & PNG_WROTE_tIME))
return;
if (mod_time->month == 0 || mod_time->month > 12 ||
mod_time->day == 0 || mod_time->day > 31 ||
mod_time->hour > 23 || mod_time->minute > 59 ||
mod_time->second > 60)
{
png_warning(png_ptr, "Ignoring invalid time value");
return;
}
png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time));
info_ptr->valid |= PNG_INFO_tIME;
}
@ -915,10 +983,10 @@ png_set_sPLT(png_structp png_ptr,
{
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
png_const_sPLT_tp from = entries + i;
png_uint_32 length;
png_size_t length;
length = png_strlen(from->name) + 1;
to->name = (png_charp)png_malloc_warn(png_ptr, (png_size_t)length);
to->name = (png_charp)png_malloc_warn(png_ptr, length);
if (to->name == NULL)
{
@ -929,7 +997,7 @@ png_set_sPLT(png_structp png_ptr,
png_memcpy(to->name, from->name, length);
to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
(png_size_t)(from->nentries * png_sizeof(png_sPLT_entry)));
from->nentries * png_sizeof(png_sPLT_entry));
if (to->entries == NULL)
{
@ -1222,4 +1290,20 @@ png_set_benign_errors(png_structp png_ptr, int allowed)
png_ptr->flags &= ~PNG_FLAG_BENIGN_ERRORS_WARN;
}
#endif /* PNG_BENIGN_ERRORS_SUPPORTED */
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Do not report invalid palette index; added at libng-1.5.10 */
void PNGAPI
png_set_check_for_invalid_index(png_structp png_ptr, int allowed)
{
png_debug(1, "in png_set_check_for_invalid_index");
if (allowed)
png_ptr->num_palette_max = 0;
else
png_ptr->num_palette_max = -1;
}
#endif
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

View File

@ -5,7 +5,7 @@
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.9 [March 29, 2012]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -29,11 +29,13 @@
struct png_struct_def
{
#ifdef PNG_SETJMP_SUPPORTED
jmp_buf png_jmpbuf; /* used in png_error */
jmp_buf longjmp_buffer; /* used in png_error */
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
#endif
png_error_ptr error_fn; /* function for printing errors and aborting */
#ifdef PNG_WARNINGS_SUPPORTED
png_error_ptr warning_fn; /* function for printing warnings */
#endif
png_voidp error_ptr; /* user supplied struct for error functions */
png_rw_ptr write_data_fn; /* function for writing output data */
png_rw_ptr read_data_fn; /* function for reading input data */
@ -64,11 +66,36 @@ struct png_struct_def
z_stream zstream; /* pointer to decompression structure (below) */
png_bytep zbuf; /* buffer for zlib */
uInt zbuf_size; /* size of zbuf (typically 65536) */
#ifdef PNG_WRITE_SUPPORTED
/* Added in 1.5.4: state to keep track of whether the zstream has been
* initialized and if so whether it is for IDAT or some other chunk.
*/
#define PNG_ZLIB_UNINITIALIZED 0
#define PNG_ZLIB_FOR_IDAT 1
#define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */
#define PNG_ZLIB_USE_MASK 3 /* bottom two bits */
#define PNG_ZLIB_IN_USE 4 /* a flag value */
png_uint_32 zlib_state; /* State of zlib initialization */
/* End of material added at libpng 1.5.4 */
int zlib_level; /* holds zlib compression level */
int zlib_method; /* holds zlib compression method */
int zlib_window_bits; /* holds zlib compression window bits */
int zlib_mem_level; /* holds zlib compression memory level */
int zlib_strategy; /* holds zlib compression strategy */
#endif
/* Added at libpng 1.5.4 */
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
int zlib_text_level; /* holds zlib compression level */
int zlib_text_method; /* holds zlib compression method */
int zlib_text_window_bits; /* holds zlib compression window bits */
int zlib_text_mem_level; /* holds zlib compression memory level */
int zlib_text_strategy; /* holds zlib compression strategy */
#endif
/* End of material added at libpng 1.5.4 */
png_uint_32 width; /* width of image in pixels */
png_uint_32 height; /* height of image in pixels */
@ -77,20 +104,30 @@ struct png_struct_def
png_size_t rowbytes; /* size of row in bytes */
png_uint_32 iwidth; /* width of current interlaced row in pixels */
png_uint_32 row_number; /* current row in interlace pass */
png_bytep prev_row; /* buffer to save previous (unfiltered) row */
png_bytep row_buf; /* buffer to save current (unfiltered) row */
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
* This is a pointer into big_prev_row
*/
png_bytep row_buf; /* buffer to save current (unfiltered) row.
* This is a pointer into big_row_buf
*/
png_bytep sub_row; /* buffer to save "sub" row when filtering */
png_bytep up_row; /* buffer to save "up" row when filtering */
png_bytep avg_row; /* buffer to save "avg" row when filtering */
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
png_row_info row_info; /* used for transformation routines */
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
png_uint_32 idat_size; /* current IDAT size for read */
png_uint_32 crc; /* current chunk CRC value */
png_colorp palette; /* palette from the input file */
png_uint_16 num_palette; /* number of color entries in palette */
/* Added at libpng-1.5.10 */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
int num_palette_max; /* maximum palette index found in IDAT */
#endif
png_uint_16 num_trans; /* number of transparency values */
png_byte chunk_name[5]; /* null-terminated name of current chunk */
png_byte compression; /* file compression type (always 0) */
png_byte filter; /* file filter type (always 0) */
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
@ -98,17 +135,24 @@ struct png_struct_def
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
png_byte color_type; /* color type of file */
png_byte bit_depth; /* bit depth of file */
png_byte usr_bit_depth; /* bit depth of users row */
png_byte usr_bit_depth; /* bit depth of users row: write only */
png_byte pixel_depth; /* number of bits per pixel */
png_byte channels; /* number of channels in file */
png_byte usr_channels; /* channels at start of write */
png_byte usr_channels; /* channels at start of write: write only */
png_byte sig_bytes; /* magic bytes read/written from start of file */
png_byte maximum_pixel_depth;
/* pixel depth used for the row buffers */
png_byte transformed_pixel_depth;
/* pixel depth after read/write transforms */
png_byte io_chunk_string[5];
/* string name of chunk */
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
png_uint_16 filler; /* filler bytes for pixel expansion */
#endif
#ifdef PNG_bKGD_SUPPORTED
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
png_byte background_gamma_type;
png_fixed_point background_gamma;
png_color_16 background; /* background color in screen gamma space */
@ -123,19 +167,21 @@ struct png_struct_def
png_uint_32 flush_rows; /* number of rows written since last flush */
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
#ifdef PNG_READ_GAMMA_SUPPORTED
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
png_fixed_point gamma; /* file gamma value */
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep gamma_table; /* gamma table for 8-bit depth files */
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_bytep gamma_from_1; /* converts from 1.0 to screen */
png_bytep gamma_to_1; /* converts from file to 1.0 */
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
@ -171,13 +217,6 @@ struct png_struct_def
int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */
# ifdef PNG_TEXT_SUPPORTED
png_size_t current_text_size; /* current size of text input data */
png_size_t current_text_left; /* how much text left to read in input */
png_charp current_text; /* current text chunk buffer */
png_charp current_text_ptr; /* current location in current_text */
# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
@ -209,7 +248,7 @@ struct png_struct_def
#endif
#ifdef PNG_TIME_RFC1123_SUPPORTED
png_charp time_buffer; /* String to hold RFC 1123 time text */
char time_buffer[29]; /* String to hold RFC 1123 time text */
#endif
/* New members added in libpng-1.0.6 */
@ -226,19 +265,24 @@ 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) */
#if defined(PNG_MNG_FEATURES_SUPPORTED) || \
defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
#if defined(PNG_MNG_FEATURES_SUPPORTED)
/* Changed from png_byte to png_uint_32 at version 1.2.0 */
png_uint_32 mng_features_permitted;
#endif
@ -293,9 +337,8 @@ struct png_struct_def
png_unknown_chunk unknown_chunk;
#endif
/* New members added in libpng-1.2.26 */
/* New member added in libpng-1.2.26 */
png_size_t old_big_row_buf_size;
png_size_t old_prev_row_size;
/* New member added in libpng-1.2.30 */
png_charp chunkdata; /* buffer for reading chunk data */
@ -304,5 +347,11 @@ struct png_struct_def
/* New member added in libpng-1.4.0 */
png_uint_32 io_state;
#endif
/* New member added in libpng-1.5.6 */
png_bytep big_prev_row;
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row);
};
#endif /* PNGSTRUCT_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.10 [March 8, 2012]
* Copyright (c) 1998-2012 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.)
*
@ -424,170 +424,119 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
/* Remove filler or alpha byte(s) */
/* Remove a channel - this used to be 'png_do_strip_filler' but it used a
* somewhat weird combination of flags to determine what to do. All the calls
* to png_do_strip_filler are changed in 1.5.2 to call this instead with the
* correct arguments.
*
* The routine isn't general - the channel must be the channel at the start or
* end (not in the middle) of each pixel.
*/
void /* PRIVATE */
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
{
png_debug(1, "in png_do_strip_filler");
png_bytep sp = row; /* source pointer */
png_bytep dp = row; /* destination pointer */
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
/* At the start sp will point to the first byte to copy and dp to where
* it is copied to. ep always points just beyond the end of the row, so
* the loop simply copies (channels-1) channels until sp reaches ep.
*
* at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.
* nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.
*/
/* GA, GX, XG cases */
if (row_info->channels == 2)
{
png_bytep sp = row;
png_bytep dp = row;
png_uint_32 row_width = row_info->width;
png_uint_32 i;
if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
(flags & PNG_FLAG_STRIP_ALPHA))) &&
row_info->channels == 4)
if (row_info->bit_depth == 8)
{
if (row_info->bit_depth == 8)
{
/* This converts from RGBX or RGBA to RGB */
if (flags & PNG_FLAG_FILLER_AFTER)
{
dp += 3; sp += 4;
for (i = 1; i < row_width; i++)
{
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
sp++;
}
}
if (at_start) /* Skip initial filler */
++sp;
else /* Skip initial channel and, for sp, the filler */
sp += 2, ++dp;
/* This converts from XRGB or ARGB to RGB */
else
{
for (i = 0; i < row_width; i++)
{
sp++;
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
}
}
row_info->pixel_depth = 24;
row_info->rowbytes = row_width * 3;
}
/* For a 1 pixel wide image there is nothing to do */
while (sp < ep)
*dp++ = *sp, sp += 2;
else /* if (row_info->bit_depth == 16) */
{
if (flags & PNG_FLAG_FILLER_AFTER)
{
/* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
sp += 8; dp += 6;
for (i = 1; i < row_width; i++)
{
/* This could be (although png_memcpy is probably slower):
png_memcpy(dp, sp, 6);
sp += 8;
dp += 6;
*/
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
sp += 2;
}
}
else
{
/* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
for (i = 0; i < row_width; i++)
{
/* This could be (although png_memcpy is probably slower):
png_memcpy(dp, sp, 6);
sp += 8;
dp += 6;
*/
sp += 2;
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
}
}
row_info->pixel_depth = 48;
row_info->rowbytes = row_width * 6;
}
row_info->channels = 3;
row_info->pixel_depth = 8;
}
else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
(row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
(flags & PNG_FLAG_STRIP_ALPHA))) &&
row_info->channels == 2)
else if (row_info->bit_depth == 16)
{
if (row_info->bit_depth == 8)
{
if (flags & PNG_FLAG_FILLER_AFTER)
{
/* This converts from GX or GA to G */
for (i = 0; i < row_width; i++)
{
*dp++ = *sp++;
sp++;
}
}
if (at_start) /* Skip initial filler */
sp += 2;
else /* Skip initial channel and, for sp, the filler */
sp += 4, dp += 2;
else
{
/* This converts from XG or AG to G */
for (i = 0; i < row_width; i++)
{
sp++;
*dp++ = *sp++;
}
}
while (sp < ep)
*dp++ = *sp++, *dp++ = *sp, sp += 3;
row_info->pixel_depth = 8;
row_info->rowbytes = row_width;
}
else /* if (row_info->bit_depth == 16) */
{
if (flags & PNG_FLAG_FILLER_AFTER)
{
/* This converts from GGXX or GGAA to GG */
sp += 4; dp += 2;
for (i = 1; i < row_width; i++)
{
*dp++ = *sp++;
*dp++ = *sp++;
sp += 2;
}
}
else
{
/* This converts from XXGG or AAGG to GG */
for (i = 0; i < row_width; i++)
{
sp += 2;
*dp++ = *sp++;
*dp++ = *sp++;
}
}
row_info->pixel_depth = 16;
row_info->rowbytes = row_width * 2;
}
row_info->channels = 1;
row_info->pixel_depth = 16;
}
if (flags & PNG_FLAG_STRIP_ALPHA)
row_info->color_type = (png_byte)(row_info->color_type &
~PNG_COLOR_MASK_ALPHA);
else
return; /* bad bit depth */
row_info->channels = 1;
/* Finally fix the color type if it records an alpha channel */
if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
row_info->color_type = PNG_COLOR_TYPE_GRAY;
}
/* RGBA, RGBX, XRGB cases */
else if (row_info->channels == 4)
{
if (row_info->bit_depth == 8)
{
if (at_start) /* Skip initial filler */
++sp;
else /* Skip initial channels and, for sp, the filler */
sp += 4, dp += 3;
/* Note that the loop adds 3 to dp and 4 to sp each time. */
while (sp < ep)
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
row_info->pixel_depth = 24;
}
else if (row_info->bit_depth == 16)
{
if (at_start) /* Skip initial filler */
sp += 2;
else /* Skip initial channels and, for sp, the filler */
sp += 8, dp += 6;
while (sp < ep)
{
/* Copy 6 bytes, skip 2 */
*dp++ = *sp++, *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp, sp += 3;
}
row_info->pixel_depth = 48;
}
else
return; /* bad bit depth */
row_info->channels = 3;
/* Finally fix the color type if it records an alpha channel */
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
row_info->color_type = PNG_COLOR_TYPE_RGB;
}
else
return; /* The filler channel has gone already */
/* Fix the rowbytes value. */
row_info->rowbytes = dp-row;
}
#endif
@ -670,6 +619,109 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
}
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
/* Added at libpng-1.5.10 */
void /* PRIVATE */
png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
{
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
png_ptr->num_palette_max >= 0)
{
/* Calculations moved outside switch in an attempt to stop different
* compiler warnings. 'padding' is in *bits* within the last byte, it is
* an 'int' because pixel_depth becomes an 'int' in the expression below,
* and this calculation is used because it avoids warnings that other
* forms produced on either GCC or MSVC.
*/
int padding = (-row_info->pixel_depth * row_info->width) & 7;
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
switch (row_info->bit_depth)
{
case 1:
{
/* in this case, all bytes must be 0 so we don't need
* to unpack the pixels except for the rightmost one.
*/
for (; rp > png_ptr->row_buf; rp--)
{
if (*rp >> padding != 0)
png_ptr->num_palette_max = 1;
padding = 0;
}
break;
}
case 2:
{
for (; rp > png_ptr->row_buf; rp--)
{
int i = ((*rp >> padding) & 0x03);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
i = (((*rp >> padding) >> 2) & 0x03);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
i = (((*rp >> padding) >> 4) & 0x03);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
i = (((*rp >> padding) >> 6) & 0x03);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
padding = 0;
}
break;
}
case 4:
{
for (; rp > png_ptr->row_buf; rp--)
{
int i = ((*rp >> padding) & 0x0f);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
i = (((*rp >> padding) >> 4) & 0x0f);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
padding = 0;
}
break;
}
case 8:
{
for (; rp > png_ptr->row_buf; rp--)
{
if (*rp >= png_ptr->num_palette_max)
png_ptr->num_palette_max = (int) *rp;
}
break;
}
default:
break;
}
}
}
#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
@ -703,11 +755,16 @@ png_get_user_transform_ptr(png_const_structp png_ptr)
}
#endif
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
png_uint_32 PNGAPI
png_get_current_row_number(png_const_structp png_ptr)
{
/* See the comments in png.h - this is the sub-image row when reading and
* interlaced image.
*/
if (png_ptr != NULL)
return png_ptr->row_number;
return PNG_UINT_32_MAX; /* help the app not to fail silently */
}
@ -718,6 +775,7 @@ png_get_current_pass_number(png_const_structp png_ptr)
return png_ptr->pass;
return 8; /* invalid */
}
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.10 [March 8, 2012]
* Copyright (c) 1998-2012 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.)
*
@ -99,8 +99,10 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
int keep = png_handle_as_unknown(png_ptr, up->name);
if (keep != PNG_HANDLE_CHUNK_NEVER &&
up->location && !(up->location & PNG_HAVE_PLTE) &&
up->location &&
!(up->location & PNG_HAVE_PLTE) &&
!(up->location & PNG_HAVE_IDAT) &&
!(up->location & PNG_AFTER_IDAT) &&
((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
{
@ -273,8 +275,10 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
{
int keep = png_handle_as_unknown(png_ptr, up->name);
if (keep != PNG_HANDLE_CHUNK_NEVER &&
up->location && (up->location & PNG_HAVE_PLTE) &&
up->location &&
(up->location & PNG_HAVE_PLTE) &&
!(up->location & PNG_HAVE_IDAT) &&
!(up->location & PNG_AFTER_IDAT) &&
((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
{
@ -301,6 +305,11 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
if (!(png_ptr->mode & PNG_HAVE_IDAT))
png_error(png_ptr, "No IDATs written into file");
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
if (png_ptr->num_palette_max > png_ptr->num_palette)
png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
#endif
/* See if user wants us to write information chunks */
if (info_ptr != NULL)
{
@ -380,7 +389,8 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
{
int keep = png_handle_as_unknown(png_ptr, up->name);
if (keep != PNG_HANDLE_CHUNK_NEVER &&
up->location && (up->location & PNG_AFTER_IDAT) &&
up->location &&
(up->location & PNG_AFTER_IDAT) &&
((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
{
@ -462,10 +472,9 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
png_structp png_ptr;
#ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD
jmp_buf png_jmpbuf;
jmp_buf tmp_jmpbuf;
#endif
#endif
int i;
png_debug(1, "in png_create_write_struct");
@ -486,15 +495,16 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
#ifdef PNG_SETJMP_SUPPORTED
/* Applications that neglect to set up their own setjmp() and then
encounter a png_error() will longjmp here. Since the jmpbuf is
then meaningless we abort instead of returning. */
* encounter a png_error() will longjmp here. Since the jmpbuf is
* then meaningless we abort instead of returning.
*/
#ifdef USE_FAR_KEYWORD
if (setjmp(png_jmpbuf))
if (setjmp(tmp_jmpbuf))
#else
if (setjmp(png_jmpbuf(png_ptr))) /* sets longjmp to match setjmp */
#endif
#ifdef USE_FAR_KEYWORD
png_memcpy(png_jmpbuf(png_ptr), png_jmpbuf, png_sizeof(jmp_buf));
png_memcpy(png_jmpbuf(png_ptr), tmp_jmpbuf, png_sizeof(jmp_buf));
#endif
PNG_ABORT();
#endif
@ -504,49 +514,8 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
#endif /* PNG_USER_MEM_SUPPORTED */
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
if (user_png_ver)
{
i = 0;
do
{
if (user_png_ver[i] != png_libpng_ver[i])
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
}
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
{
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
* we must recompile any applications that use any older library version.
* For versions after libpng 1.0, we will be compatible, so we need
* only check the first digit.
*/
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{
#ifdef PNG_CONSOLE_IO_SUPPORTED
char msg[80];
if (user_png_ver)
{
png_snprintf2(msg, 80,
"Application built with libpng-%.20s"
" but running with %.20s",
user_png_ver,
png_libpng_ver);
png_warning(png_ptr, msg);
}
#else
png_warning(png_ptr,
"Incompatible libpng version in application and library");
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags = 0;
#endif
png_cleanup_needed = 1;
}
}
if (!png_user_version_check(png_ptr, user_png_ver))
png_cleanup_needed = 1;
/* Initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
@ -645,6 +614,9 @@ png_write_image(png_structp png_ptr, png_bytepp image)
void PNGAPI
png_write_row(png_structp png_ptr, png_const_bytep row)
{
/* 1.5.6: moved from png_struct to be a local structure: */
png_row_info row_info;
if (png_ptr == NULL)
return;
@ -768,36 +740,31 @@ png_write_row(png_structp png_ptr, png_const_bytep row)
#endif
/* Set up row info for transformations */
png_ptr->row_info.color_type = png_ptr->color_type;
png_ptr->row_info.width = png_ptr->usr_width;
png_ptr->row_info.channels = png_ptr->usr_channels;
png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth;
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
png_ptr->row_info.channels);
row_info.color_type = png_ptr->color_type;
row_info.width = png_ptr->usr_width;
row_info.channels = png_ptr->usr_channels;
row_info.bit_depth = png_ptr->usr_bit_depth;
row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels);
row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
png_ptr->row_info.width);
png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type);
png_debug1(3, "row_info->width = %u", png_ptr->row_info.width);
png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels);
png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth);
png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth);
png_debug1(3, "row_info->rowbytes = %lu",
(unsigned long)png_ptr->row_info.rowbytes);
png_debug1(3, "row_info->color_type = %d", row_info.color_type);
png_debug1(3, "row_info->width = %u", row_info.width);
png_debug1(3, "row_info->channels = %d", row_info.channels);
png_debug1(3, "row_info->bit_depth = %d", row_info.bit_depth);
png_debug1(3, "row_info->pixel_depth = %d", row_info.pixel_depth);
png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes);
/* Copy user's row into buffer, leaving room for filter byte. */
png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes);
png_memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
/* Handle interlacing */
if (png_ptr->interlaced && png_ptr->pass < 6 &&
(png_ptr->transformations & PNG_INTERLACE))
{
png_do_write_interlace(&(png_ptr->row_info),
png_ptr->row_buf + 1, png_ptr->pass);
png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);
/* This should always get caught above, but still ... */
if (!(png_ptr->row_info.width))
if (!(row_info.width))
{
png_write_finish_row(png_ptr);
return;
@ -805,9 +772,18 @@ png_write_row(png_structp png_ptr, png_const_bytep row)
}
#endif
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
/* Handle other transformations */
if (png_ptr->transformations)
png_do_write_transformations(png_ptr);
png_do_write_transformations(png_ptr, &row_info);
#endif
/* At this point the row_info pixel depth must match the 'transformed' depth,
* which is also the output depth.
*/
if (row_info.pixel_depth != png_ptr->pixel_depth ||
row_info.pixel_depth != png_ptr->transformed_pixel_depth)
png_error(png_ptr, "internal write transform logic error");
#ifdef PNG_MNG_FEATURES_SUPPORTED
/* Write filter_method 64 (intrapixel differencing) only if
@ -823,12 +799,19 @@ png_write_row(png_structp png_ptr, png_const_bytep row)
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
{
/* Intrapixel differencing */
png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1);
}
#endif
/* Added at libpng-1.5.10 */
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Check for out-of-range palette index */
if(row_info.color_type == PNG_COLOR_TYPE_PALETTE)
png_do_check_palette_indexes(png_ptr, &row_info);
#endif
/* Find a filter if necessary, filter the row and write it out. */
png_write_find_filter(png_ptr, &(png_ptr->row_info));
png_write_find_filter(png_ptr, &row_info);
if (png_ptr->write_row_fn != NULL)
(*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
@ -884,8 +867,6 @@ png_write_flush(png_structp png_ptr)
{
/* Write the IDAT and reset the zlib output buffer */
png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
wrote_IDAT = 1;
}
} while (wrote_IDAT == 1);
@ -896,8 +877,6 @@ png_write_flush(png_structp png_ptr)
/* Write the IDAT and reset the zlib output buffer */
png_write_IDAT(png_ptr, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
}
png_ptr->flush_rows = 0;
png_flush(png_ptr);
@ -918,13 +897,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
png_debug(1, "in png_destroy_write_struct");
if (png_ptr_ptr != NULL)
{
png_ptr = *png_ptr_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
#endif
}
#ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr != NULL)
@ -983,7 +956,9 @@ png_write_destroy(png_structp png_ptr)
jmp_buf tmp_jmp; /* Save jump buffer */
#endif
png_error_ptr error_fn;
#ifdef PNG_WARNINGS_SUPPORTED
png_error_ptr warning_fn;
#endif
png_voidp error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn;
@ -992,7 +967,8 @@ png_write_destroy(png_structp png_ptr)
png_debug(1, "in png_write_destroy");
/* Free any memory zlib uses */
deflateEnd(&png_ptr->zstream);
if (png_ptr->zlib_state != PNG_ZLIB_UNINITIALIZED)
deflateEnd(&png_ptr->zstream);
/* Free our memory. png_free checks NULL for us. */
png_free(png_ptr, png_ptr->zbuf);
@ -1005,10 +981,6 @@ png_write_destroy(png_structp png_ptr)
png_free(png_ptr, png_ptr->paeth_row);
#endif
#ifdef PNG_TIME_RFC1123_SUPPORTED
png_free(png_ptr, png_ptr->time_buffer);
#endif
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
/* Use this to save a little code space, it doesn't free the filter_costs */
png_reset_filter_heuristics(png_ptr);
@ -1018,11 +990,13 @@ png_write_destroy(png_structp png_ptr)
#ifdef PNG_SETJMP_SUPPORTED
/* Reset structure */
png_memcpy(tmp_jmp, png_ptr->png_jmpbuf, png_sizeof(jmp_buf));
png_memcpy(tmp_jmp, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
#endif
error_fn = png_ptr->error_fn;
#ifdef PNG_WARNINGS_SUPPORTED
warning_fn = png_ptr->warning_fn;
#endif
error_ptr = png_ptr->error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
@ -1031,14 +1005,16 @@ png_write_destroy(png_structp png_ptr)
png_memset(png_ptr, 0, png_sizeof(png_struct));
png_ptr->error_fn = error_fn;
#ifdef PNG_WARNINGS_SUPPORTED
png_ptr->warning_fn = warning_fn;
#endif
png_ptr->error_ptr = error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_ptr->free_fn = free_fn;
#endif
#ifdef PNG_SETJMP_SUPPORTED
png_memcpy(png_ptr->png_jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
png_memcpy(png_ptr->longjmp_buffer, tmp_jmp, png_sizeof(jmp_buf));
#endif
}
@ -1177,7 +1153,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
* better compression.
*/
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */
/* Conveneince reset API. */
/* Convenience reset API. */
static void
png_reset_filter_heuristics(png_structp png_ptr)
{
@ -1451,6 +1427,9 @@ png_set_compression_strategy(png_structp png_ptr, int strategy)
png_ptr->zlib_strategy = strategy;
}
/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
* smaller value of window_bits if it can do so safely.
*/
void PNGAPI
png_set_compression_window_bits(png_structp png_ptr, int window_bits)
{
@ -1491,6 +1470,89 @@ png_set_compression_method(png_structp png_ptr, int method)
png_ptr->zlib_method = method;
}
/* 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)
{
png_debug(1, "in png_set_text_compression_level");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_LEVEL;
png_ptr->zlib_text_level = level;
}
void PNGAPI
png_set_text_compression_mem_level(png_structp png_ptr, int mem_level)
{
png_debug(1, "in png_set_text_compression_mem_level");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL;
png_ptr->zlib_text_mem_level = mem_level;
}
void PNGAPI
png_set_text_compression_strategy(png_structp png_ptr, int strategy)
{
png_debug(1, "in png_set_text_compression_strategy");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_STRATEGY;
png_ptr->zlib_text_strategy = strategy;
}
/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
* smaller value of window_bits if it can do so safely.
*/
void PNGAPI
png_set_text_compression_window_bits(png_structp png_ptr, int window_bits)
{
if (png_ptr == NULL)
return;
if (window_bits > 15)
png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
else if (window_bits < 8)
png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
#ifndef WBITS_8_OK
/* Avoid libpng bug with 256-byte windows */
if (window_bits == 8)
{
png_warning(png_ptr, "Text compression window is being reset to 512");
window_bits = 9;
}
#endif
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS;
png_ptr->zlib_text_window_bits = window_bits;
}
void PNGAPI
png_set_text_compression_method(png_structp png_ptr, int method)
{
png_debug(1, "in png_set_text_compression_method");
if (png_ptr == NULL)
return;
if (method != 8)
png_warning(png_ptr, "Only compression method 8 is supported by PNG");
png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_METHOD;
png_ptr->zlib_text_method = method;
}
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
/* 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)
{
@ -1557,7 +1619,7 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_WRITE_FILLER_SUPPORTED
/* Pack XRGB/RGBX/ARGB/RGBA into * RGB (4 channels -> 3 channels) */
/* Pack XRGB/RGBX/ARGB/RGBA into RGB (4 channels -> 3 channels) */
if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);

View File

@ -1,7 +1,7 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.6 [November 3, 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.)
@ -15,11 +15,12 @@
#ifdef PNG_WRITE_SUPPORTED
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
/* Transform the data according to the user's wishes. The order of
* transformations is significant.
*/
void /* PRIVATE */
png_do_write_transformations(png_structp png_ptr)
png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
{
png_debug(1, "in png_do_write_transformations");
@ -31,8 +32,8 @@ png_do_write_transformations(png_structp png_ptr)
if (png_ptr->write_user_transform_fn != NULL)
(*(png_ptr->write_user_transform_fn)) /* User write transform
function */
(png_ptr, /* png_ptr */
&(png_ptr->row_info), /* row_info: */
(png_ptr, /* png_ptr */
row_info, /* row_info: */
/* png_uint_32 width; width of row */
/* png_size_t rowbytes; number of bytes in row */
/* png_byte color_type; color type of pixels */
@ -44,50 +45,50 @@ png_do_write_transformations(png_structp png_ptr)
#ifdef PNG_WRITE_FILLER_SUPPORTED
if (png_ptr->transformations & PNG_FILLER)
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
png_ptr->flags);
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
#endif
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
if (png_ptr->transformations & PNG_PACKSWAP)
png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
png_do_packswap(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_PACK_SUPPORTED
if (png_ptr->transformations & PNG_PACK)
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
png_do_pack(row_info, png_ptr->row_buf + 1,
(png_uint_32)png_ptr->bit_depth);
#endif
#ifdef PNG_WRITE_SWAP_SUPPORTED
if (png_ptr->transformations & PNG_SWAP_BYTES)
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
png_do_swap(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_SHIFT_SUPPORTED
if (png_ptr->transformations & PNG_SHIFT)
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
png_do_shift(row_info, png_ptr->row_buf + 1,
&(png_ptr->shift));
#endif
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
if (png_ptr->transformations & PNG_SWAP_ALPHA)
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
if (png_ptr->transformations & PNG_INVERT_ALPHA)
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_BGR_SUPPORTED
if (png_ptr->transformations & PNG_BGR)
png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
png_do_bgr(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_INVERT_SUPPORTED
if (png_ptr->transformations & PNG_INVERT_MONO)
png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
png_do_invert(row_info, png_ptr->row_buf + 1);
#endif
}
@ -563,6 +564,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
}
}
#endif
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
#ifdef PNG_MNG_FEATURES_SUPPORTED
/* Undoes intrapixel differencing */

File diff suppressed because it is too large Load Diff