Update libpng to 1.2.26.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@6060 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2008-03-01 06:37:33 +00:00
parent 27147a02c4
commit 023ddf39ba
25 changed files with 1419 additions and 1180 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.2.16 - January 31, 2007
Libpng 1.2.25 - February 18, 2008
This is a public release of libpng, intended for use in production codes.
@ -8,39 +8,59 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
libpng-1.2.16.tar.gz
libpng-1.2.16.tar.bz2
libpng-1.2.25.tar.gz
libpng-1.2.25.tar.lzma
(Get the lzma codec from <http://tukaani.org/lzma>).
libpng-1.2.25.tar.bz2
Source files with LF line endings (for Unix/Linux) without the
"configure" script
libpng-1.2.16-no-config.tar.gz
libpng-1.2.16-no-config.tar.bz2
libpng-1.2.25-no-config.tar.gz
libpng-1.2.25-no-config.tar.lzma
libpng-1.2.25-no-config.tar.bz2
Source files with CRLF line endings (for Windows), without the
"configure" script
lpng1216.zip
lpng1216.tar.bz2
lpng1225.zip
lpng1225.7z
lpng1225.tar.bz2
Project files
libpng-1.2.16-project-netware.zip
libpng-1.2.16-project-wince.zip
libpng-1.2.25-project-netware.zip
libpng-1.2.25-project-wince.zip
Other information:
libpng-1.2.16-README.txt
libpng-1.2.16-KNOWNBUGS.txt
libpng-1.2.16-LICENSE.txt
libpng-1.2.16-Y2K-compliance.txt
libpng-1.2.25-README.txt
libpng-1.2.25-KNOWNBUGS.txt
libpng-1.2.25-LICENSE.txt
libpng-1.2.25-Y2K-compliance.txt
libpng-1.2.25-1.2.24-diff.txt
Changes since the last public release (1.2.15):
Changes since the last public release (1.2.24):
version 1.2.16 [January 31, 2007]
version 1.2.25 [February 18, 2008]
Fix bugs in makefile.nommx
Revised scripts/CMakeLists.txt
Fixed bug with unknown chunk handling, introduced in version 1.2.17
Prevent gamma from being applied twice.
Fixed some continue-after-malloc-failure errors in pngset.c (David Hill)
Check for info_ptr == NULL in png_read_info() and png_process_data().
Check for possible use of NULL user_png_ver[] in png_create_read_struct().
Fix overflow of "msg" in png_decompres_chunk().
Added libpng-1.2.25.tar.lzma to distribution. Get the lzma codec
from <http://tukaani.org/lzma>.
Added lpng1225.7z to distribution. Get the 7-zip decoder from
from <http://www.7-zip.org>.
Fixed some broken links in the README file.
Refactored png_read_push_finish_row() slightly, trying to satisfy Coverity.
Fixed potential NULL dereference of png_ptr in png_destroy_write_struct();
clarified potential NULL dereference of png_ptr in png_destroy_read_struct();
fixed potential NULL dereference of info_ptr in png_handle_bKGD();
fixed potential NULL dereference of user_png_ver[] in
png_create_write_struct_2(). (Coverity)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -1480,7 +1480,7 @@ version 1.2.9beta5 [March 4, 2006]
Restored scripts/makefile.elf which was inadvertently deleted.
version 1.2.9beta6 [March 6, 2006]
Fixed typo (16) in configuration files.
Fixed typo (RELEASE) in configuration files.
version 1.2.9beta7 [March 7, 2006]
Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am
@ -1669,7 +1669,7 @@ version 1.2.15rc2 [December 21, 2006]
Added scripts/makefile.nommx
version 1.2.15rc3 [December 25, 2006]
Fixed shared library numbering error that was intruduced in 1.2.15beta6.
Fixed shared library numbering error that was introduced in 1.2.15beta6.
version 1.2.15rc4 [December 27, 2006]
Fixed handling of rgb_to_gray when png_ptr->color.gray isn't set.
@ -1677,7 +1677,7 @@ version 1.2.15rc4 [December 27, 2006]
version 1.2.15rc5 [December 31, 2006]
Revised handling of rgb_to_gray.
version 1.2.15 [January 5, 2007]
version 1.0.23, 1.2.15 [January 5, 2007]
Added some (unsigned long) typecasts in pngtest.c to avoid printing errors.
version 1.2.16beta1 [January 6, 2007]
@ -1686,9 +1686,396 @@ version 1.2.16beta1 [January 6, 2007]
version 1.2.16beta2 [January 16, 2007]
Revised scripts/CMakeLists.txt
version 1.2.16 [January 31, 2007]
version 1.0.24, 1.2.16 [January 31, 2007]
No changes.
version 1.2.17beta1 [March 6, 2007]
Revised scripts/CMakeLists.txt to install both shared and static libraries.
Deleted a redundant line from pngset.c.
version 1.2.17beta2 [April 26, 2007]
Relocated misplaced test for png_ptr == NULL in pngpread.c
Change "==" to "&" for testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN
flags.
Changed remaining instances of PNG_ASSEMBLER_* to PNG_MMX_*
Added pngerror() when write_IHDR fails in deflateInit2().
Added "const" to some array declarations.
Mention examples of libpng usage in the libpng*.txt and libpng.3 documents.
version 1.2.17rc1 [May 4, 2007]
No changes.
version 1.2.17rc2 [May 8, 2007]
Moved several PNG_HAVE_* macros out of PNG_INTERNAL because applications
calling set_unknown_chunk_location() need them.
Changed transformation flag from PNG_EXPAND_tRNS to PNG_EXPAND in
png_set_expand_gray_1_2_4_to_8().
Added png_ptr->unknown_chunk to hold working unknown chunk data, so it
can be free'ed in case of error. Revised unknown chunk handling in
pngrutil.c and pngpread.c to use this structure.
version 1.2.17rc3 [May 8, 2007]
Revised symbol-handling in configure script.
version 1.2.17rc4 [May 10, 2007]
Revised unknown chunk handling to avoid storing unknown critical chunks.
version 1.0.25 [May 15, 2007]
version 1.2.17 [May 15, 2007]
Added "png_ptr->num_trans=0" before error return in png_handle_tRNS,
to eliminate a vulnerability (CVE-2007-2445, CERT VU#684664)
version 1.0.26 [May 15, 2007]
version 1.2.18 [May 15, 2007]
Reverted the libpng-1.2.17rc3 change to symbol-handling in configure script
version 1.2.19beta1 [May 18, 2007]
Changed "const static" to "static PNG_CONST" everywhere, mostly undoing
change of libpng-1.2.17beta2. Changed other "const" to "PNG_CONST"
Changed some handling of unused parameters, to avoid compiler warnings.
"if (unused == NULL) return;" becomes "unused = unused".
version 1.2.19beta2 [May 18, 2007]
Only use the valid bits of tRNS value in png_do_expand() (Brian Cartier)
version 1.2.19beta3 [May 19, 2007]
Add some "png_byte" typecasts in png_check_keyword() and write new_key
instead of key in zTXt chunk (Kevin Ryde).
version 1.2.19beta4 [May 21, 2007]
Add png_snprintf() function and use it in place of sprint() for improved
defense against buffer overflows.
version 1.2.19beta5 [May 21, 2007]
Fixed png_handle_tRNS() to only use the valid bits of tRNS value.
Changed handling of more unused parameters, to avoid compiler warnings.
Removed some PNG_CONST in pngwutil.c to avoid compiler warnings.
version 1.2.19beta6 [May 22, 2007]
Added some #ifdef PNG_MMX_CODE_SUPPORTED where needed in pngvcrd.c
Added a special "_MSC_VER" case that defines png_snprintf to _snprintf
version 1.2.19beta7 [May 22, 2007]
Squelched png_squelch_warnings() in pnggccrd.c and added an
#ifdef PNG_MMX_CODE_SUPPORTED block around the declarations that caused
the warnings that png_squelch_warnings was squelching.
version 1.2.19beta8 [May 22, 2007]
Removed __MMX__ from test in pngconf.h.
version 1.2.19beta9 [May 23, 2007]
Made png_squelch_warnings() available via PNG_SQUELCH_WARNINGS macro.
Revised png_squelch_warnings() so it might work.
Updated makefile.sgcc and makefile.solaris; added makefile.solaris-x86.
version 1.2.19beta10 [May 24, 2007]
Resquelched png_squelch_warnings(), use "__attribute__((used))" instead.
version 1.2.19beta11 [May 28, 2007]
Return 0 from png_get_sPLT() and png_get_unknown_chunks() if png_ptr is NULL;
changed three remaining instances of png_strcpy() to png_strncpy() (David
Hill).
Make test for NULL row_buf at the beginning of png_do_read_transformations
unconditional.
version 1.2.19beta12 [May 28, 2007]
Revised pnggccrd.c.
version 1.2.19beta13 [June 14, 2007]
Prefer PNG_USE_PNGVCRD when _MSC_VER is defined in pngconf.h
version 1.2.19beta14 [June 16, 2007]
Fix bug with handling of 16-bit transparency, introduced in 1.2.19beta2
version 1.2.19beta15 [June 17, 2007]
Revised pnggccrd.c.
version 1.2.19beta16 [June 18, 2007]
Revised pnggccrd.c again.
Updated contrib/gregbook.
Changed '#include "pnggccrd.c"' to 'include "$srcdir/pnggccrd.c"'
in configure.ac
version 1.2.19beta17 [June 19, 2007]
Revised many of the makefiles, to set -DPNG_NO_MMX_CODE where needed
and to not use -O3 unless -DPNG_NO_MMX_CODE is also set.
version 1.2.19beta18 [June 23, 2007]
Replaced some C++ style comments with C style comments in pnggccrd.c.
Copied optimized C code from pnggccrd.c to pngrutil.c, removed dependency
on pnggccrd.o from many makefiles.
Added sl and dylib to list of extensions be installed by Makefile.am
version 1.2.19beta19 [June 28, 2007]
Fixed testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN in pngrtran.c
More cleanup of pnggccrd.c and pngvcrd.c
version 1.2.19beta20 [June 29, 2007]
Rebuilt Makefile.in and configure using libtool-1.5.24.
Fixed typo in pnggccrd.c
version 1.2.19beta21 [June 30, 2007]
More revision of pnggccrd.c
Added "test" target to Makefile.in and Makefile.am
version 1.2.19beta22 [July 3, 2007]
Added info about pngrutil/pnggccrd/pngvcrd to png_get_header_version()
Fix type definition of dummy_value_a, b in pnggccrd.c
version 1.2.19beta23 [July 10, 2007]
Revert change to type definition of dummy_value_a, b in pnggccrd.c
Make sure __PIC__ is defined in pnggccrd.c when PIC is defined.
Require gcc-4.1 or better to use PNG_HAVE_MMX_FILTER_ROW on x86_64 platforms
version 1.2.19beta24 [July 14, 2007]
Added PNG_NO_READ_FILTER, PNG_NO_WRITE_FILTER, PNG_NO_WARNING macros.
Added contrib/pngminim to demonstrate building minimal encoder and decoder
version 1.2.19beta25 [July 15, 2007]
Removed the new PNG_NO_READ_FILTER macro since it would make the library
unable to read valid PNG files, and filtering is at the heart of the
PNG format.
version 1.2.19beta26 [July 16, 2007]
Changed "png_free(str)" to "png_free(png_ptr,str)" in pngrutil.c WinCE
code (Yves Piguet). This bug was introduced in libpng-1.2.14.
Updated scripts/CMakeLists.txt
Relocated a misplaced #endif in pnggccrd.c
version 1.2.19beta27 [July 17, 2007]
Fixed incorrect stride and number of bytes copied (was 4 instead of
6 bytes) in the cleanup loop of pnggccrd.c and pngvcrd.c for handling
the end of 48-bit interlaced rows (Glenn R-P).
version 1.2.19beta28 [July 19, 2007]
Removed requirement for gcc-4.1 or better to use PNG_HAVE_MMX_FILTER_ROW
on x86_64 platforms
Added png_warning() in pngrutil.c for short iCCP, iTXt, sPLT, or zTXT chunks.
Revised pngtest.c so warnings are displayed regardless of PNG_NO_STDIO.
version 1.2.19beta29 [July 20, 2007]
Fix typo in pnggccrd.c (%%eax should be %%ax in secondloop48)
version 1.2.19beta30 [July 26, 2007]
Revised pnggccrd.c
version 1.2.19beta31 [July 27, 2007]
Fix typos in pnggccrd.c
version 1.0.27rc1 and 1.2.19rc1 [July 31, 2007]
Disable PNG_MMX_CODE_SUPPORTED when PNG_ASSEMBLER_CODE_SUPPORTED is off.
Enable PNG_MMX_READ_FILTER_* by default, except when gcc-3.x is being
used (they were inadvertently disabled in libpng-1.2.19beta23).
Fix some debugging statements in pnggccrd.c and pngrutil.c
Added information about disabling the MMX code in libpng documentation.
version 1.0.27rc2 and 1.2.19rc2 [August 4, 2007]
Removed some "#if 0" blocks.
Made a global struct local in pngvcrd.c to make it thread safe.
Issue a png_error() if application attempts to transform a row tht
has not been initialized.
version 1.0.27rc3 and 1.2.19rc3 [August 9, 2007]
Slightly revised pngvcrd.c
version 1.0.27rc4 and 1.2.19rc4 [August 9, 2007]
Revised pnggccrd.c debugging change of rc1, which was broken.
Revised scripts/CMakeLists.txt
Change default to PNG_NO_GLOBAL_ARRAYS for MSVC.
Turn off PNG_FLAG_ROW_INIT flag when setting transforms that expand pixels.
version 1.0.27rc5 and 1.2.19rc5 [August 10, 2007]
Fix typo (missing '"') in pnggccrd.c
Revise handling of png_strtod in recent versions of WINCE
version 1.0.27rc6 and 1.2.19rc6 [August 15, 2007]
Fix typo (missing ',') in contrib/gregbook/readpng2.c
Undid row initialization error exit added to rc2 and rc4.
version 1.0.27 and 1.2.19 [August 18, 2007]
Conditionally restored row initialization error exit.
version 1.2.20beta01 [August 19, 2007]
Fixed problem with compiling pnggccrd.c on Intel-Apple platforms.
Changed png_malloc() to png_malloc_warn() in png_set_sPLT().
Added PNG_NO_ERROR_TEXT feature, with demo in contrib/pngminim
Removed define PNG_WARN_UNINITIALIZED_ROW 1 /* 0: warning; 1: error */
because it caused some trouble.
version 1.2.20beta02 [August 20, 2007]
Avoid compiling pnggccrd.c on Intel-Apple platforms.
version 1.2.20beta03 [August 20, 2007]
Added "/D PNG_NO_MMX_CODE" to the non-mmx builds of projects/visualc6
and visualc71.
version 1.2.20beta04 [August 21, 2007]
Revised pngvcrd.c for improved efficiency (Steve Snyder).
version 1.2.20rc1 [August 23, 2007]
Revised pngconf.h to set PNG_NO_MMX_CODE for gcc-3.x compilers.
version 1.2.20rc2 [August 27, 2007]
Revised scripts/CMakeLists.txt
Revised #ifdefs to ensure one and only one of pnggccrd.c, pngvcrd.c,
or part of pngrutil.c is selected.
version 1.2.20rc3 [August 30, 2007]
Remove a little more code in pngwutil.c when PNG_NO_WRITE_FILTER is selected.
Added /D _CRT_SECURE_NO_WARNINGS to visual6c and visualc71 projects.
Compile png_mmx_support() in png.c even when PNG_NO_MMX_CODE is defined.
Restored a "superfluous" #ifdef that was removed from 1.2.20rc2 pnggccrd.c,
breaking the png_mmx_support() function.
version 1.2.20rc4 [September 1, 2007]
Removed Intel contributions (MMX, Optimized C).
version 1.2.20rc5 [September 2, 2007]
Restored configure and Makefile.in to rc3 and put a snippet of code in
pnggccrd.c, to ensure configure makes the same PNG_NO_MMX_CODE selection
version 1.2.20rc6 [September 2, 2007]
Fixed bugs in scripts/CMakeLists.txt
Removed pngvcrd.c references from msvc projects.
version 1.0.28 and 1.2.20 [September 8, 2007]
Removed "(NO READ SUPPORT)" from png_get_header_version() string.
version 1.2.21beta1 [September 14, 2007]
Fixed various mistakes reported by George Cook and Jeff Phillips:
logical vs bitwise NOT in pngrtran.c, bug introduced in 1.2.19rc2
16-bit cheap transparency expansion, bug introduced in 1.2.19beta2
errors with sizeof(unknown_chunk.name), bugs introduced in 1.2.19beta11
<= compare with unsigned var in pngset.c, should be ==.
version 1.2.21beta2 [September 18, 2007]
Removed some extraneous typecasts.
version 1.2.21rc1 [September 25, 2007]
Fixed potential out-of-bounds reads in png_handle_pCAL() and
png_handle_ztXt() ("flayer" results reported by Tavis Ormandy).
version 1.2.21rc2 [September 26, 2007]
Fixed potential out-of-bounds reads in png_handle_sCAL(),
png_handle_iTXt(), and png_push_read_tEXt().
Remove some PNG_CONST declarations from pngwutil.c to avoid compiler warnings
Revised makefiles to update paths in libpng.pc properly.
version 1.2.21rc3 [September 27, 2007]
Revised makefiles to update "Libs" in libpng.pc properly.
version 1.0.29 and 1.2.21rc3 [October 4, 2007]
No changes.
version 1.2.22beta1 [October 4, 2007]
Again, fixed logical vs bitwise NOT in pngrtran.c, bug introduced
in 1.2.19rc2
version 1.2.22beta2 [October 5, 2007]
Fixed string length error in pngset.c (caused crashes while decoding iCCP)
Add terminating NULL after each instance of png_strncpy().
version 1.2.22beta3 [October 6, 2007]
Fix two off-by-one terminating NULL after png_strncpy().
version 1.2.22beta4 [October 7, 2007]
Changed some 0 to '\0'.
version 1.0.30rc1 and 1.2.22rc1 [October 8, 2007]
No changes.
version 1.0.30 and 1.2.22 [October 13, 2007]
No changes.
version 1.2.23beta01 [October 15, 2007]
Reduced number of invocations of png_strlen() in pngset.c.
Changed [azAZ09_] to [_abcde...89] in Makefile.am for better localization.
version 1.2.23beta02 [October 16, 2007]
Eliminated png_strncpy() and png_strcpy() (Pierre Poissinger)
Changed $AN to $(AN) in Makefile.am.
version 1.2.23beta03 [October 16, 2007]
Fixed off-by-one error in pngset.c
Restore statement to set last character of buffer to \0 in pngerror.c
version 1.2.23beta04 [October 23, 2007]
Reject attempt to set all-zero cHRM values.
version 1.2.23beta05 [October 26, 2007]
Add missing quotes in projects/visualc6, lost in version 1.2.20rc3
version 1.2.23rc01 [November 2, 2007]
No changes.
version 1.2.23 [November 6, 2007]
No changes.
version 1.2.24beta01 [November 19, 2007]
Moved misplaced test for malloc failure in png_set_sPLT(). This bug was
introduced in libpng-1.2.20beta01.
Ifdef out avg_row etc from png.h and pngwrite.c when PNG_NO_WRITE_FILTER
Do not use png_ptr->free_fn and png_ptr->mem_fn in png_destroy_read_struct()
when png_ptr is NULL (Marshall Clow).
Updated handling of symbol prefixes in Makefile.am and configure.ac (Mike
Frysinger).
version 1.2.24beta02 [November 30, 2007]
Removed a useless test and fixed incorrect test in png_set_cHRM_fixed()
(David Hill).
version 1.2.24rc01 [December 7, 2007]
No changes.
version 1.2.24 [December 14, 2007]
Make sure not to redefine _BSD_SOURCE in pngconf.h
Revised gather.sh and makefile.std in contrib/pngminim to avoid compiling
unused files.
version 1.2.25beta01 [January 7, 2008]
Fixed bug with unknown chunk handling, introduced in version 1.2.17rc2
version 1.2.25beta02 [January 10, 2008]
Prevent gamma from being applied twice.
version 1.2.25rc01 [January 17, 2008]
No changes.
version 1.2.25beta03 [January 22, 2008]
Fixed some continue-after-malloc-failure errors in pngset.c (David Hill)
Check for info_ptr == NULL in png_read_info() and png_process_data().
Check for possible use of NULL user_png_ver[] in png_create_read_struct().
Change "if (swidth == NULL)" to "if (sheight == NULL)" in png_handle_sCAL
(bug introduced in libpng-1.2.4/1.0.13).
Return from png_destroy_read_struct() if png_ptr_ptr is NULL.
Fix overflow of "msg" in png_decompres_chunk().
version 1.2.25beta04 [January 26, 2008]
Work around Coverity bug report by slightly refactoring
png_read_push_finish_row()
version 1.2.25beta05 [January 31, 2008]
Added libpng-1.2.25beta05.tar.lzma to distribution. Get the lzma codec
from <http://tukaani.org/lzma>.
Added lp1225b05.7z to distribution. Get the 7-zip decoder from
from <http://www.7-zip.org>.
Fixed some broken links in the README file.
version 1.2.25beta06 [February 6, 2008]
Refactored png_read_push_finish_row() again, trying to satisfy Coverity.
Fixed potential NULL dereference of png_ptr in png_destroy_write_struct();
clarified potential NULL dereference of png_ptr in png_destroy_read_struct();
fixed potential NULL dereference of info_ptr in png_handle_bKGD();
fixed potential NULL dereference of user_png_ver[] in
png_create_write_struct_2(). (Coverity)
version 1.2.25rc02 [February 10, 2008]
Reset png_ptr->pass in png_read_push_finish_row() before break.
Changed "pass" from png_byte to int.
version 1.2.25 and 1.0.31 [February 18, 2008]
No changes.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@ -1,5 +1,5 @@
Installing libpng version 1.2.16 - January 31, 2007
Installing libpng version 1.2.25 - February 18, 2008
On Unix/Linux and similar systems, you can simply type
@ -44,7 +44,7 @@ to have access to the zlib.h and zconf.h include files that
correspond to the version of zlib that's installed.
You can rename the directories that you downloaded (they
might be called "libpng-1.2.16" or "lpng109" and "zlib-1.2.1"
might be called "libpng-1.2.25" or "lpng109" and "zlib-1.2.1"
or "zlib121") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
@ -101,15 +101,9 @@ include
CMakeLists.txt => "cmake" script
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.elf => Linux/ELF makefile symbol versioning,
gcc, creates libpng12.so.0.1.2.16)
gcc, creates libpng12.so.0.1.2.25)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.16)
makefile.gcmmx => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.16,
uses assembler code tuned for Intel MMX platform)
makefile.nommx => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.16
does not use Intel MMX assembler code)
(gcc, creates libpng12.so.0.1.2.25)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
@ -131,12 +125,14 @@ include
makefile.openbsd => OpenBSD makefile
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.sggcc => Silicon Graphics (gcc,
creates libpng12.so.0.1.2.16)
creates libpng12.so.0.1.2.25)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng12.so.0.1.2.16)
creates libpng12.so.0.1.2.25)
makefile.solaris-x86 => Solaris/intelMMX 2.X makefile (gcc,
creates libpng12.so.0.1.2.25)
makefile.so9 => Solaris 9 makefile (gcc,
creates libpng12.so.0.1.2.16)
creates libpng12.so.0.1.2.25)
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
@ -152,10 +148,7 @@ include
makefile.tc3 => Turbo C 3.0 makefile
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses
assembler code tuned for Intel MMX platform)
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does
not use assembler code)
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
pngos2.def => OS/2 module definition file used by makefile.os2
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
@ -204,23 +197,3 @@ instead, as demonstrated in contrib/visupng of the libpng distribution.
Further information can be found in the README and libpng.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 need to add to configure explicitly,
which previously was done semi-automatically (if you didn't edit
scripts/makefile.* yourself, that is)
CFLAGS="-Wall -O3 -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/png12, or whatever.

View File

@ -1,23 +1,22 @@
Known bugs in libpng version 1.2.16
Known bugs in libpng version 1.2.25
1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when
reading interlaced PNG files, when assembler code is enabled but running
on a non-MMX i386 platform.
STATUS: Under investigation. The change to pnggccrd.c in libpng-1.2.1
fixed a problem under FreeBSD but not the problem with NetBSD, which
still fails as of libpng-1.2.2rc1.
2. February 23, 2006: The custom makefiles don't build libpng with -lz.
1. February 23, 2006: The custom makefiles don't build libpng with -lz.
STATUS: This is a subject of debate. The change will probably be made
as a part of a major overhaul of the makefiles in libpng version 1.3.0.
as a part of a major overhaul of the makefiles in libpng version 1.4.0.
3. February 24, 2006: The Makefile generated by the "configure" script
2. February 24, 2006: The Makefile generated by the "configure" script
fails to install symbolic links
libpng12.so => libpng12.so.0.1.2.9betaN
that are generated by the custom makefiles.
STATUS: For now, system library builders should use the custom makefiles.
3. September 4, 2007: There is a report that pngtest crashes on MacOS 10.
STATUS: workarounds are
1) Compile without optimization (crashes are observed with
-arch i386 and -O2 or -O3, using gcc-4.0.1).
2) Compile pngtest.c with PNG_DEBUG defined (the bug goes away if
you try to look at it).
3) Ignore the crash. The library itself seems to be OK.

View File

@ -8,8 +8,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following
this sentence.
libpng versions 1.2.6, August 15, 2004, through 1.2.16, January 31, 2007, are
Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are
libpng versions 1.2.6, August 15, 2004, through 1.2.25, February 18, 2008, are
Copyright (c) 2004, 2006-2008 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
@ -106,4 +106,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
January 31, 2007
February 18, 2008

View File

@ -1,11 +1,12 @@
README for libpng version 1.2.16 - January 31, 2007 (shared library 12.0)
README for libpng version 1.2.25 - February 18, 2008 (shared library 12.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
Libpng comes in several distribution formats. Get libpng-*.tar.gz
or libpng-*.tar.bz2 if you want UNIX-style line endings in the text
files, or lpng*.zip if you want DOS-style line endings.
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
libpng-*.tar.lzma, or libpng-*.tar.bz2 if you want UNIX-style line
endings in the text files, or lpng*.7z lpng*.zip if you want DOS-style
line endings.
Version 0.89 was the first official release of libpng. Don't let the
fact that it's the first release fool you. The libpng library has been in
@ -77,12 +78,12 @@ compression library that is useful for more things than just PNG files.
You can use zlib as a drop-in replacement for fread() and fwrite() if
you are so inclined.
zlib should be available at the same place that libpng is, or at.
ftp://ftp.info-zip.org/pub/infozip/zlib
zlib should be available at the same place that libpng is, or at
ftp://ftp.simplesystems.org/pub/png/src/
You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/documents/
these at http://www.libpng.org/pub/png/pngdocs.html
This code is currently being archived at libpng.sf.net in the
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
@ -113,8 +114,8 @@ 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).
the (png-mng-misc at lists.sourceforge.net, subscription required, visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement to subscribe)
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
@ -125,7 +126,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
to others, if necessary.
Please do not send suggestions on how to change PNG. We have
been discussing PNG for nine years now, and it is official and
been discussing PNG for twelve 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.
@ -140,6 +141,7 @@ Files in this distribution:
TODO => Things not implemented in the current library
Y2KINFO => Statement of Y2K compliance
example.c => Example code for using libpng functions
libpng-*-*-diff.txt => Diff from previous release
libpng.3 => manual page for libpng (includes libpng.txt)
libpng.txt => Description of libpng and its functions
libpngpf.3 => manual page for libpng's private functions
@ -147,7 +149,6 @@ Files in this distribution:
png.c => Basic interface functions common to library
png.h => Library function and interface declarations
pngconf.h => System specific library configuration
pngasmrd.h => Header file for assembler-coded functions
pngerror.c => Error/warning message I/O functions
pngget.c => Functions for retrieving info from struct
pngmem.c => Memory handling functions
@ -190,11 +191,11 @@ Files in this distribution:
descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.elf => Linux/ELF makefile symbol versioning,
gcc, creates libpng12.so.0.1.2.16)
gcc, creates libpng12.so.0.1.2.25)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.16)
(gcc, creates libpng12.so.0.1.2.25)
makefile.gcmmx => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.16,
(gcc, creates libpng12.so.0.1.2.25,
uses assembler code tuned for Intel MMX platform)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
@ -216,12 +217,12 @@ Files in this distribution:
makefile.openbsd => OpenBSD makefile
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
makefile.sggcc => Silicon Graphics
(gcc, creates libpng12.so.0.1.2.16)
(gcc, creates libpng12.so.0.1.2.25)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng12.so.0.1.2.16)
(gcc, creates libpng12.so.0.1.2.25)
makefile.so9 => Solaris 9 makefile
(gcc, creates libpng12.so.0.1.2.16)
(gcc, creates libpng12.so.0.1.2.25)
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
@ -256,7 +257,7 @@ Good luck, and happy coding.
-Andreas Eric Dilger (former maintainer, 1996-1997)
Internet: adilger at enel.ucalgary.ca
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
Web: http://members.shaw.ca/adilger/
-Guy Eric Schalnat (original author and former maintainer, 1995-1996)
(formerly of Group 42, Inc)

View File

@ -1,13 +1,13 @@
Y2K compliance in libpng:
=========================
January 31, 2007
February 18, 2008
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.2.16 are Y2K compliant. It is my belief that earlier
upward through 1.2.25 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer

View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "January 31, 2007"
.TH LIBPNG 3 "February 18, 2008"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.16
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.25
.SH SYNOPSIS
\fB
#include <png.h>\fP
@ -410,10 +410,10 @@ Following is a copy of the libpng.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng.txt - A description on how to use and modify libpng
libpng version 1.2.16 - January 31, 2007
libpng version 1.2.25 - February 18, 2008
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2005 Glenn Randers-Pehrson
Copyright (c) 1998-2008 Glenn Randers-Pehrson
For conditions of distribution and use, see copyright
notice in png.h.
@ -443,6 +443,10 @@ it is heavily commented and should include everything most people
will need. We assume that libpng is already installed; see the
INSTALL file for instructions on how to install libpng.
For examples of libpng usage, see the files "example.c", "pngtest.c",
and the files in the "contrib" directory, all of which are included in the
libpng distribution.
Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG
file format in application programs.
@ -492,9 +496,7 @@ Libpng is thread safe, provided the threads are using different
instances of the structures. Each thread should have its own
png_struct and png_info instances, and thus its own image.
Libpng does not protect itself against two threads using the
same instance of a structure. Note: thread safety may be defeated
by use of some of the MMX assembler code in pnggccrd.c, which is only
compiled when the user defines PNG_THREAD_UNSAFE_OK.
same instance of a structure.
.SH II. Structures
@ -2761,17 +2763,13 @@ For a more compact example of writing a PNG image, see the file example.c.
.SH V. Modifying/Customizing libpng:
There are three issues here. The first is changing how libpng does
There are two issues here. The first is changing how libpng does
standard things like memory allocation, input/output, and error handling.
The second deals with more complicated things like adding new chunks,
adding new transformations, and generally changing how libpng works.
Both of those are compile-time issues; that is, they are generally
determined at the time the code is written, and there is rarely a need
to provide the user with a means of changing them. The third is a
run-time issue: choosing between and/or tuning one or more alternate
versions of computationally intensive routines; specifically, optimized
assembly-language (and therefore compiler- and platform-dependent)
versions.
to provide the user with a means of changing them.
Memory allocation, input/output, and error handling
@ -3132,125 +3130,6 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
having level = 0 will be printed. There aren't any such statements in
this version of libpng, but if you insert some they will be printed.
.SH VI. Runtime optimization
A new feature in libpng 1.2.0 is the ability to dynamically switch between
standard and optimized versions of some routines. Currently these are
limited to three computationally intensive tasks when reading PNG files:
decoding row filters, expanding interlacing, and combining interlaced or
transparent row data with previous row data. Currently the optimized
versions are available only for x86 (Intel, AMD, etc.) platforms with
MMX support, though this may change in future versions. (For example,
the non-MMX assembler optimizations for zlib might become similarly
runtime-selectable in future releases, in which case libpng could be
extended to support them. Alternatively, the compile-time choice of
floating-point versus integer routines for gamma correction might become
runtime-selectable.)
Because such optimizations tend to be very platform- and compiler-dependent,
both in how they are written and in how they perform, the new runtime code
in libpng has been written to allow programs to query, enable, and disable
either specific optimizations or all such optimizations. For example, to
enable all possible optimizations (bearing in mind that some "optimizations"
may actually run more slowly in rare cases):
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
png_uint_32 mask, flags;
flags = png_get_asm_flags(png_ptr);
mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
png_set_asm_flags(png_ptr, flags | mask);
#endif
To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ
by itself when calling png_get_asm_flagmask(); similarly for optimizing
only writing. To disable all optimizations:
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
flags = png_get_asm_flags(png_ptr);
mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
png_set_asm_flags(png_ptr, flags & ~mask);
#endif
To enable or disable only MMX-related features, use png_get_mmx_flagmask()
in place of png_get_asm_flagmask(). The mmx version takes one additional
parameter:
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
int selection = PNG_SELECT_READ | PNG_SELECT_WRITE;
int compilerID;
mask = png_get_mmx_flagmask(selection, &compilerID);
#endif
On return, compilerID will indicate which version of the MMX assembler
optimizations was compiled. Currently two flavors exist: Microsoft
Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2).
On non-x86 platforms or on systems compiled without MMX optimizations, a
value of -1 is used.
Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return
all valid, settable optimization bits for the version of the library that's
currently in use. In the case of shared (dynamically linked) libraries,
this may include optimizations that did not exist at the time the code was
written and compiled. It is also possible, of course, to enable only known,
specific optimizations; for example:
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
| PNG_ASM_FLAG_MMX_READ_INTERLACE \
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
| PNG_ASM_FLAG_MMX_READ_FILTER_UP \
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
png_set_asm_flags(png_ptr, flags);
#endif
This method would enable only the MMX read-optimizations available at the
time of libpng 1.2.0's release, regardless of whether a later version of
the DLL were actually being used. (Also note that these functions did not
exist in versions older than 1.2.0, so any attempt to run a dynamically
linked app on such an older version would fail.)
To determine whether the processor supports MMX instructions at all, use
the png_mmx_support() function:
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
mmxsupport = png_mmx_support();
#endif
It returns -1 if MMX support is not compiled into libpng, 0 if MMX code
is compiled but MMX is not supported by the processor, or 1 if MMX support
is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(),
and png_get_asm_flagmask() all may be called without allocating and ini-
tializing any PNG structures (for example, as part of a usage screen or
"about" box).
The following code can be used to prevent an application from using the
thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK
defined:
#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \
&& defined(PNG_THREAD_UNSAFE_OK)
/* Disable thread-unsafe features of pnggccrd */
if (png_access_version_number() >= 10200)
{
png_uint_32 mmx_disable_mask = 0;
png_uint_32 asm_flags;
mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH );
asm_flags = png_get_asm_flags(png_ptr);
png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask);
}
#endif
For more extensive examples of runtime querying, enabling and disabling
of optimized features, see contrib/gregbook/readpng2.c in the libpng
source-code distribution.
.SH VII. MNG support
The MNG specification (available at http://www.libpng.org/pub/mng) allows
@ -3327,13 +3206,13 @@ application:
.SH IX. Y2K Compliance in libpng
January 31, 2007
February 18, 2008
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.2.16 are Y2K compliant. It is my belief that earlier
upward through 1.2.25 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that
@ -3515,6 +3394,40 @@ the first widely used release:
1.2.16rc1 13 10216 12.so.0.16[.0]
1.0.24 10 10024 10.so.0.24[.0]
1.2.16 13 10216 12.so.0.16[.0]
1.2.17beta1-2 13 10217 12.so.0.17[.0]
1.0.25rc1 10 10025 10.so.0.25[.0]
1.2.17rc1-3 13 10217 12.so.0.17[.0]
1.0.25 10 10025 10.so.0.25[.0]
1.2.17 13 10217 12.so.0.17[.0]
1.0.26 10 10026 10.so.0.26[.0]
1.2.18 13 10218 12.so.0.18[.0]
1.2.19beta1-31 13 10219 12.so.0.19[.0]
1.0.27rc1-6 10 10027 10.so.0.27[.0]
1.2.19rc1-6 13 10219 12.so.0.19[.0]
1.0.27 10 10027 10.so.0.27[.0]
1.2.19 13 10219 12.so.0.19[.0]
1.2.20beta01-04 13 10220 12.so.0.20[.0]
1.0.28rc1-6 10 10028 10.so.0.28[.0]
1.2.20rc1-6 13 10220 12.so.0.20[.0]
1.0.28 10 10028 10.so.0.28[.0]
1.2.20 13 10220 12.so.0.20[.0]
1.2.21beta1-2 13 10221 12.so.0.21[.0]
1.2.21rc1-3 13 10221 12.so.0.21[.0]
1.0.29 10 10029 10.so.0.29[.0]
1.2.21 13 10221 12.so.0.21[.0]
1.2.22beta1-4 13 10222 12.so.0.22[.0]
1.0.30rc1 13 10030 10.so.0.30[.0]
1.2.22rc1 13 10222 12.so.0.22[.0]
1.0.30 10 10030 10.so.0.30[.0]
1.2.22 13 10222 12.so.0.22[.0]
1.2.23beta01-05 13 10223 12.so.0.23[.0]
1.2.23rc01 13 10223 12.so.0.23[.0]
1.2.23 13 10223 12.so.0.23[.0]
1.2.24beta01-02 13 10224 12.so.0.24[.0]
1.2.24rc01 13 10224 12.so.0.24[.0]
1.2.24 13 10224 12.so.0.24[.0]
1.2.25beta01-06 13 10225 12.so.0.25[.0]
1.2.25rc01-02 13 10225 12.so.0.25[.0]
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@ -3527,7 +3440,7 @@ version 1.0.6j; from then on they were given the upcoming public
release number plus "betaNN" or "rcN".
.SH "SEE ALSO"
libpngpf(3), png(5)
.IR libpngpf(3) ", " png(5)
.LP
.IR libpng :
.IP
@ -3570,7 +3483,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.2.16 - January 31, 2007:
Libpng version 1.2.25 - February 18, 2008:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@ -3591,8 +3504,8 @@ included in the libpng distribution, the latter shall prevail.)
If you modify libpng you may insert additional notices immediately following
this sentence.
libpng versions 1.2.6, August 15, 2004, through 1.2.16, January 31, 2007, are
Copyright (c) 2004-2006 Glenn Randers-Pehrson, and are
libpng versions 1.2.6, August 15, 2004, through 1.2.25, February 18, 2008, are
Copyright (c) 2004,2006-2008 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
@ -3690,7 +3603,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
January 31, 2007
February 18, 2008
.\" end of man page

View File

@ -1,9 +1,9 @@
libpng.txt - A description on how to use and modify libpng
libpng version 1.2.16 - January 31, 2007
libpng version 1.2.24 - December 14, 2007
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2005 Glenn Randers-Pehrson
Copyright (c) 1998-2007 Glenn Randers-Pehrson
For conditions of distribution and use, see copyright
notice in png.h.
@ -33,6 +33,10 @@ it is heavily commented and should include everything most people
will need. We assume that libpng is already installed; see the
INSTALL file for instructions on how to install libpng.
For examples of libpng usage, see the files "example.c", "pngtest.c",
and the files in the "contrib" directory, all of which are included in the
libpng distribution.
Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG
file format in application programs.
@ -82,9 +86,7 @@ Libpng is thread safe, provided the threads are using different
instances of the structures. Each thread should have its own
png_struct and png_info instances, and thus its own image.
Libpng does not protect itself against two threads using the
same instance of a structure. Note: thread safety may be defeated
by use of some of the MMX assembler code in pnggccrd.c, which is only
compiled when the user defines PNG_THREAD_UNSAFE_OK.
same instance of a structure.
II. Structures
@ -2351,17 +2353,13 @@ For a more compact example of writing a PNG image, see the file example.c.
V. Modifying/Customizing libpng:
There are three issues here. The first is changing how libpng does
There are two issues here. The first is changing how libpng does
standard things like memory allocation, input/output, and error handling.
The second deals with more complicated things like adding new chunks,
adding new transformations, and generally changing how libpng works.
Both of those are compile-time issues; that is, they are generally
determined at the time the code is written, and there is rarely a need
to provide the user with a means of changing them. The third is a
run-time issue: choosing between and/or tuning one or more alternate
versions of computationally intensive routines; specifically, optimized
assembly-language (and therefore compiler- and platform-dependent)
versions.
to provide the user with a means of changing them.
Memory allocation, input/output, and error handling
@ -2722,125 +2720,6 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
having level = 0 will be printed. There aren't any such statements in
this version of libpng, but if you insert some they will be printed.
VI. Runtime optimization
A new feature in libpng 1.2.0 is the ability to dynamically switch between
standard and optimized versions of some routines. Currently these are
limited to three computationally intensive tasks when reading PNG files:
decoding row filters, expanding interlacing, and combining interlaced or
transparent row data with previous row data. Currently the optimized
versions are available only for x86 (Intel, AMD, etc.) platforms with
MMX support, though this may change in future versions. (For example,
the non-MMX assembler optimizations for zlib might become similarly
runtime-selectable in future releases, in which case libpng could be
extended to support them. Alternatively, the compile-time choice of
floating-point versus integer routines for gamma correction might become
runtime-selectable.)
Because such optimizations tend to be very platform- and compiler-dependent,
both in how they are written and in how they perform, the new runtime code
in libpng has been written to allow programs to query, enable, and disable
either specific optimizations or all such optimizations. For example, to
enable all possible optimizations (bearing in mind that some "optimizations"
may actually run more slowly in rare cases):
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
png_uint_32 mask, flags;
flags = png_get_asm_flags(png_ptr);
mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
png_set_asm_flags(png_ptr, flags | mask);
#endif
To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ
by itself when calling png_get_asm_flagmask(); similarly for optimizing
only writing. To disable all optimizations:
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
flags = png_get_asm_flags(png_ptr);
mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE);
png_set_asm_flags(png_ptr, flags & ~mask);
#endif
To enable or disable only MMX-related features, use png_get_mmx_flagmask()
in place of png_get_asm_flagmask(). The mmx version takes one additional
parameter:
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
int selection = PNG_SELECT_READ | PNG_SELECT_WRITE;
int compilerID;
mask = png_get_mmx_flagmask(selection, &compilerID);
#endif
On return, compilerID will indicate which version of the MMX assembler
optimizations was compiled. Currently two flavors exist: Microsoft
Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2).
On non-x86 platforms or on systems compiled without MMX optimizations, a
value of -1 is used.
Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return
all valid, settable optimization bits for the version of the library that's
currently in use. In the case of shared (dynamically linked) libraries,
this may include optimizations that did not exist at the time the code was
written and compiled. It is also possible, of course, to enable only known,
specific optimizations; for example:
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
flags = PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
| PNG_ASM_FLAG_MMX_READ_INTERLACE \
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
| PNG_ASM_FLAG_MMX_READ_FILTER_UP \
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
png_set_asm_flags(png_ptr, flags);
#endif
This method would enable only the MMX read-optimizations available at the
time of libpng 1.2.0's release, regardless of whether a later version of
the DLL were actually being used. (Also note that these functions did not
exist in versions older than 1.2.0, so any attempt to run a dynamically
linked app on such an older version would fail.)
To determine whether the processor supports MMX instructions at all, use
the png_mmx_support() function:
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
mmxsupport = png_mmx_support();
#endif
It returns -1 if MMX support is not compiled into libpng, 0 if MMX code
is compiled but MMX is not supported by the processor, or 1 if MMX support
is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(),
and png_get_asm_flagmask() all may be called without allocating and ini-
tializing any PNG structures (for example, as part of a usage screen or
"about" box).
The following code can be used to prevent an application from using the
thread_unsafe features, even if libpng was built with PNG_THREAD_UNSAFE_OK
defined:
#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \
&& defined(PNG_THREAD_UNSAFE_OK)
/* Disable thread-unsafe features of pnggccrd */
if (png_access_version_number() >= 10200)
{
png_uint_32 mmx_disable_mask = 0;
png_uint_32 asm_flags;
mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH );
asm_flags = png_get_asm_flags(png_ptr);
png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask);
}
#endif
For more extensive examples of runtime querying, enabling and disabling
of optimized features, see contrib/gregbook/readpng2.c in the libpng
source-code distribution.
VII. MNG support
The MNG specification (available at http://www.libpng.org/pub/mng) allows
@ -2917,13 +2796,13 @@ application:
IX. Y2K Compliance in libpng
January 31, 2007
December 14, 2007
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.2.16 are Y2K compliant. It is my belief that earlier
upward through 1.2.24 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that

View File

@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "January 31, 2007"
.TH LIBPNGPF 3 "February 18, 2008"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.16
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.25
(private functions)
.SH SYNOPSIS
\fB#include <png.h>\fP
@ -269,6 +269,6 @@ are listed alphabetically here as an aid to libpng maintainers.
See png.h for more information on these functions.
.SH SEE ALSO
libpng(3), png(5)
.IR libpng(3) ", " png(5)
.SH AUTHOR
Glenn Randers-Pehrson

View File

@ -1,4 +1,4 @@
.TH PNG 5 "January 31, 2007"
.TH PNG 5 "February 18, 2008"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
@ -18,7 +18,7 @@ gamma and chromaticity data for improved color matching on heterogeneous
platforms.
.SH "SEE ALSO"
.IR libpng(3), zlib(3), deflate(5), and zlib(5)
.IR libpng(3) ", " zlib(3) ", " deflate(5) ", and " zlib(5)
.LP
PNG specification (second edition), November 2003:
.IP

130
png/png.c
View File

@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.2.15 January 5, 2007
* Last changed in libpng 1.2.21 October 4, 2007
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -13,20 +13,20 @@
#include "png.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_2_16 Your_png_h_is_not_version_1_2_16;
typedef version_1_2_25 Your_png_h_is_not_version_1_2_25;
/* Version information for C files. This had better match the version
* string defined in png.h. */
#ifdef PNG_USE_GLOBAL_ARRAYS
/* png_libpng_ver was changed to a function in version 1.0.5c */
const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
#ifdef PNG_READ_SUPPORTED
/* png_sig was changed to a function in version 1.0.5c */
/* Place to hold the signature string for a PNG file. */
const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
PNG_CONST png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
#endif /* PNG_READ_SUPPORTED */
/* Invoke global declarations for constant strings for known chunk types */
@ -56,32 +56,27 @@ PNG_zTXt;
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */
const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
/* offset to next interlace block */
const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
/* start of interlace block in the y direction */
const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
/* offset to next interlace block in the y direction */
const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* width of interlace block (used in assembler routines only) */
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
#endif
PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* Height of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h
const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
*/
/* Mask to determine which pixels are valid in a pass */
const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
/* Mask to determine which pixels to overwrite while displaying */
const int FARDATA png_pass_dsp_mask[]
PNG_CONST int FARDATA png_pass_dsp_mask[]
= {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
#endif /* PNG_READ_SUPPORTED */
@ -134,7 +129,7 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
/* (Obsolete) function to check signature bytes. It does not allow one
* to check a partial signature. This function might be removed in the
* future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG.
* future - use png_sig_cmp(). Returns true (nonzero) if the file is PNG.
*/
int PNGAPI
png_check_sig(png_bytep sig, int num)
@ -490,6 +485,11 @@ if (mask & PNG_FREE_SPLT)
#endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
if(png_ptr->unknown_chunk.data)
{
png_free(png_ptr, png_ptr->unknown_chunk.data);
png_ptr->unknown_chunk.data = NULL;
}
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
#else
@ -669,7 +669,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
#ifdef USE_FAR_KEYWORD
{
char near_time_buf[29];
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
@ -677,7 +677,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
29*png_sizeof(char));
}
#else
sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
@ -687,25 +687,16 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
}
#endif /* PNG_TIME_RFC1123_SUPPORTED */
#if 0
/* Signature string for a PNG file. */
png_bytep PNGAPI
png_sig_bytes(void)
{
return ((png_bytep)"\211\120\116\107\015\012\032\012");
}
#endif
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
png_charp PNGAPI
png_get_copyright(png_structp png_ptr)
{
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return ((png_charp) "\n libpng version 1.2.16 - January 31, 2007\n\
Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
return ((png_charp) "\n libpng version 1.2.25 - February 18, 2008\n\
Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\
Copyright (c) 1996-1997 Andreas Dilger\n\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
return ((png_charp) "");
}
/* The following return the library version as a short string in the
@ -720,27 +711,28 @@ png_charp PNGAPI
png_get_libpng_ver(png_structp png_ptr)
{
/* Version of *.c files used when building libpng */
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return ((png_charp) PNG_LIBPNG_VER_STRING);
return ((png_charp) "");
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
return ((png_charp) PNG_LIBPNG_VER_STRING);
}
png_charp PNGAPI
png_get_header_ver(png_structp png_ptr)
{
/* Version of *.h files used when building libpng */
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return ((png_charp) PNG_LIBPNG_VER_STRING);
return ((png_charp) "");
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
return ((png_charp) PNG_LIBPNG_VER_STRING);
}
png_charp PNGAPI
png_get_header_version(png_structp png_ptr)
{
/* Returns longer string containing both version and date */
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return ((png_charp) PNG_HEADER_VERSION_STRING);
return ((png_charp) "");
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
return ((png_charp) PNG_HEADER_VERSION_STRING
#ifndef PNG_READ_SUPPORTED
" (NO READ SUPPORT)"
#endif
"\n");
}
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
@ -751,7 +743,7 @@ png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
/* check chunk_name and return "keep" value if it's on the list, else 0 */
int i;
png_bytep p;
if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0)
if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
return 0;
p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
for (i = png_ptr->num_chunk_list; i; i--, p-=5)
@ -781,65 +773,15 @@ png_access_version_number(void)
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
#if !defined(PNG_1_0_X)
#if defined(PNG_MMX_CODE_SUPPORTED)
/* this INTERNAL function was added to libpng 1.2.0 */
void /* PRIVATE */
png_init_mmx_flags (png_structp png_ptr)
{
if(png_ptr == NULL) return;
png_ptr->mmx_rowbytes_threshold = 0;
png_ptr->mmx_bitdepth_threshold = 0;
# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD))
png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED;
if (png_mmx_support() > 0) {
png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
# ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
| PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
# endif
# ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
| PNG_ASM_FLAG_MMX_READ_INTERLACE
# endif
# ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
;
# else
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB
| PNG_ASM_FLAG_MMX_READ_FILTER_UP
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT;
png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT;
# endif
} else {
png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
| PNG_MMX_READ_FLAGS
| PNG_MMX_WRITE_FLAGS );
}
# else /* !(PNGVCRD || PNGGCCRD) */
/* clear all MMX flags; no support is compiled in */
png_ptr->asm_flags &= ~( PNG_MMX_FLAGS );
# endif /* ?(PNGVCRD || PNGGCCRD) */
}
#endif /* !(PNG_MMX_CODE_SUPPORTED) */
/* this function was added to libpng 1.2.0 */
#if !defined(PNG_USE_PNGGCCRD) && \
!(defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD))
int PNGAPI
png_mmx_support(void)
{
/* obsolete, to be removed from libpng-1.4.0 */
return -1;
}
#endif
#endif /* PNG_1_0_X && PNG_ASSEMBLER_CODE_SUPPORTED */
#endif /* PNG_READ_SUPPORTED */
#endif /* PNG_1_0_X */
#endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
#ifdef PNG_SIZE_T

207
png/png.h
View File

@ -1,15 +1,15 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.2.16 - January 31, 2007
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
* libpng version 1.2.25 - February 18, 2008
* Copyright (c) 1998-2008 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.)
*
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.2.16 - January 31, 2007: Glenn
* libpng versions 0.97, January 1998, through 1.2.25 - February 18, 2008: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -143,6 +143,40 @@
* 1.2.16rc1 13 10216 12.so.0.16[.0]
* 1.0.24 10 10024 10.so.0.24[.0]
* 1.2.16 13 10216 12.so.0.16[.0]
* 1.2.17beta1-2 13 10217 12.so.0.17[.0]
* 1.0.25rc1 10 10025 10.so.0.25[.0]
* 1.2.17rc1-3 13 10217 12.so.0.17[.0]
* 1.0.25 10 10025 10.so.0.25[.0]
* 1.2.17 13 10217 12.so.0.17[.0]
* 1.0.26 10 10026 10.so.0.26[.0]
* 1.2.18 13 10218 12.so.0.18[.0]
* 1.2.19beta1-31 13 10219 12.so.0.19[.0]
* 1.0.27rc1-6 10 10027 10.so.0.27[.0]
* 1.2.19rc1-6 13 10219 12.so.0.19[.0]
* 1.0.27 10 10027 10.so.0.27[.0]
* 1.2.19 13 10219 12.so.0.19[.0]
* 1.2.20beta01-04 13 10220 12.so.0.20[.0]
* 1.0.28rc1-6 10 10028 10.so.0.28[.0]
* 1.2.20rc1-6 13 10220 12.so.0.20[.0]
* 1.0.28 10 10028 10.so.0.28[.0]
* 1.2.20 13 10220 12.so.0.20[.0]
* 1.2.21beta1-2 13 10221 12.so.0.21[.0]
* 1.2.21rc1-3 13 10221 12.so.0.21[.0]
* 1.0.29 10 10029 10.so.0.29[.0]
* 1.2.21 13 10221 12.so.0.21[.0]
* 1.2.22beta1-4 13 10222 12.so.0.22[.0]
* 1.0.30rc1 10 10030 10.so.0.30[.0]
* 1.2.22rc1 13 10222 12.so.0.22[.0]
* 1.0.30 10 10030 10.so.0.30[.0]
* 1.2.22 13 10222 12.so.0.22[.0]
* 1.2.23beta01-05 13 10223 12.so.0.23[.0]
* 1.2.23rc01 13 10223 12.so.0.23[.0]
* 1.2.23 13 10223 12.so.0.23[.0]
* 1.2.24beta01-02 13 10224 12.so.0.24[.0]
* 1.2.24rc01 13 10224 12.so.0.24[.0]
* 1.2.24 13 10224 12.so.0.24[.0]
* 1.2.25beta01-06 13 10225 12.so.0.25[.0]
* 1.2.25rc01-02 13 10225 12.so.0.25[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -172,8 +206,8 @@
* If you modify libpng you may insert additional notices immediately following
* this sentence.
*
* libpng versions 1.2.6, August 15, 2004, through 1.2.16, January 31, 2007, are
* Copyright (c) 2004, 2007 Glenn Randers-Pehrson, and are
* libpng versions 1.2.6, August 15, 2004, through 1.2.25, February 18, 2008, are
* Copyright (c) 2004, 2006-2008 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:
*
@ -284,13 +318,13 @@
* Y2K compliance in libpng:
* =========================
*
* January 31, 2007
* February 18, 2008
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.2.16 are Y2K compliant. It is my belief that earlier
* upward through 1.2.25 are Y2K compliant. It is my belief that earlier
* versions were also Y2K compliant.
*
* Libpng only has three year fields. One is a 2-byte unsigned integer
@ -346,9 +380,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.2.16"
#define PNG_LIBPNG_VER_STRING "1.2.25"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.2.16 - January 31, 2007 (header)\n"
" libpng version 1.2.25 - February 18, 2008\n"
#define PNG_LIBPNG_VER_SONUM 0
#define PNG_LIBPNG_VER_DLLNUM 13
@ -356,7 +390,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 2
#define PNG_LIBPNG_VER_RELEASE 16
#define PNG_LIBPNG_VER_RELEASE 25
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
@ -384,7 +418,7 @@
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
#define PNG_LIBPNG_VER 10216 /* 1.2.16 */
#define PNG_LIBPNG_VER 10225 /* 1.2.25 */
#ifndef PNG_VERSION_INFO_ONLY
/* include the compression library's header */
@ -472,7 +506,7 @@ extern "C" {
* the version above.
*/
#ifdef PNG_USE_GLOBAL_ARRAYS
PNG_EXPORT_VAR (const char) png_libpng_ver[18];
PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18];
/* need room for 99.99.99beta99z */
#else
#define png_libpng_ver png_get_header_ver(NULL)
@ -481,17 +515,14 @@ PNG_EXPORT_VAR (const char) png_libpng_ver[18];
#ifdef PNG_USE_GLOBAL_ARRAYS
/* This was removed in version 1.0.5c */
/* Structures to facilitate easy interlacing. See png.c for more details */
PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7];
PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7];
PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7];
PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7];
PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7];
PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7];
#ifdef PNG_USE_PNGGCCRD
PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7];
#endif
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_start[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_inc[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_ystart[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_yinc[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_mask[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_dsp_mask[7];
/* This isn't currently used. If you need it, see png.c for more details.
PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7];
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_height[7];
*/
#endif
@ -628,9 +659,10 @@ typedef png_time FAR * FAR * png_timepp;
* up private chunks for output even though the library doesn't actually
* know about their semantics.
*/
#define PNG_CHUNK_NAME_LENGTH 5
typedef struct png_unknown_chunk_t
{
png_byte name[5];
png_byte name[PNG_CHUNK_NAME_LENGTH];
png_byte *data;
png_size_t size;
@ -1157,10 +1189,12 @@ struct png_struct_def
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 */
#ifndef PNG_NO_WRITE_FILTERING
png_bytep sub_row; /* buffer to save "sub" row when filtering */
png_bytep up_row; /* buffer to save "up" row when filtering */
png_bytep avg_row; /* buffer to save "avg" row when filtering */
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
#endif
png_row_info row_info; /* used for transformation routines */
png_uint_32 idat_size; /* current IDAT size for read */
@ -1262,8 +1296,7 @@ struct png_struct_def
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_TEXT_SUPPORTED */
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
@ -1345,7 +1378,7 @@ struct png_struct_def
png_byte filter_type;
#endif
#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD))
#if defined(PNG_1_0_X)
/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
png_uint_32 row_buf_size;
#endif
@ -1388,13 +1421,18 @@ struct png_struct_def
png_uint_32 user_height_max;
#endif
/* New member added in libpng-1.0.25 and 1.2.17 */
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* storage for unknown chunk that the library doesn't recognize. */
png_unknown_chunk unknown_chunk;
#endif
};
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef png_structp version_1_2_16;
typedef png_structp version_1_2_25;
typedef png_struct FAR * FAR * png_structpp;
@ -2042,6 +2080,7 @@ extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
int check));
#endif /* USE_FAR_KEYWORD */
#ifndef PNG_NO_ERROR_TEXT
/* Fatal error in PNG image of libpng - can't continue */
extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
png_const_charp error_message));
@ -2049,14 +2088,22 @@ extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
/* The same, but the chunk name is prepended to the error string. */
extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
png_const_charp error_message));
#else
/* Fatal error in PNG image of libpng - can't continue */
extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr));
#endif
#ifndef PNG_NO_WARNINGS
/* Non-fatal error in libpng. Can continue, but may have a problem. */
extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
png_const_charp warning_message));
#ifdef PNG_READ_SUPPORTED
/* Non-fatal error in libpng, chunk name is prepended to message. */
extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
png_const_charp warning_message));
#endif /* PNG_READ_SUPPORTED */
#endif /* PNG_NO_WARNINGS */
/* The png_set_<chunk> functions are for storing values in the png_info_struct.
* Similarly, the png_get_<chunk> calls are used to read values from the
@ -2390,7 +2437,7 @@ extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
handling or default unknown chunk handling is not desired. Any chunks not
listed will be handled in the default manner. The IHDR and IEND chunks
must not be listed.
keep = 0: follow default behavour
keep = 0: follow default behaviour
= 1: do not keep
= 2: keep only if safe-to-copy
= 3: keep even if unsafe-to-copy
@ -2478,10 +2525,6 @@ extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
#define png_debug2(l, m, p1, p2)
#endif
#if 0
extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
#endif
extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
@ -2671,16 +2714,21 @@ extern PNG_EXPORT(void,png_save_uint_16)
* be found in the files where the functions are located.
*/
#if defined(PNG_INTERNAL)
/* Various modes of operation. Note that after an init, mode is set to
* zero automatically when the structure is created.
/* Various modes of operation, that are visible to applications because
* they are used for unknown chunk location.
*/
#define PNG_HAVE_IHDR 0x01
#define PNG_HAVE_PLTE 0x02
#define PNG_HAVE_IDAT 0x04
#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
#define PNG_HAVE_IEND 0x10
#if defined(PNG_INTERNAL)
/* More modes of operation. Note that after an init, mode is set to
* zero automatically when the structure is created.
*/
#define PNG_HAVE_gAMA 0x20
#define PNG_HAVE_cHRM 0x40
#define PNG_HAVE_sRGB 0x80
@ -2800,11 +2848,8 @@ extern PNG_EXPORT(void,png_save_uint_16)
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
/* place to hold the signature string for a PNG file. */
#ifdef PNG_USE_GLOBAL_ARRAYS
PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8];
PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8];
#else
#if 0
#define png_sig png_sig_bytes(NULL)
#endif
#endif
#endif /* PNG_NO_EXTERN */
@ -2812,50 +2857,50 @@ extern PNG_EXPORT(void,png_save_uint_16)
* define the name here, and add an invocation of the macro in png.c and
* wherever it's needed.
*/
#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'}
#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'}
#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
#define PNG_IHDR png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
#define PNG_IDAT png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
#define PNG_IEND png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
#define PNG_PLTE png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'}
#define PNG_bKGD png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'}
#define PNG_cHRM png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
#define PNG_gAMA png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
#define PNG_hIST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
#define PNG_iCCP png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
#define PNG_iTXt png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
#define PNG_oFFs png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
#define PNG_pCAL png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
#define PNG_sCAL png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
#define PNG_pHYs png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
#define PNG_sBIT png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
#define PNG_sPLT png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
#define PNG_sRGB png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
#define PNG_tEXt png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
#define PNG_tIME png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
#define PNG_tRNS png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
#define PNG_zTXt png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
#ifdef PNG_USE_GLOBAL_ARRAYS
PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5];
PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5];
#endif /* PNG_USE_GLOBAL_ARRAYS */
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)

View File

@ -1,9 +1,9 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.2.16 - January 31, 2007
* libpng version 1.2.25 - February 18, 2008
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
* Copyright (c) 1998-2008 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.)
*/
@ -75,6 +75,14 @@
/* End of material added to libpng-1.2.8 */
/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble
Restored at libpng-1.2.21 */
#if !defined(PNG_NO_WARN_UNINITIALIZED_ROW) && \
!defined(PNG_WARN_UNINITIALIZED_ROW)
# define PNG_WARN_UNINITIALIZED_ROW 1
#endif
/* End of material added at libpng-1.2.19/1.2.21 */
/* This is the size of the compression buffer, and thus the size of
* an IDAT chunk. Make this whatever size you feel is best for your
* machine. One of these will be allocated per png_struct. When this
@ -276,6 +284,7 @@
# define PNGARG(arglist) arglist
#endif /* _NO_PROTO */
#endif /* OF */
#endif /* PNGARG */
@ -314,7 +323,7 @@
/* If you encounter a compiler error here, see the explanation
* near the end of INSTALL.
*/
__png.h__ already includes setjmp.h;
__pngconf.h__ already includes setjmp.h;
__dont__ include it again.;
# endif
# endif /* __linux__ */
@ -324,7 +333,9 @@
# ifdef __linux__
# ifdef PNG_SAVE_BSD_SOURCE
# define _BSD_SOURCE
# ifndef _BSD_SOURCE
# define _BSD_SOURCE
# endif
# undef PNG_SAVE_BSD_SOURCE
# endif
# endif /* __linux__ */
@ -594,16 +605,16 @@
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
#if !defined(PNG_NO_PROGRESSIVE_READ) && \
!defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
#endif /* about interlacing capability! You'll */
/* still have interlacing unless you change the following line: */
!defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */
# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
#endif /* about interlacing capability! You'll */
/* still have interlacing unless you change the following line: */
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */
#ifndef PNG_NO_READ_COMPOSITE_NODIV
# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
# endif
#endif
@ -721,39 +732,46 @@
#endif
/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
* even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined.
*
* PNG_NO_ASSEMBLER_CODE disables use of all assembler code and optimized C,
* and removes or includes several functions in the API.
*
* PNG_NO_MMX_CODE disables the use of MMX code without changing the API.
* When MMX code is off, then optimized C replacement functions are used.
*/
#if 0 /* DISABLE AT ALL TIMES */
* and removed from version 1.2.20. The following will be removed
* from libpng-1.4.0
*/
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE)
# ifndef PNG_OPTIMIZED_CODE_SUPPORTED
# define PNG_OPTIMIZED_CODE_SUPPORTED
# endif
#endif
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
# define PNG_ASSEMBLER_CODE_SUPPORTED
# endif
# if defined(XP_MACOSX) && !defined(PNG_NO_MMX_CODE)
/* work around Intel-Mac compiler bug */
# define PNG_NO_MMX_CODE
# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4)
/* work around 64-bit gcc compiler bugs in gcc-3.x */
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_NO_MMX_CODE
# endif
# endif
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) && \
defined(__MMX__)
# if defined(__APPLE__)
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_NO_MMX_CODE
# endif
# endif
# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh))
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_NO_MMX_CODE
# endif
# endif
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_MMX_CODE_SUPPORTED
# endif
# if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_NO_MMX_CODE) && \
!defined(PNG_USE_PNGVCRD) && defined(__MMX__)
# define PNG_USE_PNGGCCRD
# endif
#endif
#endif /* 0 */
/* If you are sure that you don't need thread safety and you are compiling
with PNG_USE_PNGCCRD for an MMX application, you can define this for
faster execution. See pnggccrd.c.
#define PNG_THREAD_UNSAFE_OK
*/
#endif
/* end of obsolete code to be removed from libpng-1.4.0 */
#if !defined(PNG_1_0_X)
#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
@ -1275,7 +1293,8 @@ typedef z_stream FAR * png_zstreamp;
* but might be required for some pre-1.0.5c applications.
*/
#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
# if defined(PNG_NO_GLOBAL_ARRAYS) || \
(defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER)
# define PNG_USE_LOCAL_ARRAYS
# else
# define PNG_USE_GLOBAL_ARRAYS
@ -1412,8 +1431,7 @@ typedef z_stream FAR * png_zstreamp;
# define NOCHECK 0
# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
# define png_strcpy _fstrcpy
# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
# define png_snprintf _fsnprintf /* Added to v 1.2.19 */
# define png_strlen _fstrlen
# define png_memcmp _fmemcmp /* SJT: added */
# define png_memcpy _fmemcpy
@ -1421,8 +1439,27 @@ typedef z_stream FAR * png_zstreamp;
#else /* use the usual functions */
# define CVT_PTR(ptr) (ptr)
# define CVT_PTR_NOCHECK(ptr) (ptr)
# define png_strcpy strcpy
# define png_strncpy strncpy /* Added to v 1.2.6 */
# ifndef PNG_NO_SNPRINTF
# ifdef _MSC_VER
# define png_snprintf _snprintf /* Added to v 1.2.19 */
# define png_snprintf2 _snprintf
# define png_snprintf6 _snprintf
# else
# define png_snprintf snprintf /* Added to v 1.2.19 */
# define png_snprintf2 snprintf
# define png_snprintf6 snprintf
# endif
# else
/* You don't have or don't want to use snprintf(). Caution: Using
* sprintf instead of snprintf exposes your application to accidental
* or malevolent buffer overflows. If you don't have snprintf()
* as a general rule you should provide one (you can get one from
* Portable OpenSSH). */
# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
# endif
# define png_strlen strlen
# define png_memcmp memcmp /* SJT: added */
# define png_memcpy memcpy
@ -1438,47 +1475,6 @@ typedef z_stream FAR * png_zstreamp;
# define PNG_ZBUF_SIZE 65536L
#endif
#ifdef PNG_READ_SUPPORTED
/* Prior to libpng-1.0.9, this block was in pngasmrd.h */
#if defined(PNG_INTERNAL)
/* These are the default thresholds before the MMX code kicks in; if either
* rowbytes or bitdepth is below the threshold, plain C code is used. These
* can be overridden at runtime via the png_set_mmx_thresholds() call in
* libpng 1.2.0 and later. The values below were chosen by Intel.
*/
#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT
# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */
#endif
#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT
# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */
#endif
/* Set this in the makefile for VC++ on Pentium, not here. */
/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
* MMX will be detected at run time and used if present.
*/
#ifdef PNG_USE_PNGVCRD
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
#endif
/* Set this in the makefile for gcc/as on Pentium, not here. */
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c .
* MMX will be detected at run time and used if present.
*/
#ifdef PNG_USE_PNGGCCRD
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
#endif
/* - see pnggccrd.c for info about what is currently enabled */
#endif /* PNG_INTERNAL */
#endif /* PNG_READ_SUPPORTED */
/* Added at libpng-1.2.8 */
#endif /* PNG_VERSION_INFO_ONLY */

View File

@ -1,9 +1,9 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.2.13 November 13, 2006
* Last changed in libpng 1.2.22 [October 13, 2007]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2007 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.)
*
@ -20,15 +20,18 @@
static void /* PRIVATE */
png_default_error PNGARG((png_structp png_ptr,
png_const_charp error_message));
#ifndef PNG_NO_WARNINGS
static void /* PRIVATE */
png_default_warning PNGARG((png_structp png_ptr,
png_const_charp warning_message));
#endif /* PNG_NO_WARNINGS */
/* This function is called whenever there is a fatal error. This function
* should not be changed. If there is a need to handle errors differently,
* you should supply a replacement error function and use png_set_error_fn()
* to replace the error function at run-time.
*/
#ifndef PNG_NO_ERROR_TEXT
void PNGAPI
png_error(png_structp png_ptr, png_const_charp error_message)
{
@ -75,7 +78,20 @@ png_error(png_structp png_ptr, png_const_charp error_message)
use the default handler, which will not return. */
png_default_error(png_ptr, error_message);
}
#else
void PNGAPI
png_err(png_structp png_ptr)
{
if (png_ptr != NULL && png_ptr->error_fn != NULL)
(*(png_ptr->error_fn))(png_ptr, '\0');
/* 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');
}
#endif /* PNG_NO_ERROR_TEXT */
#ifndef PNG_NO_WARNINGS
/* 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,
* you should supply a replacement warning function and use
@ -105,6 +121,8 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
else
png_default_warning(png_ptr, warning_message+offset);
}
#endif /* PNG_NO_WARNINGS */
/* These utilities are used internally to build an error message that relates
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
@ -118,6 +136,9 @@ static PNG_CONST char png_digit[16] = {
'A', 'B', 'C', 'D', 'E', 'F'
};
#define PNG_MAX_ERROR_TEXT 64
#if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT)
static void /* PRIVATE */
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
error_message)
@ -141,20 +162,21 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
}
if (error_message == NULL)
buffer[iout] = 0;
buffer[iout] = '\0';
else
{
buffer[iout++] = ':';
buffer[iout++] = ' ';
png_strncpy(buffer+iout, error_message, 63);
buffer[iout+63] = 0;
png_memcpy(buffer+iout, error_message, PNG_MAX_ERROR_TEXT);
buffer[iout+PNG_MAX_ERROR_TEXT-1] = '\0';
}
}
#ifdef PNG_READ_SUPPORTED
void PNGAPI
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
{
char msg[18+64];
char msg[18+PNG_MAX_ERROR_TEXT];
if (png_ptr == NULL)
png_error(png_ptr, error_message);
else
@ -163,11 +185,14 @@ png_chunk_error(png_structp png_ptr, png_const_charp error_message)
png_error(png_ptr, msg);
}
}
#endif /* PNG_READ_SUPPORTED */
#endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */
#ifndef PNG_NO_WARNINGS
void PNGAPI
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
{
char msg[18+64];
char msg[18+PNG_MAX_ERROR_TEXT];
if (png_ptr == NULL)
png_warning(png_ptr, warning_message);
else
@ -176,6 +201,8 @@ png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
png_warning(png_ptr, msg);
}
}
#endif /* PNG_NO_WARNINGS */
/* This is the default error handling function. Note that replacements for
* this function MUST NOT RETURN, or the program will likely crash. This
@ -217,7 +244,7 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
# ifdef USE_FAR_KEYWORD
{
jmp_buf jmpbuf;
png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf));
png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
longjmp(jmpbuf, 1);
}
# else
@ -228,12 +255,11 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
PNG_ABORT();
#endif
#ifdef PNG_NO_CONSOLE_IO
/* make compiler happy */ ;
if (&error_message != NULL)
return;
error_message = error_message; /* make compiler happy */
#endif
}
#ifndef PNG_NO_WARNINGS
/* This function is called when there is a warning, but the library thinks
* it can continue anyway. Replacement functions don't have to do anything
* here if you don't want them to. In the default configuration, png_ptr is
@ -267,14 +293,11 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
# endif
fprintf(stderr, "libpng warning: %s\n", warning_message);
#else
/* make compiler happy */ ;
if (warning_message)
return;
warning_message = warning_message; /* make compiler happy */
#endif
/* make compiler happy */ ;
if (png_ptr)
return;
png_ptr = png_ptr; /* make compiler happy */
}
#endif /* PNG_NO_WARNINGS */
/* This function is called when the application wants to use another method
* of handling errors and warnings. Note that the error function MUST NOT

View File

@ -512,8 +512,11 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
png_sPLT_tpp spalettes)
{
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
{
*spalettes = info_ptr->splt_palettes;
return ((png_uint_32)info_ptr->splt_palettes_num);
return ((png_uint_32)info_ptr->splt_palettes_num);
}
return (0);
}
#endif
@ -800,8 +803,11 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
png_unknown_chunkpp unknowns)
{
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
{
*unknowns = info_ptr->unknown_chunks;
return ((png_uint_32)info_ptr->unknown_chunks_num);
return ((png_uint_32)info_ptr->unknown_chunks_num);
}
return (0);
}
#endif
@ -835,105 +841,44 @@ png_get_compression_buffer_size(png_structp png_ptr)
png_uint_32 PNGAPI
png_get_asm_flags (png_structp png_ptr)
{
#ifdef PNG_MMX_CODE_SUPPORTED
return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
#else
/* obsolete, to be removed from libpng-1.4.0 */
return (png_ptr? 0L: 0L);
#endif
}
/* this function was added to libpng 1.2.0 and should exist by default */
png_uint_32 PNGAPI
png_get_asm_flagmask (int flag_select)
{
#ifdef PNG_MMX_CODE_SUPPORTED
png_uint_32 settable_asm_flags = 0;
if (flag_select & PNG_SELECT_READ)
settable_asm_flags |=
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
PNG_ASM_FLAG_MMX_READ_INTERLACE |
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
/* no non-MMX flags yet */
#if 0
/* GRR: no write-flags yet, either, but someday... */
if (flag_select & PNG_SELECT_WRITE)
settable_asm_flags |=
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
#endif /* 0 */
return settable_asm_flags; /* _theoretically_ settable capabilities only */
#else
return (0L);
#endif /* PNG_MMX_CODE_SUPPORTED */
/* obsolete, to be removed from libpng-1.4.0 */
flag_select=flag_select;
return 0L;
}
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
/* this function was added to libpng 1.2.0 */
png_uint_32 PNGAPI
png_get_mmx_flagmask (int flag_select, int *compilerID)
{
#if defined(PNG_MMX_CODE_SUPPORTED)
png_uint_32 settable_mmx_flags = 0;
if (flag_select & PNG_SELECT_READ)
settable_mmx_flags |=
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
PNG_ASM_FLAG_MMX_READ_INTERLACE |
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
#if 0
/* GRR: no MMX write support yet, but someday... */
if (flag_select & PNG_SELECT_WRITE)
settable_mmx_flags |=
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
#endif /* 0 */
if (compilerID != NULL) {
#ifdef PNG_USE_PNGVCRD
*compilerID = 1; /* MSVC */
#else
#ifdef PNG_USE_PNGGCCRD
*compilerID = 2; /* gcc/gas */
#else
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
#endif
#endif
}
return settable_mmx_flags; /* _theoretically_ settable capabilities only */
#else
return (0L);
#endif /* ?PNG_MMX_CODE_SUPPORTED */
/* obsolete, to be removed from libpng-1.4.0 */
flag_select=flag_select;
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
return 0L;
}
/* this function was added to libpng 1.2.0 */
png_byte PNGAPI
png_get_mmx_bitdepth_threshold (png_structp png_ptr)
{
#if defined(PNG_MMX_CODE_SUPPORTED)
return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
#else
/* obsolete, to be removed from libpng-1.4.0 */
return (png_ptr? 0: 0);
#endif /* ?PNG_MMX_CODE_SUPPORTED */
}
/* this function was added to libpng 1.2.0 */
png_uint_32 PNGAPI
png_get_mmx_rowbytes_threshold (png_structp png_ptr)
{
#if defined(PNG_MMX_CODE_SUPPORTED)
return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
#else
/* obsolete, to be removed from libpng-1.4.0 */
return (png_ptr? 0L: 0L);
#endif /* ?PNG_MMX_CODE_SUPPORTED */
}
#endif /* ?PNG_1_0_X */
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
@ -951,5 +896,6 @@ png_get_user_height_max (png_structp png_ptr)
return (png_ptr? png_ptr->user_height_max : 0);
}
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

View File

@ -1,9 +1,9 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.2.13 November 13, 2006
* Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2008 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.)
*/
@ -28,7 +28,7 @@ void PNGAPI
png_process_data(png_structp png_ptr, png_infop info_ptr,
png_bytep buffer, png_size_t buffer_size)
{
if(png_ptr == NULL) return;
if(png_ptr == NULL || info_ptr == NULL) return;
png_push_restore_buffer(png_ptr, buffer, buffer_size);
while (png_ptr->buffer_size)
@ -137,60 +137,60 @@ void /* PRIVATE */
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
{
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IHDR;
PNG_IDAT;
PNG_IEND;
PNG_PLTE;
PNG_CONST PNG_IHDR;
PNG_CONST PNG_IDAT;
PNG_CONST PNG_IEND;
PNG_CONST PNG_PLTE;
#if defined(PNG_READ_bKGD_SUPPORTED)
PNG_bKGD;
PNG_CONST PNG_bKGD;
#endif
#if defined(PNG_READ_cHRM_SUPPORTED)
PNG_cHRM;
PNG_CONST PNG_cHRM;
#endif
#if defined(PNG_READ_gAMA_SUPPORTED)
PNG_gAMA;
PNG_CONST PNG_gAMA;
#endif
#if defined(PNG_READ_hIST_SUPPORTED)
PNG_hIST;
PNG_CONST PNG_hIST;
#endif
#if defined(PNG_READ_iCCP_SUPPORTED)
PNG_iCCP;
PNG_CONST PNG_iCCP;
#endif
#if defined(PNG_READ_iTXt_SUPPORTED)
PNG_iTXt;
PNG_CONST PNG_iTXt;
#endif
#if defined(PNG_READ_oFFs_SUPPORTED)
PNG_oFFs;
PNG_CONST PNG_oFFs;
#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
PNG_pCAL;
PNG_CONST PNG_pCAL;
#endif
#if defined(PNG_READ_pHYs_SUPPORTED)
PNG_pHYs;
PNG_CONST PNG_pHYs;
#endif
#if defined(PNG_READ_sBIT_SUPPORTED)
PNG_sBIT;
PNG_CONST PNG_sBIT;
#endif
#if defined(PNG_READ_sCAL_SUPPORTED)
PNG_sCAL;
PNG_CONST PNG_sCAL;
#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
PNG_sRGB;
PNG_CONST PNG_sRGB;
#endif
#if defined(PNG_READ_sPLT_SUPPORTED)
PNG_sPLT;
PNG_CONST PNG_sPLT;
#endif
#if defined(PNG_READ_tEXt_SUPPORTED)
PNG_tEXt;
PNG_CONST PNG_tEXt;
#endif
#if defined(PNG_READ_tIME_SUPPORTED)
PNG_tIME;
PNG_CONST PNG_tIME;
#endif
#if defined(PNG_READ_tRNS_SUPPORTED)
PNG_tRNS;
PNG_CONST PNG_tRNS;
#endif
#if defined(PNG_READ_zTXt_SUPPORTED)
PNG_zTXt;
PNG_CONST PNG_zTXt;
#endif
#endif /* PNG_USE_LOCAL_ARRAYS */
/* First we make sure we have enough data for the 4 byte chunk name
@ -216,7 +216,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
}
if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
if(png_ptr->mode & PNG_AFTER_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
@ -273,7 +273,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
}
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
}
else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
{
/* If we reach an IDAT chunk, this means we have read all of the
* header chunks, and we can start reading the image (or if this
@ -660,7 +660,7 @@ void /* PRIVATE */
png_push_read_IDAT(png_structp png_ptr)
{
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IDAT;
PNG_CONST PNG_IDAT;
#endif
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
{
@ -678,7 +678,7 @@ png_push_read_IDAT(png_structp png_ptr)
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
{
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
@ -990,25 +990,20 @@ png_read_push_finish_row(png_structp png_ptr)
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */
const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
/* offset to next interlace block */
const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
/* start of interlace block in the y direction */
const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
/* offset to next interlace block in the y direction */
const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* Width of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h
const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
*/
PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* Height of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h
const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
*/
#endif
@ -1023,32 +1018,37 @@ png_read_push_finish_row(png_structp png_ptr)
png_ptr->rowbytes + 1);
do
{
png_ptr->pass++;
if ((png_ptr->pass == 1 && png_ptr->width < 5) ||
(png_ptr->pass == 3 && png_ptr->width < 3) ||
(png_ptr->pass == 5 && png_ptr->width < 2))
png_ptr->pass++;
int pass;
pass = png_ptr->pass;
pass++;
if ((pass == 1 && png_ptr->width < 5) ||
(pass == 3 && png_ptr->width < 3) ||
(pass == 5 && png_ptr->width < 2))
pass++;
if (png_ptr->pass > 7)
png_ptr->pass--;
if (png_ptr->pass >= 7)
break;
if (pass > 7)
pass--;
png_ptr->pass = (png_byte) pass;
if (pass < 7)
{
png_ptr->iwidth = (png_ptr->width +
png_pass_inc[pass] - 1 -
png_pass_start[pass]) /
png_pass_inc[pass];
png_ptr->iwidth = (png_ptr->width +
png_pass_inc[png_ptr->pass] - 1 -
png_pass_start[png_ptr->pass]) /
png_pass_inc[png_ptr->pass];
png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
png_ptr->iwidth) + 1;
png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
png_ptr->iwidth) + 1;
if (png_ptr->transformations & PNG_INTERLACE)
break;
if (png_ptr->transformations & PNG_INTERLACE)
break;
png_ptr->num_rows = (png_ptr->height +
png_pass_yinc[png_ptr->pass] - 1 -
png_pass_ystart[png_ptr->pass]) /
png_pass_yinc[png_ptr->pass];
png_ptr->num_rows = (png_ptr->height +
png_pass_yinc[pass] - 1 -
png_pass_ystart[pass]) /
png_pass_yinc[pass];
}
else
break;
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
}
@ -1062,8 +1062,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
{
png_error(png_ptr, "Out of place tEXt");
/* to quiet some compiler warnings */
if(info_ptr == NULL) return;
info_ptr = info_ptr; /* to quiet some compiler warnings */
}
#ifdef PNG_MAX_MALLOC_64K
@ -1126,7 +1125,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
for (text = key; *text; text++)
/* empty loop */ ;
if (text != key + png_ptr->current_text_size)
if (text < key + png_ptr->current_text_size)
text++;
text_ptr = (png_textp)png_malloc(png_ptr,
@ -1159,8 +1158,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
{
png_error(png_ptr, "Out of place zTXt");
/* to quiet some compiler warnings */
if(info_ptr == NULL) return;
info_ptr = info_ptr; /* to quiet some compiler warnings */
}
#ifdef PNG_MAX_MALLOC_64K
@ -1222,7 +1220,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
/* empty loop */ ;
/* zTXt can't have zero text */
if (text == key + png_ptr->current_text_size)
if (text >= key + png_ptr->current_text_size)
{
png_ptr->current_text = NULL;
png_free(png_ptr, key);
@ -1352,8 +1350,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
{
png_error(png_ptr, "Out of place iTXt");
/* to quiet some compiler warnings */
if(info_ptr == NULL) return;
info_ptr = info_ptr; /* to quiet some compiler warnings */
}
#ifdef PNG_MAX_MALLOC_64K
@ -1420,7 +1417,7 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
for (lang = key; *lang; lang++)
/* empty loop */ ;
if (lang != key + png_ptr->current_text_size)
if (lang < key + png_ptr->current_text_size - 3)
lang++;
comp_flag = *lang++;
@ -1430,10 +1427,14 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
/* empty loop */ ;
lang_key++; /* skip NUL separator */
for (text = lang_key; *text; text++)
/* empty loop */ ;
text=lang_key;
if (lang_key < key + png_ptr->current_text_size - 1)
{
for (; *text; text++)
/* empty loop */ ;
}
if (text != key + png_ptr->current_text_size)
if (text < key + png_ptr->current_text_size)
text++;
text_ptr = (png_textp)png_malloc(png_ptr,
@ -1471,55 +1472,61 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
if (!(png_ptr->chunk_name[0] & 0x20))
{
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
&& png_ptr->read_user_chunk_fn == NULL
&& png_ptr->read_user_chunk_fn == NULL
#endif
)
)
#endif
png_chunk_error(png_ptr, "unknown critical chunk");
png_chunk_error(png_ptr, "unknown critical chunk");
/* to quiet compiler warnings about unused info_ptr */
if (info_ptr == NULL)
return;
info_ptr = info_ptr; /* to quiet some compiler warnings */
}
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
{
png_unknown_chunk chunk;
#ifdef PNG_MAX_MALLOC_64K
if (length > (png_uint_32)65535L)
{
png_warning(png_ptr, "unknown chunk too large to fit in memory");
skip = length - (png_uint_32)65535L;
length = (png_uint_32)65535L;
}
if (length > (png_uint_32)65535L)
{
png_warning(png_ptr, "unknown chunk too large to fit in memory");
skip = length - (png_uint_32)65535L;
length = (png_uint_32)65535L;
}
#endif
png_memcpy((png_charp)png_ptr->unknown_chunk.name,
(png_charp)png_ptr->chunk_name,
png_sizeof(png_ptr->unknown_chunk.name));
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1]='\0';
png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_crc_read(png_ptr, chunk.data, length);
chunk.size = length;
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_ptr->unknown_chunk.size = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if(png_ptr->read_user_chunk_fn != NULL)
{
/* callback to user unknown chunk handler */
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
{
if (!(png_ptr->chunk_name[0] & 0x20))
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS)
png_chunk_error(png_ptr, "unknown critical chunk");
}
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
}
else
if(png_ptr->read_user_chunk_fn != NULL)
{
/* callback to user unknown chunk handler */
int ret;
ret = (*(png_ptr->read_user_chunk_fn))
(png_ptr, &png_ptr->unknown_chunk);
if (ret < 0)
png_chunk_error(png_ptr, "error in user chunk");
if (ret == 0)
{
if (!(png_ptr->chunk_name[0] & 0x20))
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS)
png_chunk_error(png_ptr, "unknown critical chunk");
png_set_unknown_chunks(png_ptr, info_ptr,
&png_ptr->unknown_chunk, 1);
}
}
else
#endif
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
png_free(png_ptr, chunk.data);
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
png_free(png_ptr, png_ptr->unknown_chunk.data);
png_ptr->unknown_chunk.data = NULL;
}
else
#endif
@ -1553,11 +1560,11 @@ void PNGAPI
png_progressive_combine_row (png_structp png_ptr,
png_bytep old_row, png_bytep new_row)
{
if(png_ptr == NULL) return;
#ifdef PNG_USE_LOCAL_ARRAYS
const int FARDATA png_pass_dsp_mask[7] =
PNG_CONST int FARDATA png_pass_dsp_mask[7] =
{0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
#endif
if(png_ptr == NULL) return;
if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
}

View File

@ -1,9 +1,9 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.2.15 January 5, 2007
* Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
* Copyright (c) 1998-2008 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.)
*
@ -55,12 +55,6 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
if (png_ptr == NULL)
return (NULL);
#if !defined(PNG_1_0_X)
#ifdef PNG_MMX_CODE_SUPPORTED
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
#endif
#endif /* PNG_1_0_X */
/* added at libpng-1.2.6 */
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
@ -95,12 +89,18 @@ 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);
i=0;
do
if(user_png_ver)
{
if(user_png_ver[i] != png_libpng_ver[i])
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;
} while (png_libpng_ver[i++]);
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
{
@ -117,11 +117,13 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
char msg[80];
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
png_snprintf(msg, 80,
"Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_snprintf(msg, 80,
"Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
#endif
@ -197,11 +199,13 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_ptr->warning_fn=NULL;
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
png_snprintf(msg, 80,
"Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_snprintf(msg, 80,
"Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
}
@ -320,7 +324,7 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
void PNGAPI
png_read_info(png_structp png_ptr, png_infop info_ptr)
{
if(png_ptr == NULL) return;
if(png_ptr == NULL || info_ptr == NULL) return;
png_debug(1, "in png_read_info\n");
/* If we haven't checked all of the PNG signature bytes, do so now. */
if (png_ptr->sig_bytes < 8)
@ -346,60 +350,60 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
for(;;)
{
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IHDR;
PNG_IDAT;
PNG_IEND;
PNG_PLTE;
PNG_CONST PNG_IHDR;
PNG_CONST PNG_IDAT;
PNG_CONST PNG_IEND;
PNG_CONST PNG_PLTE;
#if defined(PNG_READ_bKGD_SUPPORTED)
PNG_bKGD;
PNG_CONST PNG_bKGD;
#endif
#if defined(PNG_READ_cHRM_SUPPORTED)
PNG_cHRM;
PNG_CONST PNG_cHRM;
#endif
#if defined(PNG_READ_gAMA_SUPPORTED)
PNG_gAMA;
PNG_CONST PNG_gAMA;
#endif
#if defined(PNG_READ_hIST_SUPPORTED)
PNG_hIST;
PNG_CONST PNG_hIST;
#endif
#if defined(PNG_READ_iCCP_SUPPORTED)
PNG_iCCP;
PNG_CONST PNG_iCCP;
#endif
#if defined(PNG_READ_iTXt_SUPPORTED)
PNG_iTXt;
PNG_CONST PNG_iTXt;
#endif
#if defined(PNG_READ_oFFs_SUPPORTED)
PNG_oFFs;
PNG_CONST PNG_oFFs;
#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
PNG_pCAL;
PNG_CONST PNG_pCAL;
#endif
#if defined(PNG_READ_pHYs_SUPPORTED)
PNG_pHYs;
PNG_CONST PNG_pHYs;
#endif
#if defined(PNG_READ_sBIT_SUPPORTED)
PNG_sBIT;
PNG_CONST PNG_sBIT;
#endif
#if defined(PNG_READ_sCAL_SUPPORTED)
PNG_sCAL;
PNG_CONST PNG_sCAL;
#endif
#if defined(PNG_READ_sPLT_SUPPORTED)
PNG_sPLT;
PNG_CONST PNG_sPLT;
#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
PNG_sRGB;
PNG_CONST PNG_sRGB;
#endif
#if defined(PNG_READ_tEXt_SUPPORTED)
PNG_tEXt;
PNG_CONST PNG_tEXt;
#endif
#if defined(PNG_READ_tIME_SUPPORTED)
PNG_tIME;
PNG_CONST PNG_tIME;
#endif
#if defined(PNG_READ_tRNS_SUPPORTED)
PNG_tRNS;
PNG_CONST PNG_tRNS;
#endif
#if defined(PNG_READ_zTXt_SUPPORTED)
PNG_zTXt;
PNG_CONST PNG_zTXt;
#endif
#endif /* PNG_USE_LOCAL_ARRAYS */
png_byte chunk_length[4];
@ -417,7 +421,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
/* This should be a binary subdivision search or a hash for
* matching the chunk name rather than a linear search.
*/
if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
if(png_ptr->mode & PNG_AFTER_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
@ -567,9 +571,10 @@ void PNGAPI
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
{
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IDAT;
const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
PNG_CONST 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};
#endif
int ret;
if(png_ptr == NULL) return;
@ -925,60 +930,60 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
do
{
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IHDR;
PNG_IDAT;
PNG_IEND;
PNG_PLTE;
PNG_CONST PNG_IHDR;
PNG_CONST PNG_IDAT;
PNG_CONST PNG_IEND;
PNG_CONST PNG_PLTE;
#if defined(PNG_READ_bKGD_SUPPORTED)
PNG_bKGD;
PNG_CONST PNG_bKGD;
#endif
#if defined(PNG_READ_cHRM_SUPPORTED)
PNG_cHRM;
PNG_CONST PNG_cHRM;
#endif
#if defined(PNG_READ_gAMA_SUPPORTED)
PNG_gAMA;
PNG_CONST PNG_gAMA;
#endif
#if defined(PNG_READ_hIST_SUPPORTED)
PNG_hIST;
PNG_CONST PNG_hIST;
#endif
#if defined(PNG_READ_iCCP_SUPPORTED)
PNG_iCCP;
PNG_CONST PNG_iCCP;
#endif
#if defined(PNG_READ_iTXt_SUPPORTED)
PNG_iTXt;
PNG_CONST PNG_iTXt;
#endif
#if defined(PNG_READ_oFFs_SUPPORTED)
PNG_oFFs;
PNG_CONST PNG_oFFs;
#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
PNG_pCAL;
PNG_CONST PNG_pCAL;
#endif
#if defined(PNG_READ_pHYs_SUPPORTED)
PNG_pHYs;
PNG_CONST PNG_pHYs;
#endif
#if defined(PNG_READ_sBIT_SUPPORTED)
PNG_sBIT;
PNG_CONST PNG_sBIT;
#endif
#if defined(PNG_READ_sCAL_SUPPORTED)
PNG_sCAL;
PNG_CONST PNG_sCAL;
#endif
#if defined(PNG_READ_sPLT_SUPPORTED)
PNG_sPLT;
PNG_CONST PNG_sPLT;
#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
PNG_sRGB;
PNG_CONST PNG_sRGB;
#endif
#if defined(PNG_READ_tEXt_SUPPORTED)
PNG_tEXt;
PNG_CONST PNG_tEXt;
#endif
#if defined(PNG_READ_tIME_SUPPORTED)
PNG_tIME;
PNG_CONST PNG_tIME;
#endif
#if defined(PNG_READ_tRNS_SUPPORTED)
PNG_tRNS;
PNG_CONST PNG_tRNS;
#endif
#if defined(PNG_READ_zTXt_SUPPORTED)
PNG_zTXt;
PNG_CONST PNG_zTXt;
#endif
#endif /* PNG_USE_LOCAL_ARRAYS */
@ -1100,13 +1105,22 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
png_structp png_ptr = NULL;
png_infop info_ptr = NULL, end_info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn;
png_voidp mem_ptr;
png_free_ptr free_fn = NULL;
png_voidp mem_ptr = NULL;
#endif
png_debug(1, "in png_destroy_read_struct\n");
if (png_ptr_ptr != NULL)
{
png_ptr = *png_ptr_ptr;
}
if (png_ptr == NULL)
return;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
#endif
if (info_ptr_ptr != NULL)
info_ptr = *info_ptr_ptr;
@ -1114,11 +1128,6 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
if (end_info_ptr_ptr != NULL)
end_info_ptr = *end_info_ptr_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
#endif
png_read_destroy(png_ptr, info_ptr, end_info_ptr);
if (info_ptr != NULL)
@ -1150,16 +1159,13 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
*end_info_ptr_ptr = NULL;
}
if (png_ptr != NULL)
{
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else
png_destroy_struct((png_voidp)png_ptr);
png_destroy_struct((png_voidp)png_ptr);
#endif
*png_ptr_ptr = NULL;
}
*png_ptr_ptr = NULL;
}
/* free all memory used by the read (old method) */
@ -1464,8 +1470,8 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr);
if(transforms == 0 || params == NULL)
/* quiet compiler warnings */ return;
transforms = transforms; /* quiet compiler warnings */
params = params;
}
#endif /* PNG_INFO_IMAGE_SUPPORTED */

View File

@ -1,9 +1,9 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.2.15 January 5, 2007
* Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
* Copyright (c) 1998-2008 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.)
*
@ -548,6 +548,9 @@ png_set_expand(png_structp png_ptr)
png_debug(1, "in png_set_expand\n");
if(png_ptr == NULL) return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
#ifdef PNG_WARN_UNINITIALIZED_ROW
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
#endif
}
/* GRR 19990627: the following three functions currently are identical
@ -574,6 +577,9 @@ png_set_palette_to_rgb(png_structp png_ptr)
png_debug(1, "in png_set_palette_to_rgb\n");
if(png_ptr == NULL) return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
#ifdef PNG_WARN_UNINITIALIZED_ROW
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
#endif
}
#if !defined(PNG_1_0_X)
@ -583,7 +589,10 @@ png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
{
png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n");
if(png_ptr == NULL) return;
png_ptr->transformations |= PNG_EXPAND_tRNS;
png_ptr->transformations |= PNG_EXPAND;
#ifdef PNG_WARN_UNINITIALIZED_ROW
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
#endif
}
#endif
@ -604,8 +613,11 @@ png_set_gray_1_2_4_to_8(png_structp png_ptr)
void PNGAPI
png_set_tRNS_to_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_expand\n");
png_debug(1, "in png_set_tRNS_to_alpha\n");
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
#ifdef PNG_WARN_UNINITIALIZED_ROW
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
#endif
}
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
@ -615,6 +627,9 @@ png_set_gray_to_rgb(png_structp png_ptr)
{
png_debug(1, "in png_set_gray_to_rgb\n");
png_ptr->transformations |= PNG_GRAY_TO_RGB;
#ifdef PNG_WARN_UNINITIALIZED_ROW
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
#endif
}
#endif
@ -842,7 +857,7 @@ png_init_read_transformations(png_structp png_ptr)
k=1; /* partial transparency is present */
}
if (k == 0)
png_ptr->transformations &= (~PNG_GAMMA);
png_ptr->transformations &= ~PNG_GAMMA;
}
if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) &&
@ -949,6 +964,14 @@ png_init_read_transformations(png_structp png_ptr)
palette[i].blue = png_ptr->gamma_table[palette[i].blue];
}
}
/* Prevent the transformations being done again, and make sure
* that the now spurious alpha channel is stripped - the code
* has just reduced background composition and gamma correction
* to a simply alpha channel strip.
*/
png_ptr->transformations &= ~PNG_BACKGROUND;
png_ptr->transformations &= ~PNG_GAMMA;
png_ptr->transformations |= PNG_STRIP_ALPHA;
}
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
else
@ -1023,6 +1046,9 @@ png_init_read_transformations(png_structp png_ptr)
palette[i].green = png_ptr->gamma_table[palette[i].green];
palette[i].blue = png_ptr->gamma_table[palette[i].blue];
}
/* Done the gamma correction. */
png_ptr->transformations &= ~PNG_GAMMA;
}
}
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
@ -1060,6 +1086,10 @@ png_init_read_transformations(png_structp png_ptr)
png_ptr->trans[i], back.blue);
}
}
/* Handled alpha, still need to strip the channel. */
png_ptr->transformations &= ~PNG_BACKGROUND;
png_ptr->transformations |= PNG_STRIP_ALPHA;
}
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
@ -1244,19 +1274,29 @@ void /* PRIVATE */
png_do_read_transformations(png_structp png_ptr)
{
png_debug(1, "in png_do_read_transformations\n");
#if !defined(PNG_USELESS_TESTS_SUPPORTED)
if (png_ptr->row_buf == NULL)
{
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[50];
sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number,
png_snprintf2(msg, 50,
"NULL row buffer for row %ld, pass %d", png_ptr->row_number,
png_ptr->pass);
png_error(png_ptr, msg);
#else
png_error(png_ptr, "NULL row buffer");
#endif
}
#ifdef PNG_WARN_UNINITIALIZED_ROW
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
/* Application has failed to call either png_read_start_image()
* or png_read_update_info() after setting transforms that expand
* pixels. This check added to libpng-1.2.19 */
#if (PNG_WARN_UNINITIALIZED_ROW==1)
png_error(png_ptr, "Uninitialized row");
#else
png_warning(png_ptr, "Uninitialized row");
#endif
#endif
#if defined(PNG_READ_EXPAND_SUPPORTED)
@ -1269,7 +1309,8 @@ png_do_read_transformations(png_structp png_ptr)
}
else
{
if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS))
if (png_ptr->num_trans &&
(png_ptr->transformations & PNG_EXPAND_tRNS))
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
&(png_ptr->trans_values));
else
@ -1293,9 +1334,11 @@ png_do_read_transformations(png_structp png_ptr)
if(rgb_error)
{
png_ptr->rgb_to_gray_status=1;
if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN)
if((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
PNG_RGB_TO_GRAY_WARN)
png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel");
if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR)
if((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
PNG_RGB_TO_GRAY_ERR)
png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel");
}
}
@ -3699,7 +3742,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
{
case 1:
{
gray = (png_uint_16)(gray*0xff);
gray = (png_uint_16)((gray&0x01)*0xff);
sp = row + (png_size_t)((row_width - 1) >> 3);
dp = row + (png_size_t)row_width - 1;
shift = 7 - (int)((row_width + 7) & 0x07);
@ -3723,7 +3766,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
case 2:
{
gray = (png_uint_16)(gray*0x55);
gray = (png_uint_16)((gray&0x03)*0x55);
sp = row + (png_size_t)((row_width - 1) >> 2);
dp = row + (png_size_t)row_width - 1;
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
@ -3746,7 +3789,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
case 4:
{
gray = (png_uint_16)(gray*0x11);
gray = (png_uint_16)((gray&0x0f)*0x11);
sp = row + (png_size_t)((row_width - 1) >> 1);
dp = row + (png_size_t)row_width - 1;
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
@ -3776,6 +3819,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
{
if (row_info->bit_depth == 8)
{
gray = gray & 0xff;
sp = row + (png_size_t)row_width - 1;
dp = row + (png_size_t)(row_width << 1) - 1;
for (i = 0; i < row_width; i++)
@ -3789,12 +3833,13 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
else if (row_info->bit_depth == 16)
{
png_byte gray_high = (gray >> 8) & 0xff;
png_byte gray_low = gray & 0xff;
sp = row + row_info->rowbytes - 1;
dp = row + (row_info->rowbytes << 1) - 1;
for (i = 0; i < row_width; i++)
{
if (((png_uint_16)*(sp) |
((png_uint_16)*(sp - 1) << 8)) == gray)
if (*(sp-1) == gray_high && *(sp) == gray_low)
{
*dp-- = 0;
*dp-- = 0;
@ -3819,13 +3864,14 @@ png_do_expand(png_row_infop row_info, png_bytep row,
{
if (row_info->bit_depth == 8)
{
png_byte red = trans_value->red & 0xff;
png_byte green = trans_value->green & 0xff;
png_byte blue = trans_value->blue & 0xff;
sp = row + (png_size_t)row_info->rowbytes - 1;
dp = row + (png_size_t)(row_width << 2) - 1;
for (i = 0; i < row_width; i++)
{
if (*(sp - 2) == trans_value->red &&
*(sp - 1) == trans_value->green &&
*(sp - 0) == trans_value->blue)
if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)
*dp-- = 0;
else
*dp-- = 0xff;
@ -3836,16 +3882,22 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
else if (row_info->bit_depth == 16)
{
png_byte red_high = (trans_value->red >> 8) & 0xff;
png_byte green_high = (trans_value->green >> 8) & 0xff;
png_byte blue_high = (trans_value->blue >> 8) & 0xff;
png_byte red_low = trans_value->red & 0xff;
png_byte green_low = trans_value->green & 0xff;
png_byte blue_low = trans_value->blue & 0xff;
sp = row + row_info->rowbytes - 1;
dp = row + (png_size_t)(row_width << 3) - 1;
for (i = 0; i < row_width; i++)
{
if ((((png_uint_16)*(sp - 4) |
((png_uint_16)*(sp - 5) << 8)) == trans_value->red) &&
(((png_uint_16)*(sp - 2) |
((png_uint_16)*(sp - 3) << 8)) == trans_value->green) &&
(((png_uint_16)*(sp - 0) |
((png_uint_16)*(sp - 1) << 8)) == trans_value->blue))
if (*(sp - 5) == red_high &&
*(sp - 4) == red_low &&
*(sp - 3) == green_high &&
*(sp - 2) == green_low &&
*(sp - 1) == blue_high &&
*(sp ) == blue_low)
{
*dp-- = 0;
*dp-- = 0;
@ -3965,7 +4017,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
#ifdef PNG_FLOATING_POINT_SUPPORTED
#if defined(PNG_READ_GAMMA_SUPPORTED)
static int png_gamma_shift[] =
static PNG_CONST int png_gamma_shift[] =
{0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00};
/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit

View File

@ -1,9 +1,9 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.2.15 January 5, 2007
* Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
* Copyright (c) 1998-2008 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.)
*
@ -16,10 +16,14 @@
#if defined(PNG_READ_SUPPORTED)
#if defined(_WIN32_WCE) && (_WIN32_WCE<0x500)
# define WIN32_WCE_OLD
#endif
#ifdef PNG_FLOATING_POINT_SUPPORTED
# if defined(_WIN32_WCE)
# if defined(WIN32_WCE_OLD)
/* strtod() function is not supported on WindowsCE */
__inline double png_strtod(png_structp png_ptr, const char *nptr, char **endptr)
__inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr)
{
double result = 0;
int len;
@ -33,7 +37,7 @@ __inline double png_strtod(png_structp png_ptr, const char *nptr, char **endptr)
result = wcstod(str, &end);
len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL);
*endptr = (char *)nptr + (png_strlen(nptr) - len + 1);
png_free(str);
png_free(png_ptr, str);
}
return result;
}
@ -181,7 +185,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
png_charp chunkdata, png_size_t chunklength,
png_size_t prefix_size, png_size_t *newlength)
{
static char msg[] = "Error decoding compressed text";
static PNG_CONST char msg[] = "Error decoding compressed text";
png_charp text;
png_size_t text_size;
@ -226,7 +230,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
text_size = (png_size_t)(chunklength - (text - chunkdata) - 1);
text_size = png_sizeof(msg) > text_size ? text_size :
png_sizeof(msg);
png_memcpy(text + prefix_size, msg, text_size + 1);
png_memcpy(text + prefix_size, msg, text_size);
break;
}
if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END)
@ -282,13 +286,16 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
char umsg[52];
if (ret == Z_BUF_ERROR)
sprintf(umsg,"Buffer error in compressed datastream in %s chunk",
png_snprintf(umsg, 52,
"Buffer error in compressed datastream in %s chunk",
png_ptr->chunk_name);
else if (ret == Z_DATA_ERROR)
sprintf(umsg,"Data error in compressed datastream in %s chunk",
png_snprintf(umsg, 52,
"Data error in compressed datastream in %s chunk",
png_ptr->chunk_name);
else
sprintf(umsg,"Incomplete compressed datastream in %s chunk",
png_snprintf(umsg, 52,
"Incomplete compressed datastream in %s chunk",
png_ptr->chunk_name);
png_warning(png_ptr, umsg);
#else
@ -321,7 +328,8 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char umsg[50];
sprintf(umsg, "Unknown zTXt compression type %d", comp_type);
png_snprintf(umsg, 50,
"Unknown zTXt compression type %d", comp_type);
png_warning(png_ptr, umsg);
#else
png_warning(png_ptr, "Unknown zTXt compression type");
@ -563,8 +571,7 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_crc_finish(png_ptr, length);
if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */
return;
info_ptr =info_ptr; /* quiet compiler warnings about unused info_ptr */
}
#if defined(PNG_READ_gAMA_SUPPORTED)
@ -1037,7 +1044,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* there should be at least one zero (the compression type byte)
following the separator, and we should be on it */
if ( profile >= chunkdata + slength)
if ( profile >= chunkdata + slength - 1)
{
png_free(png_ptr, chunkdata);
png_warning(png_ptr, "Malformed iCCP chunk");
@ -1141,7 +1148,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
++entry_start;
/* a sample depth should follow the separator, and we should be on it */
if (entry_start > chunkdata + slength)
if (entry_start > chunkdata + slength - 2)
{
png_free(png_ptr, chunkdata);
png_warning(png_ptr, "malformed sPLT chunk");
@ -1234,9 +1241,15 @@ void /* PRIVATE */
png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
int bit_mask;
png_debug(1, "in png_handle_tRNS\n");
/* For non-indexed color, mask off any bits in the tRNS value that
* exceed the bit depth. Some creators were writing extra bits there.
* This is not needed for indexed color. */
bit_mask = (1 << png_ptr->bit_depth) - 1;
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before tRNS");
else if (png_ptr->mode & PNG_HAVE_IDAT)
@ -1265,7 +1278,7 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_read(png_ptr, buf, 2);
png_ptr->num_trans = 1;
png_ptr->trans_values.gray = png_get_uint_16(buf);
png_ptr->trans_values.gray = png_get_uint_16(buf) & bit_mask;
}
else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
{
@ -1279,9 +1292,9 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_crc_read(png_ptr, buf, (png_size_t)length);
png_ptr->num_trans = 1;
png_ptr->trans_values.red = png_get_uint_16(buf);
png_ptr->trans_values.green = png_get_uint_16(buf + 2);
png_ptr->trans_values.blue = png_get_uint_16(buf + 4);
png_ptr->trans_values.red = png_get_uint_16(buf) & bit_mask;
png_ptr->trans_values.green = png_get_uint_16(buf + 2) & bit_mask;
png_ptr->trans_values.blue = png_get_uint_16(buf + 4) & bit_mask;
}
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
@ -1314,7 +1327,10 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
if (png_crc_finish(png_ptr, 0))
{
png_ptr->num_trans = 0;
return;
}
png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
&(png_ptr->trans_values));
@ -1377,7 +1393,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
png_ptr->background.index = buf[0];
if(info_ptr->num_palette)
if (info_ptr && info_ptr->num_palette)
{
if(buf[0] > info_ptr->num_palette)
{
@ -1657,7 +1673,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
buf++; /* Skip the null string terminator from previous parameter. */
png_debug1(3, "Reading pCAL parameter %d\n", i);
for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++)
for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++)
/* Empty loop to move past each parameter string */ ;
/* Make sure we haven't run out of data yet */
@ -1755,6 +1771,17 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* empty loop */ ;
ep++;
if (buffer + slength < ep)
{
png_warning(png_ptr, "Truncated sCAL chunk");
#if defined(PNG_FIXED_POINT_SUPPORTED) && \
!defined(PNG_FLOATING_POINT_SUPPORTED)
png_free(png_ptr, swidth);
#endif
png_free(png_ptr, buffer);
return;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED
height = png_strtod(png_ptr, ep, &vp);
if (*vp)
@ -1765,7 +1792,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
if (swidth == NULL)
if (sheight == NULL)
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
return;
@ -1978,10 +2005,11 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* empty loop */ ;
/* zTXt must have some text after the chunkdataword */
if (text == chunkdata + slength)
if (text >= chunkdata + slength - 2)
{
comp_type = PNG_TEXT_COMPRESSION_NONE;
png_warning(png_ptr, "Zero length zTXt chunk");
png_warning(png_ptr, "Truncated zTXt chunk");
png_free(png_ptr, chunkdata);
return;
}
else
{
@ -2081,10 +2109,11 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
translated keyword (possibly empty), and possibly some text after the
keyword */
if (lang >= chunkdata + slength)
if (lang >= chunkdata + slength - 3)
{
comp_flag = PNG_TEXT_COMPRESSION_NONE;
png_warning(png_ptr, "Zero length iTXt chunk");
png_warning(png_ptr, "Truncated iTXt chunk");
png_free(png_ptr, chunkdata);
return;
}
else
{
@ -2096,9 +2125,22 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* empty loop */ ;
lang_key++; /* skip NUL separator */
if (lang_key >= chunkdata + slength)
{
png_warning(png_ptr, "Truncated iTXt chunk");
png_free(png_ptr, chunkdata);
return;
}
for (text = lang_key; *text; text++)
/* empty loop */ ;
text++; /* skip NUL separator */
if (text >= chunkdata + slength)
{
png_warning(png_ptr, "Malformed iTXt chunk");
png_free(png_ptr, chunkdata);
return;
}
prefix_len = text - chunkdata;
@ -2148,7 +2190,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (png_ptr->mode & PNG_HAVE_IDAT)
{
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IDAT;
PNG_CONST PNG_IDAT;
#endif
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */
png_ptr->mode |= PNG_AFTER_IDAT;
@ -2173,8 +2215,6 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) ||
(png_ptr->read_user_chunk_fn != NULL))
{
png_unknown_chunk chunk;
#ifdef PNG_MAX_MALLOC_64K
if (length > (png_uint_32)65535L)
{
@ -2183,30 +2223,37 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
length = (png_uint_32)65535L;
}
#endif
png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
chunk.data = (png_bytep)png_malloc(png_ptr, length);
chunk.size = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunk.data, length);
png_memcpy((png_charp)png_ptr->unknown_chunk.name,
(png_charp)png_ptr->chunk_name,
png_sizeof(png_ptr->unknown_chunk.name));
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1] = '\0';
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_ptr->unknown_chunk.size = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if(png_ptr->read_user_chunk_fn != NULL)
{
/* callback to user unknown chunk handler */
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
int ret;
ret = (*(png_ptr->read_user_chunk_fn))
(png_ptr, &png_ptr->unknown_chunk);
if (ret < 0)
png_chunk_error(png_ptr, "error in user chunk");
if (ret == 0)
{
if (!(png_ptr->chunk_name[0] & 0x20))
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS)
{
png_free(png_ptr, chunk.data);
png_chunk_error(png_ptr, "unknown critical chunk");
}
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
png_set_unknown_chunks(png_ptr, info_ptr,
&png_ptr->unknown_chunk, 1);
}
}
else
#endif
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
png_free(png_ptr, chunk.data);
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
png_free(png_ptr, png_ptr->unknown_chunk.data);
png_ptr->unknown_chunk.data = NULL;
}
else
#endif
@ -2215,8 +2262,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, skip);
#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */
return;
info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
#endif
}
@ -2249,7 +2295,7 @@ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
a zero indicates the pixel is to be skipped. This is in addition
to any alpha or transparency value associated with the pixel. If
you want all pixels to be combined, pass 0xff (255) in mask. */
#ifndef PNG_HAVE_MMX_COMBINE_ROW
void /* PRIVATE */
png_combine_row(png_structp png_ptr, png_bytep row, int mask)
{
@ -2450,10 +2496,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
}
}
}
#endif /* !PNG_HAVE_MMX_COMBINE_ROW */
#ifdef PNG_READ_INTERLACING_SUPPORTED
#ifndef PNG_HAVE_MMX_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */
/* OLD pre-1.0.9 interface:
void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
png_uint_32 transformations)
@ -2468,10 +2512,10 @@ png_do_read_interlace(png_structp png_ptr)
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* offset to next interlace block */
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
#endif
png_debug(1,"in png_do_read_interlace (stock C version)\n");
png_debug(1,"in png_do_read_interlace\n");
if (row != NULL && row_info != NULL)
{
png_uint_32 final_width;
@ -2675,14 +2719,11 @@ png_do_read_interlace(png_structp png_ptr)
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width);
}
#if !defined(PNG_READ_PACKSWAP_SUPPORTED)
if (&transformations == NULL) /* silence compiler warning */
return;
transformations = transformations; /* silence compiler warning */
#endif
}
#endif /* !PNG_HAVE_MMX_READ_INTERLACE */
#endif /* PNG_READ_INTERLACING_SUPPORTED */
#ifndef PNG_HAVE_MMX_READ_FILTER_ROW
void /* PRIVATE */
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
png_bytep prev_row, int filter)
@ -2805,7 +2846,6 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
break;
}
}
#endif /* !PNG_HAVE_MMX_READ_FILTER_ROW */
void /* PRIVATE */
png_read_finish_row(png_structp png_ptr)
@ -2814,16 +2854,16 @@ png_read_finish_row(png_structp png_ptr)
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */
const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
/* offset to next interlace block */
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
/* start of interlace block in the y direction */
const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
/* offset to next interlace block in the y direction */
const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
png_debug(1, "in png_read_finish_row\n");
@ -2834,7 +2874,8 @@ png_read_finish_row(png_structp png_ptr)
if (png_ptr->interlaced)
{
png_ptr->row_number = 0;
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_memset_check(png_ptr, png_ptr->prev_row, 0,
png_ptr->rowbytes + 1);
do
{
png_ptr->pass++;
@ -2868,7 +2909,7 @@ png_read_finish_row(png_structp png_ptr)
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
{
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IDAT;
PNG_CONST PNG_IDAT;
#endif
char extra;
int ret;
@ -2889,7 +2930,7 @@ png_read_finish_row(png_structp png_ptr)
png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
png_error(png_ptr, "Not enough image data");
}
@ -2941,16 +2982,16 @@ png_read_start_row(png_structp png_ptr)
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */
const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
/* offset to next interlace block */
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
/* start of interlace block in the y direction */
const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
/* offset to next interlace block in the y direction */
const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
int max_pixel_depth;
@ -3099,9 +3140,6 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
#endif
png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
png_ptr->row_buf = png_ptr->big_row_buf+32;
#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)
png_ptr->row_buf_size = row_bytes;
#endif
#ifdef PNG_MAX_MALLOC_64K
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)

View File

@ -1,9 +1,9 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.2.15 January 5, 2007
* Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
* Copyright (c) 1998-2008 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.)
*
@ -41,7 +41,13 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
png_debug1(1, "in %s storage function\n", "cHRM");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
blue_x || blue_y))
{
png_warning(png_ptr,
"Ignoring attempt to set all-zero chromaticity values");
return;
}
if (white_x < 0.0 || white_y < 0.0 ||
red_x < 0.0 || red_y < 0.0 ||
green_x < 0.0 || green_y < 0.0 ||
@ -93,6 +99,13 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL)
return;
if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
blue_x || blue_y))
{
png_warning(png_ptr,
"Ignoring attempt to set all-zero chromaticity values");
return;
}
if (white_x < 0 || white_y < 0 ||
red_x < 0 || red_y < 0 ||
green_x < 0 || green_y < 0 ||
@ -102,25 +115,14 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
"Ignoring attempt to set negative chromaticity value");
return;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED
if (white_x > (double) PNG_UINT_31_MAX ||
white_y > (double) PNG_UINT_31_MAX ||
red_x > (double) PNG_UINT_31_MAX ||
red_y > (double) PNG_UINT_31_MAX ||
green_x > (double) PNG_UINT_31_MAX ||
green_y > (double) PNG_UINT_31_MAX ||
blue_x > (double) PNG_UINT_31_MAX ||
blue_y > (double) PNG_UINT_31_MAX)
#else
if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L)
#endif
if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
white_y > (png_fixed_point) PNG_UINT_31_MAX ||
red_x > (png_fixed_point) PNG_UINT_31_MAX ||
red_y > (png_fixed_point) PNG_UINT_31_MAX ||
green_x > (png_fixed_point) PNG_UINT_31_MAX ||
green_y > (png_fixed_point) PNG_UINT_31_MAX ||
blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
blue_y > (png_fixed_point) PNG_UINT_31_MAX )
{
png_warning(png_ptr,
"Ignoring attempt to set chromaticity value exceeding 21474.83");
@ -222,7 +224,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
png_debug1(1, "in %s storage function\n", "hIST");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->num_palette <= 0 || info_ptr->num_palette
if (info_ptr->num_palette == 0 || info_ptr->num_palette
> PNG_MAX_PALETTE_LENGTH)
{
png_warning(png_ptr,
@ -353,7 +355,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
/* check for potential overflow */
if ( width > (PNG_UINT_32_MAX
if (width > (PNG_UINT_32_MAX
>> 3) /* 8-byte RGBA pixels */
- 64 /* bigrowbuf hack */
- 1 /* filter byte */
@ -484,7 +486,9 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->scal_s_width == NULL)
{
png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
png_warning(png_ptr,
"Memory allocation failed while processing sCAL.");
return;
}
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
@ -494,10 +498,11 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
if (info_ptr->scal_s_height == NULL)
{
png_free (png_ptr, info_ptr->scal_s_width);
png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
png_warning(png_ptr,
"Memory allocation failed while processing sCAL.");
return;
}
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
info_ptr->valid |= PNG_INFO_sCAL;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_SCAL;
@ -677,18 +682,20 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
{
png_charp new_iccp_name;
png_charp new_iccp_profile;
png_uint_32 length;
png_debug1(1, "in %s storage function\n", "iCCP");
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
return;
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1);
length = png_strlen(name)+1;
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);
if (new_iccp_name == NULL)
{
png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
return;
}
png_strcpy(new_iccp_name, name);
png_memcpy(new_iccp_name, name, length);
new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
if (new_iccp_profile == NULL)
{
@ -877,7 +884,6 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
textp->itxt_length = 0;
#endif
}
info_ptr->text[info_ptr->num_text]= *textp;
info_ptr->num_text++;
png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
}
@ -970,14 +976,27 @@ png_set_sPLT(png_structp png_ptr,
{
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
png_sPLT_tp from = entries + i;
png_uint_32 length;
to->name = (png_charp)png_malloc(png_ptr,
png_strlen(from->name) + 1);
/* TODO: use png_malloc_warn */
png_strcpy(to->name, from->name);
to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
length = png_strlen(from->name) + 1;
to->name = (png_charp)png_malloc_warn(png_ptr, length);
if (to->name == NULL)
{
png_warning(png_ptr,
"Out of memory while processing sPLT chunk");
continue;
}
png_memcpy(to->name, from->name, length);
to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
from->nentries * png_sizeof(png_sPLT_entry));
/* TODO: use png_malloc_warn */
if (to->entries == NULL)
{
png_warning(png_ptr,
"Out of memory while processing sPLT chunk");
png_free(png_ptr,to->name);
to->name = NULL;
continue;
}
png_memcpy(to->entries, from->entries,
from->nentries * png_sizeof(png_sPLT_entry));
to->nentries = from->nentries;
@ -1009,7 +1028,8 @@ png_set_unknown_chunks(png_structp png_ptr,
png_sizeof(png_unknown_chunk));
if (np == NULL)
{
png_warning(png_ptr, "Out of memory while processing unknown chunk.");
png_warning(png_ptr,
"Out of memory while processing unknown chunk.");
return;
}
@ -1023,11 +1043,16 @@ png_set_unknown_chunks(png_structp png_ptr,
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
png_unknown_chunkp from = unknowns + i;
png_strncpy((png_charp)to->name, (png_charp)from->name, 5);
png_memcpy((png_charp)to->name,
(png_charp)from->name,
png_sizeof(from->name));
to->name[png_sizeof(to->name)-1] = '\0';
to->data = (png_bytep)png_malloc_warn(png_ptr, from->size);
if (to->data == NULL)
{
png_warning(png_ptr, "Out of memory processing unknown chunk.");
png_warning(png_ptr,
"Out of memory while processing unknown chunk.");
}
else
{
@ -1067,7 +1092,7 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
if (png_ptr == NULL)
return;
png_ptr->mng_features_permitted = (png_byte)
((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) |
((png_ptr->mng_features_permitted & (~PNG_FLAG_MNG_EMPTY_PLTE)) |
((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
}
#endif
@ -1181,57 +1206,19 @@ void PNGAPI
png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
{
if (png_ptr && info_ptr)
info_ptr->valid &= ~(mask);
info_ptr->valid &= ~mask;
}
#ifndef PNG_1_0_X
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
/* this function was added to libpng 1.2.0 and should always exist by default */
/* function was added to libpng 1.2.0 and should always exist by default */
void PNGAPI
png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
{
#ifdef PNG_MMX_CODE_SUPPORTED
png_uint_32 settable_asm_flags;
png_uint_32 settable_mmx_flags;
#endif
if (png_ptr == NULL)
return;
#ifdef PNG_MMX_CODE_SUPPORTED
settable_mmx_flags =
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
#endif
#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
PNG_ASM_FLAG_MMX_READ_INTERLACE |
#endif
#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH |
#endif
0;
/* could be some non-MMX ones in the future, but not currently: */
settable_asm_flags = settable_mmx_flags;
if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) ||
!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU))
{
/* clear all MMX flags if MMX isn't supported */
settable_asm_flags &= ~settable_mmx_flags;
png_ptr->asm_flags &= ~settable_mmx_flags;
}
/* we're replacing the settable bits with those passed in by the user,
* so first zero them out of the master copy, then bitwise-OR in the
* allowed subset that was requested */
png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */
png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */
#endif /* ?PNG_MMX_CODE_SUPPORTED */
/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
if (png_ptr != NULL)
png_ptr->asm_flags = 0;
}
/* this function was added to libpng 1.2.0 */
@ -1240,12 +1227,9 @@ png_set_mmx_thresholds (png_structp png_ptr,
png_byte mmx_bitdepth_threshold,
png_uint_32 mmx_rowbytes_threshold)
{
/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
if (png_ptr == NULL)
return;
#ifdef PNG_MMX_CODE_SUPPORTED
png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold;
png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold;
#endif /* ?PNG_MMX_CODE_SUPPORTED */
}
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */

View File

@ -1,9 +1,9 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.2.13 November 13, 2006
* Last changed in libpng 1.2.17 May 15, 2007
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2007 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.)
*/
@ -652,10 +652,11 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
png_voidp PNGAPI
png_get_user_transform_ptr(png_structp png_ptr)
{
if (png_ptr == NULL) return (NULL);
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if (png_ptr == NULL) return (NULL);
return ((png_voidp)png_ptr->user_transform_ptr);
#endif
#else
return (NULL);
#endif
}
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

View File

@ -3,7 +3,7 @@
*
* Last changed in libpng 1.2.13 November 13, 2006
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2002 Glenn Randers-Pehrson
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*

View File

@ -1,9 +1,9 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.2.15 January 5, 2007
* Last changed in libpng 1.2.25 [February 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
* Copyright (c) 1998-2008 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.)
*/
@ -391,11 +391,6 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
/* write end of PNG file */
png_write_IEND(png_ptr);
#if 0
/* This flush, added in libpng-1.0.8, causes some applications to crash
because they do not set png_ptr->output_flush_fn */
png_flush(png_ptr);
#endif
}
#if defined(PNG_WRITE_tIME_SUPPORTED)
@ -459,14 +454,6 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
if (png_ptr == NULL)
return (NULL);
#if !defined(PNG_1_0_X)
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
#ifdef PNG_MMX_CODE_SUPPORTED
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
#endif
#endif
#endif /* PNG_1_0_X */
/* added at libpng-1.2.6 */
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
@ -495,12 +482,15 @@ 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);
i=0;
do
if(user_png_ver)
{
if(user_png_ver[i] != png_libpng_ver[i])
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
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)
{
@ -517,11 +507,13 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
char msg[80];
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
png_snprintf(msg, 80,
"Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_snprintf(msg, 80,
"Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
#endif
@ -587,11 +579,13 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_ptr->warning_fn=NULL;
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
png_snprintf(msg, 80,
"Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_snprintf(msg, 80,
"Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
}
@ -671,14 +665,6 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
#endif
#if !defined(PNG_1_0_X)
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
#ifdef PNG_MMX_CODE_SUPPORTED
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
#endif
#endif
#endif /* PNG_1_0_X */
#ifdef PNG_SETJMP_SUPPORTED
/* restore jump buffer */
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
@ -1017,21 +1003,32 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
#endif
}
#ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr != NULL)
{
free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
}
#endif
if (info_ptr_ptr != NULL)
info_ptr = *info_ptr_ptr;
if (info_ptr != NULL)
{
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
if (png_ptr != NULL)
{
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
if (png_ptr->num_chunk_list)
{
png_free(png_ptr, png_ptr->chunk_list);
png_ptr->chunk_list=NULL;
png_ptr->num_chunk_list=0;
}
if (png_ptr->num_chunk_list)
{
png_free(png_ptr, png_ptr->chunk_list);
png_ptr->chunk_list=NULL;
png_ptr->num_chunk_list=0;
}
#endif
}
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
@ -1077,11 +1074,13 @@ png_write_destroy(png_structp png_ptr)
/* free our memory. png_free checks NULL for us. */
png_free(png_ptr, png_ptr->zbuf);
png_free(png_ptr, png_ptr->row_buf);
#ifndef PNG_NO_WRITE_FILTERING
png_free(png_ptr, png_ptr->prev_row);
png_free(png_ptr, png_ptr->sub_row);
png_free(png_ptr, png_ptr->up_row);
png_free(png_ptr, png_ptr->avg_row);
png_free(png_ptr, png_ptr->paeth_row);
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
png_free(png_ptr, png_ptr->time_buffer);
@ -1137,15 +1136,26 @@ png_set_filter(png_structp png_ptr, int method, int filters)
{
switch (filters & (PNG_ALL_FILTERS | 0x07))
{
#ifndef PNG_NO_WRITE_FILTER
case 5:
case 6:
case 7: png_warning(png_ptr, "Unknown row filter for method 0");
case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break;
case PNG_FILTER_VALUE_SUB: png_ptr->do_filter=PNG_FILTER_SUB; break;
case PNG_FILTER_VALUE_UP: png_ptr->do_filter=PNG_FILTER_UP; break;
case PNG_FILTER_VALUE_AVG: png_ptr->do_filter=PNG_FILTER_AVG; break;
case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter=PNG_FILTER_PAETH;break;
#endif /* PNG_NO_WRITE_FILTER */
case PNG_FILTER_VALUE_NONE:
png_ptr->do_filter=PNG_FILTER_NONE; break;
#ifndef PNG_NO_WRITE_FILTER
case PNG_FILTER_VALUE_SUB:
png_ptr->do_filter=PNG_FILTER_SUB; break;
case PNG_FILTER_VALUE_UP:
png_ptr->do_filter=PNG_FILTER_UP; break;
case PNG_FILTER_VALUE_AVG:
png_ptr->do_filter=PNG_FILTER_AVG; break;
case PNG_FILTER_VALUE_PAETH:
png_ptr->do_filter=PNG_FILTER_PAETH; break;
default: png_ptr->do_filter = (png_byte)filters; break;
#else
default: png_warning(png_ptr, "Unknown row filter for method 0");
#endif /* PNG_NO_WRITE_FILTER */
}
/* If we have allocated the row_buf, this means we have already started
@ -1159,6 +1169,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
*/
if (png_ptr->row_buf != NULL)
{
#ifndef PNG_NO_WRITE_FILTER
if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
{
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
@ -1213,6 +1224,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
}
if (png_ptr->do_filter == PNG_NO_FILTERS)
#endif /* PNG_NO_WRITE_FILTER */
png_ptr->do_filter = PNG_FILTER_NONE;
}
}
@ -1511,8 +1523,8 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
/* It is REQUIRED to call this to finish writing the rest of the file */
png_write_end(png_ptr, info_ptr);
if(transforms == 0 || params == NULL)
/* quiet compiler warnings */ return;
transforms = transforms; /* quiet compiler warnings */
params = params;
}
#endif
#endif /* PNG_WRITE_SUPPORTED */

View File

@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.2.15 January 5, 2007
* Last changed in libpng 1.2.20 Septhember 3, 2007
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -182,7 +182,7 @@ png_text_compress(png_structp png_ptr,
{
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[50];
sprintf(msg, "Unknown compression type %d", compression);
png_snprintf(msg, 50, "Unknown compression type %d", compression);
png_warning(png_ptr, msg);
#else
png_warning(png_ptr, "Unknown compression type");
@ -494,7 +494,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
buf[12] = (png_byte)interlace_type;
/* write the chunk */
png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13);
png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
/* initialize zlib with PNG info */
png_ptr->zstream.zalloc = png_zalloc;
@ -523,9 +523,10 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_ptr->zlib_window_bits = 15;
if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))
png_ptr->zlib_method = 8;
deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
if (deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
png_ptr->zlib_method, png_ptr->zlib_window_bits,
png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
png_ptr->zlib_mem_level, png_ptr->zlib_strategy) != Z_OK)
png_error(png_ptr, "zlib failed to initialize compressor");
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
/* libpng is not interested in zstream.data_type */
@ -577,7 +578,7 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
png_ptr->num_palette = (png_uint_16)num_pal;
png_debug1(3, "num_palette = %d\n", png_ptr->num_palette);
png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3);
png_write_chunk_start(png_ptr, png_PLTE, num_pal * 3);
#ifndef PNG_NO_POINTER_INDEXING
for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
{
@ -649,7 +650,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
"Invalid zlib compression method or flags in IDAT");
}
png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);
png_write_chunk(png_ptr, png_IDAT, data, length);
png_ptr->mode |= PNG_HAVE_IDAT;
}
@ -661,7 +662,7 @@ png_write_IEND(png_structp png_ptr)
PNG_IEND;
#endif
png_debug(1, "in png_write_IEND\n");
png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL,
png_write_chunk(png_ptr, png_IEND, png_bytep_NULL,
(png_size_t)0);
png_ptr->mode |= PNG_HAVE_IEND;
}
@ -682,7 +683,7 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
/* file_gamma is saved in 1/100,000ths */
igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
png_save_uint_32(buf, igamma);
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
}
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
@ -697,7 +698,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
png_debug(1, "in png_write_gAMA\n");
/* file_gamma is saved in 1/100,000ths */
png_save_uint_32(buf, (png_uint_32)file_gamma);
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
}
#endif
#endif
@ -717,7 +718,7 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
png_warning(png_ptr,
"Invalid sRGB rendering intent specified");
buf[0]=(png_byte)srgb_intent;
png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1);
png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
}
#endif
@ -782,7 +783,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
PNG_COMPRESSION_TYPE_BASE, &comp);
/* make sure we include the NULL after the name and the compression type */
png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
png_write_chunk_start(png_ptr, png_iCCP,
(png_uint_32)name_len+profile_len+2);
new_name[name_len+1]=0x00;
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2);
@ -822,7 +823,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
}
/* make sure we include the NULL after the name */
png_write_chunk_start(png_ptr, (png_bytep)png_sPLT,
png_write_chunk_start(png_ptr, png_sPLT,
(png_uint_32)(name_len + 2 + palette_size));
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);
png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);
@ -930,7 +931,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
buf[size++] = sbit->alpha;
}
png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size);
png_write_chunk(png_ptr, png_sBIT, buf, size);
}
#endif
@ -994,7 +995,7 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
itemp = (png_uint_32)(blue_y * 100000.0 + 0.5);
png_save_uint_32(buf + 28, itemp);
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
}
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
@ -1046,7 +1047,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
png_save_uint_32(buf + 24, (png_uint_32)blue_x);
png_save_uint_32(buf + 28, (png_uint_32)blue_y);
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
}
#endif
#endif
@ -1071,7 +1072,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
return;
}
/* write the chunk out as it is */
png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans);
png_write_chunk(png_ptr, png_tRNS, trans, (png_size_t)num_trans);
}
else if (color_type == PNG_COLOR_TYPE_GRAY)
{
@ -1083,7 +1084,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
return;
}
png_save_uint_16(buf, tran->gray);
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2);
png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);
}
else if (color_type == PNG_COLOR_TYPE_RGB)
{
@ -1097,7 +1098,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
return;
}
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6);
png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);
}
else
{
@ -1130,7 +1131,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
return;
}
buf[0] = back->index;
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1);
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
}
else if (color_type & PNG_COLOR_MASK_COLOR)
{
@ -1143,7 +1144,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
return;
}
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6);
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);
}
else
{
@ -1154,7 +1155,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
return;
}
png_save_uint_16(buf, back->gray);
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2);
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);
}
}
#endif
@ -1179,7 +1180,7 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
return;
}
png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2));
png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
for (i = 0; i < num_hist; i++)
{
png_save_uint_16(buf, hist[i]);
@ -1230,12 +1231,14 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
/* Replace non-printing characters with a blank and print a warning */
for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++)
{
if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1))
if ((png_byte)*kp < 0x20 ||
((png_byte)*kp > 0x7E && (png_byte)*kp < 0xA1))
{
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[40];
sprintf(msg, "invalid keyword character 0x%02X", *kp);
png_snprintf(msg, 40,
"invalid keyword character 0x%02X", (png_byte)*kp);
png_warning(png_ptr, msg);
#else
png_warning(png_ptr, "invalid character in keyword");
@ -1343,7 +1346,7 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
text_len = png_strlen(text);
/* make sure we include the 0 after the key */
png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1);
png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)key_len+text_len+1);
/*
* We leave it to the application to meet PNG-1.0 requirements on the
* contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
@ -1396,17 +1399,17 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
text_len = png_strlen(text);
png_free(png_ptr, new_key);
/* compute the compressed data; do it now for the length */
text_len = png_text_compress(png_ptr, text, text_len, compression,
&comp);
/* write start of chunk */
png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)
png_write_chunk_start(png_ptr, png_zTXt, (png_uint_32)
(key_len+text_len+2));
/* write key */
png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1);
png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
png_free(png_ptr, new_key);
buf[0] = (png_byte)compression;
/* write compression */
png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);
@ -1469,7 +1472,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
/* make sure we include the compression flag, the compression byte,
* and the NULs after the key, lang, and lang_key parts */
png_write_chunk_start(png_ptr, (png_bytep)png_iTXt,
png_write_chunk_start(png_ptr, png_iTXt,
(png_uint_32)(
5 /* comp byte, comp flag, terminators for key, lang and lang_key */
+ key_len
@ -1526,10 +1529,9 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
png_save_int_32(buf + 4, y_offset);
buf[8] = (png_byte)unit_type;
png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9);
png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
}
#endif
#if defined(PNG_WRITE_pCAL_SUPPORTED)
/* write the pCAL chunk (described in the PNG extensions document) */
void /* PRIVATE */
@ -1568,7 +1570,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
}
png_debug1(3, "pCAL total length = %d\n", (int)total_len);
png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len);
png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len);
png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);
png_save_int_32(buf, X0);
png_save_int_32(buf + 4, X1);
@ -1621,14 +1623,14 @@ png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
total_len += wc_len;
}
#else
sprintf(buf + 1, "%12.12e", width);
png_snprintf(buf + 1, 63, "%12.12e", width);
total_len = 1 + png_strlen(buf + 1) + 1;
sprintf(buf + total_len, "%12.12e", height);
png_snprintf(buf + total_len, 64-total_len, "%12.12e", height);
total_len += png_strlen(buf + total_len);
#endif
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len);
png_write_chunk(png_ptr, png_sCAL, (png_bytep)buf, total_len);
}
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
@ -1658,7 +1660,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len);
png_write_chunk(png_ptr, png_sCAL, buf, total_len);
}
#endif
#endif
@ -1684,7 +1686,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
png_save_uint_32(buf + 4, y_pixels_per_unit);
buf[8] = (png_byte)unit_type;
png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9);
png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
}
#endif
@ -1716,7 +1718,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
buf[5] = mod_time->minute;
buf[6] = mod_time->second;
png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7);
png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
}
#endif
@ -1724,6 +1726,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
void /* PRIVATE */
png_write_start_row(png_structp png_ptr)
{
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
@ -1738,6 +1741,7 @@ png_write_start_row(png_structp png_ptr)
/* offset to next interlace block in the y direction */
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
#endif
png_size_t buf_size;
@ -1750,6 +1754,7 @@ png_write_start_row(png_structp png_ptr)
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
#ifndef PNG_NO_WRITE_FILTERING
/* set up filtering buffer, if using this filter */
if (png_ptr->do_filter & PNG_FILTER_SUB)
{
@ -1767,7 +1772,7 @@ png_write_start_row(png_structp png_ptr)
if (png_ptr->do_filter & PNG_FILTER_UP)
{
png_ptr->up_row = (png_bytep )png_malloc(png_ptr,
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
}
@ -1781,10 +1786,11 @@ png_write_start_row(png_structp png_ptr)
if (png_ptr->do_filter & PNG_FILTER_PAETH)
{
png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr,
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
}
#endif /* PNG_NO_WRITE_FILTERING */
}
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
@ -1818,6 +1824,7 @@ png_write_start_row(png_structp png_ptr)
void /* PRIVATE */
png_write_finish_row(png_structp png_ptr)
{
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
@ -1832,6 +1839,7 @@ png_write_finish_row(png_structp png_ptr)
/* offset to next interlace block in the y direction */
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
#endif
int ret;
@ -2106,7 +2114,9 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
void /* PRIVATE */
png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
{
png_bytep prev_row, best_row, row_buf;
png_bytep best_row;
#ifndef PNG_NO_WRITE_FILTER
png_bytep prev_row, row_buf;
png_uint_32 mins, bpp;
png_byte filter_to_do = png_ptr->do_filter;
png_uint_32 row_bytes = row_info->rowbytes;
@ -2119,7 +2129,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
bpp = (row_info->pixel_depth + 7) >> 3;
prev_row = png_ptr->prev_row;
best_row = row_buf = png_ptr->row_buf;
#endif
best_row = png_ptr->row_buf;
#ifndef PNG_NO_WRITE_FILTER
row_buf = best_row;
mins = PNG_MAXSUM;
/* The prediction method we use is to find which method provides the
@ -2694,11 +2707,12 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
best_row = png_ptr->paeth_row;
}
}
#endif /* PNG_NO_WRITE_FILTER */
/* Do the actual writing of the filtered row data from the chosen filter. */
png_write_filtered_row(png_ptr, best_row);
#ifndef PNG_NO_WRITE_FILTER
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
/* Save the type of filter we picked this time for future calculations */
if (png_ptr->num_prev_filters > 0)
@ -2711,6 +2725,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
png_ptr->prev_filters[j] = best_row[0];
}
#endif
#endif /* PNG_NO_WRITE_FILTER */
}