@ -1,8 +1,8 @@
@@ -1,8 +1,8 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.5 .1 - February 3 , 2011
* Copyright ( c ) 1998 - 2011 Glenn Randers - Pehrson
* libpng version 1.5 .10 - March 29 , 2012
* Copyright ( c ) 1998 - 2012 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 @@
@@ -11,7 +11,7 @@
* Authors and maintainers :
* libpng versions 0.71 , May 1995 , through 0.88 , January 1996 : Guy Schalnat
* libpng versions 0.89 c , 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 .10 - March 29 , 2012 : Glenn
* See also " Contributing Authors " , below .
*
* Note about libpng version numbers :
@ -147,6 +147,33 @@
@@ -147,6 +147,33 @@
* 1.5 .1 beta01 - 11 15 10501 15. so .15 .1 [ .0 ]
* 1.5 .1 rc01 - 02 15 10501 15. so .15 .1 [ .0 ]
* 1.5 .1 15 10501 15. so .15 .1 [ .0 ]
* 1.5 .2 beta01 - 03 15 10502 15. so .15 .2 [ .0 ]
* 1.5 .2 rc01 - 03 15 10502 15. so .15 .2 [ .0 ]
* 1.5 .2 15 10502 15. so .15 .2 [ .0 ]
* 1.5 .3 beta01 - 10 15 10503 15. so .15 .3 [ .0 ]
* 1.5 .3 rc01 - 02 15 10503 15. so .15 .3 [ .0 ]
* 1.5 .3 beta11 15 10503 15. so .15 .3 [ .0 ]
* 1.5 .3 [ omitted ]
* 1.5 .4 beta01 - 08 15 10504 15. so .15 .4 [ .0 ]
* 1.5 .4 rc01 15 10504 15. so .15 .4 [ .0 ]
* 1.5 .4 15 10504 15. so .15 .4 [ .0 ]
* 1.5 .5 beta01 - 08 15 10505 15. so .15 .5 [ .0 ]
* 1.5 .5 rc01 15 10505 15. so .15 .5 [ .0 ]
* 1.5 .5 15 10505 15. so .15 .5 [ .0 ]
* 1.5 .6 beta01 - 07 15 10506 15. so .15 .6 [ .0 ]
* 1.5 .6 rc01 - 03 15 10506 15. so .15 .6 [ .0 ]
* 1.5 .6 15 10506 15. so .15 .6 [ .0 ]
* 1.5 .7 beta01 - 05 15 10507 15. so .15 .7 [ .0 ]
* 1.5 .7 rc01 - 03 15 10507 15. so .15 .7 [ .0 ]
* 1.5 .7 15 10507 15. so .15 .7 [ .0 ]
* 1.5 .8 beta01 15 10508 15. so .15 .8 [ .0 ]
* 1.5 .8 rc01 15 10508 15. so .15 .8 [ .0 ]
* 1.5 .8 15 10508 15. so .15 .8 [ .0 ]
* 1.5 .9 beta01 - 02 15 10509 15. so .15 .9 [ .0 ]
* 1.5 .9 rc01 15 10509 15. so .15 .9 [ .0 ]
* 1.5 .9 15 10509 15. so .15 .9 [ .0 ]
* 1.5 .10 beta01 - 05 15 10510 15. so .15 .10 [ .0 ]
* 1.5 .10 15 10510 15. so .15 .10 [ .0 ]
*
* Henceforth the source version will match the shared - library major
* and minor numbers ; the shared - library major version number will be
@ -156,7 +183,7 @@
@@ -156,7 +183,7 @@
* to the source version x . y . z ( leading zeros in y and z ) . Beta versions
* were given the previous public release number plus a letter , until
* version 1.0 .6 j ; from then on they were given the upcoming public
* release number plus " betaNN " or " rcN " .
* release number plus " betaNN " or " rcNN " .
*
* Binary incompatibility exists only when applications make direct access
* to the info_ptr or png_ptr members through png . h , and the compiled
@ -178,8 +205,8 @@
@@ -178,8 +205,8 @@
*
* This code is released under the libpng license .
*
* libpng versions 1.2 .6 , August 15 , 2004 , through 1.5 .1 , February 3 , 2011 , are
* Copyright ( c ) 2004 , 2006 - 2011 Glenn Randers - Pehrson , and are
* libpng versions 1.2 .6 , August 15 , 2004 , through 1.5 .10 , March 29 , 2012 , are
* Copyright ( c ) 2004 , 2006 - 2012 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,25 +317,24 @@
@@ -290,25 +317,24 @@
* Y2K compliance in libpng :
* = = = = = = = = = = = = = = = = = = = = = = = = =
*
* February 3 , 2011
* March 29 , 2012
*
* 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 .10 are Y2K compliant . It is my belief that
* earlier versions were also Y2K compliant .
*
* Libpng only has three year fields . One is a 2 - byte unsigned integer
* that will hold years up to 65535. The other two hold the date in text
* Libpng only has two year fields . One is a 2 - byte unsigned integer
* that will hold years up to 65535. The other holds the date in text
* format , and will hold years up to 9999.
*
* The integer is
* " png_uint_16 year " in png_time_struct .
*
* The strings are
* " png_charp time_buffer " in png_struct and
* " near_time_buffer " , which is a local character string in png . c .
* The string is
* " png_char time_buffer " in png_struct
*
* There are seven time - related functions :
* png . c : png_convert_to_rfc_1123 ( ) in png . c
@ -349,12 +375,15 @@
@@ -349,12 +375,15 @@
* describes how to use libpng , and the file example . c summarizes it
* with some code on which to build . This file is useful for looking
* at the actual function definitions and structure components .
*
* If you just need to read a PNG file and don ' t want to read the documentation
* skip to the end of this file and read the section entitled ' simplified API ' .
*/
/* 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.10 "
# define PNG_HEADER_VERSION_STRING \
" libpng version 1.5.1 - February 3, 2011 \n "
" libpng version 1.5.10 - March 29, 2012 \n "
# define PNG_LIBPNG_VER_SONUM 15
# define PNG_LIBPNG_VER_DLLNUM 15
@ -362,7 +391,8 @@
@@ -362,7 +391,8 @@
/* 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 10
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING , omitting any leading zero :
*/
@ -384,7 +414,7 @@
@@ -384,7 +414,7 @@
# define PNG_LIBPNG_BUILD_SPECIAL 32 / * Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */
# define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
# define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros .
@ -392,7 +422,7 @@
@@ -392,7 +422,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 1050 1 /* 1.5.1 */
# define PNG_LIBPNG_VER 10510 /* 1.5.10 */
/* Library configuration: these options cannot be changed after
* the library has been built .
@ -405,18 +435,23 @@
@@ -405,18 +435,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 +544,7 @@ extern "C" {
@@ -509,7 +544,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_10 ;
/* 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
@ -584,11 +619,20 @@ typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
@@ -584,11 +619,20 @@ typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
# ifdef PNG_TEXT_SUPPORTED
/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
* and whether that contents is compressed or not . The " key " field
* points to a regular zero - terminated C string . The " text " , " lang " , and
* " lang_key " fields can be regular C strings , empty strings , or NULL pointers .
* However , the * structure returned by png_get_text ( ) will always contain
* regular zero - terminated C strings ( possibly empty ) , never NULL pointers ,
* so they can be safely used in printf ( ) and other string - handling functions .
* points to a regular zero - terminated C string . The " text " fields can be a
* regular C string , an empty string , or a NULL pointer .
* However , the structure returned by png_get_text ( ) will always contain
* the " text " field as a regular zero - terminated C string ( possibly
* empty ) , never a NULL pointer , so it can be safely used in printf ( ) and
* other string - handling functions . Note that the " itxt_length " , " lang " , and
* " lang_key " members of the structure only exist when the library is built
* with iTXt chunk support . Prior to libpng - 1.4 .0 the library was built by
* default without iTXt support . Also note that when iTXt * is * supported ,
* the " lang " and " lang_key " fields contain NULL pointers when the
* " compression " field contains * PNG_TEXT_COMPRESSION_NONE or
* PNG_TEXT_COMPRESSION_zTXt . Note that the " compression value " is not the
* same as what appears in the PNG tEXt / zTXt / iTXt chunk ' s " compression flag "
* which is always 0 or 1 , or its " compression method " which is always 0.
*/
typedef struct png_text_struct
{
@ -657,12 +701,24 @@ typedef struct png_unknown_chunk_t
@@ -657,12 +701,24 @@ typedef struct png_unknown_chunk_t
/* libpng-using applications should NOT directly modify this byte. */
png_byte location ; /* mode of operation at read time */
}
png_unknown_chunk ;
typedef png_unknown_chunk FAR * png_unknown_chunkp ;
typedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp ;
typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp ;
# endif
/* Values for the unknown chunk location byte */
# define PNG_HAVE_IHDR 0x01
# define PNG_HAVE_PLTE 0x02
# define PNG_AFTER_IDAT 0x08
/* The complete definition of png_info has, as of libpng-1.5.0,
* been moved into a separate header file that is not accessible to
* applications . Read libpng - manual . txt or libpng .3 for more info .
*/
typedef struct png_info_def png_info ;
typedef png_info FAR * png_infop ;
typedef PNG_CONST png_info FAR * png_const_infop ;
@ -678,6 +734,8 @@ typedef png_info FAR * FAR * png_infopp;
@@ -678,6 +734,8 @@ typedef png_info FAR * FAR * png_infopp;
*/
# define PNG_FP_1 100000
# define PNG_FP_HALF 50000
# define PNG_FP_MAX ((png_fixed_point)0x7fffffffL)
# define PNG_FP_MIN (-PNG_FP_MAX)
/* These describe the color_type field in png_info. */
/* color type masks */
@ -765,7 +823,7 @@ typedef png_info FAR * FAR * png_infopp;
@@ -765,7 +823,7 @@ typedef png_info FAR * FAR * png_infopp;
# define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
# define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
# define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
# define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */
# define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */
/* This is used for the transformation routines, as some of them
* change these values for the row . It also should enable using
@ -784,6 +842,14 @@ typedef struct png_row_info_struct
@@ -784,6 +842,14 @@ typedef struct png_row_info_struct
typedef png_row_info FAR * png_row_infop ;
typedef png_row_info FAR * FAR * png_row_infopp ;
/* The complete definition of png_struct has, as of libpng-1.5.0,
* been moved into a separate header file that is not accessible to
* applications . Read libpng - manual . txt or libpng .3 for more info .
*/
typedef struct png_struct_def png_struct ;
typedef PNG_CONST png_struct FAR * png_const_structp ;
typedef png_struct FAR * png_structp ;
/* These are the function types for the I/O functions and for the functions
* that allow the user to override the default I / O functions with his or her
* own . The png_error_ptr type should match that of user - supplied warning
@ -792,61 +858,59 @@ typedef png_row_info FAR * FAR * png_row_infopp;
@@ -792,61 +858,59 @@ typedef png_row_info FAR * FAR * png_row_infopp;
* modify the buffer it is passed . The ' read ' function , on the other hand , is
* expected to return the read data in the buffer .
*/
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
/* This must match the function definition in <setjmp.h>, and the
* application must include this before png . h to obtain the definition
* of jmp_buf . The function is required to be PNG_NORETURN . ( Note that
* PNG_PTR_NORETURN is used here because current versions of the Microsoft
* C compiler do not support the PNG_NORETURN attribute on a pointer . )
*
* If you get a type warning from the compiler when linking against this line
* then your compiler has ' longjmp ' that does not match the requirements of the
* compiler that built libpng . You will have to write a wrapper function for
* your compiler ' s longjmp and call png_set_longjmp_fn directly ( not via the
* png_jmpbuf macro . )
*
* If you get a warning here while building the library you will need to make
/* This must match the function definition in <setjmp.h>, and the application
* must include this before png . h to obtain the definition of jmp_buf . The
* function is required to be PNG_NORETURN , but this is not checked . If the
* function does return the application will crash via an abort ( ) or similar
* system level call .
*
* If you get a warning here while building the library you may need to make
* changes to ensure that pnglibconf . h records the calling convention used by
* your compiler . This may be very difficult - try using a different compiler
* to build the library !
*/
typedef PNG_FUNCTION ( void , ( PNGCAPI * png_longjmp_ptr ) , PNGARG ( ( jmp_buf , int ) ) ,
PNG_PTR_NORETURN ) ;
PNG_FUNCTION ( void , ( PNGCAPI * png_longjmp_ptr ) , PNGARG ( ( jmp_buf , int ) ) , typedef ) ;
# endif
/* Transform masks for the high-level interface */
@ -868,6 +932,9 @@ typedef PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)),
@@ -868,6 +932,9 @@ typedef PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)),
# define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
/* Added to libpng-1.4.0 */
# define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
/* Added to libpng-1.5.4 */
# define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
# define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
/* Flags for MNG supported features */
# define PNG_FLAG_MNG_EMPTY_PLTE 0x01
@ -881,8 +948,8 @@ typedef PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)),
@@ -881,8 +948,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 +1128,13 @@ PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structp png_ptr));
@@ -1061,6 +1128,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 ) ) ;
@ -1073,6 +1147,11 @@ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr));
@@ -1073,6 +1147,11 @@ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr));
# ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
/* Reduce RGB to grayscale. */
# define PNG_ERROR_ACTION_NONE 1
# define PNG_ERROR_ACTION_WARN 2
# define PNG_ERROR_ACTION_ERROR 3
# define PNG_RGB_TO_GRAY_DEFAULT (-1) /*for red/green coefficients*/
PNG_FP_EXPORT ( 32 , void , png_set_rgb_to_gray , ( png_structp png_ptr ,
int error_action , double red , double green ) ) ;
PNG_FIXED_EXPORT ( 33 , void , png_set_rgb_to_gray_fixed , ( png_structp png_ptr ,
@ -1082,8 +1161,219 @@ PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp
@@ -1082,8 +1161,219 @@ PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp
png_ptr ) ) ;
# endif
# ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
PNG_EXPORT ( 35 , void , png_build_grayscale_palette , ( int bit_depth ,
png_colorp palette ) ) ;
# endif
# ifdef PNG_READ_ALPHA_MODE_SUPPORTED
/* How the alpha channel is interpreted - this affects how the color channels of
* a PNG file are returned when an alpha channel , or tRNS chunk in a palette
* file , is present .
*
* This has no effect on the way pixels are written into a PNG output
* datastream . The color samples in a PNG datastream are never premultiplied
* with the alpha samples .
*
* The default is to return data according to the PNG specification : the alpha
* channel is a linear measure of the contribution of the pixel to the
* corresponding composited pixel . The gamma encoded color channels must be
* scaled according to the contribution and to do this it is necessary to undo
* the encoding , scale the color values , perform the composition and reencode
* the values . This is the ' PNG ' mode .
*
* The alternative is to ' associate ' the alpha with the color information by
* storing color channel values that have been scaled by the alpha . The
* advantage is that the color channels can be resampled ( the image can be
* scaled ) in this form . The disadvantage is that normal practice is to store
* linear , not ( gamma ) encoded , values and this requires 16 - bit channels for
* still images rather than the 8 - bit channels that are just about sufficient if
* gamma encoding is used . In addition all non - transparent pixel values ,
* including completely opaque ones , must be gamma encoded to produce the final
* image . This is the ' STANDARD ' , ' ASSOCIATED ' or ' PREMULTIPLIED ' mode ( the
* latter being the two common names for associated alpha color channels . )
*
* Since it is not necessary to perform arithmetic on opaque color values so
* long as they are not to be resampled and are in the final color space it is
* possible to optimize the handling of alpha by storing the opaque pixels in
* the PNG format ( adjusted for the output color space ) while storing partially
* opaque pixels in the standard , linear , format . The accuracy required for
* standard alpha composition is relatively low , because the pixels are
* isolated , therefore typically the accuracy loss in storing 8 - bit linear
* values is acceptable . ( This is not true if the alpha channel is used to
* simulate transparency over large areas - use 16 bits or the PNG mode in
* this case ! ) This is the ' OPTIMIZED ' mode . For this mode a pixel is
* treated as opaque only if the alpha value is equal to the maximum value .
*
* The final choice is to gamma encode the alpha channel as well . This is
* broken because , in practice , no implementation that uses this choice
* correctly undoes the encoding before handling alpha composition . Use this
* choice only if other serious errors in the software or hardware you use
* mandate it ; the typical serious error is for dark halos to appear around
* opaque areas of the composited PNG image because of arithmetic overflow .
*
* The API function png_set_alpha_mode specifies which of these choices to use
* with an enumerated ' mode ' value and the gamma of the required output :
*/
# define PNG_ALPHA_PNG 0 /* according to the PNG standard */
# define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */
# define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */
# define PNG_ALPHA_PREMULTIPLIED 1 /* as above */
# define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */
# define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */
PNG_FP_EXPORT ( 227 , void , png_set_alpha_mode , ( png_structp png_ptr , int mode ,
double output_gamma ) ) ;
PNG_FIXED_EXPORT ( 228 , void , png_set_alpha_mode_fixed , ( png_structp png_ptr ,
int mode , png_fixed_point output_gamma ) ) ;
# endif
# if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
/* The output_gamma value is a screen gamma in libpng terminology: it expresses
* how to decode the output values , not how they are encoded . The values used
* correspond to the normal numbers used to describe the overall gamma of a
* computer display system ; for example 2.2 for an sRGB conformant system . The
* values are scaled by 100000 in the _fixed version of the API ( so 220000 for
* sRGB . )
*
* The inverse of the value is always used to provide a default for the PNG file
* encoding if it has no gAMA chunk and if png_set_gamma ( ) has not been called
* to override the PNG gamma information .
*
* When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode
* opaque pixels however pixels with lower alpha values are not encoded ,
* regardless of the output gamma setting .
*
* When the standard Porter Duff handling is requested with mode 1 the output
* encoding is set to be linear and the output_gamma value is only relevant
* as a default for input data that has no gamma information . The linear output
* encoding will be overridden if png_set_gamma ( ) is called - the results may be
* highly unexpected !
*
* The following numbers are derived from the sRGB standard and the research
* behind it . sRGB is defined to be approximated by a PNG gAMA chunk value of
* 0.45455 ( 1 / 2.2 ) for PNG . The value implicitly includes any viewing
* correction required to take account of any differences in the color
* environment of the original scene and the intended display environment ; the
* value expresses how to * decode * the image for display , not how the original
* data was * encoded * .
*
* sRGB provides a peg for the PNG standard by defining a viewing environment .
* sRGB itself , and earlier TV standards , actually use a more complex transform
* ( a linear portion then a gamma 2.4 power law ) than PNG can express . ( PNG is
* limited to simple power laws . ) By saying that an image for direct display on
* an sRGB conformant system should be stored with a gAMA chunk value of 45455
* ( 11.3 .3 .2 and 11.3 .3 .5 of the ISO PNG specification ) the PNG specification
* makes it possible to derive values for other display systems and
* environments .
*
* The Mac value is deduced from the sRGB based on an assumption that the actual
* extra viewing correction used in early Mac display systems was implemented as
* a power 1.45 lookup table .
*
* Any system where a programmable lookup table is used or where the behavior of
* the final display device characteristics can be changed requires system
* specific code to obtain the current characteristic . However this can be
* difficult and most PNG gamma correction only requires an approximate value .
*
* By default , if png_set_alpha_mode ( ) is not called , libpng assumes that all
* values are unencoded , linear , values and that the output device also has a
* linear characteristic . This is only very rarely correct - it is invariably
* better to call png_set_alpha_mode ( ) with PNG_DEFAULT_sRGB than rely on the
* default if you don ' t know what the right answer is !
*
* The special value PNG_GAMMA_MAC_18 indicates an older Mac system ( pre Mac OS
* 10.6 ) which used a correction table to implement a somewhat lower gamma on an
* otherwise sRGB system .
*
* Both these values are reserved ( not simple gamma values ) in order to allow
* more precise correction internally in the future .
*
* NOTE : the following values can be passed to either the fixed or floating
* point APIs , but the floating point API will also accept floating point
* values .
*/
# define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */
# define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */
# define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */
# define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */
# endif
/* The following are examples of calls to png_set_alpha_mode to achieve the
* required overall gamma correction and , where necessary , alpha
* premultiplication .
*
* png_set_alpha_mode ( pp , PNG_ALPHA_PNG , PNG_DEFAULT_sRGB ) ;
* This is the default libpng handling of the alpha channel - it is not
* pre - multiplied into the color components . In addition the call states
* that the output is for a sRGB system and causes all PNG files without gAMA
* chunks to be assumed to be encoded using sRGB .
*
* png_set_alpha_mode ( pp , PNG_ALPHA_PNG , PNG_GAMMA_MAC ) ;
* In this case the output is assumed to be something like an sRGB conformant
* display preceeded by a power - law lookup table of power 1.45 . This is how
* early Mac systems behaved .
*
* png_set_alpha_mode ( pp , PNG_ALPHA_STANDARD , PNG_GAMMA_LINEAR ) ;
* This is the classic Jim Blinn approach and will work in academic
* environments where everything is done by the book . It has the shortcoming
* of assuming that input PNG data with no gamma information is linear - this
* is unlikely to be correct unless the PNG files where generated locally .
* Most of the time the output precision will be so low as to show
* significant banding in dark areas of the image .
*
* png_set_expand_16 ( pp ) ;
* png_set_alpha_mode ( pp , PNG_ALPHA_STANDARD , PNG_DEFAULT_sRGB ) ;
* This is a somewhat more realistic Jim Blinn inspired approach . PNG files
* are assumed to have the sRGB encoding if not marked with a gamma value and
* the output is always 16 bits per component . This permits accurate scaling
* and processing of the data . If you know that your input PNG files were
* generated locally you might need to replace PNG_DEFAULT_sRGB with the
* correct value for your system .
*
* png_set_alpha_mode ( pp , PNG_ALPHA_OPTIMIZED , PNG_DEFAULT_sRGB ) ;
* If you just need to composite the PNG image onto an existing background
* and if you control the code that does this you can use the optimization
* setting . In this case you just copy completely opaque pixels to the
* output . For pixels that are not completely transparent ( you just skip
* those ) you do the composition math using png_composite or png_composite_16
* below then encode the resultant 8 - bit or 16 - bit values to match the output
* encoding .
*
* Other cases
* If neither the PNG nor the standard linear encoding work for you because
* of the software or hardware you use then you have a big problem . The PNG
* case will probably result in halos around the image . The linear encoding
* will probably result in a washed out , too bright , image ( it ' s actually too
* contrasty . ) Try the ALPHA_OPTIMIZED mode above - this will probably
* substantially reduce the halos . Alternatively try :
*
* png_set_alpha_mode ( pp , PNG_ALPHA_BROKEN , PNG_DEFAULT_sRGB ) ;
* This option will also reduce the halos , but there will be slight dark
* halos round the opaque parts of the image where the background is light .
* In the OPTIMIZED mode the halos will be light halos where the background
* is dark . Take your pick - the halos are unavoidable unless you can get
* your hardware / software fixed ! ( The OPTIMIZED approach is slightly
* faster . )
*
* When the default gamma of PNG files doesn ' t match the output gamma .
* If you have PNG files with no gamma information png_set_alpha_mode allows
* you to provide a default gamma , but it also sets the ouput gamma to the
* matching value . If you know your PNG files have a gamma that doesn ' t
* match the output you can take advantage of the fact that
* png_set_alpha_mode always sets the output gamma but only sets the PNG
* default if it is not already set :
*
* png_set_alpha_mode ( pp , PNG_ALPHA_PNG , PNG_DEFAULT_sRGB ) ;
* png_set_alpha_mode ( pp , PNG_ALPHA_PNG , PNG_GAMMA_MAC ) ;
* The first call sets both the default and the output gamma values , the
* second call overrides the output gamma without changing the default . This
* is easier than achieving the same effect with png_set_gamma . You must use
* PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will
* fire if more than one call to png_set_alpha_mode and png_set_background is
* made in the same read operation , however multiple calls with PNG_ALPHA_PNG
* are ignored .
*/
# ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
PNG_EXPORT ( 36 , void , png_set_strip_alpha , ( png_structp png_ptr ) ) ;
@ -1151,7 +1441,11 @@ PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr));
@@ -1151,7 +1441,11 @@ PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr));
# endif
# ifdef PNG_READ_BACKGROUND_SUPPORTED
/* Handle alpha and tRNS by replacing with a background color. */
/* Handle alpha and tRNS by replacing with a background color. Prior to
* libpng - 1.5 .4 this API must not be called before the PNG file header has been
* read . Doing so will result in unexpected behavior and possible warnings or
* errors if the PNG file contains a bKGD chunk .
*/
PNG_FP_EXPORT ( 47 , void , png_set_background , ( png_structp png_ptr ,
png_const_color_16p background_color , int background_gamma_code ,
int need_expand , double background_gamma ) ) ;
@ -1166,7 +1460,13 @@ PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr,
@@ -1166,7 +1460,13 @@ PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr,
# define PNG_BACKGROUND_GAMMA_UNIQUE 3
# endif
# ifdef PNG_READ_16_TO_8_SUPPORTED
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
/* Scale a 16-bit depth file down to 8-bit, accurately. */
PNG_EXPORT ( 229 , void , png_set_scale_16 , ( png_structp png_ptr ) ) ;
# endif
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
# define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
/* Strip the second byte of information from a 16-bit depth file. */
PNG_EXPORT ( 48 , void , png_set_strip_16 , ( png_structp png_ptr ) ) ;
# endif
@ -1187,12 +1487,22 @@ PNG_EXPORT(49, void, png_set_quantize,
@@ -1187,12 +1487,22 @@ PNG_EXPORT(49, void, png_set_quantize,
*/
# define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)
/* Handle gamma correction. Screen_gamma=(display_exponent) */
/* Handle gamma correction. Screen_gamma=(display_exponent).
* NOTE : this API simply sets the screen and file gamma values . It will
* therefore override the value for gamma in a PNG file if it is called after
* the file header has been read - use with care - call before reading the PNG
* file for best results !
*
* These routines accept the same gamma values as png_set_alpha_mode ( described
* above ) . The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either
* API ( floating point or fixed . ) Notice , however , that the ' file_gamma ' value
* is the inverse of a ' screen gamma ' value .
*/
PNG_FP_EXPORT ( 50 , void , png_set_gamma ,
( png_structp png_ptr , double screen_gamma ,
double default_file_gamma ) ) ;
double overri de_file_gamma) ) ;
PNG_FIXED_EXPORT ( 208 , void , png_set_gamma_fixed , ( png_structp png_ptr ,
png_fixed_point screen_gamma , png_fixed_point default_file_gamma ) ) ;
png_fixed_point screen_gamma , png_fixed_point overri de_file_gamma) ) ;
# endif
# ifdef PNG_WRITE_FLUSH_SUPPORTED
@ -1367,6 +1677,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
@@ -1367,6 +1677,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
# define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
# define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
# ifdef PNG_WRITE_SUPPORTED
/* Set the library compression level. Currently, valid values range from
* 0 - 9 , corresponding directly to the zlib compression levels 0 - 9
* ( 0 - no compression , 9 - " maximal " compression ) . Note that tests have
@ -1383,11 +1694,36 @@ PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structp png_ptr,
@@ -1383,11 +1694,36 @@ PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structp png_ptr,
PNG_EXPORT ( 71 , void , png_set_compression_strategy , ( png_structp png_ptr ,
int strategy ) ) ;
/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
* smaller value of window_bits if it can do so safely .
*/
PNG_EXPORT ( 72 , void , png_set_compression_window_bits , ( png_structp png_ptr ,
int window_bits ) ) ;
PNG_EXPORT ( 73 , void , png_set_compression_method , ( png_structp png_ptr ,
int method ) ) ;
# endif
# ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
/* Also set zlib parameters for compressing non-IDAT chunks */
PNG_EXPORT ( 222 , void , png_set_text_compression_level ,
( png_structp png_ptr , int level ) ) ;
PNG_EXPORT ( 223 , void , png_set_text_compression_mem_level , ( png_structp png_ptr ,
int mem_level ) ) ;
PNG_EXPORT ( 224 , void , png_set_text_compression_strategy , ( png_structp png_ptr ,
int strategy ) ) ;
/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
* smaller value of window_bits if it can do so safely .
*/
PNG_EXPORT ( 225 , void , png_set_text_compression_window_bits , ( png_structp
png_ptr , int window_bits ) ) ;
PNG_EXPORT ( 226 , void , png_set_text_compression_method , ( png_structp png_ptr ,
int method ) ) ;
# endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
/* These next functions are called for input/output, memory, and error
* handling . They are in the file pngrio . c , pngwio . c , and pngerror . c ,
@ -1475,9 +1811,13 @@ PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
@@ -1475,9 +1811,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 ) ) ;
@ -1522,6 +1862,7 @@ PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save));
@@ -1522,6 +1862,7 @@ PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save));
*/
PNG_EXPORT ( 220 , png_uint_32 , png_process_data_skip , ( png_structp ) ) ;
# ifdef PNG_READ_INTERLACING_SUPPORTED
/* Function that combines rows. 'new_row' is a flag that should come from
* the callback and be non - NULL if anything needs to be done ; the library
* stores its own version of the new data internally and ignores the passed
@ -1529,6 +1870,7 @@ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp));
@@ -1529,6 +1870,7 @@ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp));
*/
PNG_EXPORT ( 93 , void , png_progressive_combine_row , ( png_structp png_ptr ,
png_bytep old_row , png_const_bytep new_row ) ) ;
# endif /* PNG_READ_INTERLACING_SUPPORTED */
# endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
PNG_EXPORTA ( 94 , png_voidp , png_malloc ,
@ -1595,6 +1937,7 @@ PNG_EXPORTA(103, void, png_chunk_error, (png_structp png_ptr,
@@ -1595,6 +1937,7 @@ PNG_EXPORTA(103, void, png_chunk_error, (png_structp png_ptr,
PNG_EXPORTA ( 104 , void , png_err , ( png_structp png_ptr ) , PNG_NORETURN ) ;
# endif
# ifdef PNG_WARNINGS_SUPPORTED
/* Non-fatal error in libpng. Can continue, but may have a problem. */
PNG_EXPORT ( 105 , void , png_warning , ( png_structp png_ptr ,
png_const_charp warning_message ) ) ;
@ -1602,6 +1945,7 @@ PNG_EXPORT(105, void, png_warning, (png_structp png_ptr,
@@ -1602,6 +1945,7 @@ PNG_EXPORT(105, void, png_warning, (png_structp png_ptr,
/* Non-fatal error in libpng, chunk name is prepended to message. */
PNG_EXPORT ( 106 , void , png_chunk_warning , ( png_structp png_ptr ,
png_const_charp warning_message ) ) ;
# endif
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
/* Benign error in libpng. Can continue, but may have a problem.
@ -1740,6 +2084,10 @@ PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr,
@@ -1740,6 +2084,10 @@ PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr,
png_const_infop info_ptr , double * white_x , double * white_y , double * red_x ,
double * red_y , double * green_x , double * green_y , double * blue_x ,
double * blue_y ) ) ;
PNG_FP_EXPORT ( 230 , png_uint_32 , png_get_cHRM_XYZ , ( png_structp png_ptr ,
png_const_infop info_ptr , double * red_X , double * red_Y , double * red_Z ,
double * green_X , double * green_Y , double * green_Z , double * blue_X ,
double * blue_Y , double * blue_Z ) ) ;
# ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */
PNG_FIXED_EXPORT ( 134 , png_uint_32 , png_get_cHRM_fixed ,
( png_const_structp png_ptr ,
@ -1749,6 +2097,13 @@ PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
@@ -1749,6 +2097,13 @@ PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
png_fixed_point * int_green_y , png_fixed_point * int_blue_x ,
png_fixed_point * int_blue_y ) ) ;
# endif
PNG_FIXED_EXPORT ( 231 , png_uint_32 , png_get_cHRM_XYZ_fixed ,
( png_structp png_ptr , png_const_infop info_ptr ,
png_fixed_point * int_red_X , png_fixed_point * int_red_Y ,
png_fixed_point * int_red_Z , png_fixed_point * int_green_X ,
png_fixed_point * int_green_Y , png_fixed_point * int_green_Z ,
png_fixed_point * int_blue_X , png_fixed_point * int_blue_Y ,
png_fixed_point * int_blue_Z ) ) ;
# endif
# ifdef PNG_cHRM_SUPPORTED
@ -1756,12 +2111,22 @@ PNG_FP_EXPORT(135, void, png_set_cHRM,
@@ -1756,12 +2111,22 @@ PNG_FP_EXPORT(135, void, png_set_cHRM,
( png_structp png_ptr , png_infop info_ptr ,
double white_x , double white_y , double red_x , double red_y , double green_x ,
double green_y , double blue_x , double blue_y ) ) ;
PNG_FP_EXPORT ( 232 , void , png_set_cHRM_XYZ , ( png_structp png_ptr ,
png_infop info_ptr , double red_X , double red_Y , double red_Z ,
double green_X , double green_Y , double green_Z , double blue_X ,
double blue_Y , double blue_Z ) ) ;
PNG_FIXED_EXPORT ( 136 , void , png_set_cHRM_fixed , ( png_structp png_ptr ,
png_infop info_ptr , png_fixed_point int_white_x ,
png_fixed_point int_white_y , png_fixed_point int_red_x ,
png_fixed_point int_red_y , png_fixed_point int_green_x ,
png_fixed_point int_green_y , png_fixed_point int_blue_x ,
png_fixed_point int_blue_y ) ) ;
PNG_FIXED_EXPORT ( 233 , void , png_set_cHRM_XYZ_fixed , ( png_structp png_ptr ,
png_infop info_ptr , png_fixed_point int_red_X , png_fixed_point int_red_Y ,
png_fixed_point int_red_Z , png_fixed_point int_green_X ,
png_fixed_point int_green_Y , png_fixed_point int_green_Z ,
png_fixed_point int_blue_X , png_fixed_point int_blue_Y ,
png_fixed_point int_blue_Z ) ) ;
# endif
# ifdef PNG_gAMA_SUPPORTED
@ -1974,15 +2339,21 @@ PNG_EXPORT(171, void, png_set_sCAL_s,
@@ -1974,15 +2339,21 @@ PNG_EXPORT(171, void, png_set_sCAL_s,
/* Provide a list of chunks and how they are to be handled, if the built-in
handling or default unknown chunk handling is not desired . Any chunks not
listed will be handled in the default manner . The IHDR and IEND chunks
must not be listed .
keep = 0 : follow default behaviour
= 1 : do not keep
= 2 : keep only if safe - to - copy
= 3 : keep even if unsafe - to - copy
must not be listed . Because this turns off the default handling for chunks
that would otherwise be recognized the behavior of libpng transformations may
well become incorrect !
keep = 0 : PNG_HANDLE_CHUNK_AS_DEFAULT : follow default behavior
= 1 : PNG_HANDLE_CHUNK_NEVER : do not keep
= 2 : PNG_HANDLE_CHUNK_IF_SAFE : keep only if safe - to - copy
= 3 : PNG_HANDLE_CHUNK_ALWAYS : keep even if unsafe - to - copy
*/
PNG_EXPORT ( 172 , void , png_set_keep_unknown_chunks ,
( png_structp png_ptr , int keep ,
png_const_bytep chunk_list , int num_chunks ) ) ;
/* The handling code is returned; the result is therefore true (non-zero) if
* special handling is required , false for the default handling .
*/
PNG_EXPORT ( 173 , int , png_handle_as_unknown , ( png_structp png_ptr ,
png_const_bytep chunk_name ) ) ;
# endif
@ -2122,8 +2493,16 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
@@ -2122,8 +2493,16 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
* full , image which appears in a given pass . ' pass ' is in the range 0
* to 6 and the result is in the range 0 to 7.
*/
# define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7)
# define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7)
# define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)
# define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)
/* A macro to return the offset between pixels in the output row for a pair of
* pixels in the input - effectively the inverse of the ' COL_SHIFT ' macro that
* follows . Note that ROW_OFFSET is the offset from one row to the next whereas
* COL_OFFSET is from one column to the next , within a row .
*/
# define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)
# define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))
/* Two macros to help evaluate the number of rows or columns in each
* pass . This is expressed as a shift - effectively log2 of the number or
@ -2142,8 +2521,9 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
@@ -2142,8 +2521,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 ) )
@ -2157,8 +2537,8 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
@@ -2157,8 +2537,8 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
* the tile .
*/
# define PNG_PASS_MASK(pass,off) ( \
( ( 0x110145AFU > > ( ( ( 7 - ( off ) ) - ( pass ) ) < < 2 ) ) & 0xFU ) | \
( ( 0x01145AF0U > > ( ( ( 7 - ( off ) ) - ( pass ) ) < < 2 ) ) & 0xF0U ) )
( ( 0x110145AF > > ( ( ( 7 - ( off ) ) - ( pass ) ) < < 2 ) ) & 0xF ) | \
( ( 0x01145AF0 > > ( ( ( 7 - ( off ) ) - ( pass ) ) < < 2 ) ) & 0xF0 ) )
# define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
( ( PNG_PASS_MASK ( pass , 0 ) > > ( ( y ) & 7 ) ) & 1 )
@ -2184,14 +2564,14 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
@@ -2184,14 +2564,14 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
{ png_uint_16 temp = ( png_uint_16 ) ( ( png_uint_16 ) ( fg ) \
* ( png_uint_16 ) ( alpha ) \
+ ( png_uint_16 ) ( bg ) * ( png_uint_16 ) ( 255 \
- ( png_uint_16 ) ( alpha ) ) + ( png_uint_16 ) 128 ) ; \
- ( png_uint_16 ) ( alpha ) ) + 128 ) ; \
( composite ) = ( png_byte ) ( ( temp + ( temp > > 8 ) ) > > 8 ) ; }
# define png_composite_16(composite, fg, alpha, bg) \
{ png_uint_32 temp = ( png_uint_32 ) ( ( png_uint_32 ) ( fg ) \
* ( png_uint_32 ) ( alpha ) \
+ ( png_uint_32 ) ( bg ) * ( png_uint_32 ) ( 65535L \
- ( png_uint_32 ) ( alpha ) ) + ( png_uint_32 ) 32768L ) ; \
+ ( png_uint_32 ) ( bg ) * ( 65535 \
- ( png_uint_32 ) ( alpha ) ) + 32768 ) ; \
( composite ) = ( png_uint_16 ) ( ( temp + ( temp > > 16 ) ) > > 16 ) ; }
# else /* Standard method using integer division */
@ -2199,12 +2579,12 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
@@ -2199,12 +2579,12 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
# define png_composite(composite, fg, alpha, bg) \
( composite ) = ( png_byte ) ( ( ( png_uint_16 ) ( fg ) * ( png_uint_16 ) ( alpha ) + \
( png_uint_16 ) ( bg ) * ( png_uint_16 ) ( 255 - ( png_uint_16 ) ( alpha ) ) + \
( png_uint_16 ) 127 ) / 255 )
127 ) / 255 )
# define png_composite_16(composite, fg, alpha, bg) \
( composite ) = ( png_uint_16 ) ( ( ( png_uint_32 ) ( fg ) * ( png_uint_32 ) ( alpha ) + \
( png_uint_32 ) ( bg ) * ( png_uint_32 ) ( 65535L - ( png_uint_32 ) ( alpha ) ) + \
( png_uint_32 ) 32767 ) / ( png_uint_32 ) 65535L )
( png_uint_32 ) ( bg ) * ( png_uint_32 ) ( 65535 - ( png_uint_32 ) ( alpha ) ) + \
32767 ) / 65535 )
# endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
# ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
@ -2259,6 +2639,12 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
@@ -2259,6 +2639,12 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
: ( png_int_32 ) png_get_uint_32 ( buf ) ) )
# endif
# if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
defined ( PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED )
PNG_EXPORT ( 234 , void , png_set_check_for_invalid_index , ( png_structp png_ptr ,
int allowed ) ) ;
# endif
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
* defs
*/
@ -2268,7 +2654,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
@@ -2268,7 +2654,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 ( 234 ) ;
# endif
# ifdef __cplusplus