mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[CHG] libpng updated to version 1.5.2
This commit is contained in:
parent
e98868aecb
commit
7092599b47
11 changed files with 539 additions and 433 deletions
|
@ -14,7 +14,7 @@
|
||||||
#include "pngpriv.h"
|
#include "pngpriv.h"
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
typedef png_libpng_version_1_5_1 Your_png_h_is_not_version_1_5_1;
|
typedef png_libpng_version_1_5_2 Your_png_h_is_not_version_1_5_2;
|
||||||
|
|
||||||
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
||||||
* of the PNG file signature. If the PNG data is embedded into another
|
* of the PNG file signature. If the PNG data is embedded into another
|
||||||
|
@ -555,13 +555,13 @@ png_get_copyright(png_const_structp png_ptr)
|
||||||
#else
|
#else
|
||||||
# ifdef __STDC__
|
# ifdef __STDC__
|
||||||
return PNG_STRING_NEWLINE \
|
return PNG_STRING_NEWLINE \
|
||||||
"libpng version 1.5.1 - February 3, 2011" PNG_STRING_NEWLINE \
|
"libpng version 1.5.2 - March 31, 2011" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
"Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||||
PNG_STRING_NEWLINE;
|
PNG_STRING_NEWLINE;
|
||||||
# else
|
# else
|
||||||
return "libpng version 1.5.1 - February 3, 2011\
|
return "libpng version 1.5.2 - March 31, 2011\
|
||||||
Copyright (c) 1998-2011 Glenn Randers-Pehrson\
|
Copyright (c) 1998-2011 Glenn Randers-Pehrson\
|
||||||
Copyright (c) 1996-1997 Andreas Dilger\
|
Copyright (c) 1996-1997 Andreas Dilger\
|
||||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||||
|
|
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.1 - February 3, 2011
|
* libpng version 1.5.2 - March 31, 2011
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
@ -22,29 +22,31 @@
|
||||||
#ifndef PNGCONF_H
|
#ifndef PNGCONF_H
|
||||||
#define PNGCONF_H
|
#define PNGCONF_H
|
||||||
|
|
||||||
|
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||||
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
|
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
|
||||||
* definition file for machine specific limits, this may impact the
|
* definition file for machine specific limits, this may impact the
|
||||||
* correctness of the definitons below (see uses of INT_MAX).
|
* correctness of the definitons below (see uses of INT_MAX).
|
||||||
*/
|
*/
|
||||||
#ifndef PNG_NO_LIMITS_H
|
# ifndef PNG_NO_LIMITS_H
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/* For the memory copy APIs (i.e. the standard definitions of these),
|
/* For the memory copy APIs (i.e. the standard definitions of these),
|
||||||
* because this file defines png_memcpy and so on the base APIs must
|
* because this file defines png_memcpy and so on the base APIs must
|
||||||
* be defined here.
|
* be defined here.
|
||||||
*/
|
*/
|
||||||
#ifdef BSD
|
# ifdef BSD
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#else
|
# else
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/* For png_FILE_p - this provides the standard definition of a
|
/* For png_FILE_p - this provides the standard definition of a
|
||||||
* FILE
|
* FILE
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_STDIO_SUPPORTED
|
# ifdef PNG_STDIO_SUPPORTED
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This controls optimization of the reading of 16 and 32 bit values
|
/* This controls optimization of the reading of 16 and 32 bit values
|
||||||
|
@ -282,23 +284,15 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* THe following complexity is concerned with getting the 'attributes' of the
|
/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
|
||||||
* declared function in the correct place. This potentially requires a separate
|
* 'attributes' as a storage class - the attributes go at the start of the
|
||||||
* PNG_EXPORT function for every compiler.
|
* function definition, and attributes are always appended regardless of the
|
||||||
|
* compiler. This considerably simplifies these macros but may cause problems
|
||||||
|
* if any compilers both need function attributes and fail to handle them as
|
||||||
|
* a storage class (this is unlikely.)
|
||||||
*/
|
*/
|
||||||
#ifndef PNG_FUNCTION
|
#ifndef PNG_FUNCTION
|
||||||
# ifdef __GNUC__
|
# define PNG_FUNCTION(type, name, args, attributes) attributes type name args
|
||||||
# define PNG_FUNCTION(type, name, args, attributes)\
|
|
||||||
attributes type name args
|
|
||||||
# else /* !GNUC */
|
|
||||||
# ifdef _MSC_VER
|
|
||||||
# define PNG_FUNCTION(type, name, args, attributes)\
|
|
||||||
attributes type name args
|
|
||||||
# else /* !MSC */
|
|
||||||
# define PNG_FUNCTION(type, name, args, attributes)\
|
|
||||||
type name args
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_EXPORT_TYPE
|
#ifndef PNG_EXPORT_TYPE
|
||||||
|
@ -310,13 +304,19 @@
|
||||||
* scripts directory.
|
* scripts directory.
|
||||||
*/
|
*/
|
||||||
#ifndef PNG_EXPORTA
|
#ifndef PNG_EXPORTA
|
||||||
|
|
||||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||||
extern PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args),\
|
PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
|
||||||
attributes)
|
extern attributes)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||||
|
* so make something non-empty to satisfy the requirement:
|
||||||
|
*/
|
||||||
|
#define PNG_EMPTY /*empty list*/
|
||||||
|
|
||||||
#define PNG_EXPORT(ordinal, type, name, args)\
|
#define PNG_EXPORT(ordinal, type, name, args)\
|
||||||
PNG_EXPORTA(ordinal, type, name, args, )
|
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
|
||||||
|
|
||||||
/* Use PNG_REMOVED to comment out a removed interface. */
|
/* Use PNG_REMOVED to comment out a removed interface. */
|
||||||
#ifndef PNG_REMOVED
|
#ifndef PNG_REMOVED
|
||||||
|
@ -324,8 +324,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_CALLBACK
|
#ifndef PNG_CALLBACK
|
||||||
# define PNG_CALLBACK(type, name, args, attributes)\
|
# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
|
||||||
type (PNGCBAPI name) PNGARG(args) attributes
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Support for compiler specific function attributes. These are used
|
/* Support for compiler specific function attributes. These are used
|
||||||
|
@ -347,7 +346,7 @@
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
# ifdef __GNUC__
|
# if defined(__GNUC__)
|
||||||
# ifndef PNG_USE_RESULT
|
# ifndef PNG_USE_RESULT
|
||||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||||
# endif
|
# endif
|
||||||
|
@ -355,7 +354,21 @@
|
||||||
# define PNG_NORETURN __attribute__((__noreturn__))
|
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||||
# endif
|
# endif
|
||||||
# ifndef PNG_PTR_NORETURN
|
# ifndef PNG_PTR_NORETURN
|
||||||
# define PNG_PTR_NORETURN __attribute__((__noreturn__))
|
/* It's not enough to have the compiler be the correct compiler at
|
||||||
|
* this point - it's necessary for the library (which defines
|
||||||
|
* the type of the library longjmp) to also be the GNU library.
|
||||||
|
* This is because many systems use the GNU compiler with a
|
||||||
|
* non-GNU libc implementation. Min/GW headers are also compatible
|
||||||
|
* with GCC as well as uclibc, so it seems best to exclude known
|
||||||
|
* problem libcs here rather than just including known libcs.
|
||||||
|
*
|
||||||
|
* NOTE: this relies on the only use of PNG_PTR_NORETURN being with
|
||||||
|
* the system longjmp. If the same type is used elsewhere then this
|
||||||
|
* will need to be changed.
|
||||||
|
*/
|
||||||
|
# if !defined(__CYGWIN__)
|
||||||
|
# define PNG_PTR_NORETURN __attribute__((__noreturn__))
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# ifndef PNG_ALLOCATED
|
# ifndef PNG_ALLOCATED
|
||||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||||
|
@ -380,18 +393,19 @@
|
||||||
# define PNG_PRIVATE \
|
# define PNG_PRIVATE \
|
||||||
__attribute__((__deprecated__))
|
__attribute__((__deprecated__))
|
||||||
# endif
|
# endif
|
||||||
# endif /* PNG_PRIVATE */
|
# endif
|
||||||
# endif /* PNGLIB_BUILD */
|
# endif /* PNGLIB_BUILD */
|
||||||
# endif /* __GNUC__ */
|
# endif /* __GNUC__ */
|
||||||
# ifdef _MSC_VER /* may need to check value */
|
|
||||||
|
# if 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_PTR_NORETURN
|
# ifndef PNG_PTR_NORETURN
|
||||||
# define PNG_PTR_NORETURN /*not supported*/
|
# define PNG_PTR_NORETURN /* not supported */
|
||||||
# endif
|
# endif
|
||||||
# ifndef PNG_ALLOCATED
|
# ifndef PNG_ALLOCATED
|
||||||
# define PNG_ALLOCATED __declspec(restrict)
|
# define PNG_ALLOCATED __declspec(restrict)
|
||||||
|
@ -410,9 +424,9 @@
|
||||||
# endif
|
# endif
|
||||||
# ifndef PNG_PRIVATE
|
# ifndef PNG_PRIVATE
|
||||||
# define PNG_PRIVATE __declspec(deprecated)
|
# define PNG_PRIVATE __declspec(deprecated)
|
||||||
# endif /* PNG_PRIVATE */
|
# endif
|
||||||
# endif /* PNGLIB_BUILD */
|
# endif /* PNGLIB_BUILD */
|
||||||
# endif /* __GNUC__ */
|
# endif /* _MSC_VER */
|
||||||
#endif /* PNG_PEDANTIC_WARNINGS */
|
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||||
|
|
||||||
#ifndef PNG_DEPRECATED
|
#ifndef PNG_DEPRECATED
|
||||||
|
@ -424,6 +438,9 @@
|
||||||
#ifndef PNG_NORETURN
|
#ifndef PNG_NORETURN
|
||||||
# define PNG_NORETURN /* This function does not return */
|
# define PNG_NORETURN /* This function does not return */
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef PNG_PTR_NORETURN
|
||||||
|
# define PNG_PTR_NORETURN /* This function does not return */
|
||||||
|
#endif
|
||||||
#ifndef PNG_ALLOCATED
|
#ifndef PNG_ALLOCATED
|
||||||
# define PNG_ALLOCATED /* The result of the function is new memory */
|
# define PNG_ALLOCATED /* The result of the function is new memory */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngpread.c - read a png file in push mode
|
/* pngpread.c - read a png file in push mode
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.1 [February 3, 2011]
|
* Last changed in libpng 1.5.2 [March 31, 2011]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2011 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.)
|
||||||
|
@ -1026,7 +1026,7 @@ png_push_process_row(png_structp png_ptr)
|
||||||
|
|
||||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
|
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
|
||||||
|
|
||||||
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
|
if (png_ptr->transformations)
|
||||||
png_do_read_transformations(png_ptr);
|
png_do_read_transformations(png_ptr);
|
||||||
|
|
||||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* (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.5.2 [March 31, 2011]
|
||||||
*
|
*
|
||||||
* 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
|
||||||
|
@ -83,13 +83,15 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||||
# define PNG_MAX_MALLOC_64K
|
# define PNG_MAX_MALLOC_64K
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_UNUSED
|
||||||
/* Unused formal parameter warnings are silenced using the following macro
|
/* Unused formal parameter warnings are silenced using the following macro
|
||||||
* which is expected to have no bad effects on performance (optimizing
|
* which is expected to have no bad effects on performance (optimizing
|
||||||
* compilers will probably remove it entirely). Note that if you replace
|
* compilers will probably remove it entirely). Note that if you replace
|
||||||
* it with something other than whitespace, you must include the terminating
|
* it with something other than whitespace, you must include the terminating
|
||||||
* semicolon.
|
* semicolon.
|
||||||
*/
|
*/
|
||||||
#define PNG_UNUSED(param) (void)param;
|
# define PNG_UNUSED(param) (void)param;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Just a little check that someone hasn't tried to define something
|
/* Just a little check that someone hasn't tried to define something
|
||||||
* contradictory.
|
* contradictory.
|
||||||
|
@ -140,7 +142,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||||
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
|
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
|
||||||
/* png.c requires the following ANSI-C constants if the conversion of
|
/* png.c requires the following ANSI-C constants if the conversion of
|
||||||
* floating point to ASCII is implemented therein:
|
* floating point to ASCII is implemented therein:
|
||||||
*
|
*
|
||||||
* DBL_DIG Maximum number of decimal digits (can be set to any constant)
|
* DBL_DIG Maximum number of decimal digits (can be set to any constant)
|
||||||
* DBL_MIN Smallest normalized fp number (can be set to an arbitrary value)
|
* DBL_MIN Smallest normalized fp number (can be set to an arbitrary value)
|
||||||
* DBL_MAX Maximum floating point number (can be set to an arbitrary value)
|
* DBL_MAX Maximum floating point number (can be set to an arbitrary value)
|
||||||
|
@ -286,7 +288,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||||
#define PNG_QUANTIZE 0x0040
|
#define PNG_QUANTIZE 0x0040
|
||||||
#define PNG_BACKGROUND 0x0080
|
#define PNG_BACKGROUND 0x0080
|
||||||
#define PNG_BACKGROUND_EXPAND 0x0100
|
#define PNG_BACKGROUND_EXPAND 0x0100
|
||||||
/* 0x0200 unused */
|
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
|
||||||
#define PNG_16_TO_8 0x0400
|
#define PNG_16_TO_8 0x0400
|
||||||
#define PNG_RGBA 0x0800
|
#define PNG_RGBA 0x0800
|
||||||
#define PNG_EXPAND 0x1000
|
#define PNG_EXPAND 0x1000
|
||||||
|
@ -340,8 +342,8 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||||
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L
|
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L
|
||||||
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L
|
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L
|
||||||
#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L
|
#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L
|
||||||
#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */
|
/* 0x200000L unused */
|
||||||
#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */
|
/* 0x400000L unused */
|
||||||
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */
|
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */
|
||||||
/* 0x1000000L unused */
|
/* 0x1000000L unused */
|
||||||
/* 0x2000000L unused */
|
/* 0x2000000L unused */
|
||||||
|
@ -772,8 +774,8 @@ PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
|
||||||
|
|
||||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||||
PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
|
PNG_EXTERN void png_do_strip_channel PNGARG((png_row_infop row_info,
|
||||||
png_bytep row, png_uint_32 flags));
|
png_bytep row, int at_start));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_16BIT_SUPPORTED
|
#ifdef PNG_16BIT_SUPPORTED
|
||||||
|
@ -875,6 +877,11 @@ PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
|
||||||
png_bytep row, png_const_color_16p trans_color));
|
png_bytep row, png_const_color_16p trans_color));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||||
|
PNG_EXTERN void png_do_expand_16 PNGARG((png_row_infop row_info,
|
||||||
|
png_bytep row));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The following decodes the appropriate chunks, and does error correction,
|
/* The following decodes the appropriate chunks, and does error correction,
|
||||||
* then calls the appropriate callback for the chunk if it is valid.
|
* then calls the appropriate callback for the chunk if it is valid.
|
||||||
*/
|
*/
|
||||||
|
@ -1184,13 +1191,13 @@ PNG_EXTERN int png_check_fp_string PNGARG((png_const_charp string,
|
||||||
* holds the result.
|
* holds the result.
|
||||||
*/
|
*/
|
||||||
PNG_EXTERN int png_muldiv PNGARG((png_fixed_point_p res, png_fixed_point a,
|
PNG_EXTERN int png_muldiv PNGARG((png_fixed_point_p res, png_fixed_point a,
|
||||||
png_int_32 times, png_int_32 div));
|
png_int_32 multiplied_by, png_int_32 divided_by));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
|
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
|
||||||
/* Same deal, but issue a warning on overflow and return 0. */
|
/* Same deal, but issue a warning on overflow and return 0. */
|
||||||
PNG_EXTERN png_fixed_point png_muldiv_warn PNGARG((png_structp png_ptr,
|
PNG_EXTERN png_fixed_point png_muldiv_warn PNGARG((png_structp png_ptr,
|
||||||
png_fixed_point a, png_int_32 times, png_int_32 div));
|
png_fixed_point a, png_int_32 multiplied_by, png_int_32 divided_by));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||||
|
@ -1217,12 +1224,12 @@ PNG_EXTERN png_fixed_point png_reciprocal2 PNGARG((png_fixed_point a,
|
||||||
* correct bit value - 0..255 or 0..65535 as required.
|
* correct bit value - 0..255 or 0..65535 as required.
|
||||||
*/
|
*/
|
||||||
PNG_EXTERN png_uint_16 png_gamma_correct PNGARG((png_structp png_ptr,
|
PNG_EXTERN png_uint_16 png_gamma_correct PNGARG((png_structp png_ptr,
|
||||||
unsigned int value, png_fixed_point gamma));
|
unsigned int value, png_fixed_point gamma_value));
|
||||||
PNG_EXTERN int png_gamma_significant PNGARG((png_fixed_point gamma));
|
PNG_EXTERN int png_gamma_significant PNGARG((png_fixed_point gamma_value));
|
||||||
PNG_EXTERN png_uint_16 png_gamma_16bit_correct PNGARG((unsigned int value,
|
PNG_EXTERN png_uint_16 png_gamma_16bit_correct PNGARG((unsigned int value,
|
||||||
png_fixed_point gamma));
|
png_fixed_point gamma_value));
|
||||||
PNG_EXTERN png_byte png_gamma_8bit_correct PNGARG((unsigned int value,
|
PNG_EXTERN png_byte png_gamma_8bit_correct PNGARG((unsigned int value,
|
||||||
png_fixed_point gamma));
|
png_fixed_point gamma_value));
|
||||||
PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
|
PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
|
||||||
int bit_depth));
|
int bit_depth));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.1 [$RDATE%]
|
* Last changed in libpng 1.5.2 [March 31, 2011]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2011 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.)
|
||||||
|
@ -488,9 +488,11 @@ void PNGAPI
|
||||||
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||||
{
|
{
|
||||||
PNG_IDAT;
|
PNG_IDAT;
|
||||||
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
|
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
|
||||||
0xff};
|
0xff};
|
||||||
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||||
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
|
@ -702,7 +704,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
|
if (png_ptr->transformations)
|
||||||
png_do_read_transformations(png_ptr);
|
png_do_read_transformations(png_ptr);
|
||||||
|
|
||||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
|
@ -1311,7 +1313,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||||
{
|
{
|
||||||
int row;
|
int row;
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* png_read_info() gives us all of the information from the
|
/* png_read_info() gives us all of the information from the
|
||||||
|
@ -1426,6 +1428,11 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||||
|
|
||||||
/* We don't handle adding filler bytes */
|
/* We don't handle adding filler bytes */
|
||||||
|
|
||||||
|
/* We use png_read_image and rely on that for interlace handling, but we also
|
||||||
|
* call png_read_update_info therefore must turn on interlace handling now:
|
||||||
|
*/
|
||||||
|
(void)png_set_interlace_handling(png_ptr);
|
||||||
|
|
||||||
/* Optional call to gamma correct and add the background to the palette
|
/* Optional call to gamma correct and add the background to the palette
|
||||||
* and update info structure. REQUIRED if you are expecting libpng to
|
* and update info structure. REQUIRED if you are expecting libpng to
|
||||||
* update the palette for you (i.e., you selected such a transform above).
|
* update the palette for you (i.e., you selected such a transform above).
|
||||||
|
|
|
@ -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.1 [February 3, 2011]
|
* Last changed in libpng 1.5.2 [March 31, 2011]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2011 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.)
|
||||||
|
@ -137,6 +137,7 @@ png_set_strip_16(png_structp png_ptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->transformations |= PNG_16_TO_8;
|
png_ptr->transformations |= PNG_16_TO_8;
|
||||||
|
png_ptr->transformations &= ~PNG_EXPAND_16;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -149,7 +150,7 @@ png_set_strip_alpha(png_structp png_ptr)
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
|
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -686,6 +687,25 @@ png_set_tRNS_to_alpha(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||||
|
|
||||||
|
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||||
|
/* Expand to 16 bit channels, expand the tRNS chunk too (because otherwise
|
||||||
|
* it may not work correctly.)
|
||||||
|
*/
|
||||||
|
void PNGAPI
|
||||||
|
png_set_expand_16(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_set_expand_16");
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||||
|
png_ptr->transformations &= ~PNG_16_TO_8;
|
||||||
|
|
||||||
|
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||||
|
}
|
||||||
|
#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_structp png_ptr)
|
||||||
|
@ -1073,7 +1093,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
*/
|
*/
|
||||||
png_ptr->transformations &= ~PNG_BACKGROUND;
|
png_ptr->transformations &= ~PNG_BACKGROUND;
|
||||||
png_ptr->transformations &= ~PNG_GAMMA;
|
png_ptr->transformations &= ~PNG_GAMMA;
|
||||||
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
|
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
|
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
|
||||||
|
@ -1207,7 +1227,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||||
|
|
||||||
/* Handled alpha, still need to strip the channel. */
|
/* Handled alpha, still need to strip the channel. */
|
||||||
png_ptr->transformations &= ~PNG_BACKGROUND;
|
png_ptr->transformations &= ~PNG_BACKGROUND;
|
||||||
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
|
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||||
}
|
}
|
||||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
||||||
|
|
||||||
|
@ -1285,6 +1305,14 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||||
|
if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 &&
|
||||||
|
info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||||
|
{
|
||||||
|
info_ptr->bit_depth = 16;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||||
if (png_ptr->transformations & PNG_BACKGROUND)
|
if (png_ptr->transformations & PNG_BACKGROUND)
|
||||||
{
|
{
|
||||||
|
@ -1353,7 +1381,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
info_ptr->channels = 1;
|
info_ptr->channels = 1;
|
||||||
|
|
||||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||||
if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)
|
if (png_ptr->transformations & PNG_STRIP_ALPHA)
|
||||||
info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1439,24 +1467,31 @@ png_do_read_transformations(png_structp png_ptr)
|
||||||
png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
|
png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (png_ptr->num_trans &&
|
if (png_ptr->num_trans &&
|
||||||
(png_ptr->transformations & PNG_EXPAND_tRNS))
|
(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||||
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
&(png_ptr->trans_color));
|
&(png_ptr->trans_color));
|
||||||
else
|
|
||||||
|
|
||||||
|
else
|
||||||
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Delay the 'expand 16' step until later for efficiency, so that the
|
||||||
|
* intermediate steps work with 8 bit data.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||||
if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)
|
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||||
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
(png_ptr->row_info.color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||||
PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA));
|
png_ptr->row_info.color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||||
|
png_do_strip_channel(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
|
0/*!at_start, because SWAP_ALPHA happens later*/);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||||
|
@ -1565,6 +1600,16 @@ png_do_read_transformations(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||||
|
|
||||||
|
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||||
|
/* Do the expansion now, after all the arithmetic has been done. Notice
|
||||||
|
* that previous transformations can handle the PNG_EXPAND_16 flag if this
|
||||||
|
* is efficient (particularly true in the case of gamma correction, where
|
||||||
|
* better accuracy results faster!)
|
||||||
|
*/
|
||||||
|
if (png_ptr->transformations & PNG_EXPAND_16)
|
||||||
|
png_do_expand_16(&png_ptr->row_info, png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_INVERT_SUPPORTED
|
#ifdef PNG_READ_INVERT_SUPPORTED
|
||||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||||
png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
|
@ -1592,6 +1637,9 @@ png_do_read_transformations(png_structp png_ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
|
/*NOTE: this must be in the wrong place - what happens if BGR is set too?
|
||||||
|
* Need pngvalid to test this combo.
|
||||||
|
*/
|
||||||
/* If gray -> RGB, do so now only if we did not do so above */
|
/* If gray -> RGB, do so now only if we did not do so above */
|
||||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||||
|
@ -1804,7 +1852,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||||
switch (row_info->bit_depth)
|
switch (row_info->bit_depth)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
|
@ -4064,6 +4112,37 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||||
|
/* If the bit depth is 8 and the colour type is not a palette type expand the
|
||||||
|
* whole row to 16 bits. Has no effect otherwise.
|
||||||
|
*/
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_do_expand_16(png_row_infop row_info, png_bytep row)
|
||||||
|
{
|
||||||
|
if (row_info->bit_depth == 8 &&
|
||||||
|
row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||||
|
{
|
||||||
|
/* The row have a sequence of bytes containing [0..255] and we need
|
||||||
|
* to turn it into another row containing [0..65535], to do this we
|
||||||
|
* calculate:
|
||||||
|
*
|
||||||
|
* (input / 255) * 65535
|
||||||
|
*
|
||||||
|
* Which happens to be exactly input * 257 and this can be achieved
|
||||||
|
* simply by byte replication in place (copying backwards).
|
||||||
|
*/
|
||||||
|
png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */
|
||||||
|
png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */
|
||||||
|
while (dp > sp)
|
||||||
|
dp[-2] = dp[-1] = *--sp, dp -= 2;
|
||||||
|
|
||||||
|
row_info->rowbytes *= 2;
|
||||||
|
row_info->bit_depth = 16;
|
||||||
|
row_info->pixel_depth = (png_byte)(row_info->channels * 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_quantize(png_row_infop row_info, png_bytep row,
|
png_do_quantize(png_row_infop row_info, png_bytep row,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngrutil.c - utilities to read a PNG file
|
/* pngrutil.c - utilities to read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.1 [February 3, 2011]
|
* Last changed in libpng 1.5.2 [March 31, 2011]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2011 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.)
|
||||||
|
@ -1275,9 +1275,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||||
{
|
{
|
||||||
png_bytep entry_start;
|
png_bytep entry_start;
|
||||||
png_sPLT_t new_palette;
|
png_sPLT_t new_palette;
|
||||||
#ifdef PNG_POINTER_INDEXING_SUPPORTED
|
|
||||||
png_sPLT_entryp pp;
|
png_sPLT_entryp pp;
|
||||||
#endif
|
|
||||||
png_uint_32 data_length;
|
png_uint_32 data_length;
|
||||||
int entry_size, i;
|
int entry_size, i;
|
||||||
png_uint_32 skip = 0;
|
png_uint_32 skip = 0;
|
||||||
|
@ -1442,7 +1440,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||||
pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;
|
pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
|
pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3463,6 +3461,24 @@ png_read_start_row(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||||
|
if (png_ptr->transformations & PNG_EXPAND_16)
|
||||||
|
{
|
||||||
|
# ifdef PNG_READ_EXPAND_SUPPORTED
|
||||||
|
/* In fact it is an error if it isn't supported, but checking is
|
||||||
|
* the safe way.
|
||||||
|
*/
|
||||||
|
if (png_ptr->transformations & PNG_EXPAND)
|
||||||
|
{
|
||||||
|
if (png_ptr->bit_depth < 16)
|
||||||
|
max_pixel_depth *= 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
png_ptr->transformations &= ~PNG_EXPAND_16;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_FILLER_SUPPORTED
|
#ifdef PNG_READ_FILLER_SUPPORTED
|
||||||
if (png_ptr->transformations & (PNG_FILLER))
|
if (png_ptr->transformations & (PNG_FILLER))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* 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.1 [February 3, 2011]
|
* Last changed in libpng 1.5.2 [March 31, 2011]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2011 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.)
|
||||||
|
@ -424,170 +424,115 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||||
|
|
||||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||||
/* Remove filler or alpha byte(s) */
|
/* Remove a channel - this used to be 'png_do_strip_filler' but it used a
|
||||||
|
* somewhat weird combination of flags to determine what to do. All the calls
|
||||||
|
* to png_do_strip_filler are changed in 1.5.2 to call this instead with the
|
||||||
|
* correct arguments.
|
||||||
|
*
|
||||||
|
* The routine isn't general - the channel must be the channel at the start or
|
||||||
|
* end (not in the middle) of each pixel.
|
||||||
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_do_strip_filler");
|
png_bytep sp = row; /* source pointer */
|
||||||
|
png_bytep dp = row; /* destination pointer */
|
||||||
|
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
|
||||||
|
|
||||||
|
/* At the start sp will point to the first byte to copy and dp to where
|
||||||
|
* it is copied to. ep always points just beyond the end of the row, so
|
||||||
|
* the loop simply copies (channels-1) channels until sp reaches ep.
|
||||||
|
*/
|
||||||
|
/* GA, GX, XG cases */
|
||||||
|
if (row_info->channels == 2)
|
||||||
{
|
{
|
||||||
png_bytep sp = row;
|
if (row_info->bit_depth == 8)
|
||||||
png_bytep dp = row;
|
|
||||||
png_uint_32 row_width = row_info->width;
|
|
||||||
png_uint_32 i;
|
|
||||||
|
|
||||||
if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
|
|
||||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
|
|
||||||
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
|
||||||
row_info->channels == 4)
|
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (at_start) /* Skip initial filler */
|
||||||
{
|
++sp;
|
||||||
/* This converts from RGBX or RGBA to RGB */
|
else /* Skip initial channels and, for sp, the filler */
|
||||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
sp += 2, ++dp;
|
||||||
{
|
|
||||||
dp += 3; sp += 4;
|
|
||||||
for (i = 1; i < row_width; i++)
|
|
||||||
{
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
sp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This converts from XRGB or ARGB to RGB */
|
/* For a 1 pixel wide image there is nothing to do */
|
||||||
else
|
while (sp < ep)
|
||||||
{
|
*dp++ = *sp, sp += 2;
|
||||||
for (i = 0; i < row_width; i++)
|
|
||||||
{
|
|
||||||
sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
row_info->pixel_depth = 24;
|
|
||||||
row_info->rowbytes = row_width * 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
else /* if (row_info->bit_depth == 16) */
|
row_info->pixel_depth = 8;
|
||||||
{
|
|
||||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
|
||||||
{
|
|
||||||
/* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
|
|
||||||
sp += 8; dp += 6;
|
|
||||||
for (i = 1; i < row_width; i++)
|
|
||||||
{
|
|
||||||
/* This could be (although png_memcpy is probably slower):
|
|
||||||
png_memcpy(dp, sp, 6);
|
|
||||||
sp += 8;
|
|
||||||
dp += 6;
|
|
||||||
*/
|
|
||||||
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
sp += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
|
|
||||||
for (i = 0; i < row_width; i++)
|
|
||||||
{
|
|
||||||
/* This could be (although png_memcpy is probably slower):
|
|
||||||
png_memcpy(dp, sp, 6);
|
|
||||||
sp += 8;
|
|
||||||
dp += 6;
|
|
||||||
*/
|
|
||||||
|
|
||||||
sp += 2;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
row_info->pixel_depth = 48;
|
|
||||||
row_info->rowbytes = row_width * 6;
|
|
||||||
}
|
|
||||||
row_info->channels = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
|
else if (row_info->bit_depth == 16)
|
||||||
(row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
|
|
||||||
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
|
||||||
row_info->channels == 2)
|
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (at_start)
|
||||||
{
|
sp += 2;
|
||||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
else
|
||||||
{
|
sp += 4, dp += 2;
|
||||||
/* This converts from GX or GA to G */
|
|
||||||
for (i = 0; i < row_width; i++)
|
|
||||||
{
|
|
||||||
*dp++ = *sp++;
|
|
||||||
sp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
while (sp < ep)
|
||||||
{
|
*dp++ = *sp++, *dp++ = *sp, sp += 3;
|
||||||
/* This converts from XG or AG to G */
|
|
||||||
for (i = 0; i < row_width; i++)
|
|
||||||
{
|
|
||||||
sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
row_info->pixel_depth = 8;
|
row_info->pixel_depth = 16;
|
||||||
row_info->rowbytes = row_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
else /* if (row_info->bit_depth == 16) */
|
|
||||||
{
|
|
||||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
|
||||||
{
|
|
||||||
/* This converts from GGXX or GGAA to GG */
|
|
||||||
sp += 4; dp += 2;
|
|
||||||
for (i = 1; i < row_width; i++)
|
|
||||||
{
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
sp += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This converts from XXGG or AAGG to GG */
|
|
||||||
for (i = 0; i < row_width; i++)
|
|
||||||
{
|
|
||||||
sp += 2;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
*dp++ = *sp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
row_info->pixel_depth = 16;
|
|
||||||
row_info->rowbytes = row_width * 2;
|
|
||||||
}
|
|
||||||
row_info->channels = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & PNG_FLAG_STRIP_ALPHA)
|
else
|
||||||
row_info->color_type = (png_byte)(row_info->color_type &
|
return; /* bad bit depth */
|
||||||
~PNG_COLOR_MASK_ALPHA);
|
|
||||||
|
row_info->channels = 1;
|
||||||
|
|
||||||
|
/* Finally fix the color type if it records an alpha channel */
|
||||||
|
if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||||
|
row_info->color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* RGBA, RGBX, XRGB cases */
|
||||||
|
else if (row_info->channels == 4)
|
||||||
|
{
|
||||||
|
if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
if (at_start) /* Skip initial filler */
|
||||||
|
++sp;
|
||||||
|
else /* Skip initial channels and, for sp, the filler */
|
||||||
|
sp += 4, dp += 3;
|
||||||
|
|
||||||
|
/* Note that the loop adds 3 to dp and 4 to sp each time. */
|
||||||
|
while (sp < ep)
|
||||||
|
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
|
||||||
|
|
||||||
|
row_info->pixel_depth = 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (row_info->bit_depth == 16)
|
||||||
|
{
|
||||||
|
if (at_start)
|
||||||
|
sp += 2;
|
||||||
|
else
|
||||||
|
sp += 8, dp += 6;
|
||||||
|
|
||||||
|
while (sp < ep)
|
||||||
|
{
|
||||||
|
/* Copy 6 bytes, skip 2 */
|
||||||
|
*dp++ = *sp++, *dp++ = *sp++;
|
||||||
|
*dp++ = *sp++, *dp++ = *sp++;
|
||||||
|
*dp++ = *sp++, *dp++ = *sp, sp += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
row_info->pixel_depth = 48;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return; /* bad bit depth */
|
||||||
|
|
||||||
|
row_info->channels = 3;
|
||||||
|
|
||||||
|
/* Finally fix the color type if it records an alpha channel */
|
||||||
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
|
row_info->color_type = PNG_COLOR_TYPE_RGB;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return; /* The filler channel has gone already */
|
||||||
|
|
||||||
|
/* Fix the rowbytes value. */
|
||||||
|
row_info->rowbytes = dp-row;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -703,11 +648,16 @@ png_get_user_transform_ptr(png_const_structp png_ptr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#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_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
/* See the comments in png.h - this is the sub-image row when reading and
|
||||||
|
* interlaced image.
|
||||||
|
*/
|
||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
return png_ptr->row_number;
|
return png_ptr->row_number;
|
||||||
|
|
||||||
return PNG_UINT_32_MAX; /* help the app not to fail silently */
|
return PNG_UINT_32_MAX; /* help the app not to fail silently */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,6 +668,7 @@ png_get_current_pass_number(png_const_structp png_ptr)
|
||||||
return png_ptr->pass;
|
return png_ptr->pass;
|
||||||
return 8; /* invalid */
|
return 8; /* invalid */
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
|
@ -1177,7 +1177,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||||
* better compression.
|
* better compression.
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */
|
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */
|
||||||
/* Conveneince reset API. */
|
/* Convenience reset API. */
|
||||||
static void
|
static void
|
||||||
png_reset_filter_heuristics(png_structp png_ptr)
|
png_reset_filter_heuristics(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* 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.0 [January 6, 2011]
|
* Last changed in libpng 1.5.2 [March 31, 2011]
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2011 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.)
|
||||||
|
@ -44,8 +44,8 @@ png_do_write_transformations(png_structp png_ptr)
|
||||||
|
|
||||||
#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_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
png_do_strip_channel(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
png_ptr->flags);
|
!(png_ptr->flags & PNG_FILLER_AFTER));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||||
|
|
Loading…
Reference in a new issue