mirror of https://github.com/stella-emu/stella.git
Updated PNG library to version 1.6.1.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2677 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
8ff2c276c3
commit
fbf239798d
|
@ -46,6 +46,8 @@
|
||||||
match the one used for line selection. This makes it easier to
|
match the one used for line selection. This makes it easier to
|
||||||
see for those with problems seeing lighter colours.
|
see for those with problems seeing lighter colours.
|
||||||
|
|
||||||
|
* Updated included PNG library to latest stable version.
|
||||||
|
|
||||||
-Have fun!
|
-Have fun!
|
||||||
|
|
||||||
|
|
||||||
|
|
2215
src/libpng/png.c
2215
src/libpng/png.c
File diff suppressed because it is too large
Load Diff
1650
src/libpng/png.h
1650
src/libpng/png.h
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.5.14 - January 24, 2013
|
* libpng version 1.6.1 - March 28, 2013
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
@ -22,33 +22,69 @@
|
||||||
#ifndef PNGCONF_H
|
#ifndef PNGCONF_H
|
||||||
#define PNGCONF_H
|
#define PNGCONF_H
|
||||||
|
|
||||||
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
/* To do: Do all of this in scripts/pnglibconf.dfa */
|
||||||
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
|
#ifdef PNG_SAFE_LIMITS_SUPPORTED
|
||||||
* definition file for machine specific limits, this may impact the
|
# ifdef PNG_USER_WIDTH_MAX
|
||||||
* correctness of the definitions below (see uses of INT_MAX).
|
# undef PNG_USER_WIDTH_MAX
|
||||||
*/
|
# define PNG_USER_WIDTH_MAX 1000000L
|
||||||
# ifndef PNG_NO_LIMITS_H
|
|
||||||
# include <limits.h>
|
|
||||||
# endif
|
# endif
|
||||||
|
# ifdef PNG_USER_HEIGHT_MAX
|
||||||
/* For the memory copy APIs (i.e. the standard definitions of these),
|
# undef PNG_USER_HEIGHT_MAX
|
||||||
* because this file defines png_memcpy and so on the base APIs must
|
# define PNG_USER_HEIGHT_MAX 1000000L
|
||||||
* be defined here.
|
|
||||||
*/
|
|
||||||
# ifdef BSD
|
|
||||||
# include <strings.h>
|
|
||||||
# else
|
|
||||||
# include <string.h>
|
|
||||||
# endif
|
# endif
|
||||||
|
# ifdef PNG_USER_CHUNK_MALLOC_MAX
|
||||||
/* For png_FILE_p - this provides the standard definition of a
|
# undef PNG_USER_CHUNK_MALLOC_MAX
|
||||||
* FILE
|
# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
|
||||||
*/
|
# endif
|
||||||
# ifdef PNG_STDIO_SUPPORTED
|
# ifdef PNG_USER_CHUNK_CACHE_MAX
|
||||||
# include <stdio.h>
|
# undef PNG_USER_CHUNK_CACHE_MAX
|
||||||
|
# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||||
|
|
||||||
|
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
|
||||||
|
* compiler for correct compilation. The following header files are required by
|
||||||
|
* the standard. If your compiler doesn't provide these header files, or they
|
||||||
|
* do not match the standard, you will need to provide/improve them.
|
||||||
|
*/
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* Library header files. These header files are all defined by ISOC90; libpng
|
||||||
|
* expects conformant implementations, however, an ISOC90 conformant system need
|
||||||
|
* not provide these header files if the functionality cannot be implemented.
|
||||||
|
* In this case it will be necessary to disable the relevant parts of libpng in
|
||||||
|
* the build of pnglibconf.h.
|
||||||
|
*
|
||||||
|
* Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
|
||||||
|
* include this unnecessary header file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
|
/* Required for the definition of FILE: */
|
||||||
|
# include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
|
/* Required for the definition of jmp_buf and the declaration of longjmp: */
|
||||||
|
# include <setjmp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||||
|
/* Required for struct tm: */
|
||||||
|
# include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||||
|
|
||||||
|
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
|
||||||
|
* PNG_NO_CONST; this is no longer supported except for data declarations which
|
||||||
|
* apparently still cause problems in 2011 on some compilers.
|
||||||
|
*/
|
||||||
|
#define PNG_CONST const /* backward compatibility only */
|
||||||
|
|
||||||
/* This controls optimization of the reading of 16 and 32 bit values
|
/* This controls optimization of the reading of 16 and 32 bit values
|
||||||
* from PNG files. It can be set on a per-app-file basis - it
|
* from PNG files. It can be set on a per-app-file basis - it
|
||||||
* just changes whether a macro is used when the function is called.
|
* just changes whether a macro is used when the function is called.
|
||||||
|
@ -72,28 +108,13 @@
|
||||||
* may be changed on a per-file basis when compiling against libpng.
|
* may be changed on a per-file basis when compiling against libpng.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* The PNGARG macro protects us against machines that don't have function
|
/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
|
||||||
* prototypes (ie K&R style headers). If your compiler does not handle
|
* against legacy (pre ISOC90) compilers that did not understand function
|
||||||
* function prototypes, define this macro and use the included ansi2knr.
|
* prototypes. It is not required for modern C compilers.
|
||||||
* I've always been able to use _NO_PROTO as the indicator, but you may
|
|
||||||
* need to drag the empty declaration out in front of here, or change the
|
|
||||||
* ifdef to suit your own needs.
|
|
||||||
*/
|
*/
|
||||||
#ifndef PNGARG
|
#ifndef PNGARG
|
||||||
|
# define PNGARG(arglist) arglist
|
||||||
# ifdef OF /* zlib prototype munger */
|
#endif
|
||||||
# define PNGARG(arglist) OF(arglist)
|
|
||||||
# else
|
|
||||||
|
|
||||||
# ifdef _NO_PROTO
|
|
||||||
# define PNGARG(arglist) ()
|
|
||||||
# else
|
|
||||||
# define PNGARG(arglist) arglist
|
|
||||||
# endif /* _NO_PROTO */
|
|
||||||
|
|
||||||
# endif /* OF */
|
|
||||||
|
|
||||||
#endif /* PNGARG */
|
|
||||||
|
|
||||||
/* Function calling conventions.
|
/* Function calling conventions.
|
||||||
* =============================
|
* =============================
|
||||||
|
@ -197,7 +218,7 @@
|
||||||
# define PNGCAPI __watcall
|
# define PNGCAPI __watcall
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
|
# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
|
||||||
# define PNGCAPI __cdecl
|
# define PNGCAPI __cdecl
|
||||||
# if PNG_API_RULE == 1
|
# if PNG_API_RULE == 1
|
||||||
/* If this line results in an error __stdcall is not understood and
|
/* If this line results in an error __stdcall is not understood and
|
||||||
|
@ -220,7 +241,7 @@
|
||||||
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
||||||
|
|
||||||
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
||||||
ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
|
# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
||||||
|
@ -334,9 +355,10 @@
|
||||||
|
|
||||||
#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||||
/* Support for compiler specific function attributes. These are used
|
/* Support for compiler specific function attributes. These are used
|
||||||
* so that where compiler support is available incorrect use of API
|
* so that where compiler support is available, incorrect use of API
|
||||||
* functions in png.h will generate compiler warnings. Added at libpng
|
* functions in png.h will generate compiler warnings. Added at libpng
|
||||||
* version 1.2.41.
|
* version 1.2.41. Disabling these removes the warnings but may also produce
|
||||||
|
* less efficient code.
|
||||||
*/
|
*/
|
||||||
# if defined(__GNUC__)
|
# if defined(__GNUC__)
|
||||||
# ifndef PNG_USE_RESULT
|
# ifndef PNG_USE_RESULT
|
||||||
|
@ -361,15 +383,19 @@
|
||||||
__attribute__((__deprecated__))
|
__attribute__((__deprecated__))
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
# if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
|
||||||
|
# ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
|
# endif /* __GNUC__ == 3.0 */
|
||||||
# endif /* __GNUC__ >= 3 */
|
# endif /* __GNUC__ >= 3 */
|
||||||
# endif /* __GNUC__ */
|
|
||||||
|
|
||||||
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||||
# ifndef PNG_USE_RESULT
|
# ifndef PNG_USE_RESULT
|
||||||
# define PNG_USE_RESULT /* not supported */
|
# define PNG_USE_RESULT /* not supported */
|
||||||
# endif
|
# endif
|
||||||
# ifndef PNG_NORETURN
|
# ifndef PNG_NORETURN
|
||||||
# define PNG_NORETURN __declspec(noreturn)
|
# define PNG_NORETURN __declspec(noreturn)
|
||||||
# endif
|
# endif
|
||||||
# ifndef PNG_ALLOCATED
|
# ifndef PNG_ALLOCATED
|
||||||
# if (_MSC_VER >= 1400)
|
# if (_MSC_VER >= 1400)
|
||||||
|
@ -382,6 +408,16 @@
|
||||||
# ifndef PNG_PRIVATE
|
# ifndef PNG_PRIVATE
|
||||||
# define PNG_PRIVATE __declspec(deprecated)
|
# define PNG_PRIVATE __declspec(deprecated)
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef PNG_RESTRICT
|
||||||
|
# if (_MSC_VER >= 1400)
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# elif defined(__WATCOMC__)
|
||||||
|
# ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
# endif /* _MSC_VER */
|
# endif /* _MSC_VER */
|
||||||
#endif /* PNG_PEDANTIC_WARNINGS */
|
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||||
|
|
||||||
|
@ -400,6 +436,9 @@
|
||||||
#ifndef PNG_PRIVATE
|
#ifndef PNG_PRIVATE
|
||||||
# define PNG_PRIVATE /* This is a private libpng function */
|
# define PNG_PRIVATE /* This is a private libpng function */
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT /* The C99 "restrict" feature */
|
||||||
|
#endif
|
||||||
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||||
|
@ -417,183 +456,161 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The following uses const char * instead of char * for error
|
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||||
* and warning message functions, so some compilers won't complain.
|
/* Some typedefs to get us started. These should be safe on most of the common
|
||||||
* If you do not want to use const, define PNG_NO_CONST here.
|
* platforms.
|
||||||
*
|
*
|
||||||
* This should not change how the APIs are called, so it can be done
|
* png_uint_32 and png_int_32 may, currently, be larger than required to hold a
|
||||||
* on a per-file basis in the application.
|
* 32-bit value however this is not normally advisable.
|
||||||
|
*
|
||||||
|
* png_uint_16 and png_int_16 should always be two bytes in size - this is
|
||||||
|
* verified at library build time.
|
||||||
|
*
|
||||||
|
* png_byte must always be one byte in size.
|
||||||
|
*
|
||||||
|
* The checks below use constants from limits.h, as defined by the ISOC90
|
||||||
|
* standard.
|
||||||
*/
|
*/
|
||||||
#ifndef PNG_CONST
|
#if CHAR_BIT == 8 && UCHAR_MAX == 255
|
||||||
# ifndef PNG_NO_CONST
|
typedef unsigned char png_byte;
|
||||||
# define PNG_CONST const
|
#else
|
||||||
# else
|
# error "libpng requires 8 bit bytes"
|
||||||
# define PNG_CONST
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Some typedefs to get us started. These should be safe on most of the
|
#if INT_MIN == -32768 && INT_MAX == 32767
|
||||||
* common platforms. The typedefs should be at least as large as the
|
typedef int png_int_16;
|
||||||
* numbers suggest (a png_uint_32 must be at least 32 bits long), but they
|
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
|
||||||
* don't have to be exactly that size. Some compilers dislike passing
|
typedef short png_int_16;
|
||||||
* unsigned shorts as function parameters, so you may be better off using
|
|
||||||
* unsigned int for png_uint_16.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)
|
|
||||||
typedef unsigned int png_uint_32;
|
|
||||||
typedef int png_int_32;
|
|
||||||
#else
|
#else
|
||||||
typedef unsigned long png_uint_32;
|
# error "libpng requires a signed 16 bit type"
|
||||||
typedef long png_int_32;
|
|
||||||
#endif
|
#endif
|
||||||
typedef unsigned short png_uint_16;
|
|
||||||
typedef short png_int_16;
|
|
||||||
typedef unsigned char png_byte;
|
|
||||||
|
|
||||||
#ifdef PNG_NO_SIZE_T
|
#if UINT_MAX == 65535
|
||||||
typedef unsigned int png_size_t;
|
typedef unsigned int png_uint_16;
|
||||||
|
#elif USHRT_MAX == 65535
|
||||||
|
typedef unsigned short png_uint_16;
|
||||||
#else
|
#else
|
||||||
|
# error "libpng requires an unsigned 16 bit type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||||
|
typedef int png_int_32;
|
||||||
|
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||||
|
typedef long int png_int_32;
|
||||||
|
#else
|
||||||
|
# error "libpng requires a signed 32 bit (or more) type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UINT_MAX > 4294967294
|
||||||
|
typedef unsigned int png_uint_32;
|
||||||
|
#elif ULONG_MAX > 4294967294
|
||||||
|
typedef unsigned long int png_uint_32;
|
||||||
|
#else
|
||||||
|
# error "libpng requires an unsigned 32 bit (or more) type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
|
||||||
|
* requires an ISOC90 compiler and relies on consistent behavior of sizeof.
|
||||||
|
*/
|
||||||
typedef size_t png_size_t;
|
typedef size_t png_size_t;
|
||||||
#endif
|
typedef ptrdiff_t png_ptrdiff_t;
|
||||||
#define png_sizeof(x) (sizeof (x))
|
|
||||||
|
|
||||||
/* The following is needed for medium model support. It cannot be in the
|
/* libpng needs to know the maximum value of 'size_t' and this controls the
|
||||||
* pngpriv.h header. Needs modification for other compilers besides
|
* definition of png_alloc_size_t, below. This maximum value of size_t limits
|
||||||
* MSC. Model independent support declares all arrays and pointers to be
|
* but does not control the maximum allocations the library makes - there is
|
||||||
* large using the far keyword. The zlib version used must also support
|
* direct application control of this through png_set_user_limits().
|
||||||
* model independent data. As of version zlib 1.0.4, the necessary changes
|
|
||||||
* have been made in zlib. The USE_FAR_KEYWORD define triggers other
|
|
||||||
* changes that are needed. (Tim Wegner)
|
|
||||||
*/
|
*/
|
||||||
|
#ifndef PNG_SMALL_SIZE_T
|
||||||
/* Separate compiler dependencies (problem here is that zlib.h always
|
/* Compiler specific tests for systems where size_t is known to be less than
|
||||||
* defines FAR. (SJT)
|
* 32 bits (some of these systems may no longer work because of the lack of
|
||||||
*/
|
* 'far' support; see above.)
|
||||||
#ifdef __BORLANDC__
|
*/
|
||||||
# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
|
# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
|
||||||
# define LDATA 1
|
(defined(_MSC_VER) && defined(MAXSEG_64K))
|
||||||
# else
|
# define PNG_SMALL_SIZE_T
|
||||||
# define LDATA 0
|
|
||||||
# endif
|
|
||||||
/* GRR: why is Cygwin in here? Cygwin is not Borland C... */
|
|
||||||
# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
|
|
||||||
# define PNG_MAX_MALLOC_64K /* only used in build */
|
|
||||||
# if (LDATA != 1)
|
|
||||||
# ifndef FAR
|
|
||||||
# define FAR __far
|
|
||||||
# endif
|
|
||||||
# define USE_FAR_KEYWORD
|
|
||||||
# endif /* LDATA != 1 */
|
|
||||||
/* Possibly useful for moving data out of default segment.
|
|
||||||
* Uncomment it if you want. Could also define FARDATA as
|
|
||||||
* const if your compiler supports it. (SJT)
|
|
||||||
# define FARDATA FAR
|
|
||||||
*/
|
|
||||||
# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
|
|
||||||
#endif /* __BORLANDC__ */
|
|
||||||
|
|
||||||
|
|
||||||
/* Suggest testing for specific compiler first before testing for
|
|
||||||
* FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
|
|
||||||
* making reliance oncertain keywords suspect. (SJT)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* MSC Medium model */
|
|
||||||
#ifdef FAR
|
|
||||||
# ifdef M_I86MM
|
|
||||||
# define USE_FAR_KEYWORD
|
|
||||||
# define FARDATA FAR
|
|
||||||
# include <dos.h>
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* SJT: default case */
|
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
|
||||||
#ifndef FAR
|
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
|
||||||
# define FAR
|
* png_alloc_size_t are not necessary; in fact, it is recommended not to use
|
||||||
|
* them at all so that the compiler can complain when something turns out to be
|
||||||
|
* problematic.
|
||||||
|
*
|
||||||
|
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||||
|
* png_uint_32) should be explicitly applied; however, we do not expect to
|
||||||
|
* encounter practical situations that require such conversions.
|
||||||
|
*
|
||||||
|
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||||
|
* 4294967295 - i.e. less than the maximum value of png_uint_32.
|
||||||
|
*/
|
||||||
|
#ifdef PNG_SMALL_SIZE_T
|
||||||
|
typedef png_uint_32 png_alloc_size_t;
|
||||||
|
#else
|
||||||
|
typedef png_size_t png_alloc_size_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* At this point FAR is always defined */
|
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
|
||||||
#ifndef FARDATA
|
* implementations of Intel CPU specific support of user-mode segmented address
|
||||||
# define FARDATA
|
* spaces, where 16-bit pointers address more than 65536 bytes of memory using
|
||||||
#endif
|
* separate 'segment' registers. The implementation requires two different
|
||||||
|
* types of pointer (only one of which includes the segment value.)
|
||||||
|
*
|
||||||
|
* If required this support is available in version 1.2 of libpng and may be
|
||||||
|
* available in versions through 1.5, although the correctness of the code has
|
||||||
|
* not been verified recently.
|
||||||
|
*/
|
||||||
|
|
||||||
/* Typedef for floating-point numbers that are converted
|
/* Typedef for floating-point numbers that are converted to fixed-point with a
|
||||||
* to fixed-point with a multiple of 100,000, e.g., gamma
|
* multiple of 100,000, e.g., gamma
|
||||||
*/
|
*/
|
||||||
typedef png_int_32 png_fixed_point;
|
typedef png_int_32 png_fixed_point;
|
||||||
|
|
||||||
/* Add typedefs for pointers */
|
/* Add typedefs for pointers */
|
||||||
typedef void FAR * png_voidp;
|
typedef void * png_voidp;
|
||||||
typedef PNG_CONST void FAR * png_const_voidp;
|
typedef const void * png_const_voidp;
|
||||||
typedef png_byte FAR * png_bytep;
|
typedef png_byte * png_bytep;
|
||||||
typedef PNG_CONST png_byte FAR * png_const_bytep;
|
typedef const png_byte * png_const_bytep;
|
||||||
typedef png_uint_32 FAR * png_uint_32p;
|
typedef png_uint_32 * png_uint_32p;
|
||||||
typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p;
|
typedef const png_uint_32 * png_const_uint_32p;
|
||||||
typedef png_int_32 FAR * png_int_32p;
|
typedef png_int_32 * png_int_32p;
|
||||||
typedef PNG_CONST png_int_32 FAR * png_const_int_32p;
|
typedef const png_int_32 * png_const_int_32p;
|
||||||
typedef png_uint_16 FAR * png_uint_16p;
|
typedef png_uint_16 * png_uint_16p;
|
||||||
typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p;
|
typedef const png_uint_16 * png_const_uint_16p;
|
||||||
typedef png_int_16 FAR * png_int_16p;
|
typedef png_int_16 * png_int_16p;
|
||||||
typedef PNG_CONST png_int_16 FAR * png_const_int_16p;
|
typedef const png_int_16 * png_const_int_16p;
|
||||||
typedef char FAR * png_charp;
|
typedef char * png_charp;
|
||||||
typedef PNG_CONST char FAR * png_const_charp;
|
typedef const char * png_const_charp;
|
||||||
typedef png_fixed_point FAR * png_fixed_point_p;
|
typedef png_fixed_point * png_fixed_point_p;
|
||||||
typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;
|
typedef const png_fixed_point * png_const_fixed_point_p;
|
||||||
typedef png_size_t FAR * png_size_tp;
|
typedef png_size_t * png_size_tp;
|
||||||
typedef PNG_CONST png_size_t FAR * png_const_size_tp;
|
typedef const png_size_t * png_const_size_tp;
|
||||||
|
|
||||||
#ifdef PNG_STDIO_SUPPORTED
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
typedef FILE * png_FILE_p;
|
typedef FILE * png_FILE_p;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
typedef double FAR * png_doublep;
|
typedef double * png_doublep;
|
||||||
typedef PNG_CONST double FAR * png_const_doublep;
|
typedef const double * png_const_doublep;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Pointers to pointers; i.e. arrays */
|
/* Pointers to pointers; i.e. arrays */
|
||||||
typedef png_byte FAR * FAR * png_bytepp;
|
typedef png_byte * * png_bytepp;
|
||||||
typedef png_uint_32 FAR * FAR * png_uint_32pp;
|
typedef png_uint_32 * * png_uint_32pp;
|
||||||
typedef png_int_32 FAR * FAR * png_int_32pp;
|
typedef png_int_32 * * png_int_32pp;
|
||||||
typedef png_uint_16 FAR * FAR * png_uint_16pp;
|
typedef png_uint_16 * * png_uint_16pp;
|
||||||
typedef png_int_16 FAR * FAR * png_int_16pp;
|
typedef png_int_16 * * png_int_16pp;
|
||||||
typedef PNG_CONST char FAR * FAR * png_const_charpp;
|
typedef const char * * png_const_charpp;
|
||||||
typedef char FAR * FAR * png_charpp;
|
typedef char * * png_charpp;
|
||||||
typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
|
typedef png_fixed_point * * png_fixed_point_pp;
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
typedef double FAR * FAR * png_doublepp;
|
typedef double * * png_doublepp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Pointers to pointers to pointers; i.e., pointer to array */
|
/* Pointers to pointers to pointers; i.e., pointer to array */
|
||||||
typedef char FAR * FAR * FAR * png_charppp;
|
typedef char * * * png_charppp;
|
||||||
|
|
||||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
|
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||||
* and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
|
|
||||||
* to png_alloc_size_t are not necessary; in fact, it is recommended
|
|
||||||
* not to use them at all so that the compiler can complain when something
|
|
||||||
* turns out to be problematic.
|
|
||||||
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
|
||||||
* png_uint_32) should be explicitly applied; however, we do not expect
|
|
||||||
* to encounter practical situations that require such conversions.
|
|
||||||
*/
|
|
||||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
typedef unsigned long png_alloc_size_t;
|
|
||||||
#else
|
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
|
||||||
typedef unsigned long png_alloc_size_t;
|
|
||||||
# else
|
|
||||||
/* 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
|
|
||||||
typedef png_size_t png_alloc_size_t;
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* PNGCONF_H */
|
#endif /* PNGCONF_H */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.14 [January 24, 2013]
|
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
|
||||||
static PNG_FUNCTION(void, png_default_error,PNGARG((png_structp png_ptr,
|
static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
||||||
png_const_charp error_message)),PNG_NORETURN);
|
png_const_charp error_message)),PNG_NORETURN);
|
||||||
|
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_default_warning PNGARG((png_structp png_ptr,
|
png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||||
png_const_charp warning_message));
|
png_const_charp warning_message));
|
||||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||||
|
|
||||||
|
@ -36,7 +36,8 @@ png_default_warning PNGARG((png_structp png_ptr,
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||||
PNG_FUNCTION(void,PNGAPI
|
PNG_FUNCTION(void,PNGAPI
|
||||||
png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||||
|
PNG_NORETURN)
|
||||||
{
|
{
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
char msg[16];
|
char msg[16];
|
||||||
|
@ -79,7 +80,8 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||||
(*(png_ptr->error_fn))(png_ptr, error_message);
|
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
|
||||||
|
error_message);
|
||||||
|
|
||||||
/* If the custom handler doesn't exist, or if it returns,
|
/* If the custom handler doesn't exist, or if it returns,
|
||||||
use the default handler, which will not return. */
|
use the default handler, which will not return. */
|
||||||
|
@ -87,7 +89,7 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
PNG_FUNCTION(void,PNGAPI
|
PNG_FUNCTION(void,PNGAPI
|
||||||
png_err,(png_structp png_ptr),PNG_NORETURN)
|
png_err,(png_const_structrp png_ptr),PNG_NORETURN)
|
||||||
{
|
{
|
||||||
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
|
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
|
||||||
* erroneously as '\0', instead of the empty string "". This was
|
* erroneously as '\0', instead of the empty string "". This was
|
||||||
|
@ -95,7 +97,7 @@ png_err,(png_structp png_ptr),PNG_NORETURN)
|
||||||
* will crash in this case.
|
* will crash in this case.
|
||||||
*/
|
*/
|
||||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||||
(*(png_ptr->error_fn))(png_ptr, "");
|
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), "");
|
||||||
|
|
||||||
/* If the custom handler doesn't exist, or if it returns,
|
/* If the custom handler doesn't exist, or if it returns,
|
||||||
use the default handler, which will not return. */
|
use the default handler, which will not return. */
|
||||||
|
@ -211,7 +213,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||||
* png_set_error_fn() to replace the warning function at run-time.
|
* png_set_error_fn() to replace the warning function at run-time.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
|
@ -230,7 +232,8 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||||
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
|
||||||
|
warning_message + offset);
|
||||||
else
|
else
|
||||||
png_default_warning(png_ptr, warning_message + offset);
|
png_default_warning(png_ptr, warning_message + offset);
|
||||||
}
|
}
|
||||||
|
@ -278,7 +281,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||||
png_const_charp message)
|
png_const_charp message)
|
||||||
{
|
{
|
||||||
/* The internal buffer is just 192 bytes - enough for all our messages,
|
/* The internal buffer is just 192 bytes - enough for all our messages,
|
||||||
|
@ -346,9 +349,9 @@ png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
||||||
/* i is always less than (sizeof msg), so: */
|
/* i is always less than (sizeof msg), so: */
|
||||||
msg[i] = '\0';
|
msg[i] = '\0';
|
||||||
|
|
||||||
/* And this is the formatted message, it may be larger than
|
/* And this is the formatted message. It may be larger than
|
||||||
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these are
|
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these
|
||||||
* not (currently) formatted.
|
* are not (currently) formatted.
|
||||||
*/
|
*/
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
|
@ -356,14 +359,49 @@ png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
||||||
|
|
||||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_benign_error(png_structp png_ptr, png_const_charp error_message)
|
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||||
{
|
{
|
||||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||||
|
{
|
||||||
|
# ifdef PNG_READ_SUPPORTED
|
||||||
|
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||||
|
png_ptr->chunk_name != 0)
|
||||||
|
png_chunk_warning(png_ptr, error_message);
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
png_warning(png_ptr, error_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# ifdef PNG_READ_SUPPORTED
|
||||||
|
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||||
|
png_ptr->chunk_name != 0)
|
||||||
|
png_chunk_error(png_ptr, error_message);
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
png_error(png_ptr, error_message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
|
||||||
|
{
|
||||||
|
if (png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN)
|
||||||
png_warning(png_ptr, error_message);
|
png_warning(png_ptr, error_message);
|
||||||
else
|
else
|
||||||
png_error(png_ptr, error_message);
|
png_error(png_ptr, error_message);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||||
|
{
|
||||||
|
if (png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN)
|
||||||
|
png_warning(png_ptr, error_message);
|
||||||
|
else
|
||||||
|
png_error(png_ptr, error_message);
|
||||||
|
}
|
||||||
|
#endif /* BENIGN_ERRORS */
|
||||||
|
|
||||||
/* These utilities are used internally to build an error message that relates
|
/* These utilities are used internally to build an error message that relates
|
||||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||||
|
@ -377,10 +415,10 @@ static PNG_CONST char png_digit[16] = {
|
||||||
'A', 'B', 'C', 'D', 'E', 'F'
|
'A', 'B', 'C', 'D', 'E', 'F'
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PNG_MAX_ERROR_TEXT 64
|
#define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */
|
||||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||||
error_message)
|
error_message)
|
||||||
{
|
{
|
||||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||||
|
@ -426,7 +464,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||||
PNG_FUNCTION(void,PNGAPI
|
PNG_FUNCTION(void,PNGAPI
|
||||||
png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||||
PNG_NORETURN)
|
PNG_NORETURN)
|
||||||
{
|
{
|
||||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
|
@ -443,7 +481,7 @@ png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
||||||
|
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
|
@ -460,7 +498,8 @@ png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
#ifdef PNG_READ_SUPPORTED
|
#ifdef PNG_READ_SUPPORTED
|
||||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
|
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||||
|
error_message)
|
||||||
{
|
{
|
||||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||||
png_chunk_warning(png_ptr, error_message);
|
png_chunk_warning(png_ptr, error_message);
|
||||||
|
@ -471,16 +510,51 @@ png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||||
|
{
|
||||||
|
/* This is always supported, but for just read or just write it
|
||||||
|
* unconditionally does the right thing.
|
||||||
|
*/
|
||||||
|
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||||
|
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef PNG_READ_SUPPORTED
|
||||||
|
{
|
||||||
|
if (error < PNG_CHUNK_ERROR)
|
||||||
|
png_chunk_warning(png_ptr, message);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_chunk_benign_error(png_ptr, message);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||||
|
else if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
|
{
|
||||||
|
if (error < PNG_CHUNK_WRITE_ERROR)
|
||||||
|
png_app_warning(png_ptr, message);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_app_error(png_ptr, message);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
PNG_FUNCTION(void,
|
PNG_FUNCTION(void,
|
||||||
png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||||
{
|
{
|
||||||
# define fixed_message "fixed point overflow in "
|
# define fixed_message "fixed point overflow in "
|
||||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||||
int iin;
|
int iin;
|
||||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||||
png_memcpy(msg, fixed_message, fixed_message_ln);
|
memcpy(msg, fixed_message, fixed_message_ln);
|
||||||
iin = 0;
|
iin = 0;
|
||||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||||
{
|
{
|
||||||
|
@ -498,14 +572,111 @@ png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||||
* otherwise it is necessary for png_default_error to be overridden.
|
* otherwise it is necessary for png_default_error to be overridden.
|
||||||
*/
|
*/
|
||||||
jmp_buf* PNGAPI
|
jmp_buf* PNGAPI
|
||||||
png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||||
size_t jmp_buf_size)
|
size_t jmp_buf_size)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL || jmp_buf_size != png_sizeof(jmp_buf))
|
/* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value
|
||||||
|
* and it must not change after that. Libpng doesn't care how big the
|
||||||
|
* buffer is, just that it doesn't change.
|
||||||
|
*
|
||||||
|
* If the buffer size is no *larger* than the size of jmp_buf when libpng is
|
||||||
|
* compiled a built in jmp_buf is returned; this preserves the pre-1.6.0
|
||||||
|
* semantics that this call will not fail. If the size is larger, however,
|
||||||
|
* the buffer is allocated and this may fail, causing the function to return
|
||||||
|
* NULL.
|
||||||
|
*/
|
||||||
|
if (png_ptr == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (png_ptr->jmp_buf_ptr == NULL)
|
||||||
|
{
|
||||||
|
png_ptr->jmp_buf_size = 0; /* not allocated */
|
||||||
|
|
||||||
|
if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))
|
||||||
|
png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
|
||||||
|
png_malloc_warn(png_ptr, jmp_buf_size));
|
||||||
|
|
||||||
|
if (png_ptr->jmp_buf_ptr == NULL)
|
||||||
|
return NULL; /* new NULL return on OOM */
|
||||||
|
|
||||||
|
png_ptr->jmp_buf_size = jmp_buf_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else /* Already allocated: check the size */
|
||||||
|
{
|
||||||
|
size_t size = png_ptr->jmp_buf_size;
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
size = (sizeof png_ptr->jmp_buf_local);
|
||||||
|
if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
|
||||||
|
{
|
||||||
|
/* This is an internal error in libpng: somehow we have been left
|
||||||
|
* with a stack allocated jmp_buf when the application regained
|
||||||
|
* control. It's always possible to fix this up, but for the moment
|
||||||
|
* this is a png_error because that makes it easy to detect.
|
||||||
|
*/
|
||||||
|
png_error(png_ptr, "Libpng jmp_buf still allocated");
|
||||||
|
/* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size != jmp_buf_size)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "Application jmp_buf size changed");
|
||||||
|
return NULL; /* caller will probably crash: no choice here */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finally fill in the function, now we have a satisfactory buffer. It is
|
||||||
|
* valid to change the function on every call.
|
||||||
|
*/
|
||||||
png_ptr->longjmp_fn = longjmp_fn;
|
png_ptr->longjmp_fn = longjmp_fn;
|
||||||
return &png_ptr->longjmp_buffer;
|
return png_ptr->jmp_buf_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_free_jmpbuf(png_structrp png_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
jmp_buf *jb = png_ptr->jmp_buf_ptr;
|
||||||
|
|
||||||
|
/* A size of 0 is used to indicate a local, stack, allocation of the
|
||||||
|
* pointer; used here and in png.c
|
||||||
|
*/
|
||||||
|
if (jb != NULL && png_ptr->jmp_buf_size > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* This stuff is so that a failure to free the error control structure
|
||||||
|
* does not leave libpng in a state with no valid error handling: the
|
||||||
|
* free always succeeds, if there is an error it gets ignored.
|
||||||
|
*/
|
||||||
|
if (jb != &png_ptr->jmp_buf_local)
|
||||||
|
{
|
||||||
|
/* Make an internal, libpng, jmp_buf to return here */
|
||||||
|
jmp_buf free_jmp_buf;
|
||||||
|
|
||||||
|
if (!setjmp(free_jmp_buf))
|
||||||
|
{
|
||||||
|
png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */
|
||||||
|
png_ptr->jmp_buf_size = 0; /* stack allocation */
|
||||||
|
png_ptr->longjmp_fn = longjmp;
|
||||||
|
png_free(png_ptr, jb); /* Return to setjmp on error */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *Always* cancel everything out: */
|
||||||
|
png_ptr->jmp_buf_size = 0;
|
||||||
|
png_ptr->jmp_buf_ptr = NULL;
|
||||||
|
png_ptr->longjmp_fn = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -515,7 +686,7 @@ png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||||
* error function pointer in png_set_error_fn().
|
* error function pointer in png_set_error_fn().
|
||||||
*/
|
*/
|
||||||
static PNG_FUNCTION(void /* PRIVATE */,
|
static PNG_FUNCTION(void /* PRIVATE */,
|
||||||
png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||||
PNG_NORETURN)
|
PNG_NORETURN)
|
||||||
{
|
{
|
||||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||||
|
@ -562,23 +733,13 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||||
}
|
}
|
||||||
|
|
||||||
PNG_FUNCTION(void,PNGAPI
|
PNG_FUNCTION(void,PNGAPI
|
||||||
png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
|
||||||
{
|
{
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
if (png_ptr && png_ptr->longjmp_fn)
|
if (png_ptr && png_ptr->longjmp_fn && png_ptr->jmp_buf_ptr)
|
||||||
{
|
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
|
||||||
# ifdef USE_FAR_KEYWORD
|
|
||||||
{
|
|
||||||
jmp_buf tmp_jmpbuf;
|
|
||||||
png_memcpy(tmp_jmpbuf, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
|
|
||||||
png_ptr->longjmp_fn(tmp_jmpbuf, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
# else
|
|
||||||
png_ptr->longjmp_fn(png_ptr->longjmp_buffer, val);
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Here if not setjmp support or if png_ptr is null. */
|
/* Here if not setjmp support or if png_ptr is null. */
|
||||||
PNG_ABORT();
|
PNG_ABORT();
|
||||||
}
|
}
|
||||||
|
@ -590,7 +751,7 @@ png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
||||||
* not used, but it is passed in case it may be useful.
|
* not used, but it is passed in case it may be useful.
|
||||||
*/
|
*/
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
|
@ -637,10 +798,10 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
/* This function is called when the application wants to use another method
|
/* This function is called when the application wants to use another method
|
||||||
* of handling errors and warnings. Note that the error function MUST NOT
|
* of handling errors and warnings. Note that the error function MUST NOT
|
||||||
* return to the calling routine or serious problems will occur. The return
|
* return to the calling routine or serious problems will occur. The return
|
||||||
* method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1)
|
* method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1)
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr,
|
||||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
|
@ -661,7 +822,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||||
* pointer before png_write_destroy and png_read_destroy are called.
|
* pointer before png_write_destroy and png_read_destroy are called.
|
||||||
*/
|
*/
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_error_ptr(png_const_structp png_ptr)
|
png_get_error_ptr(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -672,7 +833,7 @@ png_get_error_ptr(png_const_structp png_ptr)
|
||||||
|
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
|
@ -682,4 +843,90 @@ png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||||
|
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||||
|
/* Currently the above both depend on SETJMP_SUPPORTED, however it would be
|
||||||
|
* possible to implement without setjmp support just so long as there is some
|
||||||
|
* way to handle the error return here:
|
||||||
|
*/
|
||||||
|
PNG_FUNCTION(void /* PRIVATE */,
|
||||||
|
png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||||
|
PNG_NORETURN)
|
||||||
|
{
|
||||||
|
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||||
|
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||||
|
|
||||||
|
/* An error is always logged here, overwriting anything (typically a warning)
|
||||||
|
* that is already there:
|
||||||
|
*/
|
||||||
|
if (image != NULL)
|
||||||
|
{
|
||||||
|
png_safecat(image->message, (sizeof image->message), 0, error_message);
|
||||||
|
image->warning_or_error |= PNG_IMAGE_ERROR;
|
||||||
|
|
||||||
|
/* Retrieve the jmp_buf from within the png_control, making this work for
|
||||||
|
* C++ compilation too is pretty tricky: C++ wants a pointer to the first
|
||||||
|
* element of a jmp_buf, but C doesn't tell us the type of that.
|
||||||
|
*/
|
||||||
|
if (image->opaque != NULL && image->opaque->error_buf != NULL)
|
||||||
|
longjmp(png_control_jmp_buf(image->opaque), 1);
|
||||||
|
|
||||||
|
/* Missing longjmp buffer, the following is to help debugging: */
|
||||||
|
{
|
||||||
|
size_t pos = png_safecat(image->message, (sizeof image->message), 0,
|
||||||
|
"bad longjmp: ");
|
||||||
|
png_safecat(image->message, (sizeof image->message), pos,
|
||||||
|
error_message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Here on an internal programming error. */
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||||
|
{
|
||||||
|
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||||
|
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||||
|
|
||||||
|
/* A warning is only logged if there is no prior warning or error. */
|
||||||
|
if (image->warning_or_error == 0)
|
||||||
|
{
|
||||||
|
png_safecat(image->message, (sizeof image->message), 0, warning_message);
|
||||||
|
image->warning_or_error |= PNG_IMAGE_WARNING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int /* PRIVATE */
|
||||||
|
png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||||
|
{
|
||||||
|
volatile png_imagep image = image_in;
|
||||||
|
volatile int result;
|
||||||
|
volatile png_voidp saved_error_buf;
|
||||||
|
jmp_buf safe_jmpbuf;
|
||||||
|
|
||||||
|
/* Safely execute function(arg) with png_error returning to this function. */
|
||||||
|
saved_error_buf = image->opaque->error_buf;
|
||||||
|
result = setjmp(safe_jmpbuf) == 0;
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
|
||||||
|
image->opaque->error_buf = safe_jmpbuf;
|
||||||
|
result = function(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
image->opaque->error_buf = saved_error_buf;
|
||||||
|
|
||||||
|
/* And do the cleanup prior to any failure return. */
|
||||||
|
if (!result)
|
||||||
|
png_image_free(image);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif /* SIMPLIFIED READ/WRITE */
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngget.c - retrieval of values from info struct
|
/* pngget.c - retrieval of values from info struct
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.14 [January 24, 2013]
|
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
png_uint_32 flag)
|
png_uint_32 flag)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
@ -27,7 +27,7 @@ png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
png_size_t PNGAPI
|
png_size_t PNGAPI
|
||||||
png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->rowbytes);
|
return(info_ptr->rowbytes);
|
||||||
|
@ -37,7 +37,7 @@ png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
|
|
||||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||||
png_bytepp PNGAPI
|
png_bytepp PNGAPI
|
||||||
png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->row_pointers);
|
return(info_ptr->row_pointers);
|
||||||
|
@ -49,7 +49,7 @@ png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||||
/* Easy access to info, added in libpng-0.99 */
|
/* Easy access to info, added in libpng-0.99 */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return info_ptr->width;
|
return info_ptr->width;
|
||||||
|
@ -58,7 +58,7 @@ png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return info_ptr->height;
|
return info_ptr->height;
|
||||||
|
@ -67,7 +67,7 @@ png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return info_ptr->bit_depth;
|
return info_ptr->bit_depth;
|
||||||
|
@ -76,7 +76,7 @@ png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return info_ptr->color_type;
|
return info_ptr->color_type;
|
||||||
|
@ -85,7 +85,7 @@ png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return info_ptr->filter_type;
|
return info_ptr->filter_type;
|
||||||
|
@ -94,7 +94,7 @@ png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return info_ptr->interlace_type;
|
return info_ptr->interlace_type;
|
||||||
|
@ -103,7 +103,7 @@ png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return info_ptr->compression_type;
|
return info_ptr->compression_type;
|
||||||
|
@ -112,7 +112,8 @@ png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||||
|
info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_pHYs_SUPPORTED
|
#ifdef PNG_pHYs_SUPPORTED
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||||
|
@ -129,7 +130,8 @@ png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||||
|
info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_pHYs_SUPPORTED
|
#ifdef PNG_pHYs_SUPPORTED
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||||
|
@ -146,7 +148,7 @@ png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_pHYs_SUPPORTED
|
#ifdef PNG_pHYs_SUPPORTED
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||||
|
@ -164,7 +166,8 @@ png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
|
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
float PNGAPI
|
float PNGAPI
|
||||||
png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
|
||||||
|
info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||||
|
@ -186,8 +189,8 @@ png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
|
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
png_fixed_point PNGAPI
|
png_fixed_point PNGAPI
|
||||||
png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
|
png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
|
||||||
png_const_infop info_ptr)
|
png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
|
||||||
|
@ -216,7 +219,7 @@ png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_int_32 PNGAPI
|
png_int_32 PNGAPI
|
||||||
png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_oFFs_SUPPORTED
|
#ifdef PNG_oFFs_SUPPORTED
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||||
|
@ -232,7 +235,7 @@ png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_int_32 PNGAPI
|
png_int_32 PNGAPI
|
||||||
png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_oFFs_SUPPORTED
|
#ifdef PNG_oFFs_SUPPORTED
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||||
|
@ -248,7 +251,7 @@ png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_int_32 PNGAPI
|
png_int_32 PNGAPI
|
||||||
png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_oFFs_SUPPORTED
|
#ifdef PNG_oFFs_SUPPORTED
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||||
|
@ -264,7 +267,7 @@ png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_int_32 PNGAPI
|
png_int_32 PNGAPI
|
||||||
png_get_y_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_oFFs_SUPPORTED
|
#ifdef PNG_oFFs_SUPPORTED
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||||
|
@ -313,26 +316,26 @@ ppi_from_ppm(png_uint_32 ppm)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
|
return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_x_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
|
return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_y_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
|
return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
static png_fixed_point
|
static png_fixed_point
|
||||||
png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)
|
png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
|
||||||
{
|
{
|
||||||
/* Convert from metres * 1,000,000 to inches * 100,000, meters to
|
/* Convert from metres * 1,000,000 to inches * 100,000, meters to
|
||||||
* inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
|
* inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
|
||||||
|
@ -343,8 +346,8 @@ png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_fixed_point PNGAPI
|
png_fixed_point PNGAPI
|
||||||
png_get_x_offset_inches_fixed(png_structp png_ptr,
|
png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
|
||||||
png_const_infop info_ptr)
|
png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
return png_fixed_inches_from_microns(png_ptr,
|
return png_fixed_inches_from_microns(png_ptr,
|
||||||
png_get_x_offset_microns(png_ptr, info_ptr));
|
png_get_x_offset_microns(png_ptr, info_ptr));
|
||||||
|
@ -353,8 +356,8 @@ png_get_x_offset_inches_fixed(png_structp png_ptr,
|
||||||
|
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
png_fixed_point PNGAPI
|
png_fixed_point PNGAPI
|
||||||
png_get_y_offset_inches_fixed(png_structp png_ptr,
|
png_get_y_offset_inches_fixed(png_const_structrp png_ptr,
|
||||||
png_const_infop info_ptr)
|
png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
return png_fixed_inches_from_microns(png_ptr,
|
return png_fixed_inches_from_microns(png_ptr,
|
||||||
png_get_y_offset_microns(png_ptr, info_ptr));
|
png_get_y_offset_microns(png_ptr, info_ptr));
|
||||||
|
@ -363,7 +366,7 @@ png_get_y_offset_inches_fixed(png_structp png_ptr,
|
||||||
|
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
float PNGAPI
|
float PNGAPI
|
||||||
png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
/* To avoid the overflow do the conversion directly in floating
|
/* To avoid the overflow do the conversion directly in floating
|
||||||
* point.
|
* point.
|
||||||
|
@ -374,7 +377,7 @@ png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
|
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
float PNGAPI
|
float PNGAPI
|
||||||
png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
/* To avoid the overflow do the conversion directly in floating
|
/* To avoid the overflow do the conversion directly in floating
|
||||||
* point.
|
* point.
|
||||||
|
@ -385,7 +388,7 @@ png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
|
|
||||||
#ifdef PNG_pHYs_SUPPORTED
|
#ifdef PNG_pHYs_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||||
{
|
{
|
||||||
png_uint_32 retval = 0;
|
png_uint_32 retval = 0;
|
||||||
|
@ -428,8 +431,9 @@ png_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||||
|
|
||||||
|
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
|
png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->channels);
|
return(info_ptr->channels);
|
||||||
|
@ -437,18 +441,20 @@ png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
png_const_bytep PNGAPI
|
png_const_bytep PNGAPI
|
||||||
png_get_signature(png_const_structp png_ptr, png_infop info_ptr)
|
png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->signature);
|
return(info_ptr->signature);
|
||||||
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_bKGD_SUPPORTED
|
#ifdef PNG_bKGD_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
|
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_color_16p *background)
|
png_color_16p *background)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
||||||
|
@ -469,87 +475,47 @@ png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
|
||||||
* same time to correct the rgb grayscale coefficient defaults obtained from the
|
* same time to correct the rgb grayscale coefficient defaults obtained from the
|
||||||
* cHRM chunk in 1.5.4
|
* cHRM chunk in 1.5.4
|
||||||
*/
|
*/
|
||||||
png_uint_32 PNGFAPI
|
|
||||||
png_get_cHRM_XYZ_fixed(png_structp png_ptr, png_const_infop info_ptr,
|
|
||||||
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
|
||||||
png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
|
|
||||||
png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
|
|
||||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
|
||||||
png_fixed_point *int_blue_Z)
|
|
||||||
{
|
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
|
||||||
{
|
|
||||||
png_xy xy;
|
|
||||||
png_XYZ XYZ;
|
|
||||||
|
|
||||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
|
||||||
|
|
||||||
xy.whitex = info_ptr->x_white;
|
|
||||||
xy.whitey = info_ptr->y_white;
|
|
||||||
xy.redx = info_ptr->x_red;
|
|
||||||
xy.redy = info_ptr->y_red;
|
|
||||||
xy.greenx = info_ptr->x_green;
|
|
||||||
xy.greeny = info_ptr->y_green;
|
|
||||||
xy.bluex = info_ptr->x_blue;
|
|
||||||
xy.bluey = info_ptr->y_blue;
|
|
||||||
|
|
||||||
/* The *_checked function handles error reporting, so just return 0 if
|
|
||||||
* there is a failure here.
|
|
||||||
*/
|
|
||||||
if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
|
|
||||||
{
|
|
||||||
if (int_red_X != NULL)
|
|
||||||
*int_red_X = XYZ.redX;
|
|
||||||
if (int_red_Y != NULL)
|
|
||||||
*int_red_Y = XYZ.redY;
|
|
||||||
if (int_red_Z != NULL)
|
|
||||||
*int_red_Z = XYZ.redZ;
|
|
||||||
if (int_green_X != NULL)
|
|
||||||
*int_green_X = XYZ.greenX;
|
|
||||||
if (int_green_Y != NULL)
|
|
||||||
*int_green_Y = XYZ.greenY;
|
|
||||||
if (int_green_Z != NULL)
|
|
||||||
*int_green_Z = XYZ.greenZ;
|
|
||||||
if (int_blue_X != NULL)
|
|
||||||
*int_blue_X = XYZ.blueX;
|
|
||||||
if (int_blue_Y != NULL)
|
|
||||||
*int_blue_Y = XYZ.blueY;
|
|
||||||
if (int_blue_Z != NULL)
|
|
||||||
*int_blue_Z = XYZ.blueZ;
|
|
||||||
|
|
||||||
return (PNG_INFO_cHRM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
/* Quiet API change: this code used to only return the end points if a cHRM
|
||||||
|
* chunk was present, but the end points can also come from iCCP or sRGB
|
||||||
|
* chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
|
||||||
|
* the png_set_ APIs merely check that set end points are mutually
|
||||||
|
* consistent.
|
||||||
|
*/
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
|
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||||
|
|
||||||
if (white_x != NULL)
|
if (white_x != NULL)
|
||||||
*white_x = png_float(png_ptr, info_ptr->x_white, "cHRM white X");
|
*white_x = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
|
||||||
if (white_y != NULL)
|
if (white_y != NULL)
|
||||||
*white_y = png_float(png_ptr, info_ptr->y_white, "cHRM white Y");
|
*white_y = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
|
||||||
if (red_x != NULL)
|
if (red_x != NULL)
|
||||||
*red_x = png_float(png_ptr, info_ptr->x_red, "cHRM red X");
|
*red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
|
||||||
|
"cHRM red X");
|
||||||
if (red_y != NULL)
|
if (red_y != NULL)
|
||||||
*red_y = png_float(png_ptr, info_ptr->y_red, "cHRM red Y");
|
*red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
|
||||||
|
"cHRM red Y");
|
||||||
if (green_x != NULL)
|
if (green_x != NULL)
|
||||||
*green_x = png_float(png_ptr, info_ptr->x_green, "cHRM green X");
|
*green_x = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
|
||||||
if (green_y != NULL)
|
if (green_y != NULL)
|
||||||
*green_y = png_float(png_ptr, info_ptr->y_green, "cHRM green Y");
|
*green_y = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
|
||||||
if (blue_x != NULL)
|
if (blue_x != NULL)
|
||||||
*blue_x = png_float(png_ptr, info_ptr->x_blue, "cHRM blue X");
|
*blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
|
||||||
|
"cHRM blue X");
|
||||||
if (blue_y != NULL)
|
if (blue_y != NULL)
|
||||||
*blue_y = png_float(png_ptr, info_ptr->y_blue, "cHRM blue Y");
|
*blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
|
||||||
|
"cHRM blue Y");
|
||||||
return (PNG_INFO_cHRM);
|
return (PNG_INFO_cHRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,35 +523,43 @@ png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_cHRM_XYZ(png_structp png_ptr, png_const_infop info_ptr,
|
png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
double *red_X, double *red_Y, double *red_Z, double *green_X,
|
double *red_X, double *red_Y, double *red_Z, double *green_X,
|
||||||
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
||||||
double *blue_Z)
|
double *blue_Z)
|
||||||
{
|
{
|
||||||
png_XYZ XYZ;
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
|
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||||
if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,
|
|
||||||
&XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,
|
|
||||||
&XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)
|
|
||||||
{
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
|
||||||
|
|
||||||
if (red_X != NULL)
|
if (red_X != NULL)
|
||||||
*red_X = png_float(png_ptr, XYZ.redX, "cHRM red X");
|
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
|
||||||
|
"cHRM red X");
|
||||||
if (red_Y != NULL)
|
if (red_Y != NULL)
|
||||||
*red_Y = png_float(png_ptr, XYZ.redY, "cHRM red Y");
|
*red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
|
||||||
|
"cHRM red Y");
|
||||||
if (red_Z != NULL)
|
if (red_Z != NULL)
|
||||||
*red_Z = png_float(png_ptr, XYZ.redZ, "cHRM red Z");
|
*red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
|
||||||
|
"cHRM red Z");
|
||||||
if (green_X != NULL)
|
if (green_X != NULL)
|
||||||
*green_X = png_float(png_ptr, XYZ.greenX, "cHRM green X");
|
*green_X = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
|
||||||
if (green_Y != NULL)
|
if (green_Y != NULL)
|
||||||
*green_Y = png_float(png_ptr, XYZ.greenY, "cHRM green Y");
|
*green_Y = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
|
||||||
if (green_Z != NULL)
|
if (green_Z != NULL)
|
||||||
*green_Z = png_float(png_ptr, XYZ.greenZ, "cHRM green Z");
|
*green_Z = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
|
||||||
if (blue_X != NULL)
|
if (blue_X != NULL)
|
||||||
*blue_X = png_float(png_ptr, XYZ.blueX, "cHRM blue X");
|
*blue_X = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
|
||||||
if (blue_Y != NULL)
|
if (blue_Y != NULL)
|
||||||
*blue_Y = png_float(png_ptr, XYZ.blueY, "cHRM blue Y");
|
*blue_Y = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
|
||||||
if (blue_Z != NULL)
|
if (blue_Z != NULL)
|
||||||
*blue_Z = png_float(png_ptr, XYZ.blueZ, "cHRM blue Z");
|
*blue_Z = png_float(png_ptr,
|
||||||
|
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
|
||||||
return (PNG_INFO_cHRM);
|
return (PNG_INFO_cHRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,31 +569,69 @@ png_get_cHRM_XYZ(png_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
|
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
|
||||||
|
png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
|
||||||
|
png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
|
||||||
|
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||||
|
png_fixed_point *int_blue_Z)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
|
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||||
|
{
|
||||||
|
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||||
|
|
||||||
|
if (int_red_X != NULL)
|
||||||
|
*int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
|
||||||
|
if (int_red_Y != NULL)
|
||||||
|
*int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
|
||||||
|
if (int_red_Z != NULL)
|
||||||
|
*int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
|
||||||
|
if (int_green_X != NULL)
|
||||||
|
*int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
|
||||||
|
if (int_green_Y != NULL)
|
||||||
|
*int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
|
||||||
|
if (int_green_Z != NULL)
|
||||||
|
*int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
|
||||||
|
if (int_blue_X != NULL)
|
||||||
|
*int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
|
||||||
|
if (int_blue_Y != NULL)
|
||||||
|
*int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
|
||||||
|
if (int_blue_Z != NULL)
|
||||||
|
*int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
|
||||||
|
return (PNG_INFO_cHRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32 PNGAPI
|
||||||
|
png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
|
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 *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
|
||||||
png_fixed_point *blue_x, png_fixed_point *blue_y)
|
png_fixed_point *blue_x, png_fixed_point *blue_y)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||||
|
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
|
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||||
{
|
{
|
||||||
if (white_x != NULL)
|
if (white_x != NULL)
|
||||||
*white_x = info_ptr->x_white;
|
*white_x = info_ptr->colorspace.end_points_xy.whitex;
|
||||||
if (white_y != NULL)
|
if (white_y != NULL)
|
||||||
*white_y = info_ptr->y_white;
|
*white_y = info_ptr->colorspace.end_points_xy.whitey;
|
||||||
if (red_x != NULL)
|
if (red_x != NULL)
|
||||||
*red_x = info_ptr->x_red;
|
*red_x = info_ptr->colorspace.end_points_xy.redx;
|
||||||
if (red_y != NULL)
|
if (red_y != NULL)
|
||||||
*red_y = info_ptr->y_red;
|
*red_y = info_ptr->colorspace.end_points_xy.redy;
|
||||||
if (green_x != NULL)
|
if (green_x != NULL)
|
||||||
*green_x = info_ptr->x_green;
|
*green_x = info_ptr->colorspace.end_points_xy.greenx;
|
||||||
if (green_y != NULL)
|
if (green_y != NULL)
|
||||||
*green_y = info_ptr->y_green;
|
*green_y = info_ptr->colorspace.end_points_xy.greeny;
|
||||||
if (blue_x != NULL)
|
if (blue_x != NULL)
|
||||||
*blue_x = info_ptr->x_blue;
|
*blue_x = info_ptr->colorspace.end_points_xy.bluex;
|
||||||
if (blue_y != NULL)
|
if (blue_y != NULL)
|
||||||
*blue_y = info_ptr->y_blue;
|
*blue_y = info_ptr->colorspace.end_points_xy.bluey;
|
||||||
return (PNG_INFO_cHRM);
|
return (PNG_INFO_cHRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,41 +641,49 @@ png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_gAMA_SUPPORTED
|
#ifdef PNG_gAMA_SUPPORTED
|
||||||
png_uint_32 PNGFAPI
|
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
png_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_uint_32 PNGAPI
|
||||||
|
png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
png_fixed_point *file_gamma)
|
png_fixed_point *file_gamma)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "gAMA");
|
png_debug1(1, "in %s retrieval function", "gAMA");
|
||||||
|
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
&& file_gamma != NULL)
|
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||||
|
file_gamma != NULL)
|
||||||
{
|
{
|
||||||
*file_gamma = info_ptr->gamma;
|
*file_gamma = info_ptr->colorspace.gamma;
|
||||||
return (PNG_INFO_gAMA);
|
return (PNG_INFO_gAMA);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
double *file_gamma)
|
double *file_gamma)
|
||||||
{
|
{
|
||||||
png_fixed_point igamma;
|
png_debug1(1, "in %s retrieval function", "gAMA(float)");
|
||||||
png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);
|
|
||||||
|
|
||||||
if (ok)
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
*file_gamma = png_float(png_ptr, igamma, "png_get_gAMA");
|
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||||
|
file_gamma != NULL)
|
||||||
|
{
|
||||||
|
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
|
||||||
|
"png_get_gAMA");
|
||||||
|
return (PNG_INFO_gAMA);
|
||||||
|
}
|
||||||
|
|
||||||
return ok;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_sRGB_SUPPORTED
|
#ifdef PNG_sRGB_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
int *file_srgb_intent)
|
int *file_srgb_intent)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "sRGB");
|
png_debug1(1, "in %s retrieval function", "sRGB");
|
||||||
|
@ -671,7 +691,7 @@ png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||||
&& file_srgb_intent != NULL)
|
&& file_srgb_intent != NULL)
|
||||||
{
|
{
|
||||||
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
|
||||||
return (PNG_INFO_sRGB);
|
return (PNG_INFO_sRGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,7 +701,7 @@ png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
#ifdef PNG_iCCP_SUPPORTED
|
#ifdef PNG_iCCP_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_charpp name, int *compression_type,
|
png_charpp name, int *compression_type,
|
||||||
png_bytepp profile, png_uint_32 *proflen)
|
png_bytepp profile, png_uint_32 *proflen)
|
||||||
{
|
{
|
||||||
|
@ -693,11 +713,11 @@ png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
{
|
{
|
||||||
*name = info_ptr->iccp_name;
|
*name = info_ptr->iccp_name;
|
||||||
*profile = info_ptr->iccp_profile;
|
*profile = info_ptr->iccp_profile;
|
||||||
/* Compression_type is a dummy so the API won't have to change
|
*proflen = png_get_uint_32(info_ptr->iccp_profile);
|
||||||
* if we introduce multiple compression types later.
|
/* This is somewhat irrelevant since the profile data returned has
|
||||||
|
* actually been uncompressed.
|
||||||
*/
|
*/
|
||||||
*proflen = info_ptr->iccp_proflen;
|
*compression_type = PNG_COMPRESSION_TYPE_BASE;
|
||||||
*compression_type = info_ptr->iccp_compression;
|
|
||||||
return (PNG_INFO_iCCP);
|
return (PNG_INFO_iCCP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,14 +726,14 @@ png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_sPLT_SUPPORTED
|
#ifdef PNG_sPLT_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
int PNGAPI
|
||||||
png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_sPLT_tpp spalettes)
|
png_sPLT_tpp spalettes)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||||
{
|
{
|
||||||
*spalettes = info_ptr->splt_palettes;
|
*spalettes = info_ptr->splt_palettes;
|
||||||
return ((png_uint_32)info_ptr->splt_palettes_num);
|
return info_ptr->splt_palettes_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -722,7 +742,7 @@ png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
#ifdef PNG_hIST_SUPPORTED
|
#ifdef PNG_hIST_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_uint_16p *hist)
|
png_uint_16p *hist)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "hIST");
|
png_debug1(1, "in %s retrieval function", "hIST");
|
||||||
|
@ -739,11 +759,10 @@ png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
|
png_uint_32 *width, png_uint_32 *height, int *bit_depth,
|
||||||
int *color_type, int *interlace_type, int *compression_type,
|
int *color_type, int *interlace_type, int *compression_type,
|
||||||
int *filter_type)
|
int *filter_type)
|
||||||
|
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "IHDR");
|
png_debug1(1, "in %s retrieval function", "IHDR");
|
||||||
|
|
||||||
|
@ -770,7 +789,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||||
* application has ignored our advice not to mess with the members
|
* application has ignored our advice not to mess with the members
|
||||||
* of info_ptr directly.
|
* of info_ptr directly.
|
||||||
*/
|
*/
|
||||||
png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
|
png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height,
|
||||||
info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
|
info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
|
||||||
info_ptr->compression_type, info_ptr->filter_type);
|
info_ptr->compression_type, info_ptr->filter_type);
|
||||||
|
|
||||||
|
@ -779,7 +798,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||||
|
|
||||||
#ifdef PNG_oFFs_SUPPORTED
|
#ifdef PNG_oFFs_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
|
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "oFFs");
|
png_debug1(1, "in %s retrieval function", "oFFs");
|
||||||
|
@ -799,7 +818,7 @@ png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
#ifdef PNG_pCAL_SUPPORTED
|
#ifdef PNG_pCAL_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||||
png_charp *units, png_charpp *params)
|
png_charp *units, png_charpp *params)
|
||||||
{
|
{
|
||||||
|
@ -825,16 +844,20 @@ png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
#ifdef PNG_sCAL_SUPPORTED
|
#ifdef PNG_sCAL_SUPPORTED
|
||||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||||
|
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,
|
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
int *unit, png_fixed_point *width, png_fixed_point *height)
|
int *unit, png_fixed_point *width, png_fixed_point *height)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL &&
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
(info_ptr->valid & PNG_INFO_sCAL))
|
(info_ptr->valid & PNG_INFO_sCAL))
|
||||||
{
|
{
|
||||||
*unit = info_ptr->scal_unit;
|
*unit = info_ptr->scal_unit;
|
||||||
/*TODO: make this work without FP support */
|
/*TODO: make this work without FP support; the API is currently eliminated
|
||||||
|
* if neither floating point APIs nor internal floating point arithmetic
|
||||||
|
* are enabled.
|
||||||
|
*/
|
||||||
*width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
|
*width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
|
||||||
*height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
|
*height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
|
||||||
"sCAL height");
|
"sCAL height");
|
||||||
|
@ -847,7 +870,7 @@ png_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,
|
||||||
# endif /* FIXED_POINT */
|
# endif /* FIXED_POINT */
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
int *unit, double *width, double *height)
|
int *unit, double *width, double *height)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL &&
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
|
@ -863,7 +886,7 @@ png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
}
|
}
|
||||||
# endif /* FLOATING POINT */
|
# endif /* FLOATING POINT */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
int *unit, png_charpp width, png_charpp height)
|
int *unit, png_charpp width, png_charpp height)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL &&
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
|
@ -881,7 +904,7 @@ png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
#ifdef PNG_pHYs_SUPPORTED
|
#ifdef PNG_pHYs_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||||
{
|
{
|
||||||
png_uint_32 retval = 0;
|
png_uint_32 retval = 0;
|
||||||
|
@ -915,7 +938,7 @@ png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
#endif /* pHYs */
|
#endif /* pHYs */
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_colorp *palette, int *num_palette)
|
png_colorp *palette, int *num_palette)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "PLTE");
|
png_debug1(1, "in %s retrieval function", "PLTE");
|
||||||
|
@ -934,7 +957,7 @@ png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
#ifdef PNG_sBIT_SUPPORTED
|
#ifdef PNG_sBIT_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
|
png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_color_8p *sig_bit)
|
png_color_8p *sig_bit)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "sBIT");
|
png_debug1(1, "in %s retrieval function", "sBIT");
|
||||||
|
@ -951,8 +974,8 @@ png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_TEXT_SUPPORTED
|
#ifdef PNG_TEXT_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
int PNGAPI
|
||||||
png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_textp *text_ptr, int *num_text)
|
png_textp *text_ptr, int *num_text)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
||||||
|
@ -966,7 +989,7 @@ png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
if (num_text != NULL)
|
if (num_text != NULL)
|
||||||
*num_text = info_ptr->num_text;
|
*num_text = info_ptr->num_text;
|
||||||
|
|
||||||
return ((png_uint_32)info_ptr->num_text);
|
return info_ptr->num_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_text != NULL)
|
if (num_text != NULL)
|
||||||
|
@ -978,7 +1001,8 @@ png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
#ifdef PNG_tIME_SUPPORTED
|
#ifdef PNG_tIME_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
|
png_timep *mod_time)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function", "tIME");
|
png_debug1(1, "in %s retrieval function", "tIME");
|
||||||
|
|
||||||
|
@ -995,7 +1019,7 @@ png_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||||
|
|
||||||
#ifdef PNG_tRNS_SUPPORTED
|
#ifdef PNG_tRNS_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
|
png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
|
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
|
||||||
{
|
{
|
||||||
png_uint_32 retval = 0;
|
png_uint_32 retval = 0;
|
||||||
|
@ -1038,9 +1062,9 @@ png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
|
png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_unknown_chunkpp unknowns)
|
png_unknown_chunkpp unknowns)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
||||||
|
@ -1055,7 +1079,7 @@ png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
|
||||||
|
|
||||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_rgb_to_gray_status (png_const_structp png_ptr)
|
png_get_rgb_to_gray_status (png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
|
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
|
||||||
}
|
}
|
||||||
|
@ -1063,43 +1087,60 @@ png_get_rgb_to_gray_status (png_const_structp png_ptr)
|
||||||
|
|
||||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_user_chunk_ptr(png_const_structp png_ptr)
|
png_get_user_chunk_ptr(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
|
return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_size_t PNGAPI
|
png_size_t PNGAPI
|
||||||
png_get_compression_buffer_size(png_const_structp png_ptr)
|
png_get_compression_buffer_size(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_ptr ? png_ptr->zbuf_size : 0);
|
if (png_ptr == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
|
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||||
|
# endif
|
||||||
|
{
|
||||||
|
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||||
|
return png_ptr->IDAT_read_size;
|
||||||
|
# else
|
||||||
|
return PNG_IDAT_READ_SIZE;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
|
else
|
||||||
|
return png_ptr->zbuffer_size;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
/* These functions were added to libpng 1.2.6 and were enabled
|
/* These functions were added to libpng 1.2.6 and were enabled
|
||||||
* by default in libpng-1.4.0 */
|
* by default in libpng-1.4.0 */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_user_width_max (png_const_structp png_ptr)
|
png_get_user_width_max (png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_ptr ? png_ptr->user_width_max : 0);
|
return (png_ptr ? png_ptr->user_width_max : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_user_height_max (png_const_structp png_ptr)
|
png_get_user_height_max (png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_ptr ? png_ptr->user_height_max : 0);
|
return (png_ptr ? png_ptr->user_height_max : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function was added to libpng 1.4.0 */
|
/* This function was added to libpng 1.4.0 */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_chunk_cache_max (png_const_structp png_ptr)
|
png_get_chunk_cache_max (png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
|
return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function was added to libpng 1.4.1 */
|
/* This function was added to libpng 1.4.1 */
|
||||||
png_alloc_size_t PNGAPI
|
png_alloc_size_t PNGAPI
|
||||||
png_get_chunk_malloc_max (png_const_structp png_ptr)
|
png_get_chunk_malloc_max (png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
|
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
|
||||||
}
|
}
|
||||||
|
@ -1108,23 +1149,29 @@ png_get_chunk_malloc_max (png_const_structp png_ptr)
|
||||||
/* These functions were added to libpng 1.4.0 */
|
/* These functions were added to libpng 1.4.0 */
|
||||||
#ifdef PNG_IO_STATE_SUPPORTED
|
#ifdef PNG_IO_STATE_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_io_state (png_structp png_ptr)
|
png_get_io_state (png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
return png_ptr->io_state;
|
return png_ptr->io_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_io_chunk_type (png_const_structp png_ptr)
|
png_get_io_chunk_type (png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
return png_ptr->chunk_name;
|
return png_ptr->chunk_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_const_bytep PNGAPI
|
|
||||||
png_get_io_chunk_name (png_structp png_ptr)
|
|
||||||
{
|
|
||||||
PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);
|
|
||||||
return png_ptr->io_chunk_string;
|
|
||||||
}
|
|
||||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||||
|
|
||||||
|
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||||
|
int PNGAPI
|
||||||
|
png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
return png_ptr->num_palette_max;
|
||||||
|
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
/* pnginfo.h - header file for PNG reference library
|
/* pnginfo.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
|
|
||||||
struct png_info_def
|
struct png_info_def
|
||||||
{
|
{
|
||||||
/* the following are necessary for every PNG file */
|
/* The following are necessary for every PNG file */
|
||||||
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
||||||
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
||||||
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
||||||
|
@ -70,11 +70,17 @@ struct png_info_def
|
||||||
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
||||||
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||||
|
|
||||||
/* The following is informational only on read, and not used on writes. */
|
/* The following are set by png_set_IHDR, called from the application on
|
||||||
|
* write, but the are never actually used by the write code.
|
||||||
|
*/
|
||||||
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
||||||
png_byte pixel_depth; /* number of bits per pixel */
|
png_byte pixel_depth; /* number of bits per pixel */
|
||||||
png_byte spare_byte; /* to align the data, and for future use */
|
png_byte spare_byte; /* to align the data, and for future use */
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
/* This is never set during write */
|
||||||
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The rest of the data is optional. If you are reading, check the
|
/* The rest of the data is optional. If you are reading, check the
|
||||||
* valid field to see if the information in these are valid. If you
|
* valid field to see if the information in these are valid. If you
|
||||||
|
@ -82,18 +88,25 @@ struct png_info_def
|
||||||
* and initialize the appropriate fields below.
|
* and initialize the appropriate fields below.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(PNG_gAMA_SUPPORTED)
|
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||||
/* The gAMA chunk describes the gamma characteristics of the system
|
/* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||||
* on which the image was created, normally in the range [1.0, 2.5].
|
* defined. When COLORSPACE is switched on all the colorspace-defining
|
||||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
* chunks should be enabled, when GAMMA is switched on all the gamma-defining
|
||||||
|
* chunks should be enabled. If this is not done it becomes possible to read
|
||||||
|
* inconsistent PNG files and assign a probably incorrect interpretation to
|
||||||
|
* the information. (In other words, by carefully choosing which chunks to
|
||||||
|
* recognize the system configuration can select an interpretation for PNG
|
||||||
|
* files containing ambiguous data and this will result in inconsistent
|
||||||
|
* behavior between different libpng builds!)
|
||||||
*/
|
*/
|
||||||
png_fixed_point gamma;
|
png_colorspace colorspace;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_sRGB_SUPPORTED
|
#ifdef PNG_iCCP_SUPPORTED
|
||||||
/* GR-P, 0.96a */
|
/* iCCP chunk data. */
|
||||||
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
|
png_charp iccp_name; /* profile name */
|
||||||
png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
|
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||||
|
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_TEXT_SUPPORTED
|
#ifdef PNG_TEXT_SUPPORTED
|
||||||
|
@ -183,23 +196,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||||
png_uint_16p hist;
|
png_uint_16p hist;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_cHRM_SUPPORTED
|
|
||||||
/* The cHRM chunk describes the CIE color characteristics of the monitor
|
|
||||||
* on which the PNG was created. This data allows the viewer to do gamut
|
|
||||||
* mapping of the input image to ensure that the viewer sees the same
|
|
||||||
* colors in the image as the creator. Values are in the range
|
|
||||||
* [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
|
|
||||||
*/
|
|
||||||
png_fixed_point x_white;
|
|
||||||
png_fixed_point y_white;
|
|
||||||
png_fixed_point x_red;
|
|
||||||
png_fixed_point y_red;
|
|
||||||
png_fixed_point x_green;
|
|
||||||
png_fixed_point y_green;
|
|
||||||
png_fixed_point x_blue;
|
|
||||||
png_fixed_point y_blue;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_pCAL_SUPPORTED
|
#ifdef PNG_pCAL_SUPPORTED
|
||||||
/* The pCAL chunk describes a transformation between the stored pixel
|
/* The pCAL chunk describes a transformation between the stored pixel
|
||||||
* values and original physical data values used to create the image.
|
* values and original physical data values used to create the image.
|
||||||
|
@ -224,25 +220,20 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||||
/* New members added in libpng-1.0.6 */
|
/* New members added in libpng-1.0.6 */
|
||||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||||
|
|
||||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
|
||||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||||
png_unknown_chunkp unknown_chunks;
|
png_unknown_chunkp unknown_chunks;
|
||||||
int unknown_chunks_num;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_iCCP_SUPPORTED
|
/* The type of this field is limited by the type of
|
||||||
/* iCCP chunk data. */
|
* png_struct::user_chunk_cache_max, else overflow can occur.
|
||||||
png_charp iccp_name; /* profile name */
|
*/
|
||||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
int unknown_chunks_num;
|
||||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
|
||||||
png_byte iccp_compression; /* Always zero */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_sPLT_SUPPORTED
|
#ifdef PNG_sPLT_SUPPORTED
|
||||||
/* Data on sPLT chunks (there may be more than one). */
|
/* Data on sPLT chunks (there may be more than one). */
|
||||||
png_sPLT_tp splt_palettes;
|
png_sPLT_tp splt_palettes;
|
||||||
int splt_palettes_num;
|
int splt_palettes_num; /* Match type returned by png_get API */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_sCAL_SUPPORTED
|
#ifdef PNG_sCAL_SUPPORTED
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* pnglibconf.h - library build configuration */
|
/* pnglibconf.h - library build configuration */
|
||||||
|
|
||||||
/* libpng version 1.5.3 - July 7, 2011 */
|
/* libpng version 1.6.1 - March 28, 2013 */
|
||||||
|
|
||||||
/* Copyright (c) 1998-2011 Glenn Randers-Pehrson */
|
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
|
||||||
|
|
||||||
/* This code is released under the libpng license. */
|
/* This code is released under the libpng license. */
|
||||||
/* For conditions of distribution and use, see the disclaimer */
|
/* For conditions of distribution and use, see the disclaimer */
|
||||||
|
@ -13,168 +13,197 @@
|
||||||
/* Derived from: scripts/pnglibconf.dfa */
|
/* Derived from: scripts/pnglibconf.dfa */
|
||||||
#ifndef PNGLCONF_H
|
#ifndef PNGLCONF_H
|
||||||
#define PNGLCONF_H
|
#define PNGLCONF_H
|
||||||
/* settings */
|
|
||||||
#define PNG_ZBUF_SIZE 8192
|
|
||||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
|
||||||
#define PNG_DEFAULT_READ_MACROS 1
|
|
||||||
#define PNG_USER_CHUNK_CACHE_MAX 0
|
|
||||||
#define PNG_USER_WIDTH_MAX 1000000L
|
|
||||||
#define PNG_sCAL_PRECISION 5
|
|
||||||
#define PNG_API_RULE 0
|
|
||||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
|
||||||
#define PNG_COST_SHIFT 3
|
|
||||||
#define PNG_WEIGHT_SHIFT 8
|
|
||||||
#define PNG_USER_HEIGHT_MAX 1000000L
|
|
||||||
#define PNG_QUANTIZE_RED_BITS 5
|
|
||||||
#define PNG_MAX_GAMMA_8 11
|
|
||||||
#define PNG_CALLOC_SUPPORTED
|
|
||||||
#define PNG_QUANTIZE_BLUE_BITS 5
|
|
||||||
#define PNG_USER_CHUNK_MALLOC_MAX 0
|
|
||||||
/* end of settings */
|
|
||||||
/* options */
|
/* options */
|
||||||
#define PNG_WARNINGS_SUPPORTED
|
|
||||||
#define PNG_INFO_IMAGE_SUPPORTED
|
|
||||||
#define PNG_TIME_RFC1123_SUPPORTED
|
|
||||||
#define PNG_READ_SUPPORTED
|
|
||||||
#define PNG_SETJMP_SUPPORTED
|
|
||||||
#define PNG_READ_QUANTIZE_SUPPORTED
|
|
||||||
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
|
||||||
#define PNG_POINTER_INDEXING_SUPPORTED
|
|
||||||
/*#define PNG_MNG_FEATURES_SUPPORTED*/
|
|
||||||
#define PNG_INCH_CONVERSIONS_SUPPORTED
|
|
||||||
#define PNG_IO_STATE_SUPPORTED
|
|
||||||
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
|
||||||
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
|
|
||||||
#define PNG_FIXED_POINT_SUPPORTED
|
|
||||||
#define PNG_WRITE_SUPPORTED
|
|
||||||
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
|
||||||
#define PNG_STDIO_SUPPORTED
|
|
||||||
#define PNG_FLOATING_POINT_SUPPORTED
|
|
||||||
/*#define PNG_PROGRESSIVE_READ_SUPPORTED*/
|
|
||||||
#define PNG_READ_16BIT_SUPPORTED
|
|
||||||
#define PNG_WRITE_INTERLACING_SUPPORTED
|
|
||||||
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
|
|
||||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
|
||||||
#define PNG_USER_LIMITS_SUPPORTED
|
|
||||||
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
|
||||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
|
||||||
#define PNG_CONSOLE_IO_SUPPORTED
|
|
||||||
#define PNG_ALIGN_MEMORY_SUPPORTED
|
|
||||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
|
||||||
#define PNG_EASY_ACCESS_SUPPORTED
|
|
||||||
#define PNG_USER_MEM_SUPPORTED
|
|
||||||
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
|
||||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
|
||||||
#define PNG_READ_sCAL_SUPPORTED
|
|
||||||
#define PNG_READ_INTERLACING_SUPPORTED
|
|
||||||
#define PNG_READ_TRANSFORMS_SUPPORTED
|
|
||||||
#define PNG_WRITE_PACK_SUPPORTED
|
|
||||||
#define PNG_ERROR_TEXT_SUPPORTED
|
|
||||||
#define PNG_READ_pHYs_SUPPORTED
|
|
||||||
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
|
||||||
#define PNG_READ_OPT_PLTE_SUPPORTED
|
|
||||||
#define PNG_READ_ALPHA_MODE_SUPPORTED
|
|
||||||
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
|
||||||
#define PNG_WRITE_16BIT_SUPPORTED
|
|
||||||
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
|
||||||
#define PNG_READ_oFFs_SUPPORTED
|
|
||||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
|
||||||
#define PNG_READ_SWAP_SUPPORTED
|
|
||||||
#define PNG_READ_SHIFT_SUPPORTED
|
|
||||||
#define PNG_READ_iTXt_SUPPORTED
|
|
||||||
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
|
|
||||||
#define PNG_READ_PACKSWAP_SUPPORTED
|
|
||||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
|
||||||
#define PNG_WRITE_BGR_SUPPORTED
|
|
||||||
#define PNG_READ_bKGD_SUPPORTED
|
|
||||||
#define PNG_READ_sRGB_SUPPORTED
|
|
||||||
#define PNG_WRITE_SWAP_SUPPORTED
|
|
||||||
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
|
||||||
#define PNG_READ_hIST_SUPPORTED
|
|
||||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
|
||||||
#define PNG_READ_cHRM_SUPPORTED
|
|
||||||
#define PNG_READ_tRNS_SUPPORTED
|
|
||||||
#define PNG_READ_BACKGROUND_SUPPORTED
|
|
||||||
#define PNG_WRITE_INVERT_SUPPORTED
|
|
||||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
|
||||||
#define PNG_READ_FILLER_SUPPORTED
|
|
||||||
#define PNG_READ_pCAL_SUPPORTED
|
|
||||||
#define PNG_READ_sPLT_SUPPORTED
|
|
||||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
|
||||||
#define PNG_SET_USER_LIMITS_SUPPORTED
|
|
||||||
#define PNG_WRITE_FILTER_SUPPORTED
|
|
||||||
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
|
||||||
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
|
||||||
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
|
||||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
|
||||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
|
||||||
#define PNG_READ_tIME_SUPPORTED
|
|
||||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
|
||||||
#define PNG_WRITE_FILLER_SUPPORTED
|
|
||||||
#define PNG_WRITE_tIME_SUPPORTED
|
|
||||||
#define PNG_READ_BGR_SUPPORTED
|
|
||||||
#define PNG_READ_EXPAND_16_SUPPORTED
|
|
||||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
|
||||||
#define PNG_READ_zTXt_SUPPORTED
|
|
||||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
|
||||||
#define PNG_READ_GAMMA_SUPPORTED
|
|
||||||
#define PNG_16BIT_SUPPORTED
|
#define PNG_16BIT_SUPPORTED
|
||||||
|
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||||
|
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||||
|
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||||
|
/*#undef PNG_ARM_NEON_SUPPORTED*/
|
||||||
|
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
|
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||||
|
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||||
|
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
|
||||||
|
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
#define PNG_COLORSPACE_SUPPORTED
|
||||||
|
#define PNG_CONSOLE_IO_SUPPORTED
|
||||||
#define PNG_CONVERT_tIME_SUPPORTED
|
#define PNG_CONVERT_tIME_SUPPORTED
|
||||||
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
#define PNG_EASY_ACCESS_SUPPORTED
|
||||||
#define PNG_READ_PACK_SUPPORTED
|
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||||
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
#define PNG_ERROR_TEXT_SUPPORTED
|
||||||
#define PNG_READ_sBIT_SUPPORTED
|
#define PNG_FIXED_POINT_SUPPORTED
|
||||||
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
|
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||||
#define PNG_WRITE_zTXt_SUPPORTED
|
#define PNG_FLOATING_POINT_SUPPORTED
|
||||||
#define PNG_READ_iCCP_SUPPORTED
|
#define PNG_FORMAT_AFIRST_SUPPORTED
|
||||||
#define PNG_READ_gAMA_SUPPORTED
|
#define PNG_FORMAT_BGR_SUPPORTED
|
||||||
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
#define PNG_GAMMA_SUPPORTED
|
||||||
#define PNG_READ_INVERT_SUPPORTED
|
#define PNG_GET_PALETTE_MAX_SUPPORTED
|
||||||
#define PNG_WRITE_sBIT_SUPPORTED
|
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
#define PNG_INCH_CONVERSIONS_SUPPORTED
|
||||||
#define PNG_READ_USER_CHUNKS_SUPPORTED
|
#define PNG_INFO_IMAGE_SUPPORTED
|
||||||
#define PNG_WRITE_iCCP_SUPPORTED
|
#define PNG_IO_STATE_SUPPORTED
|
||||||
#define PNG_READ_EXPAND_SUPPORTED
|
#define PNG_MNG_FEATURES_SUPPORTED
|
||||||
#define PNG_WRITE_sCAL_SUPPORTED
|
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||||
#define PNG_WRITE_gAMA_SUPPORTED
|
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||||
#define PNG_WRITE_pHYs_SUPPORTED
|
#define PNG_READ_16BIT_SUPPORTED
|
||||||
#define PNG_WRITE_oFFs_SUPPORTED
|
#define PNG_READ_ALPHA_MODE_SUPPORTED
|
||||||
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
#define PNG_tIME_SUPPORTED
|
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||||
|
#define PNG_READ_BGR_SUPPORTED
|
||||||
|
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||||
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||||
#define PNG_USER_CHUNKS_SUPPORTED
|
#define PNG_READ_EXPAND_16_SUPPORTED
|
||||||
#define PNG_WRITE_iTXt_SUPPORTED
|
#define PNG_READ_EXPAND_SUPPORTED
|
||||||
#define PNG_WRITE_bKGD_SUPPORTED
|
#define PNG_READ_FILLER_SUPPORTED
|
||||||
#define PNG_WRITE_sRGB_SUPPORTED
|
#define PNG_READ_GAMMA_SUPPORTED
|
||||||
#define PNG_WRITE_hIST_SUPPORTED
|
#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
|
||||||
#define PNG_WRITE_cHRM_SUPPORTED
|
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
#define PNG_WRITE_tRNS_SUPPORTED
|
#define PNG_READ_INTERLACING_SUPPORTED
|
||||||
#define PNG_WRITE_pCAL_SUPPORTED
|
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||||
#define PNG_WRITE_sPLT_SUPPORTED
|
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||||
#define PNG_zTXt_SUPPORTED
|
#define PNG_READ_INVERT_SUPPORTED
|
||||||
#define PNG_sBIT_SUPPORTED
|
#define PNG_READ_OPT_PLTE_SUPPORTED
|
||||||
#define PNG_iCCP_SUPPORTED
|
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||||
#define PNG_gAMA_SUPPORTED
|
#define PNG_READ_PACK_SUPPORTED
|
||||||
#define PNG_sCAL_SUPPORTED
|
#define PNG_READ_QUANTIZE_SUPPORTED
|
||||||
#define PNG_pHYs_SUPPORTED
|
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||||
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
#define PNG_oFFs_SUPPORTED
|
#define PNG_READ_SHIFT_SUPPORTED
|
||||||
#define PNG_iTXt_SUPPORTED
|
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||||
#define PNG_bKGD_SUPPORTED
|
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||||
#define PNG_sRGB_SUPPORTED
|
#define PNG_READ_SUPPORTED
|
||||||
#define PNG_hIST_SUPPORTED
|
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||||
#define PNG_cHRM_SUPPORTED
|
#define PNG_READ_SWAP_SUPPORTED
|
||||||
#define PNG_tRNS_SUPPORTED
|
|
||||||
#define PNG_pCAL_SUPPORTED
|
|
||||||
#define PNG_sPLT_SUPPORTED
|
|
||||||
#define PNG_READ_TEXT_SUPPORTED
|
#define PNG_READ_TEXT_SUPPORTED
|
||||||
|
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||||
|
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||||
|
#define PNG_READ_bKGD_SUPPORTED
|
||||||
|
#define PNG_READ_cHRM_SUPPORTED
|
||||||
|
#define PNG_READ_gAMA_SUPPORTED
|
||||||
|
#define PNG_READ_hIST_SUPPORTED
|
||||||
|
#define PNG_READ_iCCP_SUPPORTED
|
||||||
|
#define PNG_READ_iTXt_SUPPORTED
|
||||||
|
#define PNG_READ_oFFs_SUPPORTED
|
||||||
|
#define PNG_READ_pCAL_SUPPORTED
|
||||||
|
#define PNG_READ_pHYs_SUPPORTED
|
||||||
|
#define PNG_READ_sBIT_SUPPORTED
|
||||||
|
#define PNG_READ_sCAL_SUPPORTED
|
||||||
|
#define PNG_READ_sPLT_SUPPORTED
|
||||||
|
#define PNG_READ_sRGB_SUPPORTED
|
||||||
#define PNG_READ_tEXt_SUPPORTED
|
#define PNG_READ_tEXt_SUPPORTED
|
||||||
|
#define PNG_READ_tIME_SUPPORTED
|
||||||
|
#define PNG_READ_tRNS_SUPPORTED
|
||||||
|
#define PNG_READ_zTXt_SUPPORTED
|
||||||
|
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
|
||||||
#define PNG_SAVE_INT_32_SUPPORTED
|
#define PNG_SAVE_INT_32_SUPPORTED
|
||||||
#define PNG_CHECK_cHRM_SUPPORTED
|
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
#define PNG_WRITE_TEXT_SUPPORTED
|
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||||
#define PNG_WRITE_tEXt_SUPPORTED
|
#define PNG_SETJMP_SUPPORTED
|
||||||
|
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
|
||||||
|
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||||
|
/*#undef PNG_SET_OPTION_SUPPORTED*/
|
||||||
|
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||||
|
#define PNG_STDIO_SUPPORTED
|
||||||
|
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
#define PNG_TEXT_SUPPORTED
|
#define PNG_TEXT_SUPPORTED
|
||||||
|
#define PNG_TIME_RFC1123_SUPPORTED
|
||||||
|
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_USER_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_USER_LIMITS_SUPPORTED
|
||||||
|
#define PNG_USER_MEM_SUPPORTED
|
||||||
|
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||||
|
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||||
|
#define PNG_WARNINGS_SUPPORTED
|
||||||
|
#define PNG_WRITE_16BIT_SUPPORTED
|
||||||
|
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_WRITE_BGR_SUPPORTED
|
||||||
|
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||||
|
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||||
|
#define PNG_WRITE_FILLER_SUPPORTED
|
||||||
|
#define PNG_WRITE_FILTER_SUPPORTED
|
||||||
|
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||||
|
#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED
|
||||||
|
#define PNG_WRITE_INTERLACING_SUPPORTED
|
||||||
|
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
|
||||||
|
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||||
|
#define PNG_WRITE_INVERT_SUPPORTED
|
||||||
|
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||||
|
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
||||||
|
#define PNG_WRITE_PACK_SUPPORTED
|
||||||
|
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||||
|
#define PNG_WRITE_SUPPORTED
|
||||||
|
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||||
|
#define PNG_WRITE_SWAP_SUPPORTED
|
||||||
|
#define PNG_WRITE_TEXT_SUPPORTED
|
||||||
|
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||||
|
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||||
|
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||||
|
#define PNG_WRITE_bKGD_SUPPORTED
|
||||||
|
#define PNG_WRITE_cHRM_SUPPORTED
|
||||||
|
#define PNG_WRITE_gAMA_SUPPORTED
|
||||||
|
#define PNG_WRITE_hIST_SUPPORTED
|
||||||
|
#define PNG_WRITE_iCCP_SUPPORTED
|
||||||
|
#define PNG_WRITE_iTXt_SUPPORTED
|
||||||
|
#define PNG_WRITE_oFFs_SUPPORTED
|
||||||
|
#define PNG_WRITE_pCAL_SUPPORTED
|
||||||
|
#define PNG_WRITE_pHYs_SUPPORTED
|
||||||
|
#define PNG_WRITE_sBIT_SUPPORTED
|
||||||
|
#define PNG_WRITE_sCAL_SUPPORTED
|
||||||
|
#define PNG_WRITE_sPLT_SUPPORTED
|
||||||
|
#define PNG_WRITE_sRGB_SUPPORTED
|
||||||
|
#define PNG_WRITE_tEXt_SUPPORTED
|
||||||
|
#define PNG_WRITE_tIME_SUPPORTED
|
||||||
|
#define PNG_WRITE_tRNS_SUPPORTED
|
||||||
|
#define PNG_WRITE_zTXt_SUPPORTED
|
||||||
|
#define PNG_bKGD_SUPPORTED
|
||||||
|
#define PNG_cHRM_SUPPORTED
|
||||||
|
#define PNG_gAMA_SUPPORTED
|
||||||
|
#define PNG_hIST_SUPPORTED
|
||||||
|
#define PNG_iCCP_SUPPORTED
|
||||||
|
#define PNG_iTXt_SUPPORTED
|
||||||
|
#define PNG_oFFs_SUPPORTED
|
||||||
|
#define PNG_pCAL_SUPPORTED
|
||||||
|
#define PNG_pHYs_SUPPORTED
|
||||||
|
#define PNG_sBIT_SUPPORTED
|
||||||
|
#define PNG_sCAL_SUPPORTED
|
||||||
|
#define PNG_sPLT_SUPPORTED
|
||||||
|
#define PNG_sRGB_SUPPORTED
|
||||||
#define PNG_tEXt_SUPPORTED
|
#define PNG_tEXt_SUPPORTED
|
||||||
|
#define PNG_tIME_SUPPORTED
|
||||||
|
#define PNG_tRNS_SUPPORTED
|
||||||
|
#define PNG_zTXt_SUPPORTED
|
||||||
/* end of options */
|
/* end of options */
|
||||||
|
/* settings */
|
||||||
|
#define PNG_API_RULE 0
|
||||||
|
#define PNG_CALLOC_SUPPORTED
|
||||||
|
#define PNG_COST_SHIFT 3
|
||||||
|
#define PNG_DEFAULT_READ_MACROS 1
|
||||||
|
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||||
|
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
|
||||||
|
#define PNG_INFLATE_BUF_SIZE 1024
|
||||||
|
#define PNG_MAX_GAMMA_8 11
|
||||||
|
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||||
|
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||||
|
#define PNG_QUANTIZE_RED_BITS 5
|
||||||
|
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
|
||||||
|
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
|
||||||
|
#define PNG_WEIGHT_SHIFT 8
|
||||||
|
#define PNG_ZBUF_SIZE 8192
|
||||||
|
#define PNG_Z_DEFAULT_COMPRESSION (-1)
|
||||||
|
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
|
||||||
|
#define PNG_Z_DEFAULT_STRATEGY 1
|
||||||
|
#define PNG_sCAL_PRECISION 5
|
||||||
|
#define PNG_sRGB_PROFILE_CHECKS 2
|
||||||
|
/* end of settings */
|
||||||
#endif /* PNGLCONF_H */
|
#endif /* PNGLCONF_H */
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngmem.c - stub functions for memory allocation
|
/* pngmem.c - stub functions for memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.13 [September 27, 2012]
|
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -20,457 +20,23 @@
|
||||||
#include "pngpriv.h"
|
#include "pngpriv.h"
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
/* Free a png_struct */
|
||||||
/* Borland DOS special memory handler */
|
|
||||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
|
||||||
/* If you change this, be sure to change the one in png.h also */
|
|
||||||
|
|
||||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
|
||||||
by a single call to calloc() if this is thought to improve performance. */
|
|
||||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
|
||||||
png_create_struct,(int type),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
return (png_create_struct_2(type, NULL, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
|
||||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
|
||||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
|
||||||
PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
png_size_t size;
|
|
||||||
png_voidp struct_ptr;
|
|
||||||
|
|
||||||
if (type == PNG_STRUCT_INFO)
|
|
||||||
size = png_sizeof(png_info);
|
|
||||||
|
|
||||||
else if (type == PNG_STRUCT_PNG)
|
|
||||||
size = png_sizeof(png_struct);
|
|
||||||
|
|
||||||
else
|
|
||||||
return (png_get_copyright(NULL));
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (malloc_fn != NULL)
|
|
||||||
{
|
|
||||||
png_struct dummy_struct;
|
|
||||||
png_memset(&dummy_struct, 0, sizeof dummy_struct);
|
|
||||||
dummy_struct.mem_ptr=mem_ptr;
|
|
||||||
struct_ptr = (*(malloc_fn))(&dummy_struct, (png_alloc_size_t)size);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
struct_ptr = (png_voidp)farmalloc(size);
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
png_memset(struct_ptr, 0, size);
|
|
||||||
|
|
||||||
return (struct_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free memory allocated by a png_create_struct() call */
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_destroy_struct(png_voidp struct_ptr)
|
png_destroy_png_struct(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
if (png_ptr != NULL)
|
||||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free memory allocated by a png_create_struct() call */
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
|
||||||
png_voidp mem_ptr)
|
|
||||||
{
|
|
||||||
# endif
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
{
|
{
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
/* png_free might call png_error and may certainly call
|
||||||
if (free_fn != NULL)
|
* png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||||
{
|
*/
|
||||||
png_struct dummy_struct;
|
png_struct dummy_struct = *png_ptr;
|
||||||
png_memset(&dummy_struct, 0, sizeof dummy_struct);
|
memset(png_ptr, 0, (sizeof *png_ptr));
|
||||||
dummy_struct.mem_ptr=mem_ptr;
|
png_free(&dummy_struct, png_ptr);
|
||||||
(*(free_fn))(&dummy_struct, struct_ptr);
|
|
||||||
return;
|
# ifdef PNG_SETJMP_SUPPORTED
|
||||||
}
|
/* We may have a jmp_buf left to deallocate. */
|
||||||
|
png_free_jmpbuf(&dummy_struct);
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
# endif
|
||||||
farfree (struct_ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate memory. For reasonable files, size should never exceed
|
|
||||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
|
||||||
* it not to. See zconf.h and png.h for more information. zlib does
|
|
||||||
* need to allocate exactly 64K, so whatever you call here must
|
|
||||||
* have the ability to do that.
|
|
||||||
*
|
|
||||||
* Borland seems to have a problem in DOS mode for exactly 64K.
|
|
||||||
* It gives you a segment with an offset of 8 (perhaps to store its
|
|
||||||
* memory stuff). zlib doesn't like this at all, so we have to
|
|
||||||
* detect and deal with it. This code should not be needed in
|
|
||||||
* Windows or OS/2 modes, and only in 16 bit mode. This code has
|
|
||||||
* been updated by Alexander Lehmann for version 0.89 to waste less
|
|
||||||
* memory.
|
|
||||||
*
|
|
||||||
* Note that we can't use png_size_t for the "size" declaration,
|
|
||||||
* since on some systems a png_size_t is a 16-bit quantity, and as a
|
|
||||||
* result, we would be truncating potentially larger memory requests
|
|
||||||
* (which should cause a fatal error) and introducing major problems.
|
|
||||||
*/
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
|
|
||||||
ret = (png_malloc(png_ptr, size));
|
|
||||||
|
|
||||||
if (ret != NULL)
|
|
||||||
png_memset(ret,0,(png_size_t)size);
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
|
|
||||||
if (png_ptr == NULL || size == 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (png_ptr->malloc_fn != NULL)
|
|
||||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
|
||||||
|
|
||||||
else
|
|
||||||
ret = (png_malloc_default(png_ptr, size));
|
|
||||||
|
|
||||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out of memory");
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
if (png_ptr == NULL || size == 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
# ifdef PNG_MAX_MALLOC_64K
|
|
||||||
if (size > (png_uint_32)65536L)
|
|
||||||
{
|
|
||||||
png_warning(png_ptr, "Cannot Allocate > 64K");
|
|
||||||
ret = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (size != (size_t)size)
|
|
||||||
ret = NULL;
|
|
||||||
|
|
||||||
else if (size == (png_uint_32)65536L)
|
|
||||||
{
|
|
||||||
if (png_ptr->offset_table == NULL)
|
|
||||||
{
|
|
||||||
/* Try to see if we need to do any of this fancy stuff */
|
|
||||||
ret = farmalloc(size);
|
|
||||||
if (ret == NULL || ((png_size_t)ret & 0xffff))
|
|
||||||
{
|
|
||||||
int num_blocks;
|
|
||||||
png_uint_32 total_size;
|
|
||||||
png_bytep table;
|
|
||||||
int i, mem_level, window_bits;
|
|
||||||
png_byte huge * hptr;
|
|
||||||
int window_bits
|
|
||||||
|
|
||||||
if (ret != NULL)
|
|
||||||
{
|
|
||||||
farfree(ret);
|
|
||||||
ret = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
window_bits =
|
|
||||||
png_ptr->zlib_window_bits >= png_ptr->zlib_text_window_bits ?
|
|
||||||
png_ptr->zlib_window_bits : png_ptr->zlib_text_window_bits;
|
|
||||||
|
|
||||||
if (window_bits > 14)
|
|
||||||
num_blocks = (int)(1 << (window_bits - 14));
|
|
||||||
|
|
||||||
else
|
|
||||||
num_blocks = 1;
|
|
||||||
|
|
||||||
mem_level =
|
|
||||||
png_ptr->zlib_mem_level >= png_ptr->zlib_text_mem_level ?
|
|
||||||
png_ptr->zlib_mem_level : png_ptr->zlib_text_mem_level;
|
|
||||||
|
|
||||||
if (mem_level >= 7)
|
|
||||||
num_blocks += (int)(1 << (mem_level - 7));
|
|
||||||
|
|
||||||
else
|
|
||||||
num_blocks++;
|
|
||||||
|
|
||||||
total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;
|
|
||||||
|
|
||||||
table = farmalloc(total_size);
|
|
||||||
|
|
||||||
if (table == NULL)
|
|
||||||
{
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out Of Memory"); /* Note "O", "M" */
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr, "Out Of Memory");
|
|
||||||
# endif
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((png_size_t)table & 0xfff0)
|
|
||||||
{
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr,
|
|
||||||
"Farmalloc didn't return normalized pointer");
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr,
|
|
||||||
"Farmalloc didn't return normalized pointer");
|
|
||||||
# endif
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
png_ptr->offset_table = table;
|
|
||||||
png_ptr->offset_table_ptr = farmalloc(num_blocks *
|
|
||||||
png_sizeof(png_bytep));
|
|
||||||
|
|
||||||
if (png_ptr->offset_table_ptr == NULL)
|
|
||||||
{
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out Of memory"); /* Note "O", "m" */
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr, "Out Of memory");
|
|
||||||
# endif
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
hptr = (png_byte huge *)table;
|
|
||||||
if ((png_size_t)hptr & 0xf)
|
|
||||||
{
|
|
||||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
|
||||||
hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_blocks; i++)
|
|
||||||
{
|
|
||||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
|
||||||
hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */
|
|
||||||
}
|
|
||||||
|
|
||||||
png_ptr->offset_table_number = num_blocks;
|
|
||||||
png_ptr->offset_table_count = 0;
|
|
||||||
png_ptr->offset_table_count_free = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
|
||||||
{
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out of Memory"); /* Note "O" and "M" */
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr, "Out of Memory");
|
|
||||||
# endif
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
ret = farmalloc(size);
|
|
||||||
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (ret == NULL)
|
|
||||||
{
|
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
|
||||||
png_error(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
|
||||||
|
|
||||||
else
|
|
||||||
png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free a pointer allocated by png_malloc(). In the default
|
|
||||||
* configuration, png_ptr is not used, but is passed in case it
|
|
||||||
* is needed. If ptr is NULL, return without taking any action.
|
|
||||||
*/
|
|
||||||
void PNGAPI
|
|
||||||
png_free(png_structp png_ptr, png_voidp ptr)
|
|
||||||
{
|
|
||||||
if (png_ptr == NULL || ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (png_ptr->free_fn != NULL)
|
|
||||||
{
|
|
||||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
png_free_default(png_ptr, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PNGAPI
|
|
||||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
|
||||||
{
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
if (png_ptr == NULL || ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (png_ptr->offset_table != NULL)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < png_ptr->offset_table_count; i++)
|
|
||||||
{
|
|
||||||
if (ptr == png_ptr->offset_table_ptr[i])
|
|
||||||
{
|
|
||||||
ptr = NULL;
|
|
||||||
png_ptr->offset_table_count_free++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
|
|
||||||
{
|
|
||||||
farfree(png_ptr->offset_table);
|
|
||||||
farfree(png_ptr->offset_table_ptr);
|
|
||||||
png_ptr->offset_table = NULL;
|
|
||||||
png_ptr->offset_table_ptr = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ptr != NULL)
|
|
||||||
farfree(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* Not the Borland DOS special memory handler */
|
|
||||||
|
|
||||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
|
||||||
memset can be replaced by a single call to calloc() if this is thought
|
|
||||||
to improve performance noticably. */
|
|
||||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
|
||||||
png_create_struct,(int type),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
return (png_create_struct_2(type, NULL, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
|
||||||
memset can be replaced by a single call to calloc() if this is thought
|
|
||||||
to improve performance noticably. */
|
|
||||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
|
||||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
|
||||||
PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
png_size_t size;
|
|
||||||
png_voidp struct_ptr;
|
|
||||||
|
|
||||||
if (type == PNG_STRUCT_INFO)
|
|
||||||
size = png_sizeof(png_info);
|
|
||||||
|
|
||||||
else if (type == PNG_STRUCT_PNG)
|
|
||||||
size = png_sizeof(png_struct);
|
|
||||||
|
|
||||||
else
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (malloc_fn != NULL)
|
|
||||||
{
|
|
||||||
png_struct dummy_struct;
|
|
||||||
png_structp png_ptr = &dummy_struct;
|
|
||||||
png_ptr->mem_ptr=mem_ptr;
|
|
||||||
struct_ptr = (*(malloc_fn))(png_ptr, size);
|
|
||||||
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
png_memset(struct_ptr, 0, size);
|
|
||||||
|
|
||||||
return (struct_ptr);
|
|
||||||
}
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
struct_ptr = (png_voidp)farmalloc(size);
|
|
||||||
# else
|
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
|
||||||
struct_ptr = (png_voidp)halloc(size, 1);
|
|
||||||
# else
|
|
||||||
struct_ptr = (png_voidp)malloc(size);
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
png_memset(struct_ptr, 0, size);
|
|
||||||
|
|
||||||
return (struct_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Free memory allocated by a png_create_struct() call */
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_destroy_struct(png_voidp struct_ptr)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free memory allocated by a png_create_struct() call */
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
|
||||||
png_voidp mem_ptr)
|
|
||||||
{
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
if (struct_ptr != NULL)
|
|
||||||
{
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
if (free_fn != NULL)
|
|
||||||
{
|
|
||||||
png_struct dummy_struct;
|
|
||||||
png_structp png_ptr = &dummy_struct;
|
|
||||||
png_ptr->mem_ptr=mem_ptr;
|
|
||||||
(*(free_fn))(png_ptr, struct_ptr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
farfree(struct_ptr);
|
|
||||||
|
|
||||||
# else
|
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
|
||||||
hfree(struct_ptr);
|
|
||||||
|
|
||||||
# else
|
|
||||||
free(struct_ptr);
|
|
||||||
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,167 +46,211 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||||
* need to allocate exactly 64K, so whatever you call here must
|
* need to allocate exactly 64K, so whatever you call here must
|
||||||
* have the ability to do that.
|
* have the ability to do that.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
PNG_FUNCTION(png_voidp,PNGAPI
|
||||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||||
{
|
{
|
||||||
png_voidp ret;
|
png_voidp ret;
|
||||||
|
|
||||||
ret = (png_malloc(png_ptr, size));
|
ret = png_malloc(png_ptr, size);
|
||||||
|
|
||||||
if (ret != NULL)
|
if (ret != NULL)
|
||||||
png_memset(ret,0,(png_size_t)size);
|
memset(ret, 0, size);
|
||||||
|
|
||||||
return (ret);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of
|
||||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
* allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED.
|
||||||
|
* Checking and error handling must happen outside this routine; it returns NULL
|
||||||
|
* if the allocation cannot be done (for any reason.)
|
||||||
|
*/
|
||||||
|
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||||
|
png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||||
|
PNG_ALLOCATED)
|
||||||
{
|
{
|
||||||
png_voidp ret;
|
/* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
|
||||||
|
* allocators have also been removed in 1.6.0, so any 16-bit system now has
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
* to implement a user memory handler. This checks to be sure it isn't
|
||||||
if (png_ptr == NULL || size == 0)
|
* called with big numbers.
|
||||||
return (NULL);
|
*/
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
if (png_ptr->malloc_fn != NULL)
|
PNG_UNUSED(png_ptr)
|
||||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
#endif
|
||||||
|
if (size > 0 && size <= PNG_SIZE_MAX
|
||||||
else
|
# ifdef PNG_MAX_MALLOC_64K
|
||||||
ret = (png_malloc_default(png_ptr, size));
|
&& size <= 65536U
|
||||||
|
# endif
|
||||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
)
|
||||||
png_error(png_ptr, "Out of Memory");
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ret;
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
if (png_ptr == NULL || size == 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
# ifdef PNG_MAX_MALLOC_64K
|
|
||||||
if (size > (png_uint_32)65536L)
|
|
||||||
{
|
{
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
|
||||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size);
|
||||||
|
|
||||||
else
|
else
|
||||||
# endif
|
#endif
|
||||||
return NULL;
|
return malloc((size_t)size); /* checked for truncation above */
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Check for overflow */
|
|
||||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
|
|
||||||
if (size != (unsigned long)size)
|
|
||||||
ret = NULL;
|
|
||||||
|
|
||||||
else
|
else
|
||||||
ret = farmalloc(size);
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
# else
|
/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
* that arises because of the checks in png_realloc_array that are repeated in
|
||||||
if (size != (unsigned long)size)
|
* png_malloc_array.
|
||||||
ret = NULL;
|
*/
|
||||||
|
static png_voidp
|
||||||
|
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||||
|
size_t element_size)
|
||||||
|
{
|
||||||
|
png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||||
|
|
||||||
else
|
if (req <= PNG_SIZE_MAX/element_size)
|
||||||
ret = halloc(size, 1);
|
return png_malloc_base(png_ptr, req * element_size);
|
||||||
|
|
||||||
# else
|
/* The failure case when the request is too large */
|
||||||
if (size != (size_t)size)
|
return NULL;
|
||||||
ret = NULL;
|
}
|
||||||
|
|
||||||
else
|
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||||
ret = malloc((size_t)size);
|
png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||||
# endif
|
size_t element_size),PNG_ALLOCATED)
|
||||||
# endif
|
{
|
||||||
|
if (nelements <= 0 || element_size == 0)
|
||||||
|
png_error(png_ptr, "internal error: array alloc");
|
||||||
|
|
||||||
# ifndef PNG_USER_MEM_SUPPORTED
|
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
}
|
||||||
png_error(png_ptr, "Out of Memory");
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return (ret);
|
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||||
|
png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
|
||||||
|
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||||
|
{
|
||||||
|
/* These are internal errors: */
|
||||||
|
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||||
|
(old_array == NULL && old_elements > 0))
|
||||||
|
png_error(png_ptr, "internal error: array realloc");
|
||||||
|
|
||||||
|
/* Check for overflow on the elements count (so the caller does not have to
|
||||||
|
* check.)
|
||||||
|
*/
|
||||||
|
if (add_elements <= INT_MAX - old_elements)
|
||||||
|
{
|
||||||
|
png_voidp new_array = png_malloc_array_checked(png_ptr,
|
||||||
|
old_elements+add_elements, element_size);
|
||||||
|
|
||||||
|
if (new_array != NULL)
|
||||||
|
{
|
||||||
|
/* Because png_malloc_array worked the size calculations below cannot
|
||||||
|
* overflow.
|
||||||
|
*/
|
||||||
|
if (old_elements > 0)
|
||||||
|
memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||||
|
|
||||||
|
memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||||
|
element_size*(unsigned)add_elements);
|
||||||
|
|
||||||
|
return new_array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL; /* error */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Various functions that have different error handling are derived from this.
|
||||||
|
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
|
||||||
|
* function png_malloc_default is also provided.
|
||||||
|
*/
|
||||||
|
PNG_FUNCTION(png_voidp,PNGAPI
|
||||||
|
png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||||
|
{
|
||||||
|
png_voidp ret;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ret = png_malloc_base(png_ptr, size);
|
||||||
|
|
||||||
|
if (ret == NULL)
|
||||||
|
png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
PNG_FUNCTION(png_voidp,PNGAPI
|
||||||
|
png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||||
|
PNG_ALLOCATED PNG_DEPRECATED)
|
||||||
|
{
|
||||||
|
png_voidp ret;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Passing 'NULL' here bypasses the application provided memory handler. */
|
||||||
|
ret = png_malloc_base(NULL/*use malloc*/, size);
|
||||||
|
|
||||||
|
if (ret == NULL)
|
||||||
|
png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
|
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||||
|
* function will issue a png_warning and return NULL instead of issuing a
|
||||||
|
* png_error, if it fails to allocate the requested memory.
|
||||||
|
*/
|
||||||
|
PNG_FUNCTION(png_voidp,PNGAPI
|
||||||
|
png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||||
|
PNG_ALLOCATED)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
png_voidp ret = png_malloc_base(png_ptr, size);
|
||||||
|
|
||||||
|
if (ret != NULL)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
png_warning(png_ptr, "Out of memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||||
* without taking any action.
|
* without taking any action.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_free(png_structp png_ptr, png_voidp ptr)
|
png_free(png_const_structrp png_ptr, png_voidp ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL || ptr == NULL)
|
if (png_ptr == NULL || ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
# ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
if (png_ptr->free_fn != NULL)
|
if (png_ptr->free_fn != NULL)
|
||||||
{
|
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
|
||||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
png_free_default(png_ptr, ptr);
|
png_free_default(png_ptr, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PNGAPI
|
PNG_FUNCTION(void,PNGAPI
|
||||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL || ptr == NULL)
|
if (png_ptr == NULL || ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
|
||||||
|
|
||||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
|
||||||
farfree(ptr);
|
|
||||||
|
|
||||||
# else
|
|
||||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
|
||||||
hfree(ptr);
|
|
||||||
|
|
||||||
# else
|
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
#endif /* Not Borland DOS special memory handler */
|
|
||||||
|
|
||||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
|
||||||
* function will set up png_malloc() to issue a png_warning and return NULL
|
|
||||||
* instead of issuing a png_error, if it fails to allocate the requested
|
|
||||||
* memory.
|
|
||||||
*/
|
|
||||||
PNG_FUNCTION(png_voidp,PNGAPI
|
|
||||||
png_malloc_warn,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
|
||||||
{
|
|
||||||
png_voidp ptr;
|
|
||||||
png_uint_32 save_flags;
|
|
||||||
if (png_ptr == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
save_flags = png_ptr->flags;
|
|
||||||
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
|
||||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
|
||||||
png_ptr->flags=save_flags;
|
|
||||||
return(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
/* This function is called when the application wants to use another method
|
/* This function is called when the application wants to use another method
|
||||||
* of allocating and freeing memory.
|
* of allocating and freeing memory.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||||
malloc_fn, png_free_ptr free_fn)
|
malloc_fn, png_free_ptr free_fn)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
|
@ -656,12 +266,12 @@ 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.
|
* pointer before png_write_destroy and png_read_destroy are called.
|
||||||
*/
|
*/
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_mem_ptr(png_const_structp png_ptr)
|
png_get_mem_ptr(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return (NULL);
|
return NULL;
|
||||||
|
|
||||||
return ((png_voidp)png_ptr->mem_ptr);
|
return png_ptr->mem_ptr;
|
||||||
}
|
}
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngpread.c - read a png file in push mode
|
/* pngpread.c - read a png file in push mode
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.11 [June 14, 2012]
|
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
#define PNG_ERROR_MODE 8
|
#define PNG_ERROR_MODE 8
|
||||||
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_process_data(png_structp png_ptr, png_infop info_ptr,
|
png_process_data(png_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_bytep buffer, png_size_t buffer_size)
|
png_bytep buffer, png_size_t buffer_size)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
|
@ -42,7 +42,7 @@ png_process_data(png_structp png_ptr, png_infop info_ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
png_size_t PNGAPI
|
png_size_t PNGAPI
|
||||||
png_process_data_pause(png_structp png_ptr, int save)
|
png_process_data_pause(png_structrp png_ptr, int save)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ png_process_data_pause(png_structp png_ptr, int save)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_process_data_skip(png_structp png_ptr)
|
png_process_data_skip(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_uint_32 remaining = 0;
|
png_uint_32 remaining = 0;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ png_process_data_skip(png_structp png_ptr)
|
||||||
* doing before we ran out of data...
|
* doing before we ran out of data...
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -149,10 +149,10 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||||
* routine.
|
* routine.
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
{
|
{
|
||||||
png_size_t num_checked = png_ptr->sig_bytes,
|
png_size_t num_checked = png_ptr->sig_bytes,
|
||||||
num_to_check = 8 - num_checked;
|
num_to_check = 8 - num_checked;
|
||||||
|
|
||||||
if (png_ptr->buffer_size < num_to_check)
|
if (png_ptr->buffer_size < num_to_check)
|
||||||
{
|
{
|
||||||
|
@ -172,7 +172,6 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||||
else
|
else
|
||||||
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (png_ptr->sig_bytes >= 8)
|
if (png_ptr->sig_bytes >= 8)
|
||||||
|
@ -183,9 +182,12 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
{
|
{
|
||||||
png_uint_32 chunk_name;
|
png_uint_32 chunk_name;
|
||||||
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
|
int keep; /* unknown handling method */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* First we make sure we have enough data for the 4 byte chunk name
|
/* First we make sure we have enough data for the 4 byte chunk name
|
||||||
* and the 4 byte chunk length before proceeding with decoding the
|
* and the 4 byte chunk length before proceeding with decoding the
|
||||||
|
@ -217,14 +219,28 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
|
||||||
if (chunk_name == png_IDAT)
|
if (chunk_name == png_IDAT)
|
||||||
{
|
{
|
||||||
/* This is here above the if/else case statement below because if the
|
|
||||||
* unknown handling marks 'IDAT' as unknown then the IDAT handling case is
|
|
||||||
* completely skipped.
|
|
||||||
*
|
|
||||||
* TODO: there must be a better way of doing this.
|
|
||||||
*/
|
|
||||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||||
|
|
||||||
|
/* If we reach an IDAT chunk, this means we have read all of the
|
||||||
|
* header chunks, and we can start reading the image (or if this
|
||||||
|
* is called after the image has been read - we have an error).
|
||||||
|
*/
|
||||||
|
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||||
|
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||||
|
|
||||||
|
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||||
|
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||||
|
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||||
|
|
||||||
|
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||||
|
|
||||||
|
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||||
|
if (png_ptr->push_length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||||
|
png_benign_error(png_ptr, "Too many IDATs found");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunk_name == png_IHDR)
|
if (chunk_name == png_IHDR)
|
||||||
|
@ -256,7 +272,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
else if (png_chunk_unknown_handling(png_ptr, chunk_name))
|
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||||
{
|
{
|
||||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||||
{
|
{
|
||||||
|
@ -264,26 +280,13 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunk_name == png_IDAT)
|
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);
|
||||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
|
||||||
|
|
||||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
|
|
||||||
|
|
||||||
if (chunk_name == png_PLTE)
|
if (chunk_name == png_PLTE)
|
||||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||||
|
|
||||||
else if (chunk_name == png_IDAT)
|
|
||||||
{
|
|
||||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
|
||||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
|
||||||
|
|
||||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
|
||||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
|
||||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif
|
||||||
else if (chunk_name == png_PLTE)
|
else if (chunk_name == png_PLTE)
|
||||||
{
|
{
|
||||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||||
|
@ -296,30 +299,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
|
||||||
else if (chunk_name == png_IDAT)
|
else if (chunk_name == png_IDAT)
|
||||||
{
|
{
|
||||||
/* If we reach an IDAT chunk, this means we have read all of the
|
|
||||||
* header chunks, and we can start reading the image (or if this
|
|
||||||
* is called after the image has been read - we have an error).
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
|
||||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
|
||||||
|
|
||||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
|
||||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
|
||||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
|
||||||
|
|
||||||
if (png_ptr->mode & PNG_HAVE_IDAT)
|
|
||||||
{
|
|
||||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
|
||||||
if (png_ptr->push_length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
|
||||||
png_benign_error(png_ptr, "Too many IDATs found");
|
|
||||||
}
|
|
||||||
|
|
||||||
png_ptr->idat_size = png_ptr->push_length;
|
png_ptr->idat_size = png_ptr->push_length;
|
||||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
|
||||||
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
||||||
png_push_have_info(png_ptr, info_ptr);
|
png_push_have_info(png_ptr, info_ptr);
|
||||||
png_ptr->zstream.avail_out =
|
png_ptr->zstream.avail_out =
|
||||||
|
@ -550,7 +530,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||||
|
@ -558,21 +537,22 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||||
png_push_save_buffer(png_ptr);
|
png_push_save_buffer(png_ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
|
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
|
||||||
|
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_crc_skip(png_structp png_ptr, png_uint_32 skip)
|
png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)
|
||||||
{
|
{
|
||||||
png_ptr->process_mode = PNG_SKIP_MODE;
|
png_ptr->process_mode = PNG_SKIP_MODE;
|
||||||
png_ptr->skip_length = skip;
|
png_ptr->skip_length = skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_crc_finish(png_structp png_ptr)
|
png_push_crc_finish(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr->skip_length && png_ptr->save_buffer_size)
|
if (png_ptr->skip_length && png_ptr->save_buffer_size)
|
||||||
{
|
{
|
||||||
|
@ -598,7 +578,6 @@ png_push_crc_finish(png_structp png_ptr)
|
||||||
png_ptr->save_buffer_size -= save_size;
|
png_ptr->save_buffer_size -= save_size;
|
||||||
png_ptr->save_buffer_ptr += save_size;
|
png_ptr->save_buffer_ptr += save_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr->skip_length && png_ptr->current_buffer_size)
|
if (png_ptr->skip_length && png_ptr->current_buffer_size)
|
||||||
{
|
{
|
||||||
png_size_t save_size = png_ptr->current_buffer_size;
|
png_size_t save_size = png_ptr->current_buffer_size;
|
||||||
|
@ -620,7 +599,6 @@ png_push_crc_finish(png_structp png_ptr)
|
||||||
png_ptr->current_buffer_size -= save_size;
|
png_ptr->current_buffer_size -= save_size;
|
||||||
png_ptr->current_buffer_ptr += save_size;
|
png_ptr->current_buffer_ptr += save_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!png_ptr->skip_length)
|
if (!png_ptr->skip_length)
|
||||||
{
|
{
|
||||||
if (png_ptr->buffer_size < 4)
|
if (png_ptr->buffer_size < 4)
|
||||||
|
@ -643,7 +621,6 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
|
|
||||||
if (png_ptr->save_buffer_size)
|
if (png_ptr->save_buffer_size)
|
||||||
{
|
{
|
||||||
png_size_t save_size;
|
png_size_t save_size;
|
||||||
|
@ -654,14 +631,13 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||||
else
|
else
|
||||||
save_size = png_ptr->save_buffer_size;
|
save_size = png_ptr->save_buffer_size;
|
||||||
|
|
||||||
png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
|
memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
|
||||||
length -= save_size;
|
length -= save_size;
|
||||||
ptr += save_size;
|
ptr += save_size;
|
||||||
png_ptr->buffer_size -= save_size;
|
png_ptr->buffer_size -= save_size;
|
||||||
png_ptr->save_buffer_size -= save_size;
|
png_ptr->save_buffer_size -= save_size;
|
||||||
png_ptr->save_buffer_ptr += save_size;
|
png_ptr->save_buffer_ptr += save_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length && png_ptr->current_buffer_size)
|
if (length && png_ptr->current_buffer_size)
|
||||||
{
|
{
|
||||||
png_size_t save_size;
|
png_size_t save_size;
|
||||||
|
@ -672,7 +648,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||||
else
|
else
|
||||||
save_size = png_ptr->current_buffer_size;
|
save_size = png_ptr->current_buffer_size;
|
||||||
|
|
||||||
png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
|
memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
|
||||||
png_ptr->buffer_size -= save_size;
|
png_ptr->buffer_size -= save_size;
|
||||||
png_ptr->current_buffer_size -= save_size;
|
png_ptr->current_buffer_size -= save_size;
|
||||||
png_ptr->current_buffer_ptr += save_size;
|
png_ptr->current_buffer_ptr += save_size;
|
||||||
|
@ -680,7 +656,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_save_buffer(png_structp png_ptr)
|
png_push_save_buffer(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr->save_buffer_size)
|
if (png_ptr->save_buffer_size)
|
||||||
{
|
{
|
||||||
|
@ -691,7 +667,6 @@ png_push_save_buffer(png_structp png_ptr)
|
||||||
png_bytep dp;
|
png_bytep dp;
|
||||||
|
|
||||||
istop = png_ptr->save_buffer_size;
|
istop = png_ptr->save_buffer_size;
|
||||||
|
|
||||||
for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
|
for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
|
||||||
i < istop; i++, sp++, dp++)
|
i < istop; i++, sp++, dp++)
|
||||||
{
|
{
|
||||||
|
@ -699,7 +674,6 @@ png_push_save_buffer(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr->save_buffer_size + png_ptr->current_buffer_size >
|
if (png_ptr->save_buffer_size + png_ptr->current_buffer_size >
|
||||||
png_ptr->save_buffer_max)
|
png_ptr->save_buffer_max)
|
||||||
{
|
{
|
||||||
|
@ -714,7 +688,8 @@ png_push_save_buffer(png_structp png_ptr)
|
||||||
|
|
||||||
new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
|
new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
|
||||||
old_buffer = png_ptr->save_buffer;
|
old_buffer = png_ptr->save_buffer;
|
||||||
png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr, new_max);
|
png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr,
|
||||||
|
(png_size_t)new_max);
|
||||||
|
|
||||||
if (png_ptr->save_buffer == NULL)
|
if (png_ptr->save_buffer == NULL)
|
||||||
{
|
{
|
||||||
|
@ -722,25 +697,23 @@ png_push_save_buffer(png_structp png_ptr)
|
||||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||||
png_free(png_ptr, old_buffer);
|
png_free(png_ptr, old_buffer);
|
||||||
png_ptr->save_buffer_max = new_max;
|
png_ptr->save_buffer_max = new_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr->current_buffer_size)
|
if (png_ptr->current_buffer_size)
|
||||||
{
|
{
|
||||||
png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
|
memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
|
||||||
png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);
|
png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);
|
||||||
png_ptr->save_buffer_size += png_ptr->current_buffer_size;
|
png_ptr->save_buffer_size += png_ptr->current_buffer_size;
|
||||||
png_ptr->current_buffer_size = 0;
|
png_ptr->current_buffer_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_ptr->save_buffer_ptr = png_ptr->save_buffer;
|
png_ptr->save_buffer_ptr = png_ptr->save_buffer;
|
||||||
png_ptr->buffer_size = 0;
|
png_ptr->buffer_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
|
png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,
|
||||||
png_size_t buffer_length)
|
png_size_t buffer_length)
|
||||||
{
|
{
|
||||||
png_ptr->current_buffer = buffer;
|
png_ptr->current_buffer = buffer;
|
||||||
|
@ -750,7 +723,7 @@ png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_read_IDAT(png_structp png_ptr)
|
png_push_read_IDAT(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
||||||
{
|
{
|
||||||
|
@ -775,7 +748,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||||
|
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||||
png_error(png_ptr, "Not enough compressed data");
|
png_error(png_ptr, "Not enough compressed data");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -836,7 +809,6 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||||
png_ptr->current_buffer_size -= save_size;
|
png_ptr->current_buffer_size -= save_size;
|
||||||
png_ptr->current_buffer_ptr += save_size;
|
png_ptr->current_buffer_ptr += save_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!png_ptr->idat_size)
|
if (!png_ptr->idat_size)
|
||||||
{
|
{
|
||||||
if (png_ptr->buffer_size < 4)
|
if (png_ptr->buffer_size < 4)
|
||||||
|
@ -848,11 +820,12 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||||
png_crc_finish(png_ptr, 0);
|
png_crc_finish(png_ptr, 0);
|
||||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||||
|
png_ptr->zowner = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
||||||
png_size_t buffer_length)
|
png_size_t buffer_length)
|
||||||
{
|
{
|
||||||
/* The caller checks for a non-zero buffer length. */
|
/* The caller checks for a non-zero buffer length. */
|
||||||
|
@ -864,13 +837,14 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||||
* handle the uncompressed results.
|
* handle the uncompressed results.
|
||||||
*/
|
*/
|
||||||
png_ptr->zstream.next_in = buffer;
|
png_ptr->zstream.next_in = buffer;
|
||||||
|
/* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */
|
||||||
png_ptr->zstream.avail_in = (uInt)buffer_length;
|
png_ptr->zstream.avail_in = (uInt)buffer_length;
|
||||||
|
|
||||||
/* Keep going until the decompressed data is all processed
|
/* Keep going until the decompressed data is all processed
|
||||||
* or the stream marked as finished.
|
* or the stream marked as finished.
|
||||||
*/
|
*/
|
||||||
while (png_ptr->zstream.avail_in > 0 &&
|
while (png_ptr->zstream.avail_in > 0 &&
|
||||||
!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -881,9 +855,9 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||||
*/
|
*/
|
||||||
if (!(png_ptr->zstream.avail_out > 0))
|
if (!(png_ptr->zstream.avail_out > 0))
|
||||||
{
|
{
|
||||||
png_ptr->zstream.avail_out =
|
/* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */
|
||||||
(uInt) PNG_ROWBYTES(png_ptr->pixel_depth,
|
png_ptr->zstream.avail_out = (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth,
|
||||||
png_ptr->iwidth) + 1;
|
png_ptr->iwidth) + 1);
|
||||||
|
|
||||||
png_ptr->zstream.next_out = png_ptr->row_buf;
|
png_ptr->zstream.next_out = png_ptr->row_buf;
|
||||||
}
|
}
|
||||||
|
@ -901,7 +875,8 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||||
if (ret != Z_OK && ret != Z_STREAM_END)
|
if (ret != Z_OK && ret != Z_STREAM_END)
|
||||||
{
|
{
|
||||||
/* Terminate the decompression. */
|
/* Terminate the decompression. */
|
||||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||||
|
png_ptr->zowner = 0;
|
||||||
|
|
||||||
/* This may be a truncated stream (missing or
|
/* This may be a truncated stream (missing or
|
||||||
* damaged end code). Treat that as a warning.
|
* damaged end code). Treat that as a warning.
|
||||||
|
@ -929,7 +904,8 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||||
{
|
{
|
||||||
/* Extra data. */
|
/* Extra data. */
|
||||||
png_warning(png_ptr, "Extra compressed data in IDAT");
|
png_warning(png_ptr, "Extra compressed data in IDAT");
|
||||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||||
|
png_ptr->zowner = 0;
|
||||||
|
|
||||||
/* Do no more processing; skip the unprocessed
|
/* Do no more processing; skip the unprocessed
|
||||||
* input check below.
|
* input check below.
|
||||||
|
@ -944,7 +920,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||||
|
|
||||||
/* And check for the end of the stream. */
|
/* And check for the end of the stream. */
|
||||||
if (ret == Z_STREAM_END)
|
if (ret == Z_STREAM_END)
|
||||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All the data should have been processed, if anything
|
/* All the data should have been processed, if anything
|
||||||
|
@ -956,7 +932,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_process_row(png_structp png_ptr)
|
png_push_process_row(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
/* 1.5.6: row_info moved out of png_struct to a local here. */
|
/* 1.5.6: row_info moved out of png_struct to a local here. */
|
||||||
png_row_info row_info;
|
png_row_info row_info;
|
||||||
|
@ -982,7 +958,7 @@ png_push_process_row(png_structp png_ptr)
|
||||||
* it may not be in the future, so this was changed just to copy the
|
* it may not be in the future, so this was changed just to copy the
|
||||||
* interlaced row count:
|
* interlaced row count:
|
||||||
*/
|
*/
|
||||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||||
|
|
||||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||||
if (png_ptr->transformations)
|
if (png_ptr->transformations)
|
||||||
|
@ -1185,26 +1161,26 @@ png_push_process_row(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_read_push_finish_row(png_structp png_ptr)
|
png_read_push_finish_row(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
|
|
||||||
/* Start of interlace block */
|
/* Start of interlace block */
|
||||||
static PNG_CONST png_byte FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||||
|
|
||||||
/* Offset to next interlace block */
|
/* Offset to next interlace block */
|
||||||
static PNG_CONST png_byte FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
|
|
||||||
/* Start of interlace block in the y direction */
|
/* Start of interlace block in the y direction */
|
||||||
static PNG_CONST png_byte FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||||
|
|
||||||
/* Offset to next interlace block in the y direction */
|
/* Offset to next interlace block in the y direction */
|
||||||
static PNG_CONST png_byte FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
|
||||||
/* Height of interlace block. This is not currently used - if you need
|
/* Height of interlace block. This is not currently used - if you need
|
||||||
* it, uncomment it here and in png.h
|
* it, uncomment it here and in png.h
|
||||||
static PNG_CONST png_byte FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1216,7 +1192,7 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||||
if (png_ptr->interlaced)
|
if (png_ptr->interlaced)
|
||||||
{
|
{
|
||||||
png_ptr->row_number = 0;
|
png_ptr->row_number = 0;
|
||||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -1251,21 +1227,21 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_have_info(png_structp png_ptr, png_infop info_ptr)
|
png_push_have_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr->info_fn != NULL)
|
if (png_ptr->info_fn != NULL)
|
||||||
(*(png_ptr->info_fn))(png_ptr, info_ptr);
|
(*(png_ptr->info_fn))(png_ptr, info_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_have_end(png_structp png_ptr, png_infop info_ptr)
|
png_push_have_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr->end_fn != NULL)
|
if (png_ptr->end_fn != NULL)
|
||||||
(*(png_ptr->end_fn))(png_ptr, info_ptr);
|
(*(png_ptr->end_fn))(png_ptr, info_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_push_have_row(png_structp png_ptr, png_bytep row)
|
png_push_have_row(png_structrp png_ptr, png_bytep row)
|
||||||
{
|
{
|
||||||
if (png_ptr->row_fn != NULL)
|
if (png_ptr->row_fn != NULL)
|
||||||
(*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number,
|
(*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number,
|
||||||
|
@ -1274,7 +1250,7 @@ png_push_have_row(png_structp png_ptr, png_bytep row)
|
||||||
|
|
||||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_progressive_combine_row (png_structp png_ptr, png_bytep old_row,
|
png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
|
||||||
png_const_bytep new_row)
|
png_const_bytep new_row)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
|
@ -1290,7 +1266,7 @@ png_progressive_combine_row (png_structp png_ptr, png_bytep old_row,
|
||||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||||
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,
|
||||||
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
|
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
|
||||||
png_progressive_end_ptr end_fn)
|
png_progressive_end_ptr end_fn)
|
||||||
{
|
{
|
||||||
|
@ -1305,7 +1281,7 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_progressive_ptr(png_const_structp png_ptr)
|
png_get_progressive_ptr(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
1373
src/libpng/pngpriv.h
1373
src/libpng/pngpriv.h
File diff suppressed because it is too large
Load Diff
3395
src/libpng/pngread.c
3395
src/libpng/pngread.c
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngrio.c - functions for data input
|
/* pngrio.c - functions for data input
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
* to read more then 64K on a 16 bit machine.
|
* to read more then 64K on a 16 bit machine.
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
png_debug1(4, "reading %d bytes", (int)length);
|
png_debug1(4, "reading %d bytes", (int)length);
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
* read_data function and use it at run time with png_set_read_fn(), rather
|
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||||
* than changing the library.
|
* than changing the library.
|
||||||
*/
|
*/
|
||||||
# ifndef USE_FAR_KEYWORD
|
|
||||||
void PNGCBAPI
|
void PNGCBAPI
|
||||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
|
@ -58,68 +57,11 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||||
* instead of an int, which is what fread() actually returns.
|
* instead of an int, which is what fread() actually returns.
|
||||||
*/
|
*/
|
||||||
check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr);
|
check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
|
||||||
|
|
||||||
if (check != length)
|
if (check != length)
|
||||||
png_error(png_ptr, "Read Error");
|
png_error(png_ptr, "Read Error");
|
||||||
}
|
}
|
||||||
# else
|
|
||||||
/* This is the model-independent version. Since the standard I/O library
|
|
||||||
can't handle far buffers in the medium and small models, we have to copy
|
|
||||||
the data.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define NEAR_BUF_SIZE 1024
|
|
||||||
#define MIN(a,b) (a <= b ? a : b)
|
|
||||||
|
|
||||||
static void PNGCBAPI
|
|
||||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|
||||||
{
|
|
||||||
png_size_t check;
|
|
||||||
png_byte *n_data;
|
|
||||||
png_FILE_p io_ptr;
|
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Check if data really is near. If so, use usual code. */
|
|
||||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
|
||||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
|
||||||
|
|
||||||
if ((png_bytep)n_data == data)
|
|
||||||
{
|
|
||||||
check = fread(n_data, 1, length, io_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
png_byte buf[NEAR_BUF_SIZE];
|
|
||||||
png_size_t read, remaining, err;
|
|
||||||
check = 0;
|
|
||||||
remaining = length;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
|
||||||
err = fread(buf, 1, read, io_ptr);
|
|
||||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
|
||||||
|
|
||||||
if (err != read)
|
|
||||||
break;
|
|
||||||
|
|
||||||
else
|
|
||||||
check += err;
|
|
||||||
|
|
||||||
data += read;
|
|
||||||
remaining -= read;
|
|
||||||
}
|
|
||||||
while (remaining != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((png_uint_32)check != (png_uint_32)length)
|
|
||||||
png_error(png_ptr, "read Error");
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function allows the application to supply a new input function
|
/* This function allows the application to supply a new input function
|
||||||
|
@ -142,7 +84,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
* be used.
|
* be used.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||||
png_rw_ptr read_data_fn)
|
png_rw_ptr read_data_fn)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.14 [January 24, 2013]
|
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
|
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_crc_action");
|
png_debug(1, "in png_set_crc_action");
|
||||||
|
|
||||||
|
@ -88,16 +88,46 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||||
|
/* Is it OK to set a transformation now? Only if png_start_read_image or
|
||||||
|
* png_read_update_info have not been called. It is not necessary for the IHDR
|
||||||
|
* to have been read in all cases, the parameter allows for this check too.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
png_rtran_ok(png_structrp png_ptr, int need_IHDR)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
if (png_ptr->flags & PNG_FLAG_ROW_INIT)
|
||||||
|
png_app_error(png_ptr,
|
||||||
|
"invalid after png_start_read_image or png_read_update_info");
|
||||||
|
|
||||||
|
else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||||
|
png_app_error(png_ptr, "invalid before the PNG header has been read");
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Turn on failure to initialize correctly for all transforms. */
|
||||||
|
png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
|
||||||
|
|
||||||
|
return 1; /* Ok */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; /* no png_error possible! */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||||
/* Handle alpha and tRNS via a background color */
|
/* Handle alpha and tRNS via a background color */
|
||||||
void PNGFAPI
|
void PNGFAPI
|
||||||
png_set_background_fixed(png_structp png_ptr,
|
png_set_background_fixed(png_structrp png_ptr,
|
||||||
png_const_color_16p background_color, int background_gamma_code,
|
png_const_color_16p background_color, int background_gamma_code,
|
||||||
int need_expand, png_fixed_point background_gamma)
|
int need_expand, png_fixed_point background_gamma)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_background_fixed");
|
png_debug(1, "in png_set_background_fixed");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0) || background_color == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
||||||
|
@ -110,8 +140,7 @@ png_set_background_fixed(png_structp png_ptr,
|
||||||
png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
|
png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
|
||||||
png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
|
png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
|
||||||
|
|
||||||
png_memcpy(&(png_ptr->background), background_color,
|
png_ptr->background = *background_color;
|
||||||
png_sizeof(png_color_16));
|
|
||||||
png_ptr->background_gamma = background_gamma;
|
png_ptr->background_gamma = background_gamma;
|
||||||
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
|
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
|
||||||
if (need_expand)
|
if (need_expand)
|
||||||
|
@ -122,7 +151,7 @@ png_set_background_fixed(png_structp png_ptr,
|
||||||
|
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_background(png_structp png_ptr,
|
png_set_background(png_structrp png_ptr,
|
||||||
png_const_color_16p background_color, int background_gamma_code,
|
png_const_color_16p background_color, int background_gamma_code,
|
||||||
int need_expand, double background_gamma)
|
int need_expand, double background_gamma)
|
||||||
{
|
{
|
||||||
|
@ -138,11 +167,11 @@ png_set_background(png_structp png_ptr,
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_scale_16(png_structp png_ptr)
|
png_set_scale_16(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_scale_16");
|
png_debug(1, "in png_set_scale_16");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= PNG_SCALE_16_TO_8;
|
png_ptr->transformations |= PNG_SCALE_16_TO_8;
|
||||||
|
@ -152,11 +181,11 @@ png_set_scale_16(png_structp png_ptr)
|
||||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||||
/* Chop 16-bit depth files to 8-bit depth */
|
/* Chop 16-bit depth files to 8-bit depth */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_strip_16(png_structp png_ptr)
|
png_set_strip_16(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_strip_16");
|
png_debug(1, "in png_set_strip_16");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= PNG_16_TO_8;
|
png_ptr->transformations |= PNG_16_TO_8;
|
||||||
|
@ -165,11 +194,11 @@ png_set_strip_16(png_structp png_ptr)
|
||||||
|
|
||||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_strip_alpha(png_structp png_ptr)
|
png_set_strip_alpha(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_strip_alpha");
|
png_debug(1, "in png_set_strip_alpha");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||||
|
@ -178,7 +207,7 @@ png_set_strip_alpha(png_structp png_ptr)
|
||||||
|
|
||||||
#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
|
#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
|
||||||
static png_fixed_point
|
static png_fixed_point
|
||||||
translate_gamma_flags(png_structp png_ptr, png_fixed_point output_gamma,
|
translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma,
|
||||||
int is_screen)
|
int is_screen)
|
||||||
{
|
{
|
||||||
/* Check for flag values. The main reason for having the old Mac value as a
|
/* Check for flag values. The main reason for having the old Mac value as a
|
||||||
|
@ -215,7 +244,7 @@ translate_gamma_flags(png_structp png_ptr, png_fixed_point output_gamma,
|
||||||
|
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
static png_fixed_point
|
static png_fixed_point
|
||||||
convert_gamma_value(png_structp png_ptr, double output_gamma)
|
convert_gamma_value(png_structrp png_ptr, double output_gamma)
|
||||||
{
|
{
|
||||||
/* The following silently ignores cases where fixed point (times 100,000)
|
/* The following silently ignores cases where fixed point (times 100,000)
|
||||||
* gamma values are passed to the floating point API. This is safe and it
|
* gamma values are passed to the floating point API. This is safe and it
|
||||||
|
@ -240,7 +269,7 @@ convert_gamma_value(png_structp png_ptr, double output_gamma)
|
||||||
|
|
||||||
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||||
void PNGFAPI
|
void PNGFAPI
|
||||||
png_set_alpha_mode_fixed(png_structp png_ptr, int mode,
|
png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||||
png_fixed_point output_gamma)
|
png_fixed_point output_gamma)
|
||||||
{
|
{
|
||||||
int compose = 0;
|
int compose = 0;
|
||||||
|
@ -248,7 +277,7 @@ png_set_alpha_mode_fixed(png_structp png_ptr, int mode,
|
||||||
|
|
||||||
png_debug(1, "in png_set_alpha_mode");
|
png_debug(1, "in png_set_alpha_mode");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
|
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
|
||||||
|
@ -320,8 +349,11 @@ png_set_alpha_mode_fixed(png_structp png_ptr, int mode,
|
||||||
* the side effect that the gamma in a second call to png_set_alpha_mode will
|
* the side effect that the gamma in a second call to png_set_alpha_mode will
|
||||||
* be ignored.)
|
* be ignored.)
|
||||||
*/
|
*/
|
||||||
if (png_ptr->gamma == 0)
|
if (png_ptr->colorspace.gamma == 0)
|
||||||
png_ptr->gamma = file_gamma;
|
{
|
||||||
|
png_ptr->colorspace.gamma = file_gamma;
|
||||||
|
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||||
|
}
|
||||||
|
|
||||||
/* But always set the output gamma: */
|
/* But always set the output gamma: */
|
||||||
png_ptr->screen_gamma = output_gamma;
|
png_ptr->screen_gamma = output_gamma;
|
||||||
|
@ -332,8 +364,8 @@ png_set_alpha_mode_fixed(png_structp png_ptr, int mode,
|
||||||
if (compose)
|
if (compose)
|
||||||
{
|
{
|
||||||
/* And obtain alpha pre-multiplication by composing on black: */
|
/* And obtain alpha pre-multiplication by composing on black: */
|
||||||
png_memset(&png_ptr->background, 0, sizeof png_ptr->background);
|
memset(&png_ptr->background, 0, (sizeof png_ptr->background));
|
||||||
png_ptr->background_gamma = png_ptr->gamma; /* just in case */
|
png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */
|
||||||
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
|
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
|
||||||
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
|
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
|
||||||
|
|
||||||
|
@ -343,14 +375,11 @@ png_set_alpha_mode_fixed(png_structp png_ptr, int mode,
|
||||||
|
|
||||||
png_ptr->transformations |= PNG_COMPOSE;
|
png_ptr->transformations |= PNG_COMPOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* New API, make sure apps call the correct initializers: */
|
|
||||||
png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_alpha_mode(png_structp png_ptr, int mode, double output_gamma)
|
png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)
|
||||||
{
|
{
|
||||||
png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,
|
png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,
|
||||||
output_gamma));
|
output_gamma));
|
||||||
|
@ -370,21 +399,21 @@ png_set_alpha_mode(png_structp png_ptr, int mode, double output_gamma)
|
||||||
|
|
||||||
typedef struct png_dsort_struct
|
typedef struct png_dsort_struct
|
||||||
{
|
{
|
||||||
struct png_dsort_struct FAR * next;
|
struct png_dsort_struct * next;
|
||||||
png_byte left;
|
png_byte left;
|
||||||
png_byte right;
|
png_byte right;
|
||||||
} png_dsort;
|
} png_dsort;
|
||||||
typedef png_dsort FAR * png_dsortp;
|
typedef png_dsort * png_dsortp;
|
||||||
typedef png_dsort FAR * FAR * png_dsortpp;
|
typedef png_dsort * * png_dsortpp;
|
||||||
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_quantize(png_structp png_ptr, png_colorp palette,
|
png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||||
int num_palette, int maximum_colors, png_const_uint_16p histogram,
|
int num_palette, int maximum_colors, png_const_uint_16p histogram,
|
||||||
int full_quantize)
|
int full_quantize)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_quantize");
|
png_debug(1, "in png_set_quantize");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= PNG_QUANTIZE;
|
png_ptr->transformations |= PNG_QUANTIZE;
|
||||||
|
@ -394,7 +423,7 @@ png_set_quantize(png_structp png_ptr, png_colorp palette,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
png_ptr->quantize_index[i] = (png_byte)i;
|
png_ptr->quantize_index[i] = (png_byte)i;
|
||||||
}
|
}
|
||||||
|
@ -411,7 +440,7 @@ png_set_quantize(png_structp png_ptr, png_colorp palette,
|
||||||
|
|
||||||
/* Initialize an array to sort colors */
|
/* Initialize an array to sort colors */
|
||||||
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||||
|
|
||||||
/* Initialize the quantize_sort array */
|
/* Initialize the quantize_sort array */
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
|
@ -545,9 +574,9 @@ png_set_quantize(png_structp png_ptr, png_colorp palette,
|
||||||
|
|
||||||
/* Initialize palette index arrays */
|
/* Initialize palette index arrays */
|
||||||
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||||
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||||
|
|
||||||
/* Initialize the sort array */
|
/* Initialize the sort array */
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
|
@ -557,7 +586,7 @@ png_set_quantize(png_structp png_ptr, png_colorp palette,
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
|
hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
|
||||||
png_sizeof(png_dsortp)));
|
(sizeof (png_dsortp))));
|
||||||
|
|
||||||
num_new_palette = num_palette;
|
num_new_palette = num_palette;
|
||||||
|
|
||||||
|
@ -587,7 +616,7 @@ png_set_quantize(png_structp png_ptr, png_colorp palette,
|
||||||
{
|
{
|
||||||
|
|
||||||
t = (png_dsortp)png_malloc_warn(png_ptr,
|
t = (png_dsortp)png_malloc_warn(png_ptr,
|
||||||
(png_uint_32)(png_sizeof(png_dsort)));
|
(png_uint_32)(sizeof (png_dsort)));
|
||||||
|
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
break;
|
break;
|
||||||
|
@ -712,12 +741,12 @@ png_set_quantize(png_structp png_ptr, png_colorp palette,
|
||||||
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
||||||
|
|
||||||
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
|
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
|
||||||
(png_uint_32)(num_entries * png_sizeof(png_byte)));
|
(png_uint_32)(num_entries * (sizeof (png_byte))));
|
||||||
|
|
||||||
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
||||||
png_sizeof(png_byte)));
|
(sizeof (png_byte))));
|
||||||
|
|
||||||
png_memset(distance, 0xff, num_entries * png_sizeof(png_byte));
|
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
||||||
|
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
{
|
{
|
||||||
|
@ -766,19 +795,18 @@ png_set_quantize(png_structp png_ptr, png_colorp palette,
|
||||||
|
|
||||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||||
void PNGFAPI
|
void PNGFAPI
|
||||||
png_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma,
|
png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
||||||
png_fixed_point file_gamma)
|
png_fixed_point file_gamma)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_gamma_fixed");
|
png_debug(1, "in png_set_gamma_fixed");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
|
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
|
||||||
scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);
|
scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);
|
||||||
file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);
|
file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);
|
||||||
|
|
||||||
#if PNG_LIBPNG_VER >= 10600
|
|
||||||
/* Checking the gamma values for being >0 was added in 1.5.4 along with the
|
/* Checking the gamma values for being >0 was added in 1.5.4 along with the
|
||||||
* premultiplied alpha support; this actually hides an undocumented feature
|
* premultiplied alpha support; this actually hides an undocumented feature
|
||||||
* of the previous implementation which allowed gamma processing to be
|
* of the previous implementation which allowed gamma processing to be
|
||||||
|
@ -787,26 +815,27 @@ png_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma,
|
||||||
* accept '0' for the gamma value it takes, because it isn't always used.
|
* accept '0' for the gamma value it takes, because it isn't always used.
|
||||||
*
|
*
|
||||||
* Since this is an API change (albeit a very minor one that removes an
|
* Since this is an API change (albeit a very minor one that removes an
|
||||||
* undocumented API feature) it will not be made until libpng-1.6.0.
|
* undocumented API feature) the following checks were only enabled in
|
||||||
|
* libpng-1.6.0.
|
||||||
*/
|
*/
|
||||||
if (file_gamma <= 0)
|
if (file_gamma <= 0)
|
||||||
png_error(png_ptr, "invalid file gamma in png_set_gamma");
|
png_error(png_ptr, "invalid file gamma in png_set_gamma");
|
||||||
|
|
||||||
if (scrn_gamma <= 0)
|
if (scrn_gamma <= 0)
|
||||||
png_error(png_ptr, "invalid screen gamma in png_set_gamma");
|
png_error(png_ptr, "invalid screen gamma in png_set_gamma");
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set the gamma values unconditionally - this overrides the value in the PNG
|
/* Set the gamma values unconditionally - this overrides the value in the PNG
|
||||||
* file if a gAMA chunk was present. png_set_alpha_mode provides a
|
* file if a gAMA chunk was present. png_set_alpha_mode provides a
|
||||||
* different, easier, way to default the file gamma.
|
* different, easier, way to default the file gamma.
|
||||||
*/
|
*/
|
||||||
png_ptr->gamma = file_gamma;
|
png_ptr->colorspace.gamma = file_gamma;
|
||||||
|
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||||
png_ptr->screen_gamma = scrn_gamma;
|
png_ptr->screen_gamma = scrn_gamma;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma)
|
||||||
{
|
{
|
||||||
png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
|
png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
|
||||||
convert_gamma_value(png_ptr, file_gamma));
|
convert_gamma_value(png_ptr, file_gamma));
|
||||||
|
@ -820,15 +849,14 @@ png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
||||||
* to alpha channels.
|
* to alpha channels.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_expand(png_structp png_ptr)
|
png_set_expand(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_expand");
|
png_debug(1, "in png_set_expand");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GRR 19990627: the following three functions currently are identical
|
/* GRR 19990627: the following three functions currently are identical
|
||||||
|
@ -851,40 +879,38 @@ png_set_expand(png_structp png_ptr)
|
||||||
|
|
||||||
/* Expand paletted images to RGB. */
|
/* Expand paletted images to RGB. */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_palette_to_rgb(png_structp png_ptr)
|
png_set_palette_to_rgb(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_palette_to_rgb");
|
png_debug(1, "in png_set_palette_to_rgb");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expand grayscale images of less than 8-bit depth to 8 bits. */
|
/* Expand grayscale images of less than 8-bit depth to 8 bits. */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
|
png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
|
png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= PNG_EXPAND;
|
png_ptr->transformations |= PNG_EXPAND;
|
||||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Expand tRNS chunks to alpha channels. */
|
/* Expand tRNS chunks to alpha channels. */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_tRNS_to_alpha(png_structp png_ptr)
|
png_set_tRNS_to_alpha(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_tRNS_to_alpha");
|
png_debug(1, "in png_set_tRNS_to_alpha");
|
||||||
|
|
||||||
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
|
||||||
}
|
}
|
||||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||||
|
|
||||||
|
@ -893,45 +919,42 @@ png_set_tRNS_to_alpha(png_structp png_ptr)
|
||||||
* it may not work correctly.)
|
* it may not work correctly.)
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_expand_16(png_structp png_ptr)
|
png_set_expand_16(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_expand_16");
|
png_debug(1, "in png_set_expand_16");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
|
png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
|
||||||
|
|
||||||
/* New API, make sure apps call the correct initializers: */
|
|
||||||
png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_gray_to_rgb(png_structp png_ptr)
|
png_set_gray_to_rgb(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_gray_to_rgb");
|
png_debug(1, "in png_set_gray_to_rgb");
|
||||||
|
|
||||||
if (png_ptr != NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
{
|
return;
|
||||||
/* Because rgb must be 8 bits or more: */
|
|
||||||
png_set_expand_gray_1_2_4_to_8(png_ptr);
|
/* Because rgb must be 8 bits or more: */
|
||||||
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
png_set_expand_gray_1_2_4_to_8(png_ptr);
|
||||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||||
void PNGFAPI
|
void PNGFAPI
|
||||||
png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||||
png_fixed_point red, png_fixed_point green)
|
png_fixed_point red, png_fixed_point green)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_rgb_to_gray");
|
png_debug(1, "in png_set_rgb_to_gray");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
/* Need the IHDR here because of the check on color_type below. */
|
||||||
|
/* TODO: fix this */
|
||||||
|
if (!png_rtran_ok(png_ptr, 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch(error_action)
|
switch(error_action)
|
||||||
|
@ -952,15 +975,19 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
||||||
png_error(png_ptr, "invalid error action to rgb_to_gray");
|
png_error(png_ptr, "invalid error action to rgb_to_gray");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||||
png_ptr->transformations |= PNG_EXPAND;
|
png_ptr->transformations |= PNG_EXPAND;
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
png_warning(png_ptr,
|
/* Make this an error in 1.6 because otherwise the application may assume
|
||||||
|
* that it just worked and get a memory overwrite.
|
||||||
|
*/
|
||||||
|
png_error(png_ptr,
|
||||||
"Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED");
|
"Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED");
|
||||||
|
|
||||||
png_ptr->transformations &= ~PNG_RGB_TO_GRAY;
|
/* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -984,7 +1011,7 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (red >= 0 && green >= 0)
|
if (red >= 0 && green >= 0)
|
||||||
png_warning(png_ptr,
|
png_app_warning(png_ptr,
|
||||||
"ignoring out of range rgb_to_gray coefficients");
|
"ignoring out of range rgb_to_gray coefficients");
|
||||||
|
|
||||||
/* Use the defaults, from the cHRM chunk if set, else the historical
|
/* Use the defaults, from the cHRM chunk if set, else the historical
|
||||||
|
@ -1010,29 +1037,26 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
|
png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red,
|
||||||
double green)
|
double green)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
png_set_rgb_to_gray_fixed(png_ptr, error_action,
|
png_set_rgb_to_gray_fixed(png_ptr, error_action,
|
||||||
png_fixed(png_ptr, red, "rgb to gray red coefficient"),
|
png_fixed(png_ptr, red, "rgb to gray red coefficient"),
|
||||||
png_fixed(png_ptr, green, "rgb to gray green coefficient"));
|
png_fixed(png_ptr, green, "rgb to gray green coefficient"));
|
||||||
}
|
}
|
||||||
#endif /* FLOATING POINT */
|
#endif /* FLOATING POINT */
|
||||||
|
|
||||||
#endif
|
#endif /* RGB_TO_GRAY */
|
||||||
|
|
||||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr
|
||||||
read_user_transform_fn)
|
read_user_transform_fn)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_read_user_transform_fn");
|
png_debug(1, "in png_set_read_user_transform_fn");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (!png_rtran_ok(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||||
|
@ -1074,7 +1098,7 @@ png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma)
|
||||||
* extracted from 'png_init_read_transformations'.
|
* extracted from 'png_init_read_transformations'.
|
||||||
*/
|
*/
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_init_palette_transformations(png_structp png_ptr)
|
png_init_palette_transformations(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
/* Called to handle the (input) palette case. In png_do_read_transformations
|
/* Called to handle the (input) palette case. In png_do_read_transformations
|
||||||
* the first step is to expand the palette if requested, so this code must
|
* the first step is to expand the palette if requested, so this code must
|
||||||
|
@ -1157,7 +1181,7 @@ png_init_palette_transformations(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_init_rgb_transformations(png_structp png_ptr)
|
png_init_rgb_transformations(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
/* Added to libpng-1.5.4: check the color type to determine whether there
|
/* Added to libpng-1.5.4: check the color type to determine whether there
|
||||||
* is any alpha or transparency in the image and simply cancel the
|
* is any alpha or transparency in the image and simply cancel the
|
||||||
|
@ -1221,7 +1245,7 @@ png_init_rgb_transformations(png_structp png_ptr)
|
||||||
default:
|
default:
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
/* FALL THROUGH (already 8 bits) */
|
/* FALL THROUGH (Already 8 bits) */
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
/* Already a full 16 bits */
|
/* Already a full 16 bits */
|
||||||
|
@ -1242,7 +1266,7 @@ png_init_rgb_transformations(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_init_read_transformations(png_structp png_ptr)
|
png_init_read_transformations(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_init_read_transformations");
|
png_debug(1, "in png_init_read_transformations");
|
||||||
|
|
||||||
|
@ -1267,17 +1291,17 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
*/
|
*/
|
||||||
int gamma_correction = 0;
|
int gamma_correction = 0;
|
||||||
|
|
||||||
if (png_ptr->gamma != 0) /* has been set */
|
if (png_ptr->colorspace.gamma != 0) /* has been set */
|
||||||
{
|
{
|
||||||
if (png_ptr->screen_gamma != 0) /* screen set too */
|
if (png_ptr->screen_gamma != 0) /* screen set too */
|
||||||
gamma_correction = png_gamma_threshold(png_ptr->gamma,
|
gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma,
|
||||||
png_ptr->screen_gamma);
|
png_ptr->screen_gamma);
|
||||||
|
|
||||||
else
|
else
|
||||||
/* Assume the output matches the input; a long time default behavior
|
/* Assume the output matches the input; a long time default behavior
|
||||||
* of libpng, although the standard has nothing to say about this.
|
* of libpng, although the standard has nothing to say about this.
|
||||||
*/
|
*/
|
||||||
png_ptr->screen_gamma = png_reciprocal(png_ptr->gamma);
|
png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (png_ptr->screen_gamma != 0)
|
else if (png_ptr->screen_gamma != 0)
|
||||||
|
@ -1286,7 +1310,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
* png_set_alpha_mode (even if the alpha handling mode isn't required
|
* png_set_alpha_mode (even if the alpha handling mode isn't required
|
||||||
* or isn't changed from the default.)
|
* or isn't changed from the default.)
|
||||||
*/
|
*/
|
||||||
png_ptr->gamma = png_reciprocal(png_ptr->screen_gamma);
|
png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma);
|
||||||
|
|
||||||
else /* neither are set */
|
else /* neither are set */
|
||||||
/* Just in case the following prevents any processing - file and screen
|
/* Just in case the following prevents any processing - file and screen
|
||||||
|
@ -1294,7 +1318,10 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
* third gamma value other than png_set_background with 'UNIQUE', and,
|
* third gamma value other than png_set_background with 'UNIQUE', and,
|
||||||
* prior to 1.5.4
|
* prior to 1.5.4
|
||||||
*/
|
*/
|
||||||
png_ptr->screen_gamma = png_ptr->gamma = PNG_FP_1;
|
png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1;
|
||||||
|
|
||||||
|
/* We have a gamma value now. */
|
||||||
|
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||||
|
|
||||||
/* Now turn the gamma transformation on or off as appropriate. Notice
|
/* Now turn the gamma transformation on or off as appropriate. Notice
|
||||||
* that PNG_GAMMA just refers to the file->screen correction. Alpha
|
* that PNG_GAMMA just refers to the file->screen correction. Alpha
|
||||||
|
@ -1376,9 +1403,16 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
|
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||||
defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
/* Make sure the coefficients for the rgb to gray conversion are set
|
||||||
defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
* appropriately.
|
||||||
|
*/
|
||||||
|
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||||
|
png_colorspace_set_rgb_coefficients(png_ptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
|
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||||
/* Detect gray background and attempt to enable optimization for
|
/* Detect gray background and attempt to enable optimization for
|
||||||
* gray --> RGB case.
|
* gray --> RGB case.
|
||||||
*
|
*
|
||||||
|
@ -1420,7 +1454,8 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED (etc) */
|
#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
|
||||||
|
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
|
||||||
|
|
||||||
/* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations
|
/* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations
|
||||||
* can be performed directly on the palette, and some (such as rgb to gray)
|
* can be performed directly on the palette, and some (such as rgb to gray)
|
||||||
|
@ -1456,7 +1491,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
* NOTE: this discards the low 16 bits of the user supplied background
|
* NOTE: this discards the low 16 bits of the user supplied background
|
||||||
* color, but until expand_16 works properly there is no choice!
|
* color, but until expand_16 works properly there is no choice!
|
||||||
*/
|
*/
|
||||||
# define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16))
|
# define CHOP(x) (x)=((png_uint_16)PNG_DIV257(x))
|
||||||
CHOP(png_ptr->background.red);
|
CHOP(png_ptr->background.red);
|
||||||
CHOP(png_ptr->background.green);
|
CHOP(png_ptr->background.green);
|
||||||
CHOP(png_ptr->background.blue);
|
CHOP(png_ptr->background.blue);
|
||||||
|
@ -1516,10 +1551,10 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
*/
|
*/
|
||||||
if ((png_ptr->transformations & PNG_GAMMA)
|
if ((png_ptr->transformations & PNG_GAMMA)
|
||||||
|| ((png_ptr->transformations & PNG_RGB_TO_GRAY)
|
|| ((png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||||
&& (png_gamma_significant(png_ptr->gamma) ||
|
&& (png_gamma_significant(png_ptr->colorspace.gamma) ||
|
||||||
png_gamma_significant(png_ptr->screen_gamma)))
|
png_gamma_significant(png_ptr->screen_gamma)))
|
||||||
|| ((png_ptr->transformations & PNG_COMPOSE)
|
|| ((png_ptr->transformations & PNG_COMPOSE)
|
||||||
&& (png_gamma_significant(png_ptr->gamma)
|
&& (png_gamma_significant(png_ptr->colorspace.gamma)
|
||||||
|| png_gamma_significant(png_ptr->screen_gamma)
|
|| png_gamma_significant(png_ptr->screen_gamma)
|
||||||
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||||
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
|
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
|
||||||
|
@ -1576,8 +1611,8 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_BACKGROUND_GAMMA_FILE:
|
case PNG_BACKGROUND_GAMMA_FILE:
|
||||||
g = png_reciprocal(png_ptr->gamma);
|
g = png_reciprocal(png_ptr->colorspace.gamma);
|
||||||
gs = png_reciprocal2(png_ptr->gamma,
|
gs = png_reciprocal2(png_ptr->colorspace.gamma,
|
||||||
png_ptr->screen_gamma);
|
png_ptr->screen_gamma);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1685,8 +1720,9 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_BACKGROUND_GAMMA_FILE:
|
case PNG_BACKGROUND_GAMMA_FILE:
|
||||||
g = png_reciprocal(png_ptr->gamma);
|
g = png_reciprocal(png_ptr->colorspace.gamma);
|
||||||
gs = png_reciprocal2(png_ptr->gamma, png_ptr->screen_gamma);
|
gs = png_reciprocal2(png_ptr->colorspace.gamma,
|
||||||
|
png_ptr->screen_gamma);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_BACKGROUND_GAMMA_UNIQUE:
|
case PNG_BACKGROUND_GAMMA_UNIQUE:
|
||||||
|
@ -1877,7 +1913,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
* assuming the transformations result in valid PNG data.
|
* assuming the transformations result in valid PNG data.
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_read_transform_info");
|
png_debug(1, "in png_read_transform_info");
|
||||||
|
|
||||||
|
@ -1928,8 +1964,12 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
* however it seems that the code in png_init_read_transformations, which has
|
* however it seems that the code in png_init_read_transformations, which has
|
||||||
* been called before this from png_read_update_info->png_read_start_row
|
* been called before this from png_read_update_info->png_read_start_row
|
||||||
* sometimes does the gamma transform and cancels the flag.
|
* sometimes does the gamma transform and cancels the flag.
|
||||||
|
*
|
||||||
|
* TODO: this looks wrong; the info_ptr should end up with a gamma equal to
|
||||||
|
* the screen_gamma value. The following probably results in weirdness if
|
||||||
|
* the info_ptr is used by the app after the rows have been read.
|
||||||
*/
|
*/
|
||||||
info_ptr->gamma = png_ptr->gamma;
|
info_ptr->colorspace.gamma = png_ptr->colorspace.gamma;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (info_ptr->bit_depth == 16)
|
if (info_ptr->bit_depth == 16)
|
||||||
|
@ -2077,7 +2117,7 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||||
* decide how it fits in with the other transformations here.
|
* decide how it fits in with the other transformations here.
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_read_transformations(png_structp png_ptr, png_row_infop row_info)
|
png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_do_read_transformations");
|
png_debug(1, "in png_do_read_transformations");
|
||||||
|
|
||||||
|
@ -2092,8 +2132,9 @@ png_do_read_transformations(png_structp png_ptr, png_row_infop row_info)
|
||||||
|
|
||||||
/* The following is debugging; prior to 1.5.4 the code was never compiled in;
|
/* The following is debugging; prior to 1.5.4 the code was never compiled in;
|
||||||
* in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
|
* in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
|
||||||
* PNG_WARN_UNINITIALIZED_ROW removed. In 1.5 the new flag is set only for
|
* PNG_WARN_UNINITIALIZED_ROW removed. In 1.6 the new flag is set only for
|
||||||
* selected new APIs to ensure that there is no API change.
|
* all transformations, however in practice the ROW_INIT always gets done on
|
||||||
|
* demand, if necessary.
|
||||||
*/
|
*/
|
||||||
if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&
|
if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&
|
||||||
!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||||
|
@ -2198,8 +2239,8 @@ png_do_read_transformations(png_structp png_ptr, png_row_infop row_info)
|
||||||
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
|
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
|
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||||
(defined PNG_READ_ALPHA_MODE_SUPPORTED)
|
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_COMPOSE)
|
if (png_ptr->transformations & PNG_COMPOSE)
|
||||||
png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);
|
png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2210,8 +2251,8 @@ png_do_read_transformations(png_structp png_ptr, png_row_infop row_info)
|
||||||
/* Because RGB_TO_GRAY does the gamma transform. */
|
/* Because RGB_TO_GRAY does the gamma transform. */
|
||||||
!(png_ptr->transformations & PNG_RGB_TO_GRAY) &&
|
!(png_ptr->transformations & PNG_RGB_TO_GRAY) &&
|
||||||
#endif
|
#endif
|
||||||
#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
|
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||||
(defined PNG_READ_ALPHA_MODE_SUPPORTED)
|
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||||
/* Because PNG_COMPOSE does the gamma transform if there is something to
|
/* Because PNG_COMPOSE does the gamma transform if there is something to
|
||||||
* do (if there is an alpha channel or transparency.)
|
* do (if there is an alpha channel or transparency.)
|
||||||
*/
|
*/
|
||||||
|
@ -3224,7 +3265,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||||
* to that used above.
|
* to that used above.
|
||||||
*/
|
*/
|
||||||
int /* PRIVATE */
|
int /* PRIVATE */
|
||||||
png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||||
|
|
||||||
{
|
{
|
||||||
int rgb_error = 0;
|
int rgb_error = 0;
|
||||||
|
@ -3243,7 +3284,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||||
|
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||||
/* Notice that gamma to/from 1 are not necessarily inverses (if
|
/* Notice that gamma to/from 1 are not necessarily inverses (if
|
||||||
* there is an overall gamma correction). Prior to 1.5.5 this code
|
* there is an overall gamma correction). Prior to 1.5.5 this code
|
||||||
* checked the linearized values for equality; this doesn't match
|
* checked the linearized values for equality; this doesn't match
|
||||||
|
@ -3320,7 +3361,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
||||||
|
|
||||||
else /* RGB bit_depth == 16 */
|
else /* RGB bit_depth == 16 */
|
||||||
{
|
{
|
||||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||||
if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL)
|
if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL)
|
||||||
{
|
{
|
||||||
png_bytep sp = row;
|
png_bytep sp = row;
|
||||||
|
@ -3477,14 +3518,14 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||||
|
|
||||||
|
|
||||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||||
#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
|
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||||
(defined PNG_READ_ALPHA_MODE_SUPPORTED)
|
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||||
/* Replace any alpha or transparency with the supplied background color.
|
/* Replace any alpha or transparency with the supplied background color.
|
||||||
* "background" is already in the screen gamma, while "background_1" is
|
* "background" is already in the screen gamma, while "background_1" is
|
||||||
* at a gamma of 1.0. Paletted files have already been taken care of.
|
* at a gamma of 1.0. Paletted files have already been taken care of.
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||||
png_const_bytep gamma_table = png_ptr->gamma_table;
|
png_const_bytep gamma_table = png_ptr->gamma_table;
|
||||||
|
@ -3494,12 +3535,12 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1;
|
png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1;
|
||||||
png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1;
|
png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1;
|
||||||
int gamma_shift = png_ptr->gamma_shift;
|
int gamma_shift = png_ptr->gamma_shift;
|
||||||
|
int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_bytep sp;
|
png_bytep sp;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
png_uint_32 row_width = row_info->width;
|
png_uint_32 row_width = row_info->width;
|
||||||
int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0;
|
|
||||||
int shift;
|
int shift;
|
||||||
|
|
||||||
png_debug(1, "in png_do_compose");
|
png_debug(1, "in png_do_compose");
|
||||||
|
@ -3520,8 +3561,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
if ((png_uint_16)((*sp >> shift) & 0x01)
|
if ((png_uint_16)((*sp >> shift) & 0x01)
|
||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
*sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
|
unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
|
||||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
tmp |= png_ptr->background.gray << shift;
|
||||||
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shift)
|
if (!shift)
|
||||||
|
@ -3548,17 +3590,19 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
if ((png_uint_16)((*sp >> shift) & 0x03)
|
if ((png_uint_16)((*sp >> shift) & 0x03)
|
||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
tmp |= png_ptr->background.gray << shift;
|
||||||
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_byte p = (png_byte)((*sp >> shift) & 0x03);
|
unsigned int p = (*sp >> shift) & 0x03;
|
||||||
png_byte g = (png_byte)((gamma_table [p | (p << 2) |
|
unsigned int g = (gamma_table [p | (p << 2) |
|
||||||
(p << 4) | (p << 6)] >> 6) & 0x03);
|
(p << 4) | (p << 6)] >> 6) & 0x03;
|
||||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||||
*sp |= (png_byte)(g << shift);
|
tmp |= g << shift;
|
||||||
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shift)
|
if (!shift)
|
||||||
|
@ -3582,8 +3626,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
if ((png_uint_16)((*sp >> shift) & 0x03)
|
if ((png_uint_16)((*sp >> shift) & 0x03)
|
||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
tmp |= png_ptr->background.gray << shift;
|
||||||
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shift)
|
if (!shift)
|
||||||
|
@ -3611,17 +3656,19 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
|
||||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
tmp |= png_ptr->background.gray << shift;
|
||||||
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_byte p = (png_byte)((*sp >> shift) & 0x0f);
|
unsigned int p = (*sp >> shift) & 0x0f;
|
||||||
png_byte g = (png_byte)((gamma_table[p |
|
unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
|
||||||
(p << 4)] >> 4) & 0x0f);
|
0x0f;
|
||||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
|
||||||
*sp |= (png_byte)(g << shift);
|
tmp |= g << shift;
|
||||||
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shift)
|
if (!shift)
|
||||||
|
@ -3645,8 +3692,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
if ((png_uint_16)((*sp >> shift) & 0x0f)
|
||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
|
||||||
*sp |= (png_byte)(png_ptr->background.gray << shift);
|
tmp |= png_ptr->background.gray << shift;
|
||||||
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shift)
|
if (!shift)
|
||||||
|
@ -4126,16 +4174,16 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
|
v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
|
||||||
png_composite_16(w, v, a, png_ptr->background_1.red);
|
png_composite_16(w, v, a, png_ptr->background_1.red);
|
||||||
if (!optimize)
|
if (!optimize)
|
||||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)]
|
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||||
[w >> 8];
|
8];
|
||||||
*sp = (png_byte)((w >> 8) & 0xff);
|
*sp = (png_byte)((w >> 8) & 0xff);
|
||||||
*(sp + 1) = (png_byte)(w & 0xff);
|
*(sp + 1) = (png_byte)(w & 0xff);
|
||||||
|
|
||||||
v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
|
v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
|
||||||
png_composite_16(w, v, a, png_ptr->background_1.green);
|
png_composite_16(w, v, a, png_ptr->background_1.green);
|
||||||
if (!optimize)
|
if (!optimize)
|
||||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)]
|
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||||
[w >> 8];
|
8];
|
||||||
|
|
||||||
*(sp + 2) = (png_byte)((w >> 8) & 0xff);
|
*(sp + 2) = (png_byte)((w >> 8) & 0xff);
|
||||||
*(sp + 3) = (png_byte)(w & 0xff);
|
*(sp + 3) = (png_byte)(w & 0xff);
|
||||||
|
@ -4143,8 +4191,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
|
v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
|
||||||
png_composite_16(w, v, a, png_ptr->background_1.blue);
|
png_composite_16(w, v, a, png_ptr->background_1.blue);
|
||||||
if (!optimize)
|
if (!optimize)
|
||||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)]
|
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||||
[w >> 8];
|
8];
|
||||||
|
|
||||||
*(sp + 4) = (png_byte)((w >> 8) & 0xff);
|
*(sp + 4) = (png_byte)((w >> 8) & 0xff);
|
||||||
*(sp + 5) = (png_byte)(w & 0xff);
|
*(sp + 5) = (png_byte)(w & 0xff);
|
||||||
|
@ -4217,7 +4265,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
* build_gamma_table().
|
* build_gamma_table().
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_gamma(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_const_bytep gamma_table = png_ptr->gamma_table;
|
png_const_bytep gamma_table = png_ptr->gamma_table;
|
||||||
png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table;
|
png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table;
|
||||||
|
@ -4418,7 +4466,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
||||||
* from_1 tables.
|
* from_1 tables.
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structp png_ptr)
|
png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_uint_32 row_width = row_info->width;
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
@ -4650,7 +4698,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||||
{
|
{
|
||||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||||
{
|
{
|
||||||
png_uint_16 gray = (png_uint_16)(trans_color ? trans_color->gray : 0);
|
unsigned int gray = trans_color ? trans_color->gray : 0;
|
||||||
|
|
||||||
if (row_info->bit_depth < 8)
|
if (row_info->bit_depth < 8)
|
||||||
{
|
{
|
||||||
|
@ -4658,7 +4706,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
gray = (png_uint_16)((gray & 0x01) * 0xff);
|
gray = (gray & 0x01) * 0xff;
|
||||||
sp = row + (png_size_t)((row_width - 1) >> 3);
|
sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||||
dp = row + (png_size_t)row_width - 1;
|
dp = row + (png_size_t)row_width - 1;
|
||||||
shift = 7 - (int)((row_width + 7) & 0x07);
|
shift = 7 - (int)((row_width + 7) & 0x07);
|
||||||
|
@ -4686,7 +4734,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
gray = (png_uint_16)((gray & 0x03) * 0x55);
|
gray = (gray & 0x03) * 0x55;
|
||||||
sp = row + (png_size_t)((row_width - 1) >> 2);
|
sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||||
dp = row + (png_size_t)row_width - 1;
|
dp = row + (png_size_t)row_width - 1;
|
||||||
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||||
|
@ -4711,7 +4759,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
gray = (png_uint_16)((gray & 0x0f) * 0x11);
|
gray = (gray & 0x0f) * 0x11;
|
||||||
sp = row + (png_size_t)((row_width - 1) >> 1);
|
sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||||
dp = row + (png_size_t)row_width - 1;
|
dp = row + (png_size_t)row_width - 1;
|
||||||
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
||||||
|
@ -4746,9 +4794,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
/* NOTE: prior to libpng 1.5.14 this cleared out the top bits of
|
gray = gray & 0xff;
|
||||||
* 'gray', however if those are set it is an error.
|
|
||||||
*/
|
|
||||||
sp = row + (png_size_t)row_width - 1;
|
sp = row + (png_size_t)row_width - 1;
|
||||||
dp = row + (png_size_t)(row_width << 1) - 1;
|
dp = row + (png_size_t)(row_width << 1) - 1;
|
||||||
|
|
||||||
|
@ -4766,8 +4812,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||||
|
|
||||||
else if (row_info->bit_depth == 16)
|
else if (row_info->bit_depth == 16)
|
||||||
{
|
{
|
||||||
png_byte gray_high = (png_byte)((gray >> 8) & 0xff);
|
unsigned int gray_high = (gray >> 8) & 0xff;
|
||||||
png_byte gray_low = (png_byte)(gray & 0xff);
|
unsigned int gray_low = gray & 0xff;
|
||||||
sp = row + row_info->rowbytes - 1;
|
sp = row + row_info->rowbytes - 1;
|
||||||
dp = row + (row_info->rowbytes << 1) - 1;
|
dp = row + (row_info->rowbytes << 1) - 1;
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
1079
src/libpng/pngset.c
1079
src/libpng/pngset.c
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
/* pngstruct.h - header file for PNG reference library
|
/* pngstruct.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.9 [February 18, 2012]
|
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
@ -24,13 +24,130 @@
|
||||||
* in this structure and is required for decompressing the LZ compressed
|
* in this structure and is required for decompressing the LZ compressed
|
||||||
* data in PNG files.
|
* data in PNG files.
|
||||||
*/
|
*/
|
||||||
|
#ifndef ZLIB_CONST
|
||||||
|
/* We must ensure that zlib uses 'const' in declarations. */
|
||||||
|
# define ZLIB_CONST
|
||||||
|
#endif
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
#ifdef const
|
||||||
|
/* zlib.h sometimes #defines const to nothing, undo this. */
|
||||||
|
# undef const
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
|
||||||
|
* with older builds.
|
||||||
|
*/
|
||||||
|
#if ZLIB_VERNUM < 0x1260
|
||||||
|
# define PNGZ_MSG_CAST(s) png_constcast(char*,s)
|
||||||
|
# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
|
||||||
|
#else
|
||||||
|
# define PNGZ_MSG_CAST(s) (s)
|
||||||
|
# define PNGZ_INPUT_CAST(b) (b)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
|
||||||
|
* can handle at once. This type need be no larger than 16 bits (so maximum of
|
||||||
|
* 65535), this define allows us to discover how big it is, but limited by the
|
||||||
|
* maximuum for png_size_t. The value can be overriden in a library build
|
||||||
|
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
|
||||||
|
* lower value (e.g. 255 works). A lower value may help memory usage (slightly)
|
||||||
|
* and may even improve performance on some systems (and degrade it on others.)
|
||||||
|
*/
|
||||||
|
#ifndef ZLIB_IO_MAX
|
||||||
|
# define ZLIB_IO_MAX ((uInt)-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
/* The type of a compression buffer list used by the write code. */
|
||||||
|
typedef struct png_compression_buffer
|
||||||
|
{
|
||||||
|
struct png_compression_buffer *next;
|
||||||
|
png_byte output[1]; /* actually zbuf_size */
|
||||||
|
} png_compression_buffer, *png_compression_bufferp;
|
||||||
|
|
||||||
|
#define PNG_COMPRESSION_BUFFER_SIZE(pp)\
|
||||||
|
(offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Colorspace support; structures used in png_struct, png_info and in internal
|
||||||
|
* functions to hold and communicate information about the color space.
|
||||||
|
*
|
||||||
|
* PNG_COLORSPACE_SUPPORTED is only required if the application will perform
|
||||||
|
* colorspace corrections, otherwise all the colorspace information can be
|
||||||
|
* skipped and the size of libpng can be reduced (significantly) by compiling
|
||||||
|
* out the colorspace support.
|
||||||
|
*/
|
||||||
|
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||||
|
/* The chromaticities of the red, green and blue colorants and the chromaticity
|
||||||
|
* of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
|
||||||
|
*/
|
||||||
|
typedef struct png_xy
|
||||||
|
{
|
||||||
|
png_fixed_point redx, redy;
|
||||||
|
png_fixed_point greenx, greeny;
|
||||||
|
png_fixed_point bluex, bluey;
|
||||||
|
png_fixed_point whitex, whitey;
|
||||||
|
} png_xy;
|
||||||
|
|
||||||
|
/* The same data as above but encoded as CIE XYZ values. When this data comes
|
||||||
|
* from chromaticities the sum of the Y values is assumed to be 1.0
|
||||||
|
*/
|
||||||
|
typedef struct png_XYZ
|
||||||
|
{
|
||||||
|
png_fixed_point red_X, red_Y, red_Z;
|
||||||
|
png_fixed_point green_X, green_Y, green_Z;
|
||||||
|
png_fixed_point blue_X, blue_Y, blue_Z;
|
||||||
|
} png_XYZ;
|
||||||
|
#endif /* COLORSPACE */
|
||||||
|
|
||||||
|
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||||
|
/* A colorspace is all the above plus, potentially, profile information,
|
||||||
|
* however at present libpng does not use the profile internally so it is only
|
||||||
|
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||||
|
* is retained here and is checked.
|
||||||
|
*
|
||||||
|
* The file gamma encoding information is also stored here and gamma correction
|
||||||
|
* is done by libpng, whereas color correction must currently be done by the
|
||||||
|
* application.
|
||||||
|
*/
|
||||||
|
typedef struct png_colorspace
|
||||||
|
{
|
||||||
|
#ifdef PNG_GAMMA_SUPPORTED
|
||||||
|
png_fixed_point gamma; /* File gamma */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||||
|
png_xy end_points_xy; /* End points as chromaticities */
|
||||||
|
png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
|
||||||
|
png_uint_16 rendering_intent; /* Rendering intent of a profile */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Flags are always defined to simplify the code. */
|
||||||
|
png_uint_16 flags; /* As defined below */
|
||||||
|
} png_colorspace, * PNG_RESTRICT png_colorspacerp;
|
||||||
|
|
||||||
|
typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
|
||||||
|
|
||||||
|
/* General flags for the 'flags' field */
|
||||||
|
#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
|
||||||
|
#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
|
||||||
|
#define PNG_COLORSPACE_HAVE_INTENT 0x0004
|
||||||
|
#define PNG_COLORSPACE_FROM_gAMA 0x0008
|
||||||
|
#define PNG_COLORSPACE_FROM_cHRM 0x0010
|
||||||
|
#define PNG_COLORSPACE_FROM_sRGB 0x0020
|
||||||
|
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
|
||||||
|
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
|
||||||
|
#define PNG_COLORSPACE_INVALID 0x8000
|
||||||
|
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
|
||||||
|
#endif /* COLORSPACE || GAMMA */
|
||||||
|
|
||||||
struct png_struct_def
|
struct png_struct_def
|
||||||
{
|
{
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
jmp_buf longjmp_buffer; /* used in png_error */
|
jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */
|
||||||
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
|
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
|
||||||
|
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
|
||||||
|
size_t jmp_buf_size; /* size of the above, if allocated */
|
||||||
#endif
|
#endif
|
||||||
png_error_ptr error_fn; /* function for printing errors and aborting */
|
png_error_ptr error_fn; /* function for printing errors and aborting */
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
|
@ -63,22 +180,12 @@ struct png_struct_def
|
||||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||||
png_uint_32 transformations; /* which transformations to perform */
|
png_uint_32 transformations; /* which transformations to perform */
|
||||||
|
|
||||||
z_stream zstream; /* pointer to decompression structure (below) */
|
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||||
png_bytep zbuf; /* buffer for zlib */
|
z_stream zstream; /* decompression structure */
|
||||||
uInt zbuf_size; /* size of zbuf (typically 65536) */
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
||||||
/* Added in 1.5.4: state to keep track of whether the zstream has been
|
uInt zbuffer_size; /* size of the actual buffer */
|
||||||
* initialized and if so whether it is for IDAT or some other chunk.
|
|
||||||
*/
|
|
||||||
#define PNG_ZLIB_UNINITIALIZED 0
|
|
||||||
#define PNG_ZLIB_FOR_IDAT 1
|
|
||||||
#define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */
|
|
||||||
#define PNG_ZLIB_USE_MASK 3 /* bottom two bits */
|
|
||||||
#define PNG_ZLIB_IN_USE 4 /* a flag value */
|
|
||||||
|
|
||||||
png_uint_32 zlib_state; /* State of zlib initialization */
|
|
||||||
/* End of material added at libpng 1.5.4 */
|
|
||||||
|
|
||||||
int zlib_level; /* holds zlib compression level */
|
int zlib_level; /* holds zlib compression level */
|
||||||
int zlib_method; /* holds zlib compression method */
|
int zlib_method; /* holds zlib compression method */
|
||||||
|
@ -87,8 +194,7 @@ struct png_struct_def
|
||||||
int zlib_strategy; /* holds zlib compression strategy */
|
int zlib_strategy; /* holds zlib compression strategy */
|
||||||
#endif
|
#endif
|
||||||
/* Added at libpng 1.5.4 */
|
/* Added at libpng 1.5.4 */
|
||||||
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
|
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||||
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
|
|
||||||
int zlib_text_level; /* holds zlib compression level */
|
int zlib_text_level; /* holds zlib compression level */
|
||||||
int zlib_text_method; /* holds zlib compression method */
|
int zlib_text_method; /* holds zlib compression method */
|
||||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||||
|
@ -96,6 +202,14 @@ struct png_struct_def
|
||||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||||
#endif
|
#endif
|
||||||
/* End of material added at libpng 1.5.4 */
|
/* End of material added at libpng 1.5.4 */
|
||||||
|
/* Added at libpng 1.6.0 */
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
int zlib_set_level; /* Actual values set into the zstream on write */
|
||||||
|
int zlib_set_method;
|
||||||
|
int zlib_set_window_bits;
|
||||||
|
int zlib_set_mem_level;
|
||||||
|
int zlib_set_strategy;
|
||||||
|
#endif
|
||||||
|
|
||||||
png_uint_32 width; /* width of image in pixels */
|
png_uint_32 width; /* width of image in pixels */
|
||||||
png_uint_32 height; /* height of image in pixels */
|
png_uint_32 height; /* height of image in pixels */
|
||||||
|
@ -111,10 +225,12 @@ struct png_struct_def
|
||||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||||
* This is a pointer into big_row_buf
|
* This is a pointer into big_row_buf
|
||||||
*/
|
*/
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||||
|
#endif
|
||||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||||
|
|
||||||
png_uint_32 idat_size; /* current IDAT size for read */
|
png_uint_32 idat_size; /* current IDAT size for read */
|
||||||
|
@ -138,15 +254,14 @@ struct png_struct_def
|
||||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||||
png_byte pixel_depth; /* number of bits per pixel */
|
png_byte pixel_depth; /* number of bits per pixel */
|
||||||
png_byte channels; /* number of channels in file */
|
png_byte channels; /* number of channels in file */
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
png_byte usr_channels; /* channels at start of write: write only */
|
png_byte usr_channels; /* channels at start of write: write only */
|
||||||
|
#endif
|
||||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||||
png_byte maximum_pixel_depth;
|
png_byte maximum_pixel_depth;
|
||||||
/* pixel depth used for the row buffers */
|
/* pixel depth used for the row buffers */
|
||||||
png_byte transformed_pixel_depth;
|
png_byte transformed_pixel_depth;
|
||||||
/* pixel depth after read/write transforms */
|
/* pixel depth after read/write transforms */
|
||||||
png_byte io_chunk_string[5];
|
|
||||||
/* string name of chunk */
|
|
||||||
|
|
||||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||||
#endif
|
#endif
|
||||||
|
@ -169,7 +284,6 @@ struct png_struct_def
|
||||||
|
|
||||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||||
png_fixed_point gamma; /* file gamma value */
|
|
||||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||||
|
|
||||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||||
|
@ -233,10 +347,6 @@ struct png_struct_def
|
||||||
png_bytep quantize_index; /* index translation for palette files */
|
png_bytep quantize_index; /* index translation for palette files */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
|
|
||||||
png_uint_16p hist; /* histogram */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||||
|
@ -247,10 +357,17 @@ struct png_struct_def
|
||||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Options */
|
||||||
|
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||||
|
png_byte options; /* On/off state (up to 4 options) */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PNG_LIBPNG_VER < 10700
|
||||||
|
/* To do: remove this from libpng-1.7 */
|
||||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||||
/* This is going to be unused in libpng16 and removed from libpng17 */
|
|
||||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* New members added in libpng-1.0.6 */
|
/* New members added in libpng-1.0.6 */
|
||||||
|
|
||||||
|
@ -258,17 +375,16 @@ struct png_struct_def
|
||||||
|
|
||||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||||
png_voidp user_chunk_ptr;
|
png_voidp user_chunk_ptr;
|
||||||
|
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
|
||||||
int num_chunk_list;
|
|
||||||
png_bytep chunk_list;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
/* Added in 1.5.5 to record an sRGB chunk in the png. */
|
int unknown_default; /* As PNG_HANDLE_* */
|
||||||
png_byte is_sRGB;
|
unsigned int num_chunk_list; /* Number of entries in the list */
|
||||||
|
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
|
||||||
|
* followed by a PNG_HANDLE_* byte */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* New members added in libpng-1.0.3 */
|
/* New members added in libpng-1.0.3 */
|
||||||
|
@ -333,16 +449,24 @@ struct png_struct_def
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
/* Storage for unknown chunk that the library doesn't recognize. */
|
/* Temporary storage for unknown chunk that the library doesn't recognize,
|
||||||
|
* used while reading the chunk.
|
||||||
|
*/
|
||||||
png_unknown_chunk unknown_chunk;
|
png_unknown_chunk unknown_chunk;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* New member added in libpng-1.2.26 */
|
/* New member added in libpng-1.2.26 */
|
||||||
png_size_t old_big_row_buf_size;
|
png_size_t old_big_row_buf_size;
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
/* New member added in libpng-1.2.30 */
|
/* New member added in libpng-1.2.30 */
|
||||||
png_charp chunkdata; /* buffer for reading chunk data */
|
png_bytep read_buffer; /* buffer for reading chunk data */
|
||||||
|
png_alloc_size_t read_buffer_size; /* current size of the buffer */
|
||||||
|
#endif
|
||||||
|
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||||
|
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_IO_STATE_SUPPORTED
|
#ifdef PNG_IO_STATE_SUPPORTED
|
||||||
/* New member added in libpng-1.4.0 */
|
/* New member added in libpng-1.4.0 */
|
||||||
|
@ -352,7 +476,14 @@ struct png_struct_def
|
||||||
/* New member added in libpng-1.5.6 */
|
/* New member added in libpng-1.5.6 */
|
||||||
png_bytep big_prev_row;
|
png_bytep big_prev_row;
|
||||||
|
|
||||||
|
/* New member added in libpng-1.5.7 */
|
||||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||||
png_bytep row, png_const_bytep prev_row);
|
png_bytep row, png_const_bytep prev_row);
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||||
|
png_colorspace colorspace;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#endif /* PNGSTRUCT_H */
|
#endif /* PNGSTRUCT_H */
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.11 [June 14, 2012]
|
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||||
/* Turn on BGR-to-RGB mapping */
|
/* Turn on BGR-to-RGB mapping */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_bgr(png_structp png_ptr)
|
png_set_bgr(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_bgr");
|
png_debug(1, "in png_set_bgr");
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ png_set_bgr(png_structp png_ptr)
|
||||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||||
/* Turn on 16 bit byte swapping */
|
/* Turn on 16 bit byte swapping */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_swap(png_structp png_ptr)
|
png_set_swap(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_swap");
|
png_debug(1, "in png_set_swap");
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ png_set_swap(png_structp png_ptr)
|
||||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
/* Turn on pixel packing */
|
/* Turn on pixel packing */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_packing(png_structp png_ptr)
|
png_set_packing(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_packing");
|
png_debug(1, "in png_set_packing");
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ png_set_packing(png_structp png_ptr)
|
||||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||||
/* Turn on packed pixel swapping */
|
/* Turn on packed pixel swapping */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_packswap(png_structp png_ptr)
|
png_set_packswap(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_packswap");
|
png_debug(1, "in png_set_packswap");
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ png_set_packswap(png_structp png_ptr)
|
||||||
|
|
||||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_shift");
|
png_debug(1, "in png_set_shift");
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_set_interlace_handling(png_structp png_ptr)
|
png_set_interlace_handling(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_interlace handling");
|
png_debug(1, "in png_set_interlace handling");
|
||||||
|
|
||||||
|
@ -115,44 +115,91 @@ png_set_interlace_handling(png_structp png_ptr)
|
||||||
* that don't like bytes as parameters.
|
* that don't like bytes as parameters.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_filler");
|
png_debug(1, "in png_set_filler");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* In libpng 1.6 it is possible to determine whether this is a read or write
|
||||||
|
* operation and therefore to do more checking here for a valid call.
|
||||||
|
*/
|
||||||
|
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||||
|
{
|
||||||
|
# ifdef PNG_READ_FILLER_SUPPORTED
|
||||||
|
/* On read png_set_filler is always valid, regardless of the base PNG
|
||||||
|
* format, because other transformations can give a format where the
|
||||||
|
* filler code can execute (basically an 8 or 16-bit component RGB or G
|
||||||
|
* format.)
|
||||||
|
*
|
||||||
|
* NOTE: usr_channels is not used by the read code! (This has led to
|
||||||
|
* confusion in the past.) The filler is only used in the read code.
|
||||||
|
*/
|
||||||
|
png_ptr->filler = (png_uint_16)filler;
|
||||||
|
# else
|
||||||
|
png_app_error(png_ptr, "png_set_filler not supported on read");
|
||||||
|
PNG_UNUSED(filler) /* not used in the write case */
|
||||||
|
return;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
else /* write */
|
||||||
|
{
|
||||||
|
# ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||||
|
/* On write the usr_channels parameter must be set correctly at the
|
||||||
|
* start to record the number of channels in the app-supplied data.
|
||||||
|
*/
|
||||||
|
switch (png_ptr->color_type)
|
||||||
|
{
|
||||||
|
case PNG_COLOR_TYPE_RGB:
|
||||||
|
png_ptr->usr_channels = 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
|
if (png_ptr->bit_depth >= 8)
|
||||||
|
{
|
||||||
|
png_ptr->usr_channels = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* There simply isn't any code in libpng to strip out bits
|
||||||
|
* from bytes when the components are less than a byte in
|
||||||
|
* size!
|
||||||
|
*/
|
||||||
|
png_app_error(png_ptr,
|
||||||
|
"png_set_filler is invalid for low bit depth gray output");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
png_app_error(png_ptr,
|
||||||
|
"png_set_filler: inappropriate color type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
png_app_error(png_ptr, "png_set_filler not supported on write");
|
||||||
|
return;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Here on success - libpng supports the operation, set the transformation
|
||||||
|
* and the flag to say where the filler channel is.
|
||||||
|
*/
|
||||||
png_ptr->transformations |= PNG_FILLER;
|
png_ptr->transformations |= PNG_FILLER;
|
||||||
png_ptr->filler = (png_uint_16)filler;
|
|
||||||
|
|
||||||
if (filler_loc == PNG_FILLER_AFTER)
|
if (filler_loc == PNG_FILLER_AFTER)
|
||||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||||
|
|
||||||
else
|
else
|
||||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||||
|
|
||||||
/* This should probably go in the "do_read_filler" routine.
|
|
||||||
* I attempted to do that in libpng-1.0.1a but that caused problems
|
|
||||||
* so I restored it in libpng-1.0.2a
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
|
|
||||||
{
|
|
||||||
png_ptr->usr_channels = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Also I added this in libpng-1.0.2a (what happens when we expand
|
|
||||||
* a less-than-8-bit grayscale to GA?) */
|
|
||||||
|
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
|
|
||||||
{
|
|
||||||
png_ptr->usr_channels = 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Added to libpng-1.2.7 */
|
/* Added to libpng-1.2.7 */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_add_alpha");
|
png_debug(1, "in png_set_add_alpha");
|
||||||
|
|
||||||
|
@ -160,7 +207,9 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_set_filler(png_ptr, filler, filler_loc);
|
png_set_filler(png_ptr, filler, filler_loc);
|
||||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
/* The above may fail to do anything. */
|
||||||
|
if (png_ptr->transformations & PNG_FILLER)
|
||||||
|
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -168,7 +217,7 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_swap_alpha(png_structp png_ptr)
|
png_set_swap_alpha(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_swap_alpha");
|
png_debug(1, "in png_set_swap_alpha");
|
||||||
|
|
||||||
|
@ -182,7 +231,7 @@ png_set_swap_alpha(png_structp png_ptr)
|
||||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_invert_alpha(png_structp png_ptr)
|
png_set_invert_alpha(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_invert_alpha");
|
png_debug(1, "in png_set_invert_alpha");
|
||||||
|
|
||||||
|
@ -195,7 +244,7 @@ png_set_invert_alpha(png_structp png_ptr)
|
||||||
|
|
||||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_invert_mono(png_structp png_ptr)
|
png_set_invert_mono(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_invert_mono");
|
png_debug(1, "in png_set_invert_mono");
|
||||||
|
|
||||||
|
@ -623,7 +672,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||||
/* Added at libpng-1.5.10 */
|
/* Added at libpng-1.5.10 */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
|
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||||
{
|
{
|
||||||
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
||||||
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
|
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
|
||||||
|
@ -726,7 +775,7 @@ png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
|
||||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
png_set_user_transform_info(png_structrp png_ptr, png_voidp
|
||||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_user_transform_info");
|
png_debug(1, "in png_set_user_transform_info");
|
||||||
|
@ -746,18 +795,18 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_user_transform_ptr(png_const_structp png_ptr)
|
png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
return png_ptr->user_transform_ptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_current_row_number(png_const_structp png_ptr)
|
png_get_current_row_number(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
/* See the comments in png.h - this is the sub-image row when reading and
|
/* See the comments in png.h - this is the sub-image row when reading and
|
||||||
* interlaced image.
|
* interlaced image.
|
||||||
|
@ -769,7 +818,7 @@ png_get_current_row_number(png_const_structp png_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_current_pass_number(png_const_structp png_ptr)
|
png_get_current_pass_number(png_const_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
return png_ptr->pass;
|
return png_ptr->pass;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngwio.c - functions for data output
|
/* pngwio.c - functions for data output
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -30,11 +30,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
/* NOTE: write_data_fn must not change the buffer! */
|
/* NOTE: write_data_fn must not change the buffer! */
|
||||||
if (png_ptr->write_data_fn != NULL )
|
if (png_ptr->write_data_fn != NULL )
|
||||||
(*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length);
|
(*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),
|
||||||
|
length);
|
||||||
|
|
||||||
else
|
else
|
||||||
png_error(png_ptr, "Call to NULL write function");
|
png_error(png_ptr, "Call to NULL write function");
|
||||||
|
@ -46,7 +47,6 @@ png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
||||||
* write_data function and use it at run time with png_set_write_fn(), rather
|
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||||
* than changing the library.
|
* than changing the library.
|
||||||
*/
|
*/
|
||||||
#ifndef USE_FAR_KEYWORD
|
|
||||||
void PNGCBAPI
|
void PNGCBAPI
|
||||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
|
@ -60,64 +60,6 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
if (check != length)
|
if (check != length)
|
||||||
png_error(png_ptr, "Write Error");
|
png_error(png_ptr, "Write Error");
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
/* This is the model-independent version. Since the standard I/O library
|
|
||||||
* can't handle far buffers in the medium and small models, we have to copy
|
|
||||||
* the data.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define NEAR_BUF_SIZE 1024
|
|
||||||
#define MIN(a,b) (a <= b ? a : b)
|
|
||||||
|
|
||||||
void PNGCBAPI
|
|
||||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|
||||||
{
|
|
||||||
png_uint_32 check;
|
|
||||||
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
|
||||||
png_FILE_p io_ptr;
|
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Check if data really is near. If so, use usual code. */
|
|
||||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
|
||||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
|
||||||
|
|
||||||
if ((png_bytep)near_data == data)
|
|
||||||
{
|
|
||||||
check = fwrite(near_data, 1, length, io_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
png_byte buf[NEAR_BUF_SIZE];
|
|
||||||
png_size_t written, remaining, err;
|
|
||||||
check = 0;
|
|
||||||
remaining = length;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
|
||||||
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
|
||||||
err = fwrite(buf, 1, written, io_ptr);
|
|
||||||
|
|
||||||
if (err != written)
|
|
||||||
break;
|
|
||||||
|
|
||||||
else
|
|
||||||
check += err;
|
|
||||||
|
|
||||||
data += written;
|
|
||||||
remaining -= written;
|
|
||||||
}
|
|
||||||
while (remaining != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (check != length)
|
|
||||||
png_error(png_ptr, "Write Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function is called to output any data pending writing (normally
|
/* This function is called to output any data pending writing (normally
|
||||||
|
@ -126,7 +68,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_flush(png_structp png_ptr)
|
png_flush(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr->output_flush_fn != NULL)
|
if (png_ptr->output_flush_fn != NULL)
|
||||||
(*(png_ptr->output_flush_fn))(png_ptr);
|
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||||
|
@ -141,7 +83,7 @@ png_default_flush(png_structp png_ptr)
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
|
||||||
fflush(io_ptr);
|
fflush(io_ptr);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
@ -177,7 +119,7 @@ png_default_flush(png_structp png_ptr)
|
||||||
* *FILE structure.
|
* *FILE structure.
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
|
@ -219,36 +161,4 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
" same structure");
|
" same structure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FAR_KEYWORD
|
|
||||||
# ifdef _MSC_VER
|
|
||||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
|
||||||
{
|
|
||||||
void *near_ptr;
|
|
||||||
void FAR *far_ptr;
|
|
||||||
FP_OFF(near_ptr) = FP_OFF(ptr);
|
|
||||||
far_ptr = (void FAR *)near_ptr;
|
|
||||||
|
|
||||||
if (check != 0)
|
|
||||||
if (FP_SEG(ptr) != FP_SEG(far_ptr))
|
|
||||||
png_error(png_ptr, "segment lost in conversion");
|
|
||||||
|
|
||||||
return(near_ptr);
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
|
||||||
{
|
|
||||||
void *near_ptr;
|
|
||||||
void FAR *far_ptr;
|
|
||||||
near_ptr = (void FAR *)ptr;
|
|
||||||
far_ptr = (void FAR *)near_ptr;
|
|
||||||
|
|
||||||
if (check != 0)
|
|
||||||
if (far_ptr != ptr)
|
|
||||||
png_error(png_ptr, "segment lost in conversion");
|
|
||||||
|
|
||||||
return(near_ptr);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#endif /* PNG_WRITE_SUPPORTED */
|
#endif /* PNG_WRITE_SUPPORTED */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.13 [September 27, 2012]
|
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
* transformations is significant.
|
* transformations is significant.
|
||||||
*/
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
|
png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_do_write_transformations");
|
png_debug(1, "in png_do_write_transformations");
|
||||||
|
|
||||||
|
@ -45,20 +45,8 @@ png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
|
||||||
|
|
||||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||||
if (png_ptr->transformations & PNG_FILLER)
|
if (png_ptr->transformations & PNG_FILLER)
|
||||||
{
|
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||||
if (png_ptr->color_type & (PNG_COLOR_MASK_ALPHA|PNG_COLOR_MASK_PALETTE))
|
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||||
{
|
|
||||||
/* GA, RGBA or palette; in any of these cases libpng will not do the
|
|
||||||
* the correct thing (whatever that might be).
|
|
||||||
*/
|
|
||||||
png_warning(png_ptr, "incorrect png_set_filler call ignored");
|
|
||||||
png_ptr->transformations &= ~PNG_FILLER;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
|
||||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||||
|
@ -299,7 +287,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||||
{
|
{
|
||||||
png_bytep bp = row;
|
png_bytep bp = row;
|
||||||
png_size_t i;
|
png_size_t i;
|
||||||
png_byte mask;
|
unsigned int mask;
|
||||||
png_size_t row_bytes = row_info->rowbytes;
|
png_size_t row_bytes = row_info->rowbytes;
|
||||||
|
|
||||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||||
|
@ -313,20 +301,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||||
|
|
||||||
for (i = 0; i < row_bytes; i++, bp++)
|
for (i = 0; i < row_bytes; i++, bp++)
|
||||||
{
|
{
|
||||||
png_uint_16 v;
|
|
||||||
int j;
|
int j;
|
||||||
|
unsigned int v, out;
|
||||||
|
|
||||||
v = *bp;
|
v = *bp;
|
||||||
*bp = 0;
|
out = 0;
|
||||||
|
|
||||||
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
|
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
|
||||||
{
|
{
|
||||||
if (j > 0)
|
if (j > 0)
|
||||||
*bp |= (png_byte)((v << j) & 0xff);
|
out |= v << j;
|
||||||
|
|
||||||
else
|
else
|
||||||
*bp |= (png_byte)((v >> (-j)) & mask);
|
out |= (v >> (-j)) & mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*bp = (png_byte)(out & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,21 +329,23 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||||
for (i = 0; i < istop; i++, bp++)
|
for (i = 0; i < istop; i++, bp++)
|
||||||
{
|
{
|
||||||
|
|
||||||
png_uint_16 v;
|
const unsigned int c = i%channels;
|
||||||
int j;
|
int j;
|
||||||
int c = (int)(i%channels);
|
unsigned int v, out;
|
||||||
|
|
||||||
v = *bp;
|
v = *bp;
|
||||||
*bp = 0;
|
out = 0;
|
||||||
|
|
||||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||||
{
|
{
|
||||||
if (j > 0)
|
if (j > 0)
|
||||||
*bp |= (png_byte)((v << j) & 0xff);
|
out |= v << j;
|
||||||
|
|
||||||
else
|
else
|
||||||
*bp |= (png_byte)((v >> (-j)) & 0xff);
|
out |= v >> (-j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*bp = (png_byte)(out & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,22 +357,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||||
|
|
||||||
for (bp = row, i = 0; i < istop; i++)
|
for (bp = row, i = 0; i < istop; i++)
|
||||||
{
|
{
|
||||||
int c = (int)(i%channels);
|
const unsigned int c = i%channels;
|
||||||
png_uint_16 value, v;
|
|
||||||
int j;
|
int j;
|
||||||
|
unsigned int value, v;
|
||||||
|
|
||||||
v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));
|
v = png_get_uint_16(bp);
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||||
{
|
{
|
||||||
if (j > 0)
|
if (j > 0)
|
||||||
value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
|
value |= v << j;
|
||||||
|
|
||||||
else
|
else
|
||||||
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
value |= v >> (-j);
|
||||||
}
|
}
|
||||||
*bp++ = (png_byte)(value >> 8);
|
*bp++ = (png_byte)((value >> 8) & 0xff);
|
||||||
*bp++ = (png_byte)(value & 0xff);
|
*bp++ = (png_byte)(value & 0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue