Bug 624133 - Update libpng to version 1.4.7. r=joe

This commit is contained in:
Glenn Randers-Pehrson 2011-04-12 15:45:24 -04:00
Родитель 2745f0c65e
Коммит 1c22db28f2
22 изменённых файлов: 1126 добавлений и 773 удалений

Просмотреть файл

@ -1479,7 +1479,7 @@ version 1.2.9beta5 [March 4, 2006]
Removed trailing blanks from source files.
Put version and date of latest change in each source file, and changed
copyright year accordingly.
More cleanup of configure.ac, Makefile.ac, and associated scripts.
More cleanup of configure.ac, Makefile.am, and associated scripts.
Restored scripts/makefile.elf which was inadvertently deleted.
version 1.2.9beta6 [March 6, 2006]
@ -2610,6 +2610,191 @@ version 1.4.3rc03 [June 23, 2010]
version 1.4.3 [June 26, 2010]
Updated some of the "last changed" dates.
version 1.4.4beta01 [July 12, 2010]
Removed extraneous new_push_process_row.c file.
Revised the "SEE ALSO" style of libpng.3, libpngpf.3, and png.5
Removed some newly-added TAB characters from pngpread.c.
Fixed some indentation in pngpread.c and pngrutil.c
Changed "extern PNG_EXPORT" to "PNG_EXPORT" in png.h (Jan Nijtmans)
Changed "extern" to "PNG_EXTERN" in pngpriv.h (except for the 'extern "C" {')
Put "#ifndef PNG_EXTERN, #endif" around "#define PNG_EXTERN" in pngpriv.h
version 1.4.4beta02 [July 24, 2010]
Added -DNO_PNG_SNPRINTF to CFLAGS in scripts/makefile.dj2
Moved the definition of png_snprintf() outside of the enclosing
#ifdef blocks in pngconf.h
Added a special case typedef of png_longjmp_ptr for WATCOM.
version 1.4.4beta03 [July 24, 2010]
Removed reference to cbuilder5/* from Makefile.in and Makefile.am
Eliminated the new special case typedef of png_longjmp_ptr for WATCOM
and made a special case "#define PNGAPI" in pngconf.h instead.
version 1.4.4beta04 [July 31, 2010]
Updated the read macros and functions from 1.5.0beta38.
version 1.4.4beta05 [August 6, 2010]
Updated projects/visualc71 so it can find scripts/pnglibconf.h
Removed unused png_mem_* defines from pngconf.h.
Correct use of _WINDOWS_ in pngconf.h
version 1.4.4beta06 [August 11, 2010]
Don't try to use version-script with cygwin/mingw.
Revised contrib/gregbook to work under cygwin/mingw.
version 1.4.4beta07 [August 26, 2010]
Updated prebuilt aclocal.m4 and ltmain.sh
Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov)
Updated CMakeLists.txt to use CMAKE_INSTALL_LIBDIR variable; useful for
installing libpng in /usr/lib64 (Funda Wang).
Revised CMakeLists.txt to put the man pages in share/man/man* not man/man*
Revised CMakeLists.txt to make symlinks instead of copies when installing.
Changed PNG_LIB_NAME from pngNN to libpngNN in CMakeLists.txt (Philip Lowman)
Moved "#include pngusr.h" ahead of PNG_USER_PRIVATEBUILD test in pngconf.h
Eliminated a deprecated reference to png_ptr->io_ptr in pngtest.c
Eliminated new unnecessary #if tests regarding the sCAL chunk from pngrutil.c
version 1.4.4beta08 [September 2, 2010]
Updated the xcode project to work with libpng-1.4.x and added iOS targets
for simulator and device (Philippe Hausler).
version 1.4.4rc01 [September 10, 2010]
No changes.
version 1.4.4rc02 [September 13, 2010]
Revised CMakeLists.txt (Philip Lowman).
version 1.4.4rc03 [September 14, 2010]
Removed an extraneous close-double-quote from CMakeLists.txt
Eliminated another deprecated reference to png_ptr->io_ptr in pngtest.c
version 1.4.4rc04 [September 16, 2010]
Fixed indentation and removed debugging message from CMakeLists.txt
Revised autogen.sh to recognize and use $AUTOCONF, $AUTOMAKE, $AUTOHEADER,
$AUTOPOINT, $ACLOCAL and $LIBTOOLIZE
version 1.4.4rc05 [September 20, 2010]
Rebuilt configure scripts with automake-1.11.1 instead of automake-1.11.
Removed unused mkinstalldirs file.
version 1.4.4 [September 23, 2010]
No changes.
version 1.4.5beta01 [September 25, 2010]
Fixed possible configure.ac bug introduced in version 1.4.4rc05.
Rebuilt configure scripts with autoconf-2.68 instead of autoconf-2.65
version 1.4.5beta02 [October 5, 2010]
Reverted configure scripts to autoconf-2.65
Fixed problem with symbols creation in Makefile.am which was assuming that
all versions of cpp write to standard output by default (Martin Banky). The
bug was introduced in libpng-1.2.9beta5.
version 1.4.5beta03 [October 8, 2010]
Wrapped long lines in CMakeLists.txt and introduced ${libpng_public_hdrs}
Undid Makefile.am revision of 1.4.5beta02.
version 1.4.5beta04 [November 8, 2010]
Check for out-of-range text compression mode in png_set_text().
version 1.4.5rc01 [November 19, 2010]
No changes.
version 1.4.5beta05 [November 20, 2010]
Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin)
Moved reading of file signature into png_read_sig (Cosmin)
Fixed atomicity of chunk header serialization (Cosmin)
Added test for io_state in pngtest.c (Cosmin)
Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts.
version 1.4.5beta06 [November 21, 2010]
Restored the parentheses in pngrutil.c; they are needed when the
png_get_*int_*() functions are compiled (i.e., when PNG_USE_READ_MACROS
is not defined).
Make the "png_get_uint_16" macro return a png_uint_32 in libpng-1.4 for API
compatibility.
Changes to remove gcc warnings (John Bowler)
Certain optional gcc warning flags resulted in warnings in libpng code.
With these changes only -Wconversion and -Wcast-qual cannot be turned on.
Changes are trivial rearrangements of code. -Wconversion is not possible
for pngrutil.c (because of the widespread use of += et al on variables
smaller than (int) or (unsigned int)) and -Wcast-qual is not possible
with pngwio.c and pngwutil.c because the 'write' callback and zlib
compression both fail to declare their input buffers with 'const'.
version 1.4.5beta07 [November 25, 2010]
Reverted png_get_uint_16 macro to beta05 and added comment about the
potential API incompatibility.
version 1.4.5rc02 [December 2, 2010]
No changes.
version 1.4.5rc03 [December 3, 2010]
Added missing vstudio/*/*.vcxproj files to the zip and 7z distributions.
version 1.4.5 [December 9, 2010]
Removed PNG_NO_WRITE_GAMMA from pngminim/encoder/pngusr.h
version 1.4.6beta01 [December 29, 2010]
Fixed bug in background transformation handling in pngrtran.c (it was
looking for the flag in png_ptr->transformations instead of in
png_ptr->flags) (David Raymond).
version 1.4.6beta02 [January 14, 2011]
Fixed misspelled macros in contrib/pngminim (Cosmin).
Updated CMakeLists.txt (Clifford Yapp).
version 1.4.6beta03 [January 14, 2011]
Fixed some typecasts in png_debug statements (Cosmin).
version 1.4.6beta04 [January 22, 2011]
Updated documentation of png_set|get_tRNS() (Thomas Klausner).
Added png_const_structp and png_const_infop types, and used them in
prototypes for most png_get_*() functions.
In the manual, describe the png_get_IHDR() arguments in the correct order.
Ported change in png_do_rgb_to_gray() from libpng-1.5.1, to make
it more robust against internal libpng coding errors.
version 1.4.6beta05 [January 23, 2011]
Updated the synopses in the manual to reflect recent changes.
Fixed a typo in the *.def files and deleted entries that are now
declared in pngpriv.h
version 1.4.6beta06 [March 19, 2011]
Updated contrib/pngsuite/README to add the word "modify".
Added the private PNG_UNUSED() macro definition in pngconf.h.
version 1.4.6beta07 [March 22, 2011]
ifdef out mask arrays in pngread.c when interlacing is not supported.
Added attribute definition (warnings) for MSC_VER >= 1300 in pngconf.h
Added -D_CRT_SECURE_NO_DEPRECATE to CFLAGS in makefile.vcwin32
Fixed mistake in the descriptions of user read_transform and write_transform
function prototypes in the manual. The row_info struct is png_row_infop.
Added a request in the manual that applications do not use "png_" or
"PNG_" to begin any of their own symbols.
Fixed incorrect examples of callback prototypes in the manual, that were
introduced in libpng-1.0.0.
Removed "strip" from contrib/pngminim/*/makefile.
Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail
to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill)
version 1.4.6rc01 [March 31, 2011]
No changes.
version 1.4.6rc02 [April 6, 2011]
Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03).
version 1.4.6 [April 8, 2011]
No changes.
version 1.4.7rc01 [April 9, 2011]
Relocated misplaced new declarations in pngwutil.c.
version 1.4.7 [April 10, 2011]
Disabled PNG_PEDANTIC_WARNINGS for all MSC versions as in libpng-1.4.5.
Send comments/corrections/commendations to glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement).

Просмотреть файл

@ -10,8 +10,8 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.4.3, June 26, 2010, are
Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
libpng versions 1.2.6, August 15, 2004, through 1.4.7, April 10, 2011, are
Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
June 26, 2010
April 10, 2011

Просмотреть файл

@ -1,6 +1,8 @@
Changes made to pristine png source by mozilla.org developers.
2011/04/08 -- Synced with libpng-1.4.7 (bug #624133).
2010/06/30 -- Synced with libpng-1.4.3 (bug #564792).
2010/02/26 -- Synced with libpng-1.4.1 (bug #544747).

Просмотреть файл

@ -1,4 +1,4 @@
README for libpng version 1.4.3 - June 26, 2010 (shared library 14.0)
README for libpng version 1.4.7 - April 10, 2011 (shared library 14.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@ -185,9 +185,9 @@ Files in this distribution:
makefile.std => Generic UNIX makefile (cc, creates static
libpng.a)
makefile.elf => Linux/ELF makefile symbol versioning,
gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
@ -209,12 +209,12 @@ Files in this distribution:
makefile.openbsd => OpenBSD makefile
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
makefile.sggcc => Silicon Graphics
(gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
makefile.so9 => Solaris 9 makefile
(gcc, creates libpng14.so.14.1.4.3)
(gcc, creates libpng14.so.14.1.4.7)
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

Просмотреть файл

@ -42,15 +42,23 @@
#define PNG_NO_GLOBAL_ARRAYS
#ifdef _MSC_VER
/* The PNG_PEDANTIC_WARNINGS (attributes) fail to build with some MSC
* compilers; we'll play it safe and disable them for all MSC compilers.
*/
#define PNG_NO_PEDANTIC_WARNINGS
#endif
#ifndef MOZ_PNG_READ
#define PNG_NO_READ_SUPPORTED
#endif
#define PNG_NO_READ_BGR
#define PNG_NO_SET_USER_LIMITS
#define PNG_NO_USER_LIMITS
#define PNG_NO_ASSEMBLER_CODE
#define PNG_NO_WARN_UNINITIALIZED_ROW
#define PNG_NO_READ_BACKGROUND
#define PNG_NO_READ_DITHER
#define PNG_NO_READ_QUANTIZE
#define PNG_NO_READ_INVERT
#define PNG_NO_READ_SHIFT
#define PNG_NO_READ_PACK
@ -61,8 +69,10 @@
#define PNG_NO_READ_INVERT_ALPHA
#define PNG_NO_READ_RGB_TO_GRAY
#define PNG_NO_READ_USER_TRANSFORM
#define PNG_NO_READ_bKGD
#define PNG_NO_READ_hIST
#define PNG_NO_READ_oFFs
#define PNG_NO_READ_pCAL
#define PNG_NO_READ_pHYs
#define PNG_NO_READ_sBIT
@ -75,7 +85,6 @@
#define PNG_NO_READ_EMPTY_PLTE
#define PNG_NO_READ_OPT_PLTE
#define PNG_NO_READ_STRIP_ALPHA
#define PNG_NO_READ_oFFs
#define PNG_NO_SEQUENTIAL_READ_SUPPORTED
#ifndef MOZ_PNG_WRITE
@ -118,6 +127,7 @@
#define PNG_NO_HANDLE_AS_UNKNOWN
#define PNG_NO_INFO_IMAGE
#define PNG_NO_IO_STATE
#define PNG_NO_USER_MEM
#define PNG_NO_FIXED_POINT_SUPPORTED
#define PNG_NO_MNG_FEATURES
@ -126,7 +136,7 @@
#define PNG_NO_ZALLOC_ZERO
#define PNG_NO_ERROR_NUMBERS
#define PNG_NO_EASY_ACCESS
#define PNG_NO_TIME_RFC1123
/* Mangle names of exported libpng functions so different libpng versions
can coexist. It is recommended that if you do this, you give your

Просмотреть файл

@ -1,8 +1,8 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.4.2 [May 6, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -17,11 +17,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_4_3 Your_png_h_is_not_version_1_4_3;
/* Version information for C files. This had better match the version
* string defined in png.h.
*/
typedef version_1_4_7 Your_png_h_is_not_version_1_4_7;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@ -543,21 +539,21 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
png_charp PNGAPI
png_get_copyright(png_structp png_ptr)
png_get_copyright(png_const_structp png_ptr)
{
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
#ifdef PNG_STRING_COPYRIGHT
return PNG_STRING_COPYRIGHT
#else
#ifdef __STDC__
return ((png_charp) PNG_STRING_NEWLINE \
"libpng version 1.4.3 - June 26, 2010" PNG_STRING_NEWLINE \
"libpng version 1.4.7 - April 10, 2011" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE);
#else
return ((png_charp) "libpng version 1.4.3 - June 26, 2010\
return ((png_charp) "libpng version 1.4.7 - April 10, 2011\
Copyright (c) 1998-2010 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
@ -574,23 +570,23 @@ png_get_copyright(png_structp png_ptr)
* it is guaranteed that png.c uses the correct version of png.h.
*/
png_charp PNGAPI
png_get_libpng_ver(png_structp png_ptr)
png_get_libpng_ver(png_const_structp png_ptr)
{
/* Version of *.c files used when building libpng */
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
PNG_UNUSED(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)
png_get_header_ver(png_const_structp png_ptr)
{
/* Version of *.h files used when building libpng */
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
PNG_UNUSED(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)
png_get_header_version(png_const_structp png_ptr)
{
/* Returns longer string containing both version and date */
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
@ -678,7 +674,7 @@ png_convert_size(size_t size)
*/
void /* PRIVATE */
png_64bit_product (long v1, long v2, unsigned long *hi_product,
png_64bit_product(long v1, long v2, unsigned long *hi_product,
unsigned long *lo_product)
{
int a, b, c, d;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,9 +1,9 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.4.3 - June 26, 2010
* libpng version 1.4.7 - April 10, 2011
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -46,14 +46,14 @@
* includes the resource compiler for Windows DLL configurations.
*/
#ifdef PNG_USER_CONFIG
# include "pngusr.h"
# ifndef PNG_USER_PRIVATEBUILD
# define PNG_USER_PRIVATEBUILD
# endif
# include "pngusr.h"
#endif
/*
* If you create a private DLL you need to define in "pngusr.h" the followings:
* If you create a private DLL you should define in "pngusr.h" the following:
* #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
* the DLL was built>
* e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
@ -61,7 +61,7 @@
* distinguish your DLL from those of the official release. These
* correspond to the trailing letters that come after the version
* number and must match your private DLL name>
* e.g. // private DLL "libpng13gx.dll"
* e.g. // private DLL "libpng14gx.dll"
* #define PNG_USER_DLLFNAME_POSTFIX "gx"
*
* The following macros are also at your disposal if you want to complete the
@ -86,6 +86,18 @@
/* End of material added to libpng-1.2.8 */
/* Added at libpng-1.4.6 */
#ifndef PNG_UNUSED
/* Unused formal parameter warnings are silenced using the following macro
* which is expected to have no bad effects on performance (optimizing
* compilers will probably remove it entirely). Note that if you replace
* it with something other than whitespace, you must include the terminating
* semicolon.
*/
# define PNG_UNUSED(param) (void)param;
#endif
/* End of material added to libpng-1.4.6 */
#ifndef PNG_VERSION_INFO_ONLY
/* This is the size of the compression buffer, and thus the size of
@ -271,11 +283,19 @@
* #define PNG_NO_STDIO
*/
#ifdef _WIN32_WCE
# define PNG_NO_CONSOLE_IO
# define PNG_NO_STDIO
# define PNG_NO_TIME_RFC1123
# ifdef PNG_DEBUG
# undef PNG_DEBUG
# endif
#endif
#if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED)
# define PNG_STDIO_SUPPORTED
#endif
#ifdef PNG_BUILD_DLL
# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO)
# define PNG_NO_CONSOLE_IO
@ -441,7 +461,7 @@
/* The following uses const char * instead of char * for error
* and warning message functions, so some compilers won't complain.
* If you do not want to use const, define PNG_NO_CONST here.
* If you do not want to use const, define PNG_NO_CONST.
*/
#ifndef PNG_CONST
@ -456,8 +476,10 @@
* library that you will not be using. I wish I could figure out how to
* automate this, but I can't do that without making it seriously hard
* on the users. So if you are not using an ability, change the #define
* to and #undef, and that part of the library will not be compiled. If
* your linker can't find a function, you may want to make sure the
* to an #undef, or pass in PNG_NO_feature and that part of the library
* will not be compiled.
* If your linker can't find a function, you may want to make sure the
* ability is defined here. Some of these depend upon some others being
* defined. I haven't figured out all the interactions here, so you may
* have to experiment awhile to get everything to compile. If you are
@ -1129,7 +1151,7 @@ typedef unsigned char png_byte;
#else
typedef size_t png_size_t;
#endif
#define png_sizeof(x) sizeof(x)
#define png_sizeof(x) (sizeof (x))
/* The following is needed for medium model support. It cannot be in the
* pngpriv.h header. Needs modification for other compilers besides
@ -1251,6 +1273,13 @@ typedef char FAR * FAR * FAR * png_charppp;
# define PNG_DLL
#endif
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
* Don't ignore those warnings; you must also reset the default calling
* convention in your compiler to match your PNGAPI, and you must build
* zlib and your applications the same way you build libpng.
*/
#ifdef __CYGWIN__
# undef PNGAPI
# define PNGAPI __cdecl
@ -1258,14 +1287,11 @@ typedef char FAR * FAR * FAR * png_charppp;
# define PNG_IMPEXP
#endif
#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
* Don't ignore those warnings; you must also reset the default calling
* convention in your compiler to match your PNGAPI, and you must build
* zlib and your applications the same way you build libpng.
*/
#ifdef __WATCOMC__
# ifndef PNGAPI
# define PNGAPI
# endif
#endif
#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
# ifndef PNG_NO_MODULEDEF
@ -1350,6 +1376,8 @@ typedef char FAR * FAR * FAR * png_charppp;
# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
#endif
#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
/* Support for compiler specific function attributes. These are used
* so that where compiler support is available incorrect use of API
* functions in png.h will generate compiler warnings.
@ -1378,15 +1406,15 @@ typedef char FAR * FAR * FAR * png_charppp;
# endif
# ifndef PNG_ALLOCATED
# define PNG_ALLOCATED __attribute__((__malloc__))
# endif
# ifndef PNG_DEPRECATED
# define PNG_DEPRECATED __attribute__((__deprecated__))
# endif
/* This specifically protects structure members that should only be
* accessed from within the library, therefore should be empty during
* a library build.
*/
# ifndef PNG_DEPRECATED
# define PNG_DEPRECATED __attribute__((__deprecated__))
# endif
# ifndef PNG_DEPSTRUCT
# define PNG_DEPSTRUCT __attribute__((__deprecated__))
# endif
@ -1427,7 +1455,7 @@ typedef char FAR * FAR * FAR * png_charppp;
/* memory model/platform independent fns */
#ifndef PNG_ABORT
# ifdef _WINDOWS_
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
# define PNG_ABORT() ExitProcess(0)
# else
# define PNG_ABORT() abort()
@ -1448,7 +1476,8 @@ typedef char FAR * FAR * FAR * png_charppp;
# define png_memset _fmemset
# define png_sprintf sprintf
#else
# ifdef _WINDOWS_ /* Favor Windows over C runtime fns */
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
# /* Favor Windows over C runtime fns */
# define CVT_PTR(ptr) (ptr)
# define CVT_PTR_NOCHECK(ptr) (ptr)
# define png_strcpy lstrcpyA
@ -1468,31 +1497,32 @@ typedef char FAR * FAR * FAR * png_charppp;
# define png_memcpy memcpy
# define png_memset memset
# define png_sprintf sprintf
# 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
# endif
#endif
#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) png_sprintf(s1,fmt,x1)
# define png_snprintf2(s1,n,fmt,x1,x2) png_sprintf(s1,fmt,x1,x2)
# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
png_sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
#endif
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
* and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
* to png_alloc_size_t are not necessary; in fact, it is recommended
@ -1503,22 +1533,19 @@ typedef char FAR * FAR * FAR * png_charppp;
* to encounter practical situations that require such conversions.
*/
#if defined(__TURBOC__) && !defined(__FLAT__)
# define png_mem_alloc farmalloc
# define png_mem_free farfree
typedef unsigned long png_alloc_size_t;
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
# define png_mem_alloc(s) halloc(s, 1)
# define png_mem_free hfree
typedef unsigned long png_alloc_size_t;
# else
# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
typedef DWORD png_alloc_size_t;
/* This is an attempt to detect an old Windows system where (int) is
* actually 16 bits, in that case png_malloc must have an argument with a
* bigger size to accomodate the requirements of the library.
*/
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
(!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
typedef DWORD png_alloc_size_t;
# else
# define png_mem_alloc malloc
# define png_mem_free free
typedef png_size_t png_alloc_size_t;
# endif
# endif

Просмотреть файл

@ -1,8 +1,8 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.4.0 [January 3, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -306,7 +306,7 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
/* Here if not setjmp support or if png_ptr is null. */
PNG_ABORT();
#ifndef PNG_CONSOLE_IO_SUPPORTED
error_message = error_message; /* Make compiler happy */
PNG_UNUSED(error_message) /* Make compiler happy */
#endif
}
@ -352,9 +352,9 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
fprintf(stderr, PNG_STRING_NEWLINE);
}
#else
warning_message = warning_message; /* Make compiler happy */
PNG_UNUSED(warning_message) /* Make compiler happy */
#endif
png_ptr = png_ptr; /* Make compiler happy */
PNG_UNUSED(png_ptr) /* Make compiler happy */
}
#endif /* PNG_WARNINGS_SUPPORTED */
@ -380,7 +380,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
* pointer before png_write_destroy and png_read_destroy are called.
*/
png_voidp PNGAPI
png_get_error_ptr(png_structp png_ptr)
png_get_error_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return NULL;

Просмотреть файл

@ -1,8 +1,8 @@
/* pngget.c - retrieval of values from info struct
*
* Last changed in libpng 1.4.2 [May 6, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [April 10, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -18,7 +18,8 @@
#include "pngpriv.h"
png_uint_32 PNGAPI
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 flag)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->valid & flag);
@ -28,7 +29,7 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
}
png_size_t PNGAPI
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->rowbytes);
@ -39,7 +40,7 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_INFO_IMAGE_SUPPORTED
png_bytepp PNGAPI
png_get_rows(png_structp png_ptr, png_infop info_ptr)
png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->row_pointers);
@ -52,7 +53,7 @@ png_get_rows(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_EASY_ACCESS_SUPPORTED
/* Easy access to info, added in libpng-0.99 */
png_uint_32 PNGAPI
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->width;
@ -61,7 +62,7 @@ png_get_image_width(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->height;
@ -70,7 +71,7 @@ png_get_image_height(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->bit_depth;
@ -79,7 +80,7 @@ png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->color_type;
@ -88,7 +89,7 @@ png_get_color_type(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->filter_type;
@ -97,7 +98,7 @@ png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->interlace_type;
@ -106,7 +107,7 @@ png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->compression_type;
@ -115,7 +116,7 @@ png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_pHYs_SUPPORTED
@ -136,7 +137,7 @@ png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_pHYs_SUPPORTED
@ -157,7 +158,7 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_pHYs_SUPPORTED
@ -180,7 +181,7 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_FLOATING_POINT_SUPPORTED
float PNGAPI
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_pHYs_SUPPORTED
@ -204,7 +205,7 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
#endif
png_int_32 PNGAPI
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
#ifdef PNG_oFFs_SUPPORTED
@ -226,7 +227,7 @@ png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
}
png_int_32 PNGAPI
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
@ -248,7 +249,7 @@ png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
}
png_int_32 PNGAPI
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
@ -270,7 +271,7 @@ png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
}
png_int_32 PNGAPI
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
@ -293,35 +294,35 @@ png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
png_uint_32 PNGAPI
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
png_get_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
*.0254 +.5));
}
png_uint_32 PNGAPI
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
png_get_x_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
*.0254 +.5));
}
png_uint_32 PNGAPI
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
png_get_y_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
*.0254 +.5));
}
float PNGAPI
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
*.00003937);
}
float PNGAPI
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
*.00003937);
@ -329,7 +330,7 @@ png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
png_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{
png_uint_32 retval = 0;
@ -369,7 +370,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
#endif /* PNG_EASY_ACCESS_SUPPORTED */
png_byte PNGAPI
png_get_channels(png_structp png_ptr, png_infop info_ptr)
png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->channels);
@ -378,7 +379,7 @@ png_get_channels(png_structp png_ptr, png_infop info_ptr)
}
png_bytep PNGAPI
png_get_signature(png_structp png_ptr, png_infop info_ptr)
png_get_signature(png_const_structp png_ptr, png_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->signature);
@ -388,7 +389,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_bKGD_SUPPORTED
png_uint_32 PNGAPI
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
png_color_16p *background)
{
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
@ -406,7 +407,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_cHRM_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y)
{
@ -437,7 +438,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
png_fixed_point *blue_x, png_fixed_point *blue_y)
@ -472,7 +473,7 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_gAMA_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
png_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr, double *file_gamma)
{
png_debug1(1, "in %s retrieval function", "gAMA");
@ -487,7 +488,7 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
png_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
png_fixed_point *int_file_gamma)
{
png_debug1(1, "in %s retrieval function", "gAMA");
@ -505,7 +506,8 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_sRGB_SUPPORTED
png_uint_32 PNGAPI
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
int *file_srgb_intent)
{
png_debug1(1, "in %s retrieval function", "sRGB");
@ -521,7 +523,7 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
#ifdef PNG_iCCP_SUPPORTED
png_uint_32 PNGAPI
png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
png_charpp name, int *compression_type,
png_charpp profile, png_uint_32 *proflen)
{
@ -545,7 +547,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_sPLT_SUPPORTED
png_uint_32 PNGAPI
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
png_sPLT_tpp spalettes)
{
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
@ -559,7 +561,8 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_hIST_SUPPORTED
png_uint_32 PNGAPI
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_16p *hist)
{
png_debug1(1, "in %s retrieval function", "hIST");
@ -614,7 +617,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_oFFs_SUPPORTED
png_uint_32 PNGAPI
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
{
png_debug1(1, "in %s retrieval function", "oFFs");
@ -633,7 +636,7 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_pCAL_SUPPORTED
png_uint_32 PNGAPI
png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
png_charp *units, png_charpp *params)
{
@ -659,7 +662,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_sCAL_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
int *unit, double *width, double *height)
{
if (png_ptr != NULL && info_ptr != NULL &&
@ -675,7 +678,7 @@ png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
int *unit, png_charpp width, png_charpp height)
{
if (png_ptr != NULL && info_ptr != NULL &&
@ -694,7 +697,7 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{
png_uint_32 retval = 0;
@ -727,7 +730,8 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
#endif
png_uint_32 PNGAPI
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
png_colorp *palette,
int *num_palette)
{
png_debug1(1, "in %s retrieval function", "PLTE");
@ -745,7 +749,8 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
#ifdef PNG_sBIT_SUPPORTED
png_uint_32 PNGAPI
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
png_color_8p *sig_bit)
{
png_debug1(1, "in %s retrieval function", "sBIT");
@ -761,8 +766,8 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
#ifdef PNG_TEXT_SUPPORTED
png_uint_32 PNGAPI
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
int *num_text)
png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
png_textp *text_ptr, int *num_text)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{
@ -786,7 +791,8 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
#ifdef PNG_tIME_SUPPORTED
png_uint_32 PNGAPI
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
png_get_tIME(png_const_structp png_ptr, png_infop info_ptr,
png_timep *mod_time)
{
png_debug1(1, "in %s retrieval function", "tIME");
@ -802,7 +808,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
#ifdef PNG_tRNS_SUPPORTED
png_uint_32 PNGAPI
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
{
png_uint_32 retval = 0;
@ -848,7 +854,7 @@ png_get_acTL(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *num_frames, png_uint_32 *num_plays)
{
png_debug1(1, "in %s retrieval function", "acTL");
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_acTL) &&
num_frames != NULL && num_plays != NULL)
@ -857,7 +863,7 @@ png_get_acTL(png_structp png_ptr, png_infop info_ptr,
*num_plays = info_ptr->num_plays;
return (1);
}
return (0);
}
@ -865,7 +871,7 @@ png_uint_32 PNGAPI
png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_num_frames()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->num_frames);
return (0);
@ -875,7 +881,7 @@ png_uint_32 PNGAPI
png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_num_plays()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->num_plays);
return (0);
@ -889,11 +895,11 @@ png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
png_byte *dispose_op, png_byte *blend_op)
{
png_debug1(1, "in %s retrieval function", "fcTL");
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_fcTL) &&
width != NULL && height != NULL &&
x_offset != NULL && x_offset != NULL &&
width != NULL && height != NULL &&
x_offset != NULL && x_offset != NULL &&
delay_num != NULL && delay_den != NULL &&
dispose_op != NULL && blend_op != NULL)
{
@ -907,7 +913,7 @@ png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
*blend_op = info_ptr->next_frame_blend_op;
return (1);
}
return (0);
}
@ -915,7 +921,7 @@ png_uint_32 PNGAPI
png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_width()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_width);
return (0);
@ -925,7 +931,7 @@ png_uint_32 PNGAPI
png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_height()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_height);
return (0);
@ -935,7 +941,7 @@ png_uint_32 PNGAPI
png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_x_offset()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_x_offset);
return (0);
@ -945,7 +951,7 @@ png_uint_32 PNGAPI
png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_y_offset()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_y_offset);
return (0);
@ -955,7 +961,7 @@ png_uint_16 PNGAPI
png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_delay_num()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_delay_num);
return (0);
@ -965,7 +971,7 @@ png_uint_16 PNGAPI
png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_delay_den()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_delay_den);
return (0);
@ -975,7 +981,7 @@ png_byte PNGAPI
png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_dispose_op()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_dispose_op);
return (0);
@ -985,7 +991,7 @@ png_byte PNGAPI
png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_get_next_frame_blend_op()");
if (png_ptr != NULL && info_ptr != NULL)
return (info_ptr->next_frame_blend_op);
return (0);
@ -995,16 +1001,17 @@ png_byte PNGAPI
png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_first_frame_is_hidden()");
if (png_ptr != NULL)
return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
return 0;
}
#endif /* PNG_APNG_SUPPORTED */
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
png_uint_32 PNGAPI
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
png_unknown_chunkpp unknowns)
{
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
@ -1018,7 +1025,7 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
png_byte PNGAPI
png_get_rgb_to_gray_status (png_structp png_ptr)
png_get_rgb_to_gray_status(png_const_structp png_ptr)
{
return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
}
@ -1026,14 +1033,14 @@ png_get_rgb_to_gray_status (png_structp png_ptr)
#ifdef PNG_USER_CHUNKS_SUPPORTED
png_voidp PNGAPI
png_get_user_chunk_ptr(png_structp png_ptr)
png_get_user_chunk_ptr(png_const_structp png_ptr)
{
return (png_ptr? png_ptr->user_chunk_ptr : NULL);
}
#endif
png_size_t PNGAPI
png_get_compression_buffer_size(png_structp png_ptr)
png_get_compression_buffer_size(png_const_structp png_ptr)
{
return (png_ptr ? png_ptr->zbuf_size : 0L);
}
@ -1043,25 +1050,24 @@ png_get_compression_buffer_size(png_structp png_ptr)
/* These functions were added to libpng 1.2.6 and were enabled
* by default in libpng-1.4.0 */
png_uint_32 PNGAPI
png_get_user_width_max (png_structp png_ptr)
png_get_user_width_max(png_const_structp png_ptr)
{
return (png_ptr? png_ptr->user_width_max : 0);
}
png_uint_32 PNGAPI
png_get_user_height_max (png_structp png_ptr)
png_get_user_height_max(png_const_structp png_ptr)
{
return (png_ptr? png_ptr->user_height_max : 0);
}
/* This function was added to libpng 1.4.0 */
png_uint_32 PNGAPI
png_get_chunk_cache_max (png_structp png_ptr)
png_get_chunk_cache_max(png_const_structp png_ptr)
{
return (png_ptr? png_ptr->user_chunk_cache_max : 0);
}
/* This function was added to libpng 1.4.1 */
png_alloc_size_t PNGAPI
png_get_chunk_malloc_max (png_structp png_ptr)
png_get_chunk_malloc_max(png_const_structp png_ptr)
{
return (png_ptr?
png_ptr->user_chunk_malloc_max : 0);
@ -1071,13 +1077,13 @@ png_get_chunk_malloc_max (png_structp png_ptr)
/* These functions were added to libpng 1.4.0 */
#ifdef PNG_IO_STATE_SUPPORTED
png_uint_32 PNGAPI
png_get_io_state (png_structp png_ptr)
png_get_io_state(png_const_structp png_ptr)
{
return png_ptr->io_state;
}
png_bytep PNGAPI
png_get_io_chunk_name (png_structp png_ptr)
png_get_io_chunk_name(png_structp png_ptr)
{
return png_ptr->chunk_name;
}

Просмотреть файл

@ -1,8 +1,8 @@
/* pngmem.c - stub functions for memory allocation
*
* Last changed in libpng 1.4.2 [May 6, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [April 10, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -601,7 +601,7 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
* pointer before png_write_destroy and png_read_destroy are called.
*/
png_voidp PNGAPI
png_get_mem_ptr(png_structp png_ptr)
png_get_mem_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return (NULL);

Просмотреть файл

@ -1,8 +1,8 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.4.3 [June 26, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -234,9 +234,9 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
}
#ifdef PNG_READ_APNG_SUPPORTED
if (png_ptr->num_frames_read > 0 &&
if (png_ptr->num_frames_read > 0 &&
png_ptr->num_frames_read < info_ptr->num_frames)
{
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
@ -244,7 +244,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
/* Discard trailing IDATs for the first frame */
if (png_ptr->mode & PNG_HAVE_fcTL || png_ptr->num_frames_read > 1)
png_error(png_ptr, "out of place IDAT");
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
png_push_save_buffer(png_ptr);
@ -262,13 +262,13 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
return;
}
png_ensure_sequence_number(png_ptr, 4);
if (!(png_ptr->mode & PNG_HAVE_fcTL))
{
/* Discard trailing fdATs for frames other than the first */
if (png_ptr->num_frames_read < 2)
png_error(png_ptr, "out of place fdAT");
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
png_push_save_buffer(png_ptr);
@ -284,7 +284,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_ptr->idat_size = png_ptr->push_length - 4;
png_ptr->mode |= PNG_HAVE_IDAT;
png_ptr->process_mode = PNG_READ_IDAT_MODE;
return;
}
}
@ -295,23 +295,23 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr);
return;
}
png_read_reset(png_ptr);
png_ptr->mode &= ~PNG_HAVE_fcTL;
png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
if (!(png_ptr->mode & PNG_HAVE_fcTL))
png_error(png_ptr, "missing required fcTL chunk");
png_read_reinit(png_ptr, info_ptr);
png_progressive_read_reset(png_ptr);
if (png_ptr->frame_info_fn != NULL)
(*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read);
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
return;
}
else
@ -327,11 +327,11 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
return;
}
return;
}
#endif /* PNG_READ_APNG_SUPPORTED */
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;
@ -921,7 +921,7 @@ png_push_read_IDAT(png_structp png_ptr)
return;
}
}
else
else
#endif
#ifdef PNG_READ_APNG_SUPPORTED
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)
@ -942,7 +942,7 @@ png_push_read_IDAT(png_structp png_ptr)
}
png_ptr->idat_size = png_ptr->push_length;
#ifdef PNG_READ_APNG_SUPPORTED
if (png_ptr->num_frames_read > 0)
{
@ -1032,7 +1032,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
* or the stream marked as finished.
*/
while (png_ptr->zstream.avail_in > 0 &&
!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
{
int ret;
@ -1061,49 +1061,49 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
/* Check for any failure before proceeding. */
if (ret != Z_OK && ret != Z_STREAM_END)
{
/* Terminate the decompression. */
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
/* Terminate the decompression. */
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
/* This may be a truncated stream (missing or
* damaged end code). Treat that as a warning.
*/
* damaged end code). Treat that as a warning.
*/
if (png_ptr->row_number >= png_ptr->num_rows ||
png_ptr->pass > 6)
png_warning(png_ptr, "Truncated compressed data in IDAT");
else
png_error(png_ptr, "Decompression error in IDAT");
png_ptr->pass > 6)
png_warning(png_ptr, "Truncated compressed data in IDAT");
else
png_error(png_ptr, "Decompression error in IDAT");
/* Skip the check on unprocessed input */
/* Skip the check on unprocessed input */
return;
}
/* Did inflate output any data? */
if (png_ptr->zstream.next_out != png_ptr->row_buf)
{
/* Is this unexpected data after the last row?
* If it is, artificially terminate the LZ output
* here.
*/
/* Is this unexpected data after the last row?
* If it is, artificially terminate the LZ output
* here.
*/
if (png_ptr->row_number >= png_ptr->num_rows ||
png_ptr->pass > 6)
png_ptr->pass > 6)
{
/* Extra data. */
png_warning(png_ptr, "Extra compressed data in IDAT");
/* Extra data. */
png_warning(png_ptr, "Extra compressed data in IDAT");
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
/* Do no more processing; skip the unprocessed
* input check below.
*/
/* Do no more processing; skip the unprocessed
* input check below.
*/
return;
}
}
/* Do we have a complete row? */
if (png_ptr->zstream.avail_out == 0)
png_push_process_row(png_ptr);
/* Do we have a complete row? */
if (png_ptr->zstream.avail_out == 0)
png_push_process_row(png_ptr);
}
/* And check for the end of the stream. */
if (ret == Z_STREAM_END)
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
}
/* All the data should have been processed, if anything
@ -1177,7 +1177,7 @@ png_push_process_row(png_structp png_ptr)
if (png_ptr->pass == 6 && png_ptr->height <= 4)
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
@ -1217,7 +1217,7 @@ png_push_process_row(png_structp png_ptr)
for (i = 0; i < 4 && png_ptr->pass == 2; i++)
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
@ -1267,13 +1267,13 @@ png_push_process_row(png_structp png_ptr)
for (i = 0; i < 2 && png_ptr->pass == 4; i++)
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
if (png_ptr->pass == 6) /* Pass 5 might be empty */
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
@ -1292,12 +1292,14 @@ png_push_process_row(png_structp png_ptr)
if (png_ptr->pass == 6) /* Skip top generated row */
{
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
break;
}
default:
case 6:
{
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
@ -1306,7 +1308,7 @@ png_push_process_row(png_structp png_ptr)
if (png_ptr->pass != 6)
break;
png_push_have_row(png_ptr, NULL);
png_push_have_row(png_ptr, NULL);
png_read_push_finish_row(png_ptr);
}
}
@ -1391,7 +1393,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");
info_ptr = info_ptr; /* To quiet some compiler warnings */
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
}
#ifdef PNG_MAX_MALLOC_64K
@ -1489,7 +1491,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");
info_ptr = info_ptr; /* To quiet some compiler warnings */
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
}
#ifdef PNG_MAX_MALLOC_64K
@ -1690,7 +1692,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");
info_ptr = info_ptr; /* To quiet some compiler warnings */
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
}
#ifdef PNG_MAX_MALLOC_64K
@ -1817,15 +1819,14 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
{
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS
PNG_HANDLE_CHUNK_ALWAYS
#ifdef 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");
info_ptr = info_ptr; /* To quiet some compiler warnings */
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
}
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
@ -1915,7 +1916,7 @@ png_push_have_row(png_structp png_ptr, png_bytep row)
}
void PNGAPI
png_progressive_combine_row (png_structp png_ptr,
png_progressive_combine_row(png_structp png_ptr,
png_bytep old_row, png_bytep new_row)
{
PNG_CONST int FARDATA png_pass_dsp_mask[7] =
@ -1955,7 +1956,7 @@ png_set_progressive_frame_fn(png_structp png_ptr,
#endif
png_voidp PNGAPI
png_get_progressive_ptr(png_structp png_ptr)
png_get_progressive_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return (NULL);

Просмотреть файл

@ -1,9 +1,9 @@
/* pngpriv.h - private declarations for use inside libpng
*
* libpng version 1.4.3 - June 26, 2010
* libpng version 1.4.7 - April 10, 2011
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -28,14 +28,16 @@
#include <stdlib.h>
#ifndef PNG_EXTERN
/* The functions exported by PNG_EXTERN are internal functions, which
* aren't usually used outside the library (as far as I know), so it is
* debatable if they should be exported at all. In the future, when it
* is possible to have run-time registry of chunk-handling functions,
* some of these will be made available again.
#define PNG_EXTERN extern
# define PNG_EXTERN extern
*/
#define PNG_EXTERN
# define PNG_EXTERN
#endif
/* Other defines specific to compilers can go here. Try to keep
* them inside an appropriate ifdef/endif pair for portability.
@ -75,10 +77,6 @@
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
defined(_WIN32) || defined(__WIN32__)
# include <windows.h> /* defines _WINDOWS_ macro */
/* I have no idea why is this necessary... */
# ifdef _MSC_VER
# include <malloc.h>
# endif
#endif
/* Various modes of operation. Note that after an init, mode is set to
@ -301,6 +299,9 @@ PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
png_size_t length));
/* Read and check the PNG file signature */
PNG_EXTERN void png_read_sig PNGARG((png_structp png_ptr, png_infop info_ptr));
/* Read the chunk header (length + type name) */
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
@ -481,9 +482,9 @@ PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
PNG_EXTERN void png_write_acTL PNGARG((png_structp png_ptr,
png_uint_32 num_frames, png_uint_32 num_plays));
PNG_EXTERN void png_write_fcTL PNGARG((png_structp png_ptr,
png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
PNG_EXTERN void png_write_fcTL PNGARG((png_structp png_ptr,
png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den,
png_byte dispose_op, png_byte blend_op));
#endif
@ -550,7 +551,7 @@ PNG_EXTERN void png_progressive_read_reset PNGARG((png_structp png_ptr));
#ifdef PNG_WRITE_APNG_SUPPORTED
/* Private, reset some things to become ready for writing next frame */
PNG_EXTERN void png_write_reset PNGARG((png_structp png_ptr));
PNG_EXTERN void png_write_reinit PNGARG((png_structp png_ptr,
PNG_EXTERN void png_write_reinit PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 width, png_uint_32 height));
#endif
@ -706,7 +707,7 @@ PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_READ_iCCP_SUPPORTED
extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
PNG_EXTERN void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif /* PNG_READ_iCCP_SUPPORTED */
@ -741,7 +742,7 @@ PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_READ_sPLT_SUPPORTED
extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
PNG_EXTERN void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif /* PNG_READ_sPLT_SUPPORTED */
@ -778,7 +779,7 @@ PNG_EXTERN void png_handle_fcTL PNGARG((png_structp png_ptr, png_infop info_ptr,
PNG_EXTERN void png_have_info PNGARG((png_structp png_ptr, png_infop info_ptr));
PNG_EXTERN void png_handle_fdAT PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
PNG_EXTERN void png_ensure_sequence_number PNGARG((png_structp png_ptr,
PNG_EXTERN void png_ensure_sequence_number PNGARG((png_structp png_ptr,
png_uint_32 length));
#endif
@ -874,14 +875,14 @@ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
int filter_type));
/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
PNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
png_infop end_info_ptr));
/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
extern void png_write_destroy PNGARG((png_structp png_ptr));
PNG_EXTERN void png_write_destroy PNGARG((png_structp png_ptr));
#ifdef USE_FAR_KEYWORD /* memory model conversion function */
extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
PNG_EXTERN void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
int check));
#endif /* USE_FAR_KEYWORD */

Просмотреть файл

@ -1,8 +1,8 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.4.1 [February 25, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -214,34 +214,12 @@ void PNGAPI
png_read_info(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_read_info");
if (png_ptr == NULL || info_ptr == NULL)
return;
/* If we haven't checked all of the PNG signature bytes, do so now. */
if (png_ptr->sig_bytes < 8)
{
png_size_t num_checked = png_ptr->sig_bytes,
num_to_check = 8 - num_checked;
#ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
#endif
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
png_ptr->sig_bytes = 8;
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
{
if (num_checked < 4 &&
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
png_error(png_ptr, "Not a PNG file");
else
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
}
if (num_checked < 3)
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
}
/* Read and check the PNG file signature. */
png_read_sig(png_ptr, info_ptr);
for (;;)
{
@ -442,22 +420,22 @@ void PNGAPI
png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
{
png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */
png_debug(0, "Reading frame head");
if (!(png_ptr->mode & PNG_HAVE_acTL))
png_error(png_ptr, "attempt to png_read_frame_head() but "
"no acTL present");
/* do nothing for the main IDAT */
if (png_ptr->num_frames_read == 0)
return;
png_crc_finish(png_ptr, 0); /* CRC from last IDAT or fdAT chunk */
png_read_reset(png_ptr);
png_ptr->mode &= ~PNG_HAVE_fcTL;
have_chunk_after_DAT = 0;
for (;;)
{
@ -466,13 +444,13 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
PNG_fcTL;
png_byte chunk_length[4];
png_uint_32 length;
png_read_data(png_ptr, chunk_length, 4);
length = 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_IDAT, 4))
{
/* discard trailing IDATs for the first frame */
@ -488,7 +466,7 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
{
png_ensure_sequence_number(png_ptr, length);
/* discard trailing fdATs for frames other than the first */
if (!have_chunk_after_DAT && png_ptr->num_frames_read > 1)
png_crc_finish(png_ptr, length - 4);
@ -496,7 +474,7 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
{
png_ptr->idat_size = length - 4;
png_ptr->mode |= PNG_HAVE_IDAT;
break;
}
else
@ -517,7 +495,7 @@ void PNGAPI
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_read_update_info");
if (png_ptr == NULL)
return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
@ -539,7 +517,7 @@ void PNGAPI
png_start_read_image(png_structp png_ptr)
{
png_debug(1, "in png_start_read_image");
if (png_ptr == NULL)
return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
@ -556,14 +534,16 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
PNG_fdAT;
PNG_IEND;
#endif
#ifdef PNG_READ_INTERLACING_SUPPORTED
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
0xff};
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
int ret;
#endif
if (png_ptr == NULL)
return;
png_debug2(1, "in png_read_row (row %lu, pass %d)",
(unsigned long) png_ptr->row_number, png_ptr->pass);
@ -619,6 +599,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 1:
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
{
@ -629,6 +610,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 2:
if ((png_ptr->row_number & 0x07) != 4)
{
@ -639,6 +621,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 3:
if ((png_ptr->row_number & 3) || png_ptr->width < 3)
{
@ -649,6 +632,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 4:
if ((png_ptr->row_number & 3) != 2)
{
@ -659,6 +643,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 5:
if ((png_ptr->row_number & 1) || png_ptr->width < 2)
{
@ -669,6 +654,8 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
default:
case 6:
if (!(png_ptr->row_number & 1))
{
@ -822,7 +809,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
png_bytepp dp;
png_debug(1, "in png_read_rows");
if (png_ptr == NULL)
return;
rp = row;
@ -873,7 +860,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
png_bytepp rp;
png_debug(1, "in png_read_image");
if (png_ptr == NULL)
return;
@ -911,7 +898,7 @@ void PNGAPI
png_read_end(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_read_end");
if (png_ptr == NULL)
return;
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
@ -1096,7 +1083,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
#endif
png_debug(1, "in png_destroy_read_struct");
if (png_ptr_ptr != NULL)
png_ptr = *png_ptr_ptr;
if (png_ptr == NULL)
@ -1172,7 +1159,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
#endif
png_debug(1, "in png_read_destroy");
if (info_ptr != NULL)
png_info_destroy(png_ptr, info_ptr);
@ -1455,8 +1442,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);
transforms = transforms; /* Quiet compiler warnings */
params = params;
PNG_UNUSED(transforms) /* Quiet compiler warnings */
PNG_UNUSED(params)
}
#endif /* PNG_INFO_IMAGE_SUPPORTED */

Просмотреть файл

@ -1,8 +1,8 @@
/* pngrio.c - functions for data input
*
* Last changed in libpng 1.4.1 [February 25, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [January 14, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -33,7 +33,7 @@ void /* PRIVATE */
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
png_debug1(4, "reading %d bytes", (int)length);
if (png_ptr->read_data_fn != NULL)
(*(png_ptr->read_data_fn))(png_ptr, data, length);
else

Просмотреть файл

@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.4.2 [May 6, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [%RDATE%]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -26,7 +26,7 @@ void PNGAPI
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
{
png_debug(1, "in png_set_crc_action");
if (png_ptr == NULL)
return;
@ -98,7 +98,7 @@ png_set_background(png_structp png_ptr,
int need_expand, double background_gamma)
{
png_debug(1, "in png_set_background");
if (png_ptr == NULL)
return;
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
@ -686,6 +686,11 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
break;
case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
break;
default:
png_error(png_ptr, "invalid error action in png_set_rgb_to_gray");
break;
}
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
#ifdef PNG_READ_EXPAND_SUPPORTED
@ -828,6 +833,8 @@ png_init_read_transformations(png_structp png_ptr)
}
break;
default:
case 8:
case 16:
@ -1001,7 +1008,7 @@ png_init_read_transformations(png_structp png_ptr)
*/
png_ptr->transformations &= ~PNG_BACKGROUND;
png_ptr->transformations &= ~PNG_GAMMA;
png_ptr->transformations |= PNG_STRIP_ALPHA;
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
}
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
else
@ -1028,6 +1035,9 @@ png_init_read_transformations(png_structp png_ptr)
gs = 1.0 / (png_ptr->background_gamma *
png_ptr->screen_gamma);
break;
default:
png_error(png_ptr, "invalid background gamma type");
}
png_ptr->background_1.gray = (png_uint_16)(pow(
@ -1121,7 +1131,7 @@ png_init_read_transformations(png_structp png_ptr)
/* Handled alpha, still need to strip the channel. */
png_ptr->transformations &= ~PNG_BACKGROUND;
png_ptr->transformations |= PNG_STRIP_ALPHA;
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
}
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
@ -1626,6 +1636,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
}
break;
}
default:
break;
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
@ -1682,6 +1695,9 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
switch (row_info->bit_depth)
{
default:
break;
case 2:
{
png_bytep bp;
@ -2274,7 +2290,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_debug(1, "in png_do_rgb_to_gray");
if (
if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
@ -2798,6 +2814,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
break;
}
@ -3230,6 +3249,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
@ -3428,6 +3450,9 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
}
}
@ -3522,6 +3547,9 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
row_info->bit_depth = 8;
row_info->pixel_depth = 8;
@ -3672,6 +3700,9 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
row_info->bit_depth = 8;

Просмотреть файл

@ -1,8 +1,8 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.4.3 [June 26, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -23,50 +23,98 @@
png_uint_32 PNGAPI
png_get_uint_31(png_structp png_ptr, png_bytep buf)
{
png_uint_32 i = png_get_uint_32(buf);
if (i > PNG_UINT_31_MAX)
png_error(png_ptr, "PNG unsigned integer out of range");
return (i);
}
#ifndef PNG_USE_READ_MACROS
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32 PNGAPI
png_get_uint_32(png_bytep buf)
{
png_uint_32 i = ((png_uint_32)(*buf) << 24) +
((png_uint_32)(*(buf + 1)) << 16) +
((png_uint_32)(*(buf + 2)) << 8) +
(png_uint_32)(*(buf + 3));
png_uint_32 val = png_get_uint_32(buf);
return (i);
if (val > PNG_UINT_31_MAX)
png_error(png_ptr, "PNG unsigned integer out of range");
return (val);
}
#ifndef PNG_USE_READ_MACROS
/* The parentheses around "PNGAPI function_name" in the following three
* functions are necessary because they allow the macros to co-exist with
* these (unused but exported) functions.
*/
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32 (PNGAPI
png_get_uint_32)(png_bytep buf)
{
png_uint_32 uval = png_get_uint_32(buf);
if ((uval & 0x80000000L) == 0) /* non-negative */
return uval;
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
return -(png_int_32)uval;
}
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
* data is stored in the PNG file in two's complement format, and it is
* assumed that the machine format for signed integers is the same.
* data is stored in the PNG file in two's complement format and there
* is no guarantee that a 'png_int_32' is exactly 32 bits, therefore
* the following code does a two's complement to native conversion.
*/
png_int_32 PNGAPI
png_get_int_32(png_bytep buf)
png_int_32 (PNGAPI
png_get_int_32)(png_bytep buf)
{
png_int_32 i = ((png_int_32)(*buf) << 24) +
((png_int_32)(*(buf + 1)) << 16) +
((png_int_32)(*(buf + 2)) << 8) +
(png_int_32)(*(buf + 3));
png_uint_32 uval = png_get_uint_32(buf);
if ((uval & 0x80000000L) == 0) /* non-negative */
return uval;
return (i);
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
return -(png_int_32)uval;
}
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
png_uint_16 PNGAPI
png_get_uint_16(png_bytep buf)
png_uint_16 (PNGAPI
png_get_uint_16)(png_bytep buf)
{
png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
(png_uint_16)(*(buf + 1)));
/* ANSI-C requires an int value to accomodate at least 16 bits so this
* works and allows the compiler not to worry about possible narrowing
* on 32 bit systems. (Pre-ANSI systems did not make integers smaller
* than 16 bits either.)
*/
unsigned int val =
((unsigned int)(*buf) << 8) +
((unsigned int)(*(buf + 1)));
return (i);
return (png_uint_16)val;
}
#endif /* PNG_USE_READ_MACROS */
/* Read and check the PNG file signature */
void /* PRIVATE */
png_read_sig(png_structp png_ptr, png_infop info_ptr)
{
png_size_t num_checked, num_to_check;
/* Exit if the user application does not expect a signature. */
if (png_ptr->sig_bytes >= 8)
return;
num_checked = png_ptr->sig_bytes;
num_to_check = 8 - num_checked;
#ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
#endif
/* The signature must be serialized in a single I/O call. */
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
png_ptr->sig_bytes = 8;
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
{
if (num_checked < 4 &&
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
png_error(png_ptr, "Not a PNG file");
else
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
}
if (num_checked < 3)
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
}
/* Read the chunk header (length + type name).
* Put the type name into png_ptr->chunk_name, and return the length.
*/
@ -77,32 +125,31 @@ png_read_chunk_header(png_structp png_ptr)
png_uint_32 length;
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that the chunk header is being read.
* PNG_IO_CHUNK_HDR requires a single I/O call.
*/
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;
#endif
/* Read the length and the chunk name */
/* Read the length and the chunk name.
* This must be performed in a single I/O call.
*/
png_read_data(png_ptr, buf, 8);
length = png_get_uint_31(png_ptr, buf);
/* Put the chunk name into png_ptr->chunk_name */
/* Put the chunk name into png_ptr->chunk_name. */
png_memcpy(png_ptr->chunk_name, buf + 4, 4);
png_debug2(0, "Reading %s chunk, length = %lu",
png_ptr->chunk_name, length);
png_ptr->chunk_name, (unsigned long)length);
/* Reset the crc and run it over the chunk name */
/* Reset the crc and run it over the chunk name. */
png_reset_crc(png_ptr);
png_calculate_crc(png_ptr, png_ptr->chunk_name, 4);
/* Check to see if chunk name is valid */
/* Check to see if chunk name is valid. */
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that chunk data will (possibly) be read.
* PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.
/* It is unspecified how many I/O calls will be performed
* during the serialization of the chunk data.
*/
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
#endif
@ -116,6 +163,7 @@ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
{
if (png_ptr == NULL)
return;
png_read_data(png_ptr, buf, length);
png_calculate_crc(png_ptr, buf, length);
}
@ -135,6 +183,7 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
{
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
}
if (i)
{
png_crc_read(png_ptr, png_ptr->zbuf, i);
@ -149,11 +198,13 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
{
png_chunk_warning(png_ptr, "CRC error");
}
else
{
png_chunk_benign_error(png_ptr, "CRC error");
return (0);
}
return (1);
}
@ -176,6 +227,7 @@ png_crc_error(png_structp png_ptr)
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
need_crc = 0;
}
else /* critical */
{
if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
@ -183,11 +235,10 @@ png_crc_error(png_structp png_ptr)
}
#ifdef PNG_IO_STATE_SUPPORTED
/* Inform the I/O callback that the chunk CRC is being read */
/* PNG_IO_CHUNK_CRC requires the I/O to be done at once */
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;
#endif
/* The chunk CRC must be serialized in a single I/O call. */
png_read_data(png_ptr, crc_bytes, 4);
if (need_crc)
@ -195,6 +246,7 @@ png_crc_error(png_structp png_ptr)
crc = png_get_uint_32(crc_bytes);
return ((int)(crc != png_ptr->crc));
}
else
return (0);
}
@ -234,6 +286,7 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
if (avail < copy) copy = avail;
png_memcpy(output + count, png_ptr->zbuf, copy);
}
count += avail;
}
@ -267,9 +320,11 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
case Z_BUF_ERROR:
msg = "Buffer error in compressed datastream in %s chunk";
break;
case Z_DATA_ERROR:
msg = "Data error in compressed datastream in %s chunk";
break;
default:
msg = "Incomplete compressed datastream in %s chunk";
break;
@ -369,6 +424,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
png_warning(png_ptr, "png_inflate logic error");
png_free(png_ptr, text);
}
else
png_warning(png_ptr, "Not enough memory to decompress chunk");
}
@ -652,7 +708,7 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_crc_finish(png_ptr, length);
info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */
PNG_UNUSED(info_ptr) /* Quiet compiler warnings about unused info_ptr */
}
#ifdef PNG_READ_gAMA_SUPPORTED
@ -1165,9 +1221,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_bytep entry_start;
png_sPLT_t new_palette;
#ifdef PNG_POINTER_INDEXING_SUPPORTED
png_sPLT_entryp pp;
#endif
int data_length, entry_size, i;
png_uint_32 skip = 0;
png_size_t slength;
@ -1306,7 +1360,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
pp[i].blue = png_get_uint_16(entry_start); entry_start += 2;
pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;
}
pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2;
}
#endif
@ -1675,7 +1729,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)",
length + 1);
(unsigned long)(length + 1));
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (png_ptr->chunkdata == NULL)
@ -1813,7 +1867,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)",
length + 1);
(unsigned long)(length + 1));
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (png_ptr->chunkdata == NULL)
{
@ -1880,9 +1934,6 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_warning(png_ptr, "malformed height string in sCAL chunk");
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
png_free(png_ptr, swidth);
#endif
return;
}
#else
@ -1893,9 +1944,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
png_free(png_ptr, swidth);
#endif
return;
}
png_memcpy(sheight, ep, png_strlen(ep));
@ -2357,7 +2406,7 @@ png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_uint_32 num_frames;
png_uint_32 num_plays;
png_uint_32 didSet;
png_debug(1, "in png_handle_acTL");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
@ -2382,13 +2431,13 @@ png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, length);
return;
}
png_crc_read(png_ptr, data, 8);
png_crc_finish(png_ptr, 0);
num_frames = png_get_uint_31(png_ptr, data);
num_plays = png_get_uint_31(png_ptr, data + 4);
/* the set function will do error checking on num_frames */
didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
if(didSet)
@ -2407,9 +2456,11 @@ png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_uint_16 delay_den;
png_byte dispose_op;
png_byte blend_op;
png_debug(1, "in png_handle_fcTL");
png_ensure_sequence_number(png_ptr, length);
if (!(png_ptr->mode & PNG_HAVE_IHDR))
{
png_error(png_ptr, "Missing IHDR before fcTL");
@ -2420,13 +2471,13 @@ png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
* but correct. PNG_HAVE_IDAT is unset before the frame head is read
* i can't think of a better message */
png_warning(png_ptr, "Invalid fcTL after IDAT skipped");
png_crc_finish(png_ptr, length);
png_crc_finish(png_ptr, length-4);
return;
}
else if (png_ptr->mode & PNG_HAVE_fcTL)
{
png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
png_crc_finish(png_ptr, length);
png_crc_finish(png_ptr, length-4);
return;
}
else if (length != 26)
@ -2435,12 +2486,10 @@ png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, length);
return;
}
png_ensure_sequence_number(png_ptr, length);
png_crc_read(png_ptr, data, 22);
png_crc_finish(png_ptr, 0);
width = png_get_uint_31(png_ptr, data);
height = png_get_uint_31(png_ptr, data + 4);
x_offset = png_get_uint_31(png_ptr, data + 8);
@ -2449,21 +2498,29 @@ png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
delay_den = png_get_uint_16(data + 18);
dispose_op = data[20];
blend_op = data[21];
if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0))
png_error(png_ptr, "fcTL for the first frame must have zero offset");
if (png_ptr->num_frames_read == 0 &&
if (png_ptr->num_frames_read == 0 &&
(width != info_ptr->width || height != info_ptr->height))
png_error(png_ptr, "size in first frame's fcTL must match "
"the size in IHDR");
/* the set function will do more error checking */
png_set_next_frame_fcTL(png_ptr, info_ptr, width, height,
x_offset, y_offset, delay_num, delay_den,
dispose_op, blend_op);
png_read_reinit(png_ptr, info_ptr);
if (info_ptr != NULL)
{
if (png_ptr->num_frames_read == 0 &&
(width != info_ptr->width || height != info_ptr->height))
png_error(png_ptr, "size in first frame's fcTL must match "
"the size in IHDR");
/* the set function will do more error checking */
png_set_next_frame_fcTL(png_ptr, info_ptr, width, height,
x_offset, y_offset, delay_num, delay_den,
dispose_op, blend_op);
png_read_reinit(png_ptr, info_ptr);
}
png_ptr->mode |= PNG_HAVE_fcTL;
}
@ -2481,8 +2538,8 @@ void /* PRIVATE */
png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_ensure_sequence_number(png_ptr, length);
/* This function is only called from png_read_end(), png_read_info(),
/* This function is only called from png_read_end(), png_read_info(),
* and png_push_read_chunk() which means that:
* - the user doesn't want to read this frame
* - or this is an out-of-place fdAT
@ -2496,17 +2553,17 @@ png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length)
{
png_byte data[4];
png_uint_32 sequence_number;
if (length < 4)
png_error(png_ptr, "invalid fcTL or fdAT chunk found");
png_crc_read(png_ptr, data, 4);
sequence_number = png_get_uint_31(png_ptr, data);
if (sequence_number != png_ptr->next_seq_num)
png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence "
"number found");
png_ptr->next_seq_num++;
}
#endif /* PNG_READ_APNG_SUPPORTED */
@ -2621,7 +2678,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, skip);
#ifndef PNG_READ_USER_CHUNKS_SUPPORTED
info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */
PNG_UNUSED(info_ptr) /* Quiet compiler warnings about unused info_ptr */
#endif
}
@ -3077,7 +3134,7 @@ png_do_read_interlace(png_structp png_ptr)
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
}
#ifndef PNG_READ_PACKSWAP_SUPPORTED
transformations = transformations; /* Silence compiler warning */
PNG_UNUSED(transformations) /* Silence compiler warning */
#endif
}
#endif /* PNG_READ_INTERLACING_SUPPORTED */
@ -3087,7 +3144,8 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
png_bytep prev_row, int filter)
{
png_debug(1, "in png_read_filter_row");
png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter);
png_debug2(2, "row = %lu, filter = %d",
(unsigned long)png_ptr->row_number, filter);
switch (filter)
{
case PNG_FILTER_VALUE_NONE:
@ -3278,17 +3336,10 @@ png_read_finish_row(png_structp png_ptr)
{
while (!png_ptr->idat_size)
{
png_byte chunk_length[4];
png_crc_finish(png_ptr, 0);
png_read_data(png_ptr, chunk_length, 4);
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);
png_ptr->idat_size = png_read_chunk_header(png_ptr);
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
png_error(png_ptr, "Not enough image data");
}
png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_in = png_ptr->zbuf;
@ -3535,13 +3586,13 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_debug1(3, "width = %lu,", png_ptr->width);
png_debug1(3, "height = %lu,", png_ptr->height);
png_debug1(3, "iwidth = %lu,", png_ptr->iwidth);
png_debug1(3, "num_rows = %lu,", png_ptr->num_rows);
png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes);
png_debug1(3, "width = %lu,", (unsigned long)png_ptr->width);
png_debug1(3, "height = %lu,", (unsigned long)png_ptr->height);
png_debug1(3, "iwidth = %lu,", (unsigned long)png_ptr->iwidth);
png_debug1(3, "num_rows = %lu,", (unsigned long)png_ptr->num_rows);
png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes);
png_debug1(3, "irowbytes = %lu",
PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
(unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
png_ptr->flags |= PNG_FLAG_ROW_INIT;
}
@ -3585,7 +3636,7 @@ png_progressive_read_reset(png_structp png_ptr)
/* offset to next interlace block in the y direction */
const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
if (png_ptr->interlaced)
{
if (!(png_ptr->transformations & PNG_INTERLACE))

Просмотреть файл

@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.4.1 [February 25, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [January 14, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -260,7 +260,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
info_ptr->rowbytes = 0;
else
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
#if defined(PNG_APNG_SUPPORTED)
/* for non-animated png. this may be overwritten from an acTL chunk later */
info_ptr->num_frames = 1;
@ -695,6 +695,13 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
if (text_ptr[i].key == NULL)
continue;
if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||
text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
{
png_warning(png_ptr, "text compression mode is out of range");
continue;
}
key_len = png_strlen(text_ptr[i].key);
if (text_ptr[i].compression <= 0)
@ -939,49 +946,49 @@ png_set_sPLT(png_structp png_ptr,
#if defined(PNG_APNG_SUPPORTED)
png_uint_32 PNGAPI
png_set_acTL(png_structp png_ptr, png_infop info_ptr,
png_set_acTL(png_structp png_ptr, png_infop info_ptr,
png_uint_32 num_frames, png_uint_32 num_plays)
{
png_debug1(1, "in %s storage function", "acTL");
if (png_ptr == NULL || info_ptr == NULL)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Call to png_set_acTL() with NULL png_ptr "
"or info_ptr ignored");
return (0);
}
if (num_frames == 0)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Ignoring attempt to set acTL with num_frames zero");
return (0);
}
if (num_frames > PNG_UINT_31_MAX)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Ignoring attempt to set acTL with num_frames > 2^31-1");
return (0);
}
if (num_plays > PNG_UINT_31_MAX)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Ignoring attempt to set acTL with num_plays "
"> 2^31-1");
return (0);
}
info_ptr->num_frames = num_frames;
info_ptr->num_plays = num_plays;
info_ptr->valid |= PNG_INFO_acTL;
return (1);
}
/* delay_num and delay_den can hold any 16-bit values including zero */
png_uint_32 PNGAPI
png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den,
@ -991,15 +998,15 @@ png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL)
{
png_warning(png_ptr,
png_warning(png_ptr,
"Call to png_set_fcTL() with NULL png_ptr or info_ptr "
"ignored");
return (0);
}
png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
delay_num, delay_den, dispose_op, blend_op);
/* For efficiency, ignore BLEND_OP_OVER when image is opaque.
* See bug #441971 and #455140
*/
@ -1023,20 +1030,20 @@ png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
info_ptr->next_frame_delay_den = delay_den;
info_ptr->next_frame_dispose_op = dispose_op;
info_ptr->next_frame_blend_op = blend_op;
info_ptr->valid |= PNG_INFO_fcTL;
return (1);
}
void /* PRIVATE */
png_ensure_fcTL_is_valid(png_structp png_ptr,
png_ensure_fcTL_is_valid(png_structp png_ptr,
png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den,
png_byte dispose_op, png_byte blend_op)
{
if (width + x_offset > png_ptr->first_frame_width ||
if (width + x_offset > png_ptr->first_frame_width ||
height + y_offset > png_ptr->first_frame_height)
png_error(png_ptr, "dimensions of a frame are greater than"
"the ones in IHDR");
@ -1064,15 +1071,15 @@ png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
png_byte is_hidden)
{
png_debug(1, "in png_first_frame_is_hidden()");
if (png_ptr == NULL)
return 0;
if(is_hidden)
png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
else
png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
return 1;
}
#endif /* PNG_APNG_SUPPORTED */
@ -1149,7 +1156,7 @@ png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_MNG_FEATURES_SUPPORTED
png_uint_32 PNGAPI
png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
png_permit_mng_features(png_structp png_ptr, png_uint_32 mng_features)
{
png_debug(1, "in png_permit_mng_features");
@ -1263,7 +1270,7 @@ png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* This function was added to libpng 1.2.6 */
void PNGAPI
png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
png_set_user_limits(png_structp png_ptr, png_uint_32 user_width_max,
png_uint_32 user_height_max)
{
/* Images with dimensions larger than these limits will be
@ -1278,7 +1285,7 @@ png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
/* This function was added to libpng 1.4.0 */
void PNGAPI
png_set_chunk_cache_max (png_structp png_ptr,
png_set_chunk_cache_max(png_structp png_ptr,
png_uint_32 user_chunk_cache_max)
{
if (png_ptr)
@ -1287,7 +1294,7 @@ png_set_chunk_cache_max (png_structp png_ptr,
/* This function was added to libpng 1.4.1 */
void PNGAPI
png_set_chunk_malloc_max (png_structp png_ptr,
png_set_chunk_malloc_max(png_structp png_ptr,
png_alloc_size_t user_chunk_malloc_max)
{
if (png_ptr)

Просмотреть файл

@ -1,8 +1,8 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.4.2 [April 29, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [April 10, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -662,7 +662,7 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
* are called.
*/
png_voidp PNGAPI
png_get_user_transform_ptr(png_structp png_ptr)
png_get_user_transform_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return (NULL);
@ -673,5 +673,5 @@ png_get_user_transform_ptr(png_structp png_ptr)
#endif
}
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

Просмотреть файл

@ -1,8 +1,8 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.4.0 [January 3, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Last changed in libpng 1.4.6 [March 8, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -669,8 +669,8 @@ png_write_row(png_structp png_ptr, png_bytep row)
if (png_ptr == NULL)
return;
png_debug2(1, "in png_write_row (row %ld, pass %d)",
png_ptr->row_number, png_ptr->pass);
png_debug2(1, "in png_write_row (row %lu, pass %d)",
(unsigned long)png_ptr->row_number, png_ptr->pass);
/* Initialize transformations and other stuff if first time */
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
@ -786,7 +786,8 @@ png_write_row(png_structp png_ptr, png_bytep row)
png_ptr->row_info.width);
png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type);
png_debug1(3, "row_info->width = %lu", png_ptr->row_info.width);
png_debug1(3, "row_info->width = %lu",
(unsigned long)png_ptr->row_info.width);
png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels);
png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth);
png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth);
@ -1458,33 +1459,33 @@ 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);
transforms = transforms; /* Quiet compiler warnings */
params = params;
PNG_UNUSED(transforms) /* Quiet compiler warnings */
PNG_UNUSED(params)
}
#endif
#if defined(PNG_WRITE_APNG_SUPPORTED)
void PNGAPI
png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
png_bytepp row_pointers, png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_bytepp row_pointers, png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
png_byte blend_op)
{
png_debug(1, "in png_write_frame_head");
/* there is a chance this has been set after png_write_info was called,
* so it would be set but not written. is there a way to be sure? */
if (!(info_ptr->valid & PNG_INFO_acTL))
png_error(png_ptr, "png_write_frame_head(): acTL not set");
png_write_reset(png_ptr);
png_write_reinit(png_ptr, info_ptr, width, height);
if ( !(png_ptr->num_frames_written == 0 &&
if ( !(png_ptr->num_frames_written == 0 &&
(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) ) )
png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
delay_num, delay_den, dispose_op, blend_op);
}
@ -1492,9 +1493,8 @@ void PNGAPI
png_write_frame_tail(png_structp png_ptr, png_infop png_info)
{
png_debug(1, "in png_write_frame_tail");
png_ptr->num_frames_written++;
}
#endif /* PNG_WRITE_APNG_SUPPORTED */
#endif /* PNG_WRITE_SUPPORTED */

Просмотреть файл

@ -195,6 +195,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
*dp = (png_byte)v;
break;
}
default:
break;
}
row_info->bit_depth = (png_byte)bit_depth;
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);

Просмотреть файл

@ -246,10 +246,12 @@ png_text_compress(png_structp png_ptr,
*/
/* Set up the compression buffers */
/* TODO: the following cast hides a potential overflow problem. */
png_ptr->zstream.avail_in = (uInt)text_len;
/* NOTE: assume zlib doesn't overwrite the input */
png_ptr->zstream.next_in = (Bytef *)text;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
png_ptr->zstream.next_out = png_ptr->zbuf;
/* This is the same compression loop as in png_write_row() */
do
@ -688,11 +690,29 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
if (length >= 2 &&
png_ptr->height < 16384 && png_ptr->width < 16384)
{
unsigned int z_cinfo;
unsigned int half_z_window_size;
/* Compute the maximum possible length of the datastream */
/* Number of pixels, plus for each row a filter byte and possible
* and possibly a padding byte, so increase the maximum
* size to account for these.
*/
png_uint_32 uncompressed_idat_size = png_ptr->height *
((png_ptr->width *
png_ptr->channels * png_ptr->bit_depth + 15) >> 3);
unsigned int z_cinfo = z_cmf >> 4;
unsigned int half_z_window_size = 1 << (z_cinfo + 7);
/* If it's interlaced, each block of 8 rows is sent as up to
* 14 rows, i.e., 6 additional rows, each with a filter byte
* and possibly a padding byte
*/
if (png_ptr->interlaced)
uncompressed_idat_size += ((png_ptr->height + 7)/8) *
(png_ptr->bit_depth < 8 ? 12 : 6);
z_cinfo = z_cmf >> 4;
half_z_window_size = 1 << (z_cinfo + 7);
while (uncompressed_idat_size <= half_z_window_size &&
half_z_window_size >= 256)
{
@ -721,16 +741,16 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
else
{
png_byte buf[4];
png_write_chunk_start(png_ptr, (png_bytep)png_fdAT, 4 + length);
png_save_uint_32(buf, png_ptr->next_seq_num);
png_write_chunk_data(png_ptr, buf, 4);
png_write_chunk_data(png_ptr, data, length);
png_write_chunk_end(png_ptr);
png_ptr->next_seq_num++;
}
#endif
@ -1748,43 +1768,43 @@ png_write_acTL(png_structp png_ptr,
{
PNG_acTL;
png_byte data[16];
png_debug(1, "in png_write_acTL");
png_ptr->num_frames_to_write = num_frames;
if (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN)
num_frames--;
png_save_uint_32(data, num_frames);
png_save_uint_32(data + 4, num_plays);
png_write_chunk(png_ptr, (png_bytep)png_acTL, data, (png_size_t)8);
}
void /* PRIVATE */
png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
png_byte blend_op)
{
PNG_fcTL;
png_byte data[26];
png_debug(1, "in png_write_fcTL");
if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0))
png_error(png_ptr, "x and/or y offset for the first frame aren't 0");
if (png_ptr->num_frames_written == 0 &&
(width != png_ptr->first_frame_width ||
if (png_ptr->num_frames_written == 0 &&
(width != png_ptr->first_frame_width ||
height != png_ptr->first_frame_height))
png_error(png_ptr, "width and/or height in the first frame's fcTL "
"don't match the ones in IHDR");
/* more error checking */
png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
delay_num, delay_den, dispose_op, blend_op);
png_save_uint_32(data, png_ptr->next_seq_num);
png_save_uint_32(data + 4, width);
png_save_uint_32(data + 8, height);
@ -1794,9 +1814,9 @@ png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_save_uint_16(data + 22, delay_den);
data[24] = dispose_op;
data[25] = blend_op;
png_write_chunk(png_ptr, (png_bytep)png_fcTL, data, (png_size_t)26);
png_ptr->next_seq_num++;
}
#endif /* PNG_WRITE_APNG_SUPPORTED */
@ -2883,24 +2903,24 @@ png_write_reset(png_structp png_ptr)
}
void /* PRIVATE */
png_write_reinit(png_structp png_ptr, png_infop info_ptr,
png_write_reinit(png_structp png_ptr, png_infop info_ptr,
png_uint_32 width, png_uint_32 height)
{
if (png_ptr->num_frames_written == 0 &&
(width != png_ptr->first_frame_width ||
if (png_ptr->num_frames_written == 0 &&
(width != png_ptr->first_frame_width ||
height != png_ptr->first_frame_height))
png_error(png_ptr, "width and/or height in the first frame's fcTL "
"don't match the ones in IHDR");
if (width > png_ptr->first_frame_width ||
if (width > png_ptr->first_frame_width ||
height > png_ptr->first_frame_height)
png_error(png_ptr, "width and/or height for a frame greater than"
"the ones in IHDR");
png_set_IHDR(png_ptr, info_ptr, width, height,
info_ptr->bit_depth, info_ptr->color_type,
png_set_IHDR(png_ptr, info_ptr, width, height,
info_ptr->bit_depth, info_ptr->color_type,
info_ptr->interlace_type, info_ptr->compression_type,
info_ptr->filter_type);
png_ptr->width = width;
png_ptr->height = height;
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);