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"
|
||||
|
||||
/* 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
|
||||
* 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
|
||||
# ifdef __STDC__
|
||||
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) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||
PNG_STRING_NEWLINE;
|
||||
# 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) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.5.1 - February 3, 2011
|
||||
* libpng version 1.5.2 - March 31, 2011
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -11,7 +11,7 @@
|
|||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.5.1 - February 3, 2011: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.5.2 - March 31, 2011: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
|
@ -147,6 +147,9 @@
|
|||
* 1.5.1beta01-11 15 10501 15.so.15.1[.0]
|
||||
* 1.5.1rc01-02 15 10501 15.so.15.1[.0]
|
||||
* 1.5.1 15 10501 15.so.15.1[.0]
|
||||
* 1.5.2beta01-03 15 10502 15.so.15.2[.0]
|
||||
* 1.5.2rc01-03 15 10502 15.so.15.2[.0]
|
||||
* 1.5.2 15 10502 15.so.15.2[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
|
@ -178,7 +181,7 @@
|
|||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.5.1, February 3, 2011, are
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.5.2, March 31, 2011, are
|
||||
* Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
* with the following individual added to the list of Contributing Authors:
|
||||
|
@ -290,13 +293,13 @@
|
|||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* February 3, 2011
|
||||
* March 31, 2011
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.5.1 are Y2K compliant. It is my belief that
|
||||
* upward through 1.5.2 are Y2K compliant. It is my belief that
|
||||
* earlier versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has three year fields. One is a 2-byte unsigned integer
|
||||
|
@ -352,9 +355,9 @@
|
|||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.5.1"
|
||||
#define PNG_LIBPNG_VER_STRING "1.5.2"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.5.1 - February 3, 2011\n"
|
||||
" libpng version 1.5.2 - March 31, 2011\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 15
|
||||
#define PNG_LIBPNG_VER_DLLNUM 15
|
||||
|
@ -362,7 +365,7 @@
|
|||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 5
|
||||
#define PNG_LIBPNG_VER_RELEASE 1
|
||||
#define PNG_LIBPNG_VER_RELEASE 2
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
*/
|
||||
|
@ -392,7 +395,7 @@
|
|||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10501 /* 1.5.1 */
|
||||
#define PNG_LIBPNG_VER 10502 /* 1.5.2 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
|
@ -405,18 +408,23 @@
|
|||
#endif
|
||||
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
/* Standard header files (not needed for the version info) */
|
||||
# ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||
/*
|
||||
* Standard header files (not needed for the version info or while
|
||||
* building symbol table -- see scripts/pnglibconf.dfa)
|
||||
*/
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
# include <setjmp.h>
|
||||
# endif
|
||||
|
||||
/* Need the time information for converting tIME chunks, it
|
||||
/* Need the time information for converting tIME chunks, it
|
||||
* defines struct tm:
|
||||
*/
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
# ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
/* "time.h" functions are not supported on all operating systems */
|
||||
# include <time.h>
|
||||
#endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Machine specific configuration. */
|
||||
# include "pngconf.h"
|
||||
|
@ -509,7 +517,7 @@ extern "C" {
|
|||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_5_1;
|
||||
typedef char* png_libpng_version_1_5_2;
|
||||
|
||||
/* Three color definitions. The order of the red, green, and blue, (and the
|
||||
* exact size) is not important, although the size of the fields need to
|
||||
|
@ -796,35 +804,44 @@ typedef struct png_struct_def png_struct;
|
|||
typedef PNG_CONST png_struct FAR * png_const_structp;
|
||||
typedef png_struct FAR * png_structp;
|
||||
|
||||
typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp), );
|
||||
typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t), );
|
||||
typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp), );
|
||||
typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));
|
||||
typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));
|
||||
typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));
|
||||
typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,
|
||||
int), );
|
||||
int));
|
||||
typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,
|
||||
int), );
|
||||
int));
|
||||
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
typedef PNG_CALLBACK(void, *png_progressive_info_ptr,
|
||||
(png_structp, png_infop), );
|
||||
typedef PNG_CALLBACK(void, *png_progressive_end_ptr,
|
||||
(png_structp, png_infop), );
|
||||
typedef PNG_CALLBACK(void, *png_progressive_row_ptr,
|
||||
(png_structp, png_bytep, png_uint_32, int), );
|
||||
typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
|
||||
typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
|
||||
|
||||
/* The following callback receives png_uint_32 row_number, int pass for the
|
||||
* png_bytep data of the row. When transforming an interlaced image the
|
||||
* row number is the row number within the sub-image of the interlace pass, so
|
||||
* the value will increase to the height of the sub-image (not the full image)
|
||||
* then reset to 0 for the next pass.
|
||||
*
|
||||
* Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
|
||||
* find the output pixel (x,y) given an interlaced sub-image pixel
|
||||
* (row,col,pass). (See below for these macros.)
|
||||
*/
|
||||
typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,
|
||||
png_uint_32, int));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
typedef PNG_CALLBACK(void, *png_user_transform_ptr,
|
||||
(png_structp, png_row_infop, png_bytep), );
|
||||
typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,
|
||||
png_bytep));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,
|
||||
png_unknown_chunkp), );
|
||||
png_unknown_chunkp));
|
||||
#endif
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp), );
|
||||
typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
|
@ -881,8 +898,8 @@ typedef PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)),
|
|||
* following.
|
||||
*/
|
||||
typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
|
||||
png_alloc_size_t), );
|
||||
typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp), );
|
||||
png_alloc_size_t));
|
||||
typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
|
||||
|
||||
typedef png_struct FAR * FAR * png_structpp;
|
||||
|
||||
|
@ -1061,6 +1078,13 @@ PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structp png_ptr));
|
|||
PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structp png_ptr));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
/* Expand to 16 bit channels, forces conversion of palette to RGB and expansion
|
||||
* of a tRNS chunk if present.
|
||||
*/
|
||||
PNG_EXPORT(221, void, png_set_expand_16, (png_structp png_ptr));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* Use blue, green, red order for pixels. */
|
||||
PNG_EXPORT(30, void, png_set_bgr, (png_structp png_ptr));
|
||||
|
@ -1475,9 +1499,13 @@ PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
|
|||
/* Return information about the row currently being processed. Note that these
|
||||
* APIs do not fail but will return unexpected results if called outside a user
|
||||
* transform callback. Also note that when transforming an interlaced image the
|
||||
* row number is still the row in the final, de-interlaced, image but the row
|
||||
* only contains the data of the current pass - consult png_row_info for the
|
||||
* actual width of the row!
|
||||
* row number is the row number within the sub-image of the interlace pass, so
|
||||
* the value will increase to the height of the sub-image (not the full image)
|
||||
* then reset to 0 for the next pass.
|
||||
*
|
||||
* Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
|
||||
* find the output pixel (x,y) given an interlaced sub-image pixel
|
||||
* (row,col,pass). (See below for these macros.)
|
||||
*/
|
||||
PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structp));
|
||||
PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structp));
|
||||
|
@ -2142,8 +2170,9 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
|
|||
#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\
|
||||
-1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))
|
||||
|
||||
/* For the progressive reader it is necessary to find the row in the output
|
||||
* image given a row in an interlaced image, so two more macros:
|
||||
/* For the reader row callbacks (both progressive and sequential) it is
|
||||
* necessary to find the row in the output image given a row in an interlaced
|
||||
* image, so two more macros:
|
||||
*/
|
||||
#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \
|
||||
(((yIn)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
|
||||
|
@ -2268,7 +2297,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
|||
* scripts/symbols.def as well.
|
||||
*/
|
||||
#ifdef PNG_EXPORT_LAST_ORDINAL
|
||||
PNG_EXPORT_LAST_ORDINAL(220);
|
||||
PNG_EXPORT_LAST_ORDINAL(221);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* 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
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
@ -22,29 +22,31 @@
|
|||
#ifndef PNGCONF_H
|
||||
#define PNGCONF_H
|
||||
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
|
||||
* definition file for machine specific limits, this may impact the
|
||||
* correctness of the definitons below (see uses of INT_MAX).
|
||||
*/
|
||||
#ifndef PNG_NO_LIMITS_H
|
||||
# ifndef PNG_NO_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
# endif
|
||||
|
||||
/* For the memory copy APIs (i.e. the standard definitions of these),
|
||||
* because this file defines png_memcpy and so on the base APIs must
|
||||
* be defined here.
|
||||
*/
|
||||
#ifdef BSD
|
||||
# ifdef BSD
|
||||
# include <strings.h>
|
||||
#else
|
||||
# else
|
||||
# include <string.h>
|
||||
#endif
|
||||
# endif
|
||||
|
||||
/* For png_FILE_p - this provides the standard definition of a
|
||||
* FILE
|
||||
*/
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This controls optimization of the reading of 16 and 32 bit values
|
||||
|
@ -282,23 +284,15 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* THe following complexity is concerned with getting the 'attributes' of the
|
||||
* declared function in the correct place. This potentially requires a separate
|
||||
* PNG_EXPORT function for every compiler.
|
||||
/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
|
||||
* 'attributes' as a storage class - the attributes go at the start of the
|
||||
* function definition, and attributes are always appended regardless of the
|
||||
* compiler. This considerably simplifies these macros but may cause problems
|
||||
* if any compilers both need function attributes and fail to handle them as
|
||||
* a storage class (this is unlikely.)
|
||||
*/
|
||||
#ifndef PNG_FUNCTION
|
||||
# ifdef __GNUC__
|
||||
# define PNG_FUNCTION(type, name, args, attributes)\
|
||||
attributes type name args
|
||||
# else /* !GNUC */
|
||||
# ifdef _MSC_VER
|
||||
# define PNG_FUNCTION(type, name, args, attributes)\
|
||||
attributes type name args
|
||||
# else /* !MSC */
|
||||
# define PNG_FUNCTION(type, name, args, attributes)\
|
||||
type name args
|
||||
# endif
|
||||
# endif
|
||||
# define PNG_FUNCTION(type, name, args, attributes) attributes type name args
|
||||
#endif
|
||||
|
||||
#ifndef PNG_EXPORT_TYPE
|
||||
|
@ -310,13 +304,19 @@
|
|||
* scripts directory.
|
||||
*/
|
||||
#ifndef PNG_EXPORTA
|
||||
|
||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
extern PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args),\
|
||||
attributes)
|
||||
PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
|
||||
extern attributes)
|
||||
#endif
|
||||
|
||||
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||
* so make something non-empty to satisfy the requirement:
|
||||
*/
|
||||
#define PNG_EMPTY /*empty list*/
|
||||
|
||||
#define PNG_EXPORT(ordinal, type, name, args)\
|
||||
PNG_EXPORTA(ordinal, type, name, args, )
|
||||
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
|
||||
|
||||
/* Use PNG_REMOVED to comment out a removed interface. */
|
||||
#ifndef PNG_REMOVED
|
||||
|
@ -324,8 +324,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef PNG_CALLBACK
|
||||
# define PNG_CALLBACK(type, name, args, attributes)\
|
||||
type (PNGCBAPI name) PNGARG(args) attributes
|
||||
# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
|
||||
#endif
|
||||
|
||||
/* Support for compiler specific function attributes. These are used
|
||||
|
@ -347,7 +346,7 @@
|
|||
* functions in png.h will generate compiler warnings. Added at libpng
|
||||
* version 1.2.41.
|
||||
*/
|
||||
# ifdef __GNUC__
|
||||
# if defined(__GNUC__)
|
||||
# ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||
# endif
|
||||
|
@ -355,8 +354,22 @@
|
|||
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||
# endif
|
||||
# ifndef PNG_PTR_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
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||
# endif
|
||||
|
@ -380,18 +393,19 @@
|
|||
# define PNG_PRIVATE \
|
||||
__attribute__((__deprecated__))
|
||||
# endif
|
||||
# endif /* PNG_PRIVATE */
|
||||
# endif
|
||||
# endif /* PNGLIB_BUILD */
|
||||
# endif /* __GNUC__ */
|
||||
# ifdef _MSC_VER /* may need to check value */
|
||||
|
||||
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# ifndef PNG_USE_RESULT
|
||||
# define PNG_USE_RESULT /*not supported*/
|
||||
# define PNG_USE_RESULT /* not supported */
|
||||
# endif
|
||||
# ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN __declspec(noreturn)
|
||||
# endif
|
||||
# ifndef PNG_PTR_NORETURN
|
||||
# define PNG_PTR_NORETURN /*not supported*/
|
||||
# define PNG_PTR_NORETURN /* not supported */
|
||||
# endif
|
||||
# ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED __declspec(restrict)
|
||||
|
@ -410,9 +424,9 @@
|
|||
# endif
|
||||
# ifndef PNG_PRIVATE
|
||||
# define PNG_PRIVATE __declspec(deprecated)
|
||||
# endif /* PNG_PRIVATE */
|
||||
# endif
|
||||
# endif /* PNGLIB_BUILD */
|
||||
# endif /* __GNUC__ */
|
||||
# endif /* _MSC_VER */
|
||||
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||
|
||||
#ifndef PNG_DEPRECATED
|
||||
|
@ -424,6 +438,9 @@
|
|||
#ifndef PNG_NORETURN
|
||||
# define PNG_NORETURN /* This function does not return */
|
||||
#endif
|
||||
#ifndef PNG_PTR_NORETURN
|
||||
# define PNG_PTR_NORETURN /* This function does not return */
|
||||
#endif
|
||||
#ifndef PNG_ALLOCATED
|
||||
# define PNG_ALLOCATED /* The result of the function is new memory */
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* 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
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (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);
|
||||
|
||||
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
|
||||
if (png_ptr->transformations)
|
||||
png_do_read_transformations(png_ptr);
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Last changed in libpng 1.5.2 [March 31, 2011]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* 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
|
||||
#endif
|
||||
|
||||
#ifndef PNG_UNUSED
|
||||
/* Unused formal parameter warnings are silenced using the following macro
|
||||
* which is expected to have no bad effects on performance (optimizing
|
||||
* compilers will probably remove it entirely). Note that if you replace
|
||||
* it with something other than whitespace, you must include the terminating
|
||||
* semicolon.
|
||||
*/
|
||||
#define PNG_UNUSED(param) (void)param;
|
||||
# define PNG_UNUSED(param) (void)param;
|
||||
#endif
|
||||
|
||||
/* Just a little check that someone hasn't tried to define something
|
||||
* contradictory.
|
||||
|
@ -286,7 +288,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
|||
#define PNG_QUANTIZE 0x0040
|
||||
#define PNG_BACKGROUND 0x0080
|
||||
#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_RGBA 0x0800
|
||||
#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_TEXT 0x80000L
|
||||
#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L
|
||||
#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */
|
||||
#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */
|
||||
/* 0x200000L unused */
|
||||
/* 0x400000L unused */
|
||||
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */
|
||||
/* 0x1000000L 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) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_uint_32 flags));
|
||||
PNG_EXTERN void png_do_strip_channel PNGARG((png_row_infop row_info,
|
||||
png_bytep row, int at_start));
|
||||
#endif
|
||||
|
||||
#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));
|
||||
#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,
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
|
||||
/* 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_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
|
||||
|
||||
#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.
|
||||
*/
|
||||
PNG_EXTERN png_uint_16 png_gamma_correct PNGARG((png_structp png_ptr,
|
||||
unsigned int value, png_fixed_point gamma));
|
||||
PNG_EXTERN int png_gamma_significant PNGARG((png_fixed_point gamma));
|
||||
unsigned int value, png_fixed_point gamma_value));
|
||||
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_fixed_point gamma));
|
||||
png_fixed_point gamma_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,
|
||||
int bit_depth));
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* 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
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (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_IDAT;
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
|
||||
0xff};
|
||||
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
|
@ -702,7 +704,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
#endif
|
||||
|
||||
|
||||
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
|
||||
if (png_ptr->transformations)
|
||||
png_do_read_transformations(png_ptr);
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
|
@ -1311,7 +1313,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
|||
{
|
||||
int row;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* png_read_info() gives us all of the information from the
|
||||
|
@ -1426,6 +1428,11 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
|||
|
||||
/* We don't handle adding filler bytes */
|
||||
|
||||
/* We use png_read_image and rely on that for interlace handling, but we also
|
||||
* call png_read_update_info therefore must turn on interlace handling now:
|
||||
*/
|
||||
(void)png_set_interlace_handling(png_ptr);
|
||||
|
||||
/* Optional call to gamma correct and add the background to the palette
|
||||
* and update info structure. REQUIRED if you are expecting libpng to
|
||||
* update the palette for you (i.e., you selected such a transform above).
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* 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
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (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;
|
||||
|
||||
png_ptr->transformations |= PNG_16_TO_8;
|
||||
png_ptr->transformations &= ~PNG_EXPAND_16;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -149,7 +150,7 @@ png_set_strip_alpha(png_structp png_ptr)
|
|||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
|
||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -686,6 +687,25 @@ png_set_tRNS_to_alpha(png_structp png_ptr)
|
|||
}
|
||||
#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
|
||||
void PNGAPI
|
||||
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_GAMMA;
|
||||
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
|
||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
png_ptr->transformations &= ~PNG_BACKGROUND;
|
||||
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
|
||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||
}
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
||||
|
||||
|
@ -1285,6 +1305,14 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
|||
}
|
||||
#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
|
||||
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;
|
||||
|
||||
#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;
|
||||
#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_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (png_ptr->num_trans &&
|
||||
(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
&(png_ptr->trans_color));
|
||||
else
|
||||
|
||||
else
|
||||
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
#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
|
||||
if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)
|
||||
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA));
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||
(png_ptr->row_info.color_type == PNG_COLOR_TYPE_RGB_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
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
|
@ -1565,6 +1600,16 @@ png_do_read_transformations(png_structp png_ptr)
|
|||
}
|
||||
#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
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
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
|
||||
|
||||
#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 ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
|
@ -4064,6 +4112,37 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
#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
|
||||
void /* PRIVATE */
|
||||
png_do_quantize(png_row_infop row_info, png_bytep row,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* 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
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (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_sPLT_t new_palette;
|
||||
#ifdef PNG_POINTER_INDEXING_SUPPORTED
|
||||
png_sPLT_entryp pp;
|
||||
#endif
|
||||
png_uint_32 data_length;
|
||||
int entry_size, i;
|
||||
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->frequency = png_get_uint_16(entry_start); entry_start += 2;
|
||||
pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3463,6 +3461,24 @@ png_read_start_row(png_structp png_ptr)
|
|||
}
|
||||
#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
|
||||
if (png_ptr->transformations & (PNG_FILLER))
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* 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
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -424,170 +424,115 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
|||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
/* Remove filler or alpha byte(s) */
|
||||
/* Remove a channel - this used to be 'png_do_strip_filler' but it used a
|
||||
* somewhat weird combination of flags to determine what to do. All the calls
|
||||
* to png_do_strip_filler are changed in 1.5.2 to call this instead with the
|
||||
* correct arguments.
|
||||
*
|
||||
* The routine isn't general - the channel must be the channel at the start or
|
||||
* end (not in the middle) of each pixel.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
png_debug(1, "in png_do_strip_filler");
|
||||
png_bytep sp = row; /* source pointer */
|
||||
png_bytep dp = row; /* destination pointer */
|
||||
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
|
||||
|
||||
{
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
png_uint_32 i;
|
||||
|
||||
if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
|
||||
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
||||
row_info->channels == 4)
|
||||
/* 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)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This converts from RGBX or RGBA to RGB */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
dp += 3; sp += 4;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
sp++;
|
||||
}
|
||||
if (at_start) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 2, ++dp;
|
||||
|
||||
/* For a 1 pixel wide image there is nothing to do */
|
||||
while (sp < ep)
|
||||
*dp++ = *sp, sp += 2;
|
||||
|
||||
row_info->pixel_depth = 8;
|
||||
}
|
||||
|
||||
/* This converts from XRGB or ARGB to RGB */
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start)
|
||||
sp += 2;
|
||||
else
|
||||
{
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
sp += 4, dp += 2;
|
||||
|
||||
while (sp < ep)
|
||||
*dp++ = *sp++, *dp++ = *sp, sp += 3;
|
||||
|
||||
row_info->pixel_depth = 16;
|
||||
}
|
||||
|
||||
else
|
||||
return; /* bad bit depth */
|
||||
|
||||
row_info->channels = 1;
|
||||
|
||||
/* Finally fix the color type if it records an alpha channel */
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
row_info->color_type = PNG_COLOR_TYPE_GRAY;
|
||||
}
|
||||
|
||||
/* RGBA, RGBX, XRGB cases */
|
||||
else if (row_info->channels == 4)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 4, dp += 3;
|
||||
|
||||
/* Note that the loop adds 3 to dp and 4 to sp each time. */
|
||||
while (sp < ep)
|
||||
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
|
||||
|
||||
row_info->pixel_depth = 24;
|
||||
row_info->rowbytes = row_width * 3;
|
||||
}
|
||||
|
||||
else /* if (row_info->bit_depth == 16) */
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
|
||||
sp += 8; dp += 6;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
/* This could be (although png_memcpy is probably slower):
|
||||
png_memcpy(dp, sp, 6);
|
||||
sp += 8;
|
||||
dp += 6;
|
||||
*/
|
||||
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
if (at_start)
|
||||
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 += 8, dp += 6;
|
||||
|
||||
sp += 2;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
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;
|
||||
row_info->rowbytes = row_width * 6;
|
||||
}
|
||||
|
||||
else
|
||||
return; /* bad bit depth */
|
||||
|
||||
row_info->channels = 3;
|
||||
}
|
||||
|
||||
else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
(row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
|
||||
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
||||
row_info->channels == 2)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This converts from GX or GA to G */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
sp++;
|
||||
}
|
||||
/* 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
|
||||
{
|
||||
/* This converts from XG or AG to G */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
return; /* The filler channel has gone already */
|
||||
|
||||
row_info->pixel_depth = 8;
|
||||
row_info->rowbytes = row_width;
|
||||
}
|
||||
|
||||
else /* if (row_info->bit_depth == 16) */
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This converts from GGXX or GGAA to GG */
|
||||
sp += 4; dp += 2;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
sp += 2;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* This converts from XXGG or AAGG to GG */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp += 2;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
|
||||
row_info->pixel_depth = 16;
|
||||
row_info->rowbytes = row_width * 2;
|
||||
}
|
||||
row_info->channels = 1;
|
||||
}
|
||||
|
||||
if (flags & PNG_FLAG_STRIP_ALPHA)
|
||||
row_info->color_type = (png_byte)(row_info->color_type &
|
||||
~PNG_COLOR_MASK_ALPHA);
|
||||
}
|
||||
/* Fix the rowbytes value. */
|
||||
row_info->rowbytes = dp-row;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -703,11 +648,16 @@ png_get_user_transform_ptr(png_const_structp png_ptr)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_current_row_number(png_const_structp png_ptr)
|
||||
{
|
||||
/* See the comments in png.h - this is the sub-image row when reading and
|
||||
* interlaced image.
|
||||
*/
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->row_number;
|
||||
|
||||
return PNG_UINT_32_MAX; /* help the app not to fail silently */
|
||||
}
|
||||
|
||||
|
@ -718,6 +668,7 @@ png_get_current_pass_number(png_const_structp png_ptr)
|
|||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -1177,7 +1177,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||
* better compression.
|
||||
*/
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */
|
||||
/* Conveneince reset API. */
|
||||
/* Convenience reset API. */
|
||||
static void
|
||||
png_reset_filter_heuristics(png_structp png_ptr)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* Last changed in libpng 1.5.2 [March 31, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -44,8 +44,8 @@ png_do_write_transformations(png_structp png_ptr)
|
|||
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->flags);
|
||||
png_do_strip_channel(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
|
|
Loading…
Reference in a new issue