COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
png.h File Reference
#include "pnglibconf.h"
#include "pngconf.h"
Include dependency graph for png.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  png_color_struct
 
struct  png_color_16_struct
 
struct  png_color_8_struct
 
struct  png_sPLT_entry_struct
 
struct  png_sPLT_struct
 
struct  png_text_struct
 
struct  png_time_struct
 
struct  png_unknown_chunk_t
 
struct  png_row_info_struct
 
struct  png_image
 

Macros

#define PNG_LIBPNG_VER_STRING   "1.6.16"
 
#define PNG_HEADER_VERSION_STRING   " libpng version 1.6.16 - December 22, 2014\n"
 
#define PNG_LIBPNG_VER_SONUM   16
 
#define PNG_LIBPNG_VER_DLLNUM   16
 
#define PNG_LIBPNG_VER_MAJOR   1
 
#define PNG_LIBPNG_VER_MINOR   6
 
#define PNG_LIBPNG_VER_RELEASE   16
 
#define PNG_LIBPNG_VER_BUILD   0
 
#define PNG_LIBPNG_BUILD_ALPHA   1
 
#define PNG_LIBPNG_BUILD_BETA   2
 
#define PNG_LIBPNG_BUILD_RC   3
 
#define PNG_LIBPNG_BUILD_STABLE   4
 
#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK   7
 
#define PNG_LIBPNG_BUILD_PATCH
 
#define PNG_LIBPNG_BUILD_PRIVATE
 
#define PNG_LIBPNG_BUILD_SPECIAL
 
#define PNG_LIBPNG_BUILD_BASE_TYPE   PNG_LIBPNG_BUILD_STABLE
 
#define PNG_LIBPNG_VER   10616 /* 1.6.16 */
 
#define PNG_LIBPNG_BUILD_TYPE   (PNG_LIBPNG_BUILD_BASE_TYPE)
 
#define png_libpng_ver   png_get_header_ver(NULL)
 
#define PNG_TEXT_COMPRESSION_NONE_WR   -3
 
#define PNG_TEXT_COMPRESSION_zTXt_WR   -2
 
#define PNG_TEXT_COMPRESSION_NONE   -1
 
#define PNG_TEXT_COMPRESSION_zTXt   0
 
#define PNG_ITXT_COMPRESSION_NONE   1
 
#define PNG_ITXT_COMPRESSION_zTXt   2
 
#define PNG_TEXT_COMPRESSION_LAST   3 /* Not a valid value */
 
#define PNG_HAVE_IHDR   0x01
 
#define PNG_HAVE_PLTE   0x02
 
#define PNG_AFTER_IDAT   0x08
 
#define PNG_UINT_31_MAX   ((png_uint_32)0x7fffffffL)
 
#define PNG_UINT_32_MAX   ((png_uint_32)(-1))
 
#define PNG_SIZE_MAX   ((png_size_t)(-1))
 
#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)
 
#define PNG_COLOR_MASK_PALETTE   1
 
#define PNG_COLOR_MASK_COLOR   2
 
#define PNG_COLOR_MASK_ALPHA   4
 
#define PNG_COLOR_TYPE_GRAY   0
 
#define PNG_COLOR_TYPE_PALETTE   (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
 
#define PNG_COLOR_TYPE_RGB   (PNG_COLOR_MASK_COLOR)
 
#define PNG_COLOR_TYPE_RGB_ALPHA   (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
 
#define PNG_COLOR_TYPE_GRAY_ALPHA   (PNG_COLOR_MASK_ALPHA)
 
#define PNG_COLOR_TYPE_RGBA   PNG_COLOR_TYPE_RGB_ALPHA
 
#define PNG_COLOR_TYPE_GA   PNG_COLOR_TYPE_GRAY_ALPHA
 
#define PNG_COMPRESSION_TYPE_BASE   0 /* Deflate method 8, 32K window */
 
#define PNG_COMPRESSION_TYPE_DEFAULT   PNG_COMPRESSION_TYPE_BASE
 
#define PNG_FILTER_TYPE_BASE   0 /* Single row per-byte filtering */
 
#define PNG_INTRAPIXEL_DIFFERENCING   64 /* Used only in MNG datastreams */
 
#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE
 
#define PNG_INTERLACE_NONE   0 /* Non-interlaced image */
 
#define PNG_INTERLACE_ADAM7   1 /* Adam7 interlacing */
 
#define PNG_INTERLACE_LAST   2 /* Not a valid value */
 
#define PNG_OFFSET_PIXEL   0 /* Offset in pixels */
 
#define PNG_OFFSET_MICROMETER   1 /* Offset in micrometers (1/10^6 meter) */
 
#define PNG_OFFSET_LAST   2 /* Not a valid value */
 
#define PNG_EQUATION_LINEAR   0 /* Linear transformation */
 
#define PNG_EQUATION_BASE_E   1 /* Exponential base e transform */
 
#define PNG_EQUATION_ARBITRARY   2 /* Arbitrary base exponential transform */
 
#define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */
 
#define PNG_EQUATION_LAST   4 /* Not a valid value */
 
#define PNG_SCALE_UNKNOWN   0 /* unknown unit (image scale) */
 
#define PNG_SCALE_METER   1 /* meters per pixel */
 
#define PNG_SCALE_RADIAN   2 /* radians per pixel */
 
#define PNG_SCALE_LAST   3 /* Not a valid value */
 
#define PNG_RESOLUTION_UNKNOWN   0 /* pixels/unknown unit (aspect ratio) */
 
#define PNG_RESOLUTION_METER   1 /* pixels/meter */
 
#define PNG_RESOLUTION_LAST   2 /* Not a valid value */
 
#define PNG_sRGB_INTENT_PERCEPTUAL   0
 
#define PNG_sRGB_INTENT_RELATIVE   1
 
#define PNG_sRGB_INTENT_SATURATION   2
 
#define PNG_sRGB_INTENT_ABSOLUTE   3
 
#define PNG_sRGB_INTENT_LAST   4 /* Not a valid value */
 
#define PNG_KEYWORD_MAX_LENGTH   79
 
#define PNG_MAX_PALETTE_LENGTH   256
 
#define PNG_INFO_gAMA   0x0001
 
#define PNG_INFO_sBIT   0x0002
 
#define PNG_INFO_cHRM   0x0004
 
#define PNG_INFO_PLTE   0x0008
 
#define PNG_INFO_tRNS   0x0010
 
#define PNG_INFO_bKGD   0x0020
 
#define PNG_INFO_hIST   0x0040
 
#define PNG_INFO_pHYs   0x0080
 
#define PNG_INFO_oFFs   0x0100
 
#define PNG_INFO_tIME   0x0200
 
#define PNG_INFO_pCAL   0x0400
 
#define PNG_INFO_sRGB   0x0800 /* GR-P, 0.96a */
 
#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   0x8000 /* ESR, 1.0.6 */
 
#define PNG_TRANSFORM_IDENTITY   0x0000 /* read and write */
 
#define PNG_TRANSFORM_STRIP_16   0x0001 /* read only */
 
#define PNG_TRANSFORM_STRIP_ALPHA   0x0002 /* read only */
 
#define PNG_TRANSFORM_PACKING   0x0004 /* read and write */
 
#define PNG_TRANSFORM_PACKSWAP   0x0008 /* read and write */
 
#define PNG_TRANSFORM_EXPAND   0x0010 /* read only */
 
#define PNG_TRANSFORM_INVERT_MONO   0x0020 /* read and write */
 
#define PNG_TRANSFORM_SHIFT   0x0040 /* read and write */
 
#define PNG_TRANSFORM_BGR   0x0080 /* read and write */
 
#define PNG_TRANSFORM_SWAP_ALPHA   0x0100 /* read and write */
 
#define PNG_TRANSFORM_SWAP_ENDIAN   0x0200 /* read and write */
 
#define PNG_TRANSFORM_INVERT_ALPHA   0x0400 /* read and write */
 
#define PNG_TRANSFORM_STRIP_FILLER   0x0800 /* write only */
 
#define PNG_TRANSFORM_STRIP_FILLER_BEFORE   PNG_TRANSFORM_STRIP_FILLER
 
#define PNG_TRANSFORM_STRIP_FILLER_AFTER   0x1000 /* write only */
 
#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000 /* read only */
 
#define PNG_TRANSFORM_EXPAND_16   0x4000 /* read only */
 
#define PNG_TRANSFORM_SCALE_16   0x8000 /* read only */
 
#define PNG_FLAG_MNG_EMPTY_PLTE   0x01
 
#define PNG_FLAG_MNG_FILTER_64   0x04
 
#define PNG_ALL_MNG_FEATURES   0x05
 
#define png_check_sig(sig, n)   !png_sig_cmp((sig), 0, (n))
 
#define png_jmpbuf(png_ptr)   (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))
 
#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*/
 
#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 */
 
#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 */
 
#define PNG_FILLER_BEFORE   0
 
#define PNG_FILLER_AFTER   1
 
#define PNG_BACKGROUND_GAMMA_UNKNOWN   0
 
#define PNG_BACKGROUND_GAMMA_SCREEN   1
 
#define PNG_BACKGROUND_GAMMA_FILE   2
 
#define PNG_BACKGROUND_GAMMA_UNIQUE   3
 
#define PNG_READ_16_TO_8   SUPPORTED /* Name prior to 1.5.4 */
 
#define PNG_GAMMA_THRESHOLD   (PNG_GAMMA_THRESHOLD_FIXED*.00001)
 
#define PNG_CRC_DEFAULT   0 /* error/quit warn/discard data */
 
#define PNG_CRC_ERROR_QUIT   1 /* error/quit error/quit */
 
#define PNG_CRC_WARN_DISCARD   2 /* (INVALID) warn/discard data */
 
#define PNG_CRC_WARN_USE   3 /* warn/use data warn/use data */
 
#define PNG_CRC_QUIET_USE   4 /* quiet/use data quiet/use data */
 
#define PNG_CRC_NO_CHANGE   5 /* use current value use current value */
 
#define PNG_NO_FILTERS   0x00
 
#define PNG_FILTER_NONE   0x08
 
#define PNG_FILTER_SUB   0x10
 
#define PNG_FILTER_UP   0x20
 
#define PNG_FILTER_AVG   0x40
 
#define PNG_FILTER_PAETH   0x80
 
#define PNG_ALL_FILTERS
 
#define PNG_FILTER_VALUE_NONE   0
 
#define PNG_FILTER_VALUE_SUB   1
 
#define PNG_FILTER_VALUE_UP   2
 
#define PNG_FILTER_VALUE_AVG   3
 
#define PNG_FILTER_VALUE_PAETH   4
 
#define PNG_FILTER_VALUE_LAST   5
 
#define PNG_FILTER_HEURISTIC_DEFAULT   0 /* Currently "UNWEIGHTED" */
 
#define PNG_FILTER_HEURISTIC_UNWEIGHTED   1 /* Used by libpng < 0.95 */
 
#define PNG_FILTER_HEURISTIC_WEIGHTED   2 /* Experimental feature */
 
#define PNG_FILTER_HEURISTIC_LAST   3 /* Not a valid value */
 
#define PNG_DESTROY_WILL_FREE_DATA   1
 
#define PNG_SET_WILL_FREE_DATA   1
 
#define PNG_USER_WILL_FREE_DATA   2
 
#define PNG_FREE_HIST   0x0008
 
#define PNG_FREE_ICCP   0x0010
 
#define PNG_FREE_SPLT   0x0020
 
#define PNG_FREE_ROWS   0x0040
 
#define PNG_FREE_PCAL   0x0080
 
#define PNG_FREE_SCAL   0x0100
 
#define PNG_FREE_UNKN   0x0200
 
#define PNG_FREE_PLTE   0x1000
 
#define PNG_FREE_TRNS   0x2000
 
#define PNG_FREE_TEXT   0x4000
 
#define PNG_FREE_ALL   0x7fff
 
#define PNG_FREE_MUL   0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
 
#define PNG_HANDLE_CHUNK_AS_DEFAULT   0
 
#define PNG_HANDLE_CHUNK_NEVER   1
 
#define PNG_HANDLE_CHUNK_IF_SAFE   2
 
#define PNG_HANDLE_CHUNK_ALWAYS   3
 
#define PNG_HANDLE_CHUNK_LAST   4
 
#define PNG_IO_NONE   0x0000 /* no I/O at this moment */
 
#define PNG_IO_READING   0x0001 /* currently reading */
 
#define PNG_IO_WRITING   0x0002 /* currently writing */
 
#define PNG_IO_SIGNATURE   0x0010 /* currently at the file signature */
 
#define PNG_IO_CHUNK_HDR   0x0020 /* currently at the chunk header */
 
#define PNG_IO_CHUNK_DATA   0x0040 /* currently at the chunk data */
 
#define PNG_IO_CHUNK_CRC   0x0080 /* currently at the chunk crc */
 
#define PNG_IO_MASK_OP   0x000f /* current operation: reading/writing */
 
#define PNG_IO_MASK_LOC   0x00f0 /* current location: sig/hdr/data/crc */
 
#define PNG_INTERLACE_ADAM7_PASSES   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)
 
#define PNG_PASS_ROW_OFFSET(pass)   ((pass)>2?(8>>(((pass)-1)>>1)):8)
 
#define PNG_PASS_COL_OFFSET(pass)   (1<<((7-(pass))>>1))
 
#define PNG_PASS_ROW_SHIFT(pass)   ((pass)>2?(8-(pass))>>1:3)
 
#define PNG_PASS_COL_SHIFT(pass)   ((pass)>1?(7-(pass))>>1:3)
 
#define PNG_PASS_ROWS(height, pass)
 
#define PNG_PASS_COLS(width, pass)
 
#define PNG_ROW_FROM_PASS_ROW(y_in, pass)   (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
 
#define PNG_COL_FROM_PASS_COL(x_in, pass)   (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
 
#define PNG_PASS_MASK(pass, off)
 
#define PNG_ROW_IN_INTERLACE_PASS(y, pass)   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
 
#define PNG_COL_IN_INTERLACE_PASS(x, pass)   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
 
#define png_composite(composite, fg, alpha, bg)
 
#define png_composite_16(composite, fg, alpha, bg)
 
#define PNG_get_uint_32(buf)
 
#define PNG_get_uint_16(buf)
 
#define PNG_get_int_32(buf)
 
#define png_get_uint_32(buf)   PNG_get_uint_32(buf)
 
#define png_get_uint_16(buf)   PNG_get_uint_16(buf)
 
#define png_get_int_32(buf)   PNG_get_int_32(buf)
 
#define PNG_IMAGE_VERSION   1
 
#define PNG_IMAGE_WARNING   1
 
#define PNG_IMAGE_ERROR   2
 
#define PNG_IMAGE_FAILED(png_cntrl)   ((((png_cntrl).warning_or_error)&0x03)>1)
 
#define PNG_FORMAT_FLAG_ALPHA   0x01U /* format with an alpha channel */
 
#define PNG_FORMAT_FLAG_COLOR   0x02U /* color format: otherwise grayscale */
 
#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2 byte channels else 1 byte */
 
#define PNG_FORMAT_FLAG_COLORMAP   0x08U /* image data is color-mapped */
 
#define PNG_FORMAT_FLAG_BGR   0x10U /* BGR colors, else order is RGB */
 
#define PNG_FORMAT_FLAG_AFIRST   0x20U /* alpha channel comes first */
 
#define PNG_FORMAT_GRAY   0
 
#define PNG_FORMAT_GA   PNG_FORMAT_FLAG_ALPHA
 
#define PNG_FORMAT_AG   (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)
 
#define PNG_FORMAT_RGB   PNG_FORMAT_FLAG_COLOR
 
#define PNG_FORMAT_BGR   (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)
 
#define PNG_FORMAT_RGBA   (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)
 
#define PNG_FORMAT_ARGB   (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)
 
#define PNG_FORMAT_BGRA   (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)
 
#define PNG_FORMAT_ABGR   (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)
 
#define PNG_FORMAT_LINEAR_Y   PNG_FORMAT_FLAG_LINEAR
 
#define PNG_FORMAT_LINEAR_Y_ALPHA   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)
 
#define PNG_FORMAT_LINEAR_RGB   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)
 
#define PNG_FORMAT_LINEAR_RGB_ALPHA   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)
 
#define PNG_FORMAT_RGB_COLORMAP   (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)
 
#define PNG_FORMAT_BGR_COLORMAP   (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)
 
#define PNG_FORMAT_RGBA_COLORMAP   (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)
 
#define PNG_FORMAT_ARGB_COLORMAP   (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)
 
#define PNG_FORMAT_BGRA_COLORMAP   (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)
 
#define PNG_FORMAT_ABGR_COLORMAP   (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)
 
#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)   (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1)
 
#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)   ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)
 
#define PNG_IMAGE_SAMPLE_SIZE(fmt)   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))
 
#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)
 
#define PNG_IMAGE_PIXEL_(test, fmt)   (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt))
 
#define PNG_IMAGE_PIXEL_CHANNELS(fmt)   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt)
 
#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)
 
#define PNG_IMAGE_PIXEL_SIZE(fmt)   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)
 
#define PNG_IMAGE_ROW_STRIDE(image)   (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)
 
#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)   (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
 
#define PNG_IMAGE_SIZE(image)   PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
 
#define PNG_IMAGE_COLORMAP_SIZE(image)   (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
 
#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB   0x01
 
#define PNG_IMAGE_FLAG_FAST   0x02
 
#define PNG_IMAGE_FLAG_16BIT_sRGB   0x04
 
#define PNG_MAXIMUM_INFLATE_WINDOW   2 /* SOFTWARE: force maximum window */
 
#define PNG_SKIP_sRGB_CHECK_PROFILE   4 /* SOFTWARE: Check ICC profile for sRGB */
 
#define PNG_OPTION_NEXT   6 /* Next option - numbers must be even */
 
#define PNG_OPTION_UNSET   0 /* Unset - defaults to off */
 
#define PNG_OPTION_INVALID   1 /* Option number out of range */
 
#define PNG_OPTION_OFF   2
 
#define PNG_OPTION_ON   3
 

Typedefs

typedef char * png_libpng_version_1_6_16
 
typedef struct png_struct_def png_struct
 
typedef const png_structpng_const_structp
 
typedef png_structpng_structp
 
typedef png_struct ** png_structpp
 
typedef struct png_info_def png_info
 
typedef png_infopng_infop
 
typedef const png_infopng_const_infop
 
typedef png_info ** png_infopp
 
typedef png_structpng_structrp
 
typedef const png_structpng_const_structrp
 
typedef png_infopng_inforp
 
typedef const png_infopng_const_inforp
 
typedef struct png_color_struct png_color
 
typedef png_colorpng_colorp
 
typedef const png_colorpng_const_colorp
 
typedef png_color ** png_colorpp
 
typedef struct png_color_16_struct png_color_16
 
typedef png_color_16png_color_16p
 
typedef const png_color_16png_const_color_16p
 
typedef png_color_16 ** png_color_16pp
 
typedef struct png_color_8_struct png_color_8
 
typedef png_color_8png_color_8p
 
typedef const png_color_8png_const_color_8p
 
typedef png_color_8 ** png_color_8pp
 
typedef struct png_sPLT_entry_struct png_sPLT_entry
 
typedef png_sPLT_entrypng_sPLT_entryp
 
typedef const png_sPLT_entrypng_const_sPLT_entryp
 
typedef png_sPLT_entry ** png_sPLT_entrypp
 
typedef struct png_sPLT_struct png_sPLT_t
 
typedef png_sPLT_tpng_sPLT_tp
 
typedef const png_sPLT_tpng_const_sPLT_tp
 
typedef png_sPLT_t ** png_sPLT_tpp
 
typedef struct png_text_struct png_text
 
typedef png_textpng_textp
 
typedef const png_textpng_const_textp
 
typedef png_text ** png_textpp
 
typedef struct png_time_struct png_time
 
typedef png_timepng_timep
 
typedef const png_timepng_const_timep
 
typedef png_time ** png_timepp
 
typedef struct png_unknown_chunk_t png_unknown_chunk
 
typedef png_unknown_chunkpng_unknown_chunkp
 
typedef const png_unknown_chunkpng_const_unknown_chunkp
 
typedef png_unknown_chunk ** png_unknown_chunkpp
 
typedef struct png_row_info_struct png_row_info
 
typedef png_row_infopng_row_infop
 
typedef png_row_info ** png_row_infopp
 
typedef void(* png_error_ptr) (png_structp, png_const_charp)
 
typedef void(* png_rw_ptr) (png_structp, png_bytep, png_size_t)
 
typedef void(* png_flush_ptr) (png_structp)
 
typedef void(* png_read_status_ptr) (png_structp, png_uint_32, int)
 
typedef void(* png_write_status_ptr) (png_structp, png_uint_32, int)
 
typedef void(* png_progressive_info_ptr) (png_structp, png_infop)
 
typedef void(* png_progressive_end_ptr) (png_structp, png_infop)
 
typedef void(* png_progressive_row_ptr) (png_structp, png_bytep, png_uint_32, int)
 
typedef void(* png_user_transform_ptr) (png_structp, png_row_infop, png_bytep)
 
typedef int(* png_user_chunk_ptr) (png_structp, png_unknown_chunkp)
 
typedef void(* png_longjmp_ptr) (jmp_buf, int)
 
typedef png_voidp(* png_malloc_ptr) (png_structp, png_alloc_size_t)
 
typedef void(* png_free_ptr) (png_structp, png_voidp)
 
typedef struct png_controlpng_controlp
 
typedef struct png_imagepng_imagep
 

Functions

PNG_IMPEXP png_uint_32() png_access_version_number (void)
 
PNG_IMPEXP void() png_set_sig_bytes (png_structrp png_ptr, int num_bytes)
 
PNG_IMPEXP int() png_sig_cmp (png_const_bytep sig, png_size_t start, png_size_t num_to_check)
 
PNG_IMPEXP png_structp() png_create_read_struct (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
 
PNG_IMPEXP png_structp() png_create_write_struct (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
 
PNG_IMPEXP png_size_t() png_get_compression_buffer_size (png_const_structrp png_ptr)
 
PNG_IMPEXP void() png_set_compression_buffer_size (png_structrp png_ptr, png_size_t size)
 
PNG_IMPEXP jmp_buf *() png_set_longjmp_fn (png_structrp png_ptr, png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)
 
PNG_IMPEXP void() png_longjmp (png_const_structrp png_ptr, int val)
 
PNG_DEPRECATED PNG_IMPEXP int() png_reset_zstream (png_structrp png_ptr)
 
PNG_IMPEXP png_structp() png_create_read_struct_2 (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
 
PNG_IMPEXP png_structp() png_create_write_struct_2 (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
 
PNG_IMPEXP void() png_write_sig (png_structrp png_ptr)
 
PNG_IMPEXP void() png_write_chunk (png_structrp png_ptr, png_const_bytep chunk_name, png_const_bytep data, png_size_t length)
 
PNG_IMPEXP void() png_write_chunk_start (png_structrp png_ptr, png_const_bytep chunk_name, png_uint_32 length)
 
PNG_IMPEXP void() png_write_chunk_data (png_structrp png_ptr, png_const_bytep data, png_size_t length)
 
PNG_IMPEXP void() png_write_chunk_end (png_structrp png_ptr)
 
PNG_IMPEXP png_infop() png_create_info_struct (png_const_structrp png_ptr)
 
PNG_DEPRECATED PNG_IMPEXP void() png_info_init_3 (png_infopp info_ptr, png_size_t png_info_struct_size)
 
PNG_IMPEXP void() png_write_info_before_PLTE (png_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP void() png_write_info (png_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP void() png_read_info (png_structrp png_ptr, png_inforp info_ptr)
 
PNG_DEPRECATED PNG_IMPEXP png_const_charp() png_convert_to_rfc1123 (png_structrp png_ptr, png_const_timep ptime)
 
PNG_IMPEXP int() png_convert_to_rfc1123_buffer (char out[29], png_const_timep ptime)
 
PNG_IMPEXP void() png_convert_from_struct_tm (png_timep ptime, const struct tm *ttime)
 
PNG_IMPEXP void() png_convert_from_time_t (png_timep ptime, time_t ttime)
 
PNG_IMPEXP void() png_set_expand (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_expand_gray_1_2_4_to_8 (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_palette_to_rgb (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_tRNS_to_alpha (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_expand_16 (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_bgr (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_gray_to_rgb (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_rgb_to_gray (png_structrp png_ptr, int error_action, double red, double green)
 
PNG_IMPEXP void() png_set_rgb_to_gray_fixed (png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)
 
PNG_IMPEXP png_byte() png_get_rgb_to_gray_status (png_const_structrp png_ptr)
 
PNG_IMPEXP void() png_build_grayscale_palette (int bit_depth, png_colorp palette)
 
PNG_IMPEXP void() png_set_alpha_mode (png_structrp png_ptr, int mode, double output_gamma)
 
PNG_IMPEXP void() png_set_alpha_mode_fixed (png_structrp png_ptr, int mode, png_fixed_point output_gamma)
 
PNG_IMPEXP void() png_set_strip_alpha (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_swap_alpha (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_invert_alpha (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_filler (png_structrp png_ptr, png_uint_32 filler, int flags)
 
PNG_IMPEXP void() png_set_add_alpha (png_structrp png_ptr, png_uint_32 filler, int flags)
 
PNG_IMPEXP void() png_set_swap (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_packing (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_packswap (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_shift (png_structrp png_ptr, png_const_color_8p true_bits)
 
PNG_IMPEXP int() png_set_interlace_handling (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_invert_mono (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_background (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)
 
PNG_IMPEXP void() png_set_background_fixed (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma)
 
PNG_IMPEXP void() png_set_scale_16 (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_strip_16 (png_structrp png_ptr)
 
PNG_IMPEXP void() png_set_quantize (png_structrp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_const_uint_16p histogram, int full_quantize)
 
PNG_IMPEXP void() png_set_gamma (png_structrp png_ptr, double screen_gamma, double override_file_gamma)
 
PNG_IMPEXP void() png_set_gamma_fixed (png_structrp png_ptr, png_fixed_point screen_gamma, png_fixed_point override_file_gamma)
 
PNG_IMPEXP void() png_set_flush (png_structrp png_ptr, int nrows)
 
PNG_IMPEXP void() png_write_flush (png_structrp png_ptr)
 
PNG_IMPEXP void() png_start_read_image (png_structrp png_ptr)
 
PNG_IMPEXP void() png_read_update_info (png_structrp png_ptr, png_inforp info_ptr)
 
PNG_IMPEXP void() png_read_rows (png_structrp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)
 
PNG_IMPEXP void() png_read_row (png_structrp png_ptr, png_bytep row, png_bytep display_row)
 
PNG_IMPEXP void() png_read_image (png_structrp png_ptr, png_bytepp image)
 
PNG_IMPEXP void() png_write_row (png_structrp png_ptr, png_const_bytep row)
 
PNG_IMPEXP void() png_write_rows (png_structrp png_ptr, png_bytepp row, png_uint_32 num_rows)
 
PNG_IMPEXP void() png_write_image (png_structrp png_ptr, png_bytepp image)
 
PNG_IMPEXP void() png_write_end (png_structrp png_ptr, png_inforp info_ptr)
 
PNG_IMPEXP void() png_read_end (png_structrp png_ptr, png_inforp info_ptr)
 
PNG_IMPEXP void() png_destroy_info_struct (png_const_structrp png_ptr, png_infopp info_ptr_ptr)
 
PNG_IMPEXP void() png_destroy_read_struct (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)
 
PNG_IMPEXP void() png_destroy_write_struct (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
 
PNG_IMPEXP void() png_set_crc_action (png_structrp png_ptr, int crit_action, int ancil_action)
 
PNG_IMPEXP void() png_set_filter (png_structrp png_ptr, int method, int filters)
 
PNG_IMPEXP void() png_set_filter_heuristics (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_doublep filter_weights, png_const_doublep filter_costs)
 
PNG_IMPEXP void() png_set_filter_heuristics_fixed (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_fixed_point_p filter_weights, png_const_fixed_point_p filter_costs)
 
PNG_IMPEXP void() png_set_compression_level (png_structrp png_ptr, int level)
 
PNG_IMPEXP void() png_set_compression_mem_level (png_structrp png_ptr, int mem_level)
 
PNG_IMPEXP void() png_set_compression_strategy (png_structrp png_ptr, int strategy)
 
PNG_IMPEXP void() png_set_compression_window_bits (png_structrp png_ptr, int window_bits)
 
PNG_IMPEXP void() png_set_compression_method (png_structrp png_ptr, int method)
 
PNG_IMPEXP void() png_set_text_compression_level (png_structrp png_ptr, int level)
 
PNG_IMPEXP void() png_set_text_compression_mem_level (png_structrp png_ptr, int mem_level)
 
PNG_IMPEXP void() png_set_text_compression_strategy (png_structrp png_ptr, int strategy)
 
PNG_IMPEXP void() png_set_text_compression_window_bits (png_structrp png_ptr, int window_bits)
 
PNG_IMPEXP void() png_set_text_compression_method (png_structrp png_ptr, int method)
 
PNG_IMPEXP void() png_init_io (png_structrp png_ptr, png_FILE_p fp)
 
PNG_IMPEXP void() png_set_error_fn (png_structrp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)
 
PNG_IMPEXP png_voidp() png_get_error_ptr (png_const_structrp png_ptr)
 
PNG_IMPEXP void() png_set_write_fn (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
 
PNG_IMPEXP void() png_set_read_fn (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)
 
PNG_IMPEXP png_voidp() png_get_io_ptr (png_const_structrp png_ptr)
 
PNG_IMPEXP void() png_set_read_status_fn (png_structrp png_ptr, png_read_status_ptr read_row_fn)
 
PNG_IMPEXP void() png_set_write_status_fn (png_structrp png_ptr, png_write_status_ptr write_row_fn)
 
PNG_IMPEXP void() png_set_mem_fn (png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
 
PNG_IMPEXP png_voidp() png_get_mem_ptr (png_const_structrp png_ptr)
 
PNG_IMPEXP void() png_set_read_user_transform_fn (png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn)
 
PNG_IMPEXP void() png_set_write_user_transform_fn (png_structrp png_ptr, png_user_transform_ptr write_user_transform_fn)
 
PNG_IMPEXP void() png_set_user_transform_info (png_structrp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels)
 
PNG_IMPEXP png_voidp() png_get_user_transform_ptr (png_const_structrp png_ptr)
 
PNG_IMPEXP png_uint_32() png_get_current_row_number (png_const_structrp)
 
PNG_IMPEXP png_byte() png_get_current_pass_number (png_const_structrp)
 
PNG_IMPEXP void() png_set_read_user_chunk_fn (png_structrp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)
 
PNG_IMPEXP png_voidp() png_get_user_chunk_ptr (png_const_structrp png_ptr)
 
PNG_IMPEXP void() png_set_progressive_read_fn (png_structrp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)
 
PNG_IMPEXP png_voidp() png_get_progressive_ptr (png_const_structrp png_ptr)
 
PNG_IMPEXP void() png_process_data (png_structrp png_ptr, png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size)
 
PNG_IMPEXP png_size_t() png_process_data_pause (png_structrp, int save)
 
PNG_IMPEXP png_uint_32() png_process_data_skip (png_structrp)
 
PNG_IMPEXP void() png_progressive_combine_row (png_const_structrp png_ptr, png_bytep old_row, png_const_bytep new_row)
 
PNG_IMPEXP png_voidp() png_malloc (png_const_structrp png_ptr, png_alloc_size_t size)
 
PNG_IMPEXP png_voidp() png_calloc (png_const_structrp png_ptr, png_alloc_size_t size)
 
PNG_IMPEXP png_voidp() png_malloc_warn (png_const_structrp png_ptr, png_alloc_size_t size)
 
PNG_IMPEXP void() png_free (png_const_structrp png_ptr, png_voidp ptr)
 
PNG_IMPEXP void() png_free_data (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 free_me, int num)
 
PNG_IMPEXP void() png_data_freer (png_const_structrp png_ptr, png_inforp info_ptr, int freer, png_uint_32 mask)
 
PNG_DEPRECATED PNG_IMPEXP png_voidp() png_malloc_default (png_const_structrp png_ptr, png_alloc_size_t size)
 
PNG_DEPRECATED PNG_IMPEXP void() png_free_default (png_const_structrp png_ptr, png_voidp ptr)
 
PNG_IMPEXP void() png_error (png_const_structrp png_ptr, png_const_charp error_message)
 
PNG_IMPEXP void() png_chunk_error (png_const_structrp png_ptr, png_const_charp error_message)
 
PNG_IMPEXP void() png_warning (png_const_structrp png_ptr, png_const_charp warning_message)
 
PNG_IMPEXP void() png_chunk_warning (png_const_structrp png_ptr, png_const_charp warning_message)
 
PNG_IMPEXP void() png_benign_error (png_const_structrp png_ptr, png_const_charp warning_message)
 
PNG_IMPEXP void() png_chunk_benign_error (png_const_structrp png_ptr, png_const_charp warning_message)
 
PNG_IMPEXP void() png_set_benign_errors (png_structrp png_ptr, int allowed)
 
PNG_IMPEXP png_uint_32() png_get_valid (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag)
 
PNG_IMPEXP png_size_t() png_get_rowbytes (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_bytepp() png_get_rows (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP void() png_set_rows (png_const_structrp png_ptr, png_inforp info_ptr, png_bytepp row_pointers)
 
PNG_IMPEXP png_byte() png_get_channels (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_uint_32() png_get_image_width (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_uint_32() png_get_image_height (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_byte() png_get_bit_depth (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_byte() png_get_color_type (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_byte() png_get_filter_type (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_byte() png_get_interlace_type (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_byte() png_get_compression_type (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_uint_32() png_get_pixels_per_meter (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_uint_32() png_get_x_pixels_per_meter (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_uint_32() png_get_y_pixels_per_meter (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP float() png_get_pixel_aspect_ratio (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_fixed_point() png_get_pixel_aspect_ratio_fixed (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_int_32() png_get_x_offset_pixels (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_int_32() png_get_y_offset_pixels (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_int_32() png_get_x_offset_microns (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_int_32() png_get_y_offset_microns (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_const_bytep() png_get_signature (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_uint_32() png_get_bKGD (png_const_structrp png_ptr, png_inforp info_ptr, png_color_16p *background)
 
PNG_IMPEXP void() png_set_bKGD (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_16p background)
 
PNG_IMPEXP png_uint_32() png_get_cHRM (png_const_structrp png_ptr, png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y)
 
PNG_IMPEXP png_uint_32() png_get_cHRM_XYZ (png_const_structrp png_ptr, png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, double *green_X, double *green_Y, double *green_Z, double *blue_X, double *blue_Y, double *blue_Z)
 
PNG_IMPEXP png_uint_32() png_get_cHRM_fixed (png_const_structrp png_ptr, png_const_inforp 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_IMPEXP png_uint_32() png_get_cHRM_XYZ_fixed (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_red_X, png_fixed_point *int_red_Y, png_fixed_point *int_red_Z, png_fixed_point *int_green_X, png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, png_fixed_point *int_blue_Z)
 
PNG_IMPEXP void() png_set_cHRM (png_const_structrp png_ptr, png_inforp 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_IMPEXP void() png_set_cHRM_XYZ (png_const_structrp png_ptr, png_inforp 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_IMPEXP void() png_set_cHRM_fixed (png_const_structrp png_ptr, png_inforp 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_IMPEXP void() png_set_cHRM_XYZ_fixed (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, png_fixed_point int_blue_X, png_fixed_point int_blue_Y, png_fixed_point int_blue_Z)
 
PNG_IMPEXP png_uint_32() png_get_gAMA (png_const_structrp png_ptr, png_const_inforp info_ptr, double *file_gamma)
 
PNG_IMPEXP png_uint_32() png_get_gAMA_fixed (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_file_gamma)
 
PNG_IMPEXP void() png_set_gAMA (png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)
 
PNG_IMPEXP void() png_set_gAMA_fixed (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_file_gamma)
 
PNG_IMPEXP png_uint_32() png_get_hIST (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_16p *hist)
 
PNG_IMPEXP void() png_set_hIST (png_const_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist)
 
PNG_IMPEXP png_uint_32() png_get_IHDR (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method)
 
PNG_IMPEXP void() png_set_IHDR (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_method, int compression_method, int filter_method)
 
PNG_IMPEXP png_uint_32() png_get_oFFs (png_const_structrp png_ptr, png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
 
PNG_IMPEXP void() png_set_oFFs (png_const_structrp png_ptr, png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type)
 
PNG_IMPEXP png_uint_32() png_get_pCAL (png_const_structrp png_ptr, png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params)
 
PNG_IMPEXP void() png_set_pCAL (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)
 
PNG_IMPEXP png_uint_32() png_get_pHYs (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
 
PNG_IMPEXP void() png_set_pHYs (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)
 
PNG_IMPEXP png_uint_32() png_get_PLTE (png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette)
 
PNG_IMPEXP void() png_set_PLTE (png_structrp png_ptr, png_inforp info_ptr, png_const_colorp palette, int num_palette)
 
PNG_IMPEXP png_uint_32() png_get_sBIT (png_const_structrp png_ptr, png_inforp info_ptr, png_color_8p *sig_bit)
 
PNG_IMPEXP void() png_set_sBIT (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_8p sig_bit)
 
PNG_IMPEXP png_uint_32() png_get_sRGB (png_const_structrp png_ptr, png_const_inforp info_ptr, int *file_srgb_intent)
 
PNG_IMPEXP void() png_set_sRGB (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)
 
PNG_IMPEXP void() png_set_sRGB_gAMA_and_cHRM (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)
 
PNG_IMPEXP png_uint_32() png_get_iCCP (png_const_structrp png_ptr, png_inforp info_ptr, png_charpp name, int *compression_type, png_bytepp profile, png_uint_32 *proflen)
 
PNG_IMPEXP void() png_set_iCCP (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp name, int compression_type, png_const_bytep profile, png_uint_32 proflen)
 
PNG_IMPEXP int() png_get_sPLT (png_const_structrp png_ptr, png_inforp info_ptr, png_sPLT_tpp entries)
 
PNG_IMPEXP void() png_set_sPLT (png_const_structrp png_ptr, png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)
 
PNG_IMPEXP int() png_get_text (png_const_structrp png_ptr, png_inforp info_ptr, png_textp *text_ptr, int *num_text)
 
PNG_IMPEXP void() png_set_text (png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)
 
PNG_IMPEXP png_uint_32() png_get_tIME (png_const_structrp png_ptr, png_inforp info_ptr, png_timep *mod_time)
 
PNG_IMPEXP void() png_set_tIME (png_const_structrp png_ptr, png_inforp info_ptr, png_const_timep mod_time)
 
PNG_IMPEXP png_uint_32() png_get_tRNS (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
 
PNG_IMPEXP void() png_set_tRNS (png_structrp png_ptr, png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)
 
PNG_IMPEXP png_uint_32() png_get_sCAL (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, double *width, double *height)
 
PNG_IMPEXP png_uint_32() png_get_sCAL_fixed (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_fixed_point *width, png_fixed_point *height)
 
PNG_IMPEXP png_uint_32() png_get_sCAL_s (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_charpp swidth, png_charpp sheight)
 
PNG_IMPEXP void() png_set_sCAL (png_const_structrp png_ptr, png_inforp info_ptr, int unit, double width, double height)
 
PNG_IMPEXP void() png_set_sCAL_fixed (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_fixed_point width, png_fixed_point height)
 
PNG_IMPEXP void() png_set_sCAL_s (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)
 
PNG_IMPEXP void() png_set_keep_unknown_chunks (png_structrp png_ptr, int keep, png_const_bytep chunk_list, int num_chunks)
 
PNG_IMPEXP int() png_handle_as_unknown (png_const_structrp png_ptr, png_const_bytep chunk_name)
 
PNG_IMPEXP void() png_set_unknown_chunks (png_const_structrp png_ptr, png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
 
PNG_IMPEXP void() png_set_unknown_chunk_location (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)
 
PNG_IMPEXP int() png_get_unknown_chunks (png_const_structrp png_ptr, png_inforp info_ptr, png_unknown_chunkpp entries)
 
PNG_IMPEXP void() png_set_invalid (png_const_structrp png_ptr, png_inforp info_ptr, int mask)
 
PNG_IMPEXP void() png_read_png (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)
 
PNG_IMPEXP void() png_write_png (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)
 
PNG_IMPEXP png_const_charp() png_get_copyright (png_const_structrp png_ptr)
 
PNG_IMPEXP png_const_charp() png_get_header_ver (png_const_structrp png_ptr)
 
PNG_IMPEXP png_const_charp() png_get_header_version (png_const_structrp png_ptr)
 
PNG_IMPEXP png_const_charp() png_get_libpng_ver (png_const_structrp png_ptr)
 
PNG_IMPEXP png_uint_32() png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features_permitted)
 
PNG_IMPEXP void() png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)
 
PNG_IMPEXP png_uint_32() png_get_user_width_max (png_const_structrp png_ptr)
 
PNG_IMPEXP png_uint_32() png_get_user_height_max (png_const_structrp png_ptr)
 
PNG_IMPEXP void() png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
 
PNG_IMPEXP png_uint_32() png_get_chunk_cache_max (png_const_structrp png_ptr)
 
PNG_IMPEXP void() png_set_chunk_malloc_max (png_structrp png_ptr, png_alloc_size_t user_chunk_cache_max)
 
PNG_IMPEXP png_alloc_size_t() png_get_chunk_malloc_max (png_const_structrp png_ptr)
 
PNG_IMPEXP png_uint_32() png_get_pixels_per_inch (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_uint_32() png_get_x_pixels_per_inch (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_uint_32() png_get_y_pixels_per_inch (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP float() png_get_x_offset_inches (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_fixed_point() png_get_x_offset_inches_fixed (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP float() png_get_y_offset_inches (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_fixed_point() png_get_y_offset_inches_fixed (png_const_structrp png_ptr, png_const_inforp info_ptr)
 
PNG_IMPEXP png_uint_32() png_get_pHYs_dpi (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
 
PNG_IMPEXP png_uint_32() png_get_io_state (png_const_structrp png_ptr)
 
PNG_IMPEXP png_uint_32() png_get_io_chunk_type (png_const_structrp png_ptr)
 
PNG_IMPEXP png_uint_32() png_get_uint_32 (png_const_bytep buf)
 
PNG_IMPEXP png_uint_16() png_get_uint_16 (png_const_bytep buf)
 
PNG_IMPEXP png_int_32() png_get_int_32 (png_const_bytep buf)
 
PNG_IMPEXP png_uint_32() png_get_uint_31 (png_const_structrp png_ptr, png_const_bytep buf)
 
PNG_IMPEXP void() png_save_uint_32 (png_bytep buf, png_uint_32 i)
 
PNG_IMPEXP void() png_save_int_32 (png_bytep buf, png_int_32 i)
 
PNG_IMPEXP void() png_save_uint_16 (png_bytep buf, unsigned int i)
 
PNG_IMPEXP int() png_image_begin_read_from_file (png_imagep image, const char *file_name)
 
PNG_IMPEXP int() png_image_begin_read_from_stdio (png_imagep image, FILE *file)
 
PNG_IMPEXP int() png_image_begin_read_from_memory (png_imagep image, png_const_voidp memory, png_size_t size)
 
PNG_IMPEXP int() png_image_finish_read (png_imagep image, png_const_colorp background, void *buffer, png_int_32 row_stride, void *colormap)
 
PNG_IMPEXP void() png_image_free (png_imagep image)
 
PNG_IMPEXP int() png_image_write_to_file (png_imagep image, const char *file, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap)
 
PNG_IMPEXP int() png_image_write_to_stdio (png_imagep image, FILE *file, int convert_to_8_bit, const void *buffer, png_int_32 row_stride, const void *colormap)
 
PNG_IMPEXP void() png_set_check_for_invalid_index (png_structrp png_ptr, int allowed)
 
PNG_IMPEXP int() png_get_palette_max (png_const_structp png_ptr, png_const_infop info_ptr)
 
PNG_IMPEXP int() png_set_option (png_structrp png_ptr, int option, int onoff)
 

Macro Definition Documentation

#define PNG_LIBPNG_VER_STRING   "1.6.16"
#define PNG_HEADER_VERSION_STRING   " libpng version 1.6.16 - December 22, 2014\n"
#define PNG_LIBPNG_VER_SONUM   16
#define PNG_LIBPNG_VER_DLLNUM   16
#define PNG_LIBPNG_VER_MAJOR   1
#define PNG_LIBPNG_VER_MINOR   6
#define PNG_LIBPNG_VER_RELEASE   16
#define PNG_LIBPNG_VER_BUILD   0
#define PNG_LIBPNG_BUILD_ALPHA   1
#define PNG_LIBPNG_BUILD_BETA   2
#define PNG_LIBPNG_BUILD_RC   3
#define PNG_LIBPNG_BUILD_STABLE   4
#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK   7
#define PNG_LIBPNG_BUILD_PATCH
Value:
8 /* Can be OR'ed with
PNG_LIBPNG_BUILD_STABLE only */
#define PNG_LIBPNG_BUILD_PRIVATE
Value:
16 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_SPECIAL */
#define PNG_LIBPNG_BUILD_SPECIAL
Value:
32 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */
#define PNG_LIBPNG_BUILD_BASE_TYPE   PNG_LIBPNG_BUILD_STABLE
#define PNG_LIBPNG_VER   10616 /* 1.6.16 */
#define PNG_LIBPNG_BUILD_TYPE   (PNG_LIBPNG_BUILD_BASE_TYPE)
#define png_libpng_ver   png_get_header_ver(NULL)
#define PNG_TEXT_COMPRESSION_NONE_WR   -3
#define PNG_TEXT_COMPRESSION_zTXt_WR   -2
#define PNG_TEXT_COMPRESSION_NONE   -1
#define PNG_TEXT_COMPRESSION_zTXt   0
#define PNG_ITXT_COMPRESSION_NONE   1
#define PNG_ITXT_COMPRESSION_zTXt   2
#define PNG_TEXT_COMPRESSION_LAST   3 /* Not a valid value */
#define PNG_HAVE_IHDR   0x01
#define PNG_HAVE_PLTE   0x02
#define PNG_AFTER_IDAT   0x08
#define PNG_UINT_31_MAX   ((png_uint_32)0x7fffffffL)
#define PNG_UINT_32_MAX   ((png_uint_32)(-1))
#define PNG_SIZE_MAX   ((png_size_t)(-1))
#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)
#define PNG_COLOR_MASK_PALETTE   1
#define PNG_COLOR_MASK_COLOR   2
#define PNG_COLOR_MASK_ALPHA   4
#define PNG_COLOR_TYPE_GRAY   0
#define PNG_COLOR_TYPE_PALETTE   (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
#define PNG_COLOR_TYPE_RGB   (PNG_COLOR_MASK_COLOR)
#define PNG_COLOR_TYPE_RGB_ALPHA   (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
#define PNG_COLOR_TYPE_GRAY_ALPHA   (PNG_COLOR_MASK_ALPHA)
#define PNG_COLOR_TYPE_RGBA   PNG_COLOR_TYPE_RGB_ALPHA
#define PNG_COLOR_TYPE_GA   PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COMPRESSION_TYPE_BASE   0 /* Deflate method 8, 32K window */
#define PNG_COMPRESSION_TYPE_DEFAULT   PNG_COMPRESSION_TYPE_BASE
#define PNG_FILTER_TYPE_BASE   0 /* Single row per-byte filtering */
#define PNG_INTRAPIXEL_DIFFERENCING   64 /* Used only in MNG datastreams */
#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE
#define PNG_INTERLACE_NONE   0 /* Non-interlaced image */
#define PNG_INTERLACE_ADAM7   1 /* Adam7 interlacing */
#define PNG_INTERLACE_LAST   2 /* Not a valid value */
#define PNG_OFFSET_PIXEL   0 /* Offset in pixels */
#define PNG_OFFSET_MICROMETER   1 /* Offset in micrometers (1/10^6 meter) */
#define PNG_OFFSET_LAST   2 /* Not a valid value */
#define PNG_EQUATION_LINEAR   0 /* Linear transformation */
#define PNG_EQUATION_BASE_E   1 /* Exponential base e transform */
#define PNG_EQUATION_ARBITRARY   2 /* Arbitrary base exponential transform */
#define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */
#define PNG_EQUATION_LAST   4 /* Not a valid value */
#define PNG_SCALE_UNKNOWN   0 /* unknown unit (image scale) */
#define PNG_SCALE_METER   1 /* meters per pixel */
#define PNG_SCALE_RADIAN   2 /* radians per pixel */
#define PNG_SCALE_LAST   3 /* Not a valid value */
#define PNG_RESOLUTION_UNKNOWN   0 /* pixels/unknown unit (aspect ratio) */
#define PNG_RESOLUTION_METER   1 /* pixels/meter */
#define PNG_RESOLUTION_LAST   2 /* Not a valid value */
#define PNG_sRGB_INTENT_PERCEPTUAL   0
#define PNG_sRGB_INTENT_RELATIVE   1
#define PNG_sRGB_INTENT_SATURATION   2
#define PNG_sRGB_INTENT_ABSOLUTE   3
#define PNG_sRGB_INTENT_LAST   4 /* Not a valid value */
#define PNG_KEYWORD_MAX_LENGTH   79
#define PNG_MAX_PALETTE_LENGTH   256
#define PNG_INFO_gAMA   0x0001
#define PNG_INFO_sBIT   0x0002
#define PNG_INFO_cHRM   0x0004
#define PNG_INFO_PLTE   0x0008
#define PNG_INFO_tRNS   0x0010
#define PNG_INFO_bKGD   0x0020
#define PNG_INFO_hIST   0x0040
#define PNG_INFO_pHYs   0x0080
#define PNG_INFO_oFFs   0x0100
#define PNG_INFO_tIME   0x0200
#define PNG_INFO_pCAL   0x0400
#define PNG_INFO_sRGB   0x0800 /* GR-P, 0.96a */
#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   0x8000 /* ESR, 1.0.6 */
#define PNG_TRANSFORM_IDENTITY   0x0000 /* read and write */
#define PNG_TRANSFORM_STRIP_16   0x0001 /* read only */
#define PNG_TRANSFORM_STRIP_ALPHA   0x0002 /* read only */
#define PNG_TRANSFORM_PACKING   0x0004 /* read and write */
#define PNG_TRANSFORM_PACKSWAP   0x0008 /* read and write */
#define PNG_TRANSFORM_EXPAND   0x0010 /* read only */
#define PNG_TRANSFORM_INVERT_MONO   0x0020 /* read and write */
#define PNG_TRANSFORM_SHIFT   0x0040 /* read and write */
#define PNG_TRANSFORM_BGR   0x0080 /* read and write */
#define PNG_TRANSFORM_SWAP_ALPHA   0x0100 /* read and write */
#define PNG_TRANSFORM_SWAP_ENDIAN   0x0200 /* read and write */
#define PNG_TRANSFORM_INVERT_ALPHA   0x0400 /* read and write */
#define PNG_TRANSFORM_STRIP_FILLER   0x0800 /* write only */
#define PNG_TRANSFORM_STRIP_FILLER_BEFORE   PNG_TRANSFORM_STRIP_FILLER
#define PNG_TRANSFORM_STRIP_FILLER_AFTER   0x1000 /* write only */
#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000 /* read only */
#define PNG_TRANSFORM_EXPAND_16   0x4000 /* read only */
#define PNG_TRANSFORM_SCALE_16   0x8000 /* read only */
#define PNG_FLAG_MNG_EMPTY_PLTE   0x01
#define PNG_FLAG_MNG_FILTER_64   0x04
#define PNG_ALL_MNG_FEATURES   0x05
#define png_check_sig (   sig,
 
)    !png_sig_cmp((sig), 0, (n))
#define png_jmpbuf (   png_ptr)    (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))
#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*/
#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 */
#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 */
#define PNG_FILLER_BEFORE   0
#define PNG_FILLER_AFTER   1
#define PNG_BACKGROUND_GAMMA_UNKNOWN   0
#define PNG_BACKGROUND_GAMMA_SCREEN   1
#define PNG_BACKGROUND_GAMMA_FILE   2
#define PNG_BACKGROUND_GAMMA_UNIQUE   3
#define PNG_READ_16_TO_8   SUPPORTED /* Name prior to 1.5.4 */
#define PNG_GAMMA_THRESHOLD   (PNG_GAMMA_THRESHOLD_FIXED*.00001)
#define PNG_CRC_DEFAULT   0 /* error/quit warn/discard data */
#define PNG_CRC_ERROR_QUIT   1 /* error/quit error/quit */
#define PNG_CRC_WARN_DISCARD   2 /* (INVALID) warn/discard data */
#define PNG_CRC_WARN_USE   3 /* warn/use data warn/use data */
#define PNG_CRC_QUIET_USE   4 /* quiet/use data quiet/use data */
#define PNG_CRC_NO_CHANGE   5 /* use current value use current value */
#define PNG_NO_FILTERS   0x00
#define PNG_FILTER_NONE   0x08
#define PNG_FILTER_SUB   0x10
#define PNG_FILTER_UP   0x20
#define PNG_FILTER_AVG   0x40
#define PNG_FILTER_PAETH   0x80
#define PNG_ALL_FILTERS
Value:
#define PNG_FILTER_PAETH
Definition: png.h:1605
#define PNG_FILTER_SUB
Definition: png.h:1602
#define PNG_FILTER_UP
Definition: png.h:1603
#define PNG_FILTER_AVG
Definition: png.h:1604
#define PNG_FILTER_NONE
Definition: png.h:1601
#define PNG_FILTER_VALUE_NONE   0
#define PNG_FILTER_VALUE_SUB   1
#define PNG_FILTER_VALUE_UP   2
#define PNG_FILTER_VALUE_AVG   3
#define PNG_FILTER_VALUE_PAETH   4
#define PNG_FILTER_VALUE_LAST   5
#define PNG_FILTER_HEURISTIC_DEFAULT   0 /* Currently "UNWEIGHTED" */
#define PNG_FILTER_HEURISTIC_UNWEIGHTED   1 /* Used by libpng < 0.95 */
#define PNG_FILTER_HEURISTIC_WEIGHTED   2 /* Experimental feature */
#define PNG_FILTER_HEURISTIC_LAST   3 /* Not a valid value */
#define PNG_DESTROY_WILL_FREE_DATA   1
#define PNG_SET_WILL_FREE_DATA   1
#define PNG_USER_WILL_FREE_DATA   2
#define PNG_FREE_HIST   0x0008
#define PNG_FREE_ICCP   0x0010
#define PNG_FREE_SPLT   0x0020
#define PNG_FREE_ROWS   0x0040
#define PNG_FREE_PCAL   0x0080
#define PNG_FREE_SCAL   0x0100
#define PNG_FREE_UNKN   0x0200
#define PNG_FREE_PLTE   0x1000
#define PNG_FREE_TRNS   0x2000
#define PNG_FREE_TEXT   0x4000
#define PNG_FREE_ALL   0x7fff
#define PNG_FREE_MUL   0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
#define PNG_HANDLE_CHUNK_AS_DEFAULT   0
#define PNG_HANDLE_CHUNK_NEVER   1
#define PNG_HANDLE_CHUNK_IF_SAFE   2
#define PNG_HANDLE_CHUNK_ALWAYS   3
#define PNG_HANDLE_CHUNK_LAST   4
#define PNG_IO_NONE   0x0000 /* no I/O at this moment */
#define PNG_IO_READING   0x0001 /* currently reading */
#define PNG_IO_WRITING   0x0002 /* currently writing */
#define PNG_IO_SIGNATURE   0x0010 /* currently at the file signature */
#define PNG_IO_CHUNK_HDR   0x0020 /* currently at the chunk header */
#define PNG_IO_CHUNK_DATA   0x0040 /* currently at the chunk data */
#define PNG_IO_CHUNK_CRC   0x0080 /* currently at the chunk crc */
#define PNG_IO_MASK_OP   0x000f /* current operation: reading/writing */
#define PNG_IO_MASK_LOC   0x00f0 /* current location: sig/hdr/data/crc */
#define PNG_INTERLACE_ADAM7_PASSES   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)
#define PNG_PASS_ROW_OFFSET (   pass)    ((pass)>2?(8>>(((pass)-1)>>1)):8)
#define PNG_PASS_COL_OFFSET (   pass)    (1<<((7-(pass))>>1))
#define PNG_PASS_ROW_SHIFT (   pass)    ((pass)>2?(8-(pass))>>1:3)
#define PNG_PASS_COL_SHIFT (   pass)    ((pass)>1?(7-(pass))>>1:3)
#define PNG_PASS_ROWS (   height,
  pass 
)
Value:
(((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\
#define PNG_PASS_START_ROW(pass)
Definition: png.h:2595
#define PNG_PASS_ROW_SHIFT(pass)
Definition: png.h:2610
#define PNG_PASS_COLS (   width,
  pass 
)
Value:
(((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\
#define PNG_PASS_START_COL(pass)
Definition: png.h:2596
#define PNG_PASS_COL_SHIFT(pass)
Definition: png.h:2611
#define PNG_ROW_FROM_PASS_ROW (   y_in,
  pass 
)    (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))
#define PNG_COL_FROM_PASS_COL (   x_in,
  pass 
)    (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))
#define PNG_PASS_MASK (   pass,
  off 
)
Value:
( \
((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)
#define PNG_COL_IN_INTERLACE_PASS (   x,
  pass 
)    ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
#define png_composite (   composite,
  fg,
  alpha,
  bg 
)
Value:
{ 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)) + 128); \
(composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
#define png_composite_16 (   composite,
  fg,
  alpha,
  bg 
)
Value:
{ png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
* (png_uint_32)(alpha) \
+ (png_uint_32)(bg)*(65535 \
- (png_uint_32)(alpha)) + 32768); \
(composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
#define PNG_get_uint_32 (   buf)
Value:
(((png_uint_32)(*(buf)) << 24) + \
((png_uint_32)(*((buf) + 1)) << 16) + \
((png_uint_32)(*((buf) + 2)) << 8) + \
((png_uint_32)(*((buf) + 3))))
char buf[128]
Definition: rw_test.cpp:40
#define PNG_get_uint_16 (   buf)
Value:
((png_uint_16) \
(((unsigned int)(*(buf)) << 8) + \
((unsigned int)(*((buf) + 1)))))
char buf[128]
Definition: rw_test.cpp:40
#define PNG_get_int_32 (   buf)
Value:
((png_int_32)((*(buf) & 0x80) \
? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
: (png_int_32)png_get_uint_32(buf)))
#define png_get_uint_32(buf)
Definition: png.h:2744
char buf[128]
Definition: rw_test.cpp:40
#define png_get_uint_32 (   buf)    PNG_get_uint_32(buf)
#define png_get_uint_16 (   buf)    PNG_get_uint_16(buf)
#define png_get_int_32 (   buf)    PNG_get_int_32(buf)
#define PNG_IMAGE_VERSION   1
#define PNG_IMAGE_WARNING   1
#define PNG_IMAGE_ERROR   2
#define PNG_IMAGE_FAILED (   png_cntrl)    ((((png_cntrl).warning_or_error)&0x03)>1)
#define PNG_FORMAT_FLAG_ALPHA   0x01U /* format with an alpha channel */
#define PNG_FORMAT_FLAG_COLOR   0x02U /* color format: otherwise grayscale */
#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2 byte channels else 1 byte */
#define PNG_FORMAT_FLAG_COLORMAP   0x08U /* image data is color-mapped */
#define PNG_FORMAT_FLAG_BGR   0x10U /* BGR colors, else order is RGB */
#define PNG_FORMAT_FLAG_AFIRST   0x20U /* alpha channel comes first */
#define PNG_FORMAT_GRAY   0
#define PNG_FORMAT_GA   PNG_FORMAT_FLAG_ALPHA
#define PNG_FORMAT_AG   (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)
#define PNG_FORMAT_RGB   PNG_FORMAT_FLAG_COLOR
#define PNG_FORMAT_BGR   (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)
#define PNG_FORMAT_RGBA   (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)
#define PNG_FORMAT_ARGB   (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)
#define PNG_FORMAT_BGRA   (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)
#define PNG_FORMAT_ABGR   (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)
#define PNG_FORMAT_LINEAR_Y   PNG_FORMAT_FLAG_LINEAR
#define PNG_FORMAT_LINEAR_Y_ALPHA   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)
#define PNG_FORMAT_LINEAR_RGB   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)
#define PNG_FORMAT_LINEAR_RGB_ALPHA   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)
#define PNG_FORMAT_RGB_COLORMAP   (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)
#define PNG_FORMAT_BGR_COLORMAP   (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)
#define PNG_FORMAT_RGBA_COLORMAP   (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)
#define PNG_FORMAT_ARGB_COLORMAP   (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)
#define PNG_FORMAT_BGRA_COLORMAP   (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)
#define PNG_FORMAT_ABGR_COLORMAP   (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)
#define PNG_IMAGE_SAMPLE_CHANNELS (   fmt)    (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1)
#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE (   fmt)    ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)
#define PNG_IMAGE_SAMPLE_SIZE (   fmt)    (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))
#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS (   fmt)    (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)
#define PNG_IMAGE_PIXEL_ (   test,
  fmt 
)    (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt))
#define PNG_IMAGE_PIXEL_CHANNELS (   fmt)    PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt)
#define PNG_IMAGE_PIXEL_COMPONENT_SIZE (   fmt)    PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)
#define PNG_IMAGE_PIXEL_SIZE (   fmt)    PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)
#define PNG_IMAGE_ROW_STRIDE (   image)    (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)
#define PNG_IMAGE_BUFFER_SIZE (   image,
  row_stride 
)    (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
#define PNG_IMAGE_SIZE (   image)    PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
#define PNG_IMAGE_COLORMAP_SIZE (   image)    (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB   0x01
#define PNG_IMAGE_FLAG_FAST   0x02
#define PNG_IMAGE_FLAG_16BIT_sRGB   0x04
#define PNG_MAXIMUM_INFLATE_WINDOW   2 /* SOFTWARE: force maximum window */
#define PNG_SKIP_sRGB_CHECK_PROFILE   4 /* SOFTWARE: Check ICC profile for sRGB */
#define PNG_OPTION_NEXT   6 /* Next option - numbers must be even */
#define PNG_OPTION_UNSET   0 /* Unset - defaults to off */
#define PNG_OPTION_INVALID   1 /* Option number out of range */
#define PNG_OPTION_OFF   2
#define PNG_OPTION_ON   3

Typedef Documentation

typedef struct png_struct_def png_struct
typedef struct png_info_def png_info
typedef png_info* png_infop
typedef png_info* * png_infopp
typedef png_info* png_inforp
typedef struct png_color_struct png_color
typedef png_color* * png_colorpp
typedef struct png_sPLT_struct png_sPLT_t
typedef struct png_text_struct png_text
typedef png_text* png_textp
typedef png_text* * png_textpp
typedef struct png_time_struct png_time
typedef png_time* png_timep
typedef png_time* * png_timepp
typedef void( * png_error_ptr) (png_structp, png_const_charp)
typedef void( * png_rw_ptr) (png_structp, png_bytep, png_size_t)
typedef void( * png_flush_ptr) (png_structp)
typedef void( * png_read_status_ptr) (png_structp, png_uint_32, int)
typedef void( * png_write_status_ptr) (png_structp, png_uint_32, int)
typedef void( * png_progressive_info_ptr) (png_structp, png_infop)
typedef void( * png_progressive_end_ptr) (png_structp, png_infop)
typedef void( * png_progressive_row_ptr) (png_structp, png_bytep, png_uint_32, int)
typedef void( * png_user_transform_ptr) (png_structp, png_row_infop, png_bytep)
typedef int( * png_user_chunk_ptr) (png_structp, png_unknown_chunkp)
typedef void( * png_longjmp_ptr) (jmp_buf, int)
typedef png_voidp( * png_malloc_ptr) (png_structp, png_alloc_size_t)
typedef void( * png_free_ptr) (png_structp, png_voidp)
typedef struct png_control* png_controlp
typedef struct png_image * png_imagep

Function Documentation

PNG_IMPEXP png_uint_32() png_access_version_number ( void  )
945 {
946  /* Version of *.c files used when building libpng */
947  return((png_uint_32)PNG_LIBPNG_VER);
948 }
#define PNG_LIBPNG_VER
Definition: png.h:467
PNG_IMPEXP void() png_set_sig_bytes ( png_structrp  png_ptr,
int  num_bytes 
)
28 {
29  png_debug(1, "in png_set_sig_bytes");
30 
31  if (png_ptr == NULL)
32  return;
33 
34  if (num_bytes > 8)
35  png_error(png_ptr, "Too many bytes for PNG signature");
36 
37  png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);
38 }
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte sig_bytes
Definition: pngstruct.h:260
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
PNG_IMPEXP int() png_sig_cmp ( png_const_bytep  sig,
png_size_t  start,
png_size_t  num_to_check 
)
50 {
51  png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
52 
53  if (num_to_check > 8)
54  num_to_check = 8;
55 
56  else if (num_to_check < 1)
57  return (-1);
58 
59  if (start > 7)
60  return (-1);
61 
62  if (start + num_to_check > 8)
63  num_to_check = 8 - start;
64 
65  return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));
66 }
PNG_IMPEXP png_structp() png_create_read_struct ( png_const_charp  user_png_ver,
png_voidp  error_ptr,
png_error_ptr  error_fn,
png_error_ptr  warn_fn 
)
28 {
29 #ifndef PNG_USER_MEM_SUPPORTED
30  png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
31  error_fn, warn_fn, NULL, NULL, NULL);
32 #else
33  return png_create_read_struct_2(user_png_ver, error_ptr, error_fn,
34  warn_fn, NULL, NULL, NULL);
35 }
Definition: pngstruct.h:144
png_structp png_create_png_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
Definition: png.c:225
png_structp png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
Definition: pngread.c:43
PNG_IMPEXP png_structp() png_create_write_struct ( png_const_charp  user_png_ver,
png_voidp  error_ptr,
png_error_ptr  error_fn,
png_error_ptr  warn_fn 
)
483 {
484 #ifndef PNG_USER_MEM_SUPPORTED
485  png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
486  error_fn, warn_fn, NULL, NULL, NULL);
487 #else
488  return png_create_write_struct_2(user_png_ver, error_ptr, error_fn,
489  warn_fn, NULL, NULL, NULL);
490 }
Definition: pngstruct.h:144
png_structp png_create_png_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
Definition: png.c:225
png_structp png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
Definition: pngwrite.c:496
PNG_IMPEXP png_size_t() png_get_compression_buffer_size ( png_const_structrp  png_ptr)
1134 {
1135  if (png_ptr == NULL)
1136  return 0;
1137 
1138 # ifdef PNG_WRITE_SUPPORTED
1139  if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
1140 # endif
1141  {
1142 # ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1143  return png_ptr->IDAT_read_size;
1144 # else
1145  return PNG_IDAT_READ_SIZE;
1146 # endif
1147  }
1148 
1149 # ifdef PNG_WRITE_SUPPORTED
1150  else
1151  return png_ptr->zbuffer_size;
1152 # endif
1153 }
#define PNG_IDAT_READ_SIZE
Definition: pnglibconf.h:193
#define PNG_IS_READ_STRUCT
Definition: pngpriv.h:557
png_uint_32 mode
Definition: pngstruct.h:179
PNG_IMPEXP void() png_set_compression_buffer_size ( png_structrp  png_ptr,
png_size_t  size 
)
1473 {
1474  if (png_ptr == NULL)
1475  return;
1476 
1477  if (size == 0 || size > PNG_UINT_31_MAX)
1478  png_error(png_ptr, "invalid compression buffer size");
1479 
1480 # ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1481  if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
1482  {
1483  png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */
1484  return;
1485  }
1486 # endif
1487 
1488 # ifdef PNG_WRITE_SUPPORTED
1489  if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
1490  {
1491  if (png_ptr->zowner != 0)
1492  {
1493  png_warning(png_ptr,
1494  "Compression buffer size cannot be changed because it is in use");
1495  return;
1496  }
1497 
1498  if (size > ZLIB_IO_MAX)
1499  {
1500  png_warning(png_ptr,
1501  "Compression buffer size limited to system maximum");
1502  size = ZLIB_IO_MAX; /* must fit */
1503  }
1504 
1505  else if (size < 6)
1506  {
1507  /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
1508  * if this is permitted.
1509  */
1510  png_warning(png_ptr,
1511  "Compression buffer size cannot be reduced below 6");
1512  return;
1513  }
1514 
1515  if (png_ptr->zbuffer_size != size)
1516  {
1517  png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
1518  png_ptr->zbuffer_size = (uInt)size;
1519  }
1520  }
1521 # endif
1522 }
#define PNG_UINT_31_MAX
Definition: png.h:790
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define PNG_IS_READ_STRUCT
Definition: pngpriv.h:557
#define ZLIB_IO_MAX
Definition: pngstruct.h:57
png_uint_32 mode
Definition: pngstruct.h:179
void png_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *list)
Definition: pngwutil.c:440
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
png_uint_32 zowner
Definition: pngstruct.h:183
unsigned int uInt
Definition: zconf.h:370
PNG_IMPEXP jmp_buf*() png_set_longjmp_fn ( png_structrp  png_ptr,
png_longjmp_ptr  longjmp_fn,
size_t  jmp_buf_size 
)
599 {
600  /* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value
601  * and it must not change after that. Libpng doesn't care how big the
602  * buffer is, just that it doesn't change.
603  *
604  * If the buffer size is no *larger* than the size of jmp_buf when libpng is
605  * compiled a built in jmp_buf is returned; this preserves the pre-1.6.0
606  * semantics that this call will not fail. If the size is larger, however,
607  * the buffer is allocated and this may fail, causing the function to return
608  * NULL.
609  */
610  if (png_ptr == NULL)
611  return NULL;
612 
613  if (png_ptr->jmp_buf_ptr == NULL)
614  {
615  png_ptr->jmp_buf_size = 0; /* not allocated */
616 
617  if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))
618  png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
619 
620  else
621  {
622  png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
623  png_malloc_warn(png_ptr, jmp_buf_size));
624 
625  if (png_ptr->jmp_buf_ptr == NULL)
626  return NULL; /* new NULL return on OOM */
627 
628  png_ptr->jmp_buf_size = jmp_buf_size;
629  }
630  }
631 
632  else /* Already allocated: check the size */
633  {
634  size_t size = png_ptr->jmp_buf_size;
635 
636  if (size == 0)
637  {
638  size = (sizeof png_ptr->jmp_buf_local);
639  if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
640  {
641  /* This is an internal error in libpng: somehow we have been left
642  * with a stack allocated jmp_buf when the application regained
643  * control. It's always possible to fix this up, but for the moment
644  * this is a png_error because that makes it easy to detect.
645  */
646  png_error(png_ptr, "Libpng jmp_buf still allocated");
647  /* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */
648  }
649  }
650 
651  if (size != jmp_buf_size)
652  {
653  png_warning(png_ptr, "Application jmp_buf size changed");
654  return NULL; /* caller will probably crash: no choice here */
655  }
656  }
657 
658  /* Finally fill in the function, now we have a satisfactory buffer. It is
659  * valid to change the function on every call.
660  */
661  png_ptr->longjmp_fn = longjmp_fn;
662  return png_ptr->jmp_buf_ptr;
663 }
PNG_IMPEXP png_voidp() png_malloc_warn(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:210
#define png_voidcast(type, value)
Definition: pngpriv.h:408
void png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
void png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
PNG_IMPEXP void() png_longjmp ( png_const_structrp  png_ptr,
int  val 
)
759 {
760 #ifdef PNG_SETJMP_SUPPORTED
761  if (png_ptr != NULL && png_ptr->longjmp_fn != NULL &&
762  png_ptr->jmp_buf_ptr != NULL)
763  png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
764 #else
765  PNG_UNUSED(png_ptr)
766  PNG_UNUSED(val)
767 #endif
768 
769  /* If control reaches this point, png_longjmp() must not return. The only
770  * choice is to terminate the whole process (or maybe the thread); to do
771  * this the ANSI-C abort() function is used unless a different method is
772  * implemented by overriding the default configuration setting for
773  * PNG_ABORT().
774  */
775  PNG_ABORT();
776 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_ABORT()
Definition: pngpriv.h:481
PNG_DEPRECATED PNG_IMPEXP int() png_reset_zstream ( png_structrp  png_ptr)
933 {
934  if (png_ptr == NULL)
935  return Z_STREAM_ERROR;
936 
937  /* WARNING: this resets the window bits to the maximum! */
938  return (inflateReset(&png_ptr->zstream));
939 }
z_stream zstream
Definition: pngstruct.h:184
int ZEXPORT inflateReset(z_streamp strm)
Definition: inflate.c:129
#define Z_STREAM_ERROR
Definition: zlib.h:177
PNG_IMPEXP png_structp() png_create_read_struct_2 ( png_const_charp  user_png_ver,
png_voidp  error_ptr,
png_error_ptr  error_fn,
png_error_ptr  warn_fn,
png_voidp  mem_ptr,
png_malloc_ptr  malloc_fn,
png_free_ptr  free_fn 
)
44 {
45  png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
46  error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
47 #endif /* USER_MEM */
48 
49  if (png_ptr != NULL)
50  {
51  png_ptr->mode = PNG_IS_READ_STRUCT;
52 
53  /* Added in libpng-1.6.0; this can be used to detect a read structure if
54  * required (it will be zero in a write structure.)
55  */
56 # ifdef PNG_SEQUENTIAL_READ_SUPPORTED
57  png_ptr->IDAT_read_size = PNG_IDAT_READ_SIZE;
58 # endif
59 
60 # ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED
62 
63  /* In stable builds only warn if an application error can be completely
64  * handled.
65  */
66 # if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
68 # endif
69 # endif
70 
71  /* TODO: delay this, it can be done in png_init_io (if the app doesn't
72  * do it itself) avoiding setting the default function if it is not
73  * required.
74  */
75  png_set_read_fn(png_ptr, NULL, NULL);
76  }
77 
78  return png_ptr;
79 }
#define PNG_FLAG_APP_WARNINGS_WARN
Definition: pngpriv.h:622
#define PNG_IDAT_READ_SIZE
Definition: pnglibconf.h:193
Definition: pngstruct.h:144
#define PNG_IS_READ_STRUCT
Definition: pngpriv.h:557
png_structp png_create_png_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
Definition: png.c:225
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_FLAG_BENIGN_ERRORS_WARN
Definition: pngpriv.h:621
PNG_IMPEXP void() png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)
Definition: pngrio.c:87
png_uint_32 mode
Definition: pngstruct.h:179
PNG_IMPEXP png_structp() png_create_write_struct_2 ( png_const_charp  user_png_ver,
png_voidp  error_ptr,
png_error_ptr  error_fn,
png_error_ptr  warn_fn,
png_voidp  mem_ptr,
png_malloc_ptr  malloc_fn,
png_free_ptr  free_fn 
)
497 {
498  png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
499  error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
500 #endif /* USER_MEM */
501  if (png_ptr != NULL)
502  {
503  /* Set the zlib control values to defaults; they can be overridden by the
504  * application after the struct has been created.
505  */
506  png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
507 
508  /* The 'zlib_strategy' setting is irrelevant because png_default_claim in
509  * pngwutil.c defaults it according to whether or not filters will be
510  * used, and ignores this setting.
511  */
512  png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY;
513  png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION;
514  png_ptr->zlib_mem_level = 8;
515  png_ptr->zlib_window_bits = 15;
516  png_ptr->zlib_method = 8;
517 
518 #ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
519  png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY;
520  png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION;
521  png_ptr->zlib_text_mem_level = 8;
522  png_ptr->zlib_text_window_bits = 15;
523  png_ptr->zlib_text_method = 8;
524 #endif /* WRITE_COMPRESSED_TEXT */
525 
526  /* This is a highly dubious configuration option; by default it is off,
527  * but it may be appropriate for private builds that are testing
528  * extensions not conformant to the current specification, or of
529  * applications that must not fail to write at all costs!
530  */
531 #ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
532  /* In stable builds only warn if an application error can be completely
533  * handled.
534  */
536 #endif
537 
538  /* App warnings are warnings in release (or release candidate) builds but
539  * are errors during development.
540  */
541 #if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
542  png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
543 #endif
544 
545  /* TODO: delay this, it can be done in png_init_io() (if the app doesn't
546  * do it itself) avoiding setting the default function if it is not
547  * required.
548  */
549  png_set_write_fn(png_ptr, NULL, NULL, NULL);
550  }
551 
552  return png_ptr;
553 }
#define PNG_FLAG_APP_WARNINGS_WARN
Definition: pngpriv.h:622
#define PNG_Z_DEFAULT_COMPRESSION
Definition: pnglibconf.h:204
PNG_IMPEXP void() png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
Definition: pngwio.c:122
Definition: pngstruct.h:144
png_structp png_create_png_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
Definition: png.c:225
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_TEXT_Z_DEFAULT_STRATEGY
Definition: pnglibconf.h:200
#define PNG_FLAG_BENIGN_ERRORS_WARN
Definition: pngpriv.h:621
#define PNG_TEXT_Z_DEFAULT_COMPRESSION
Definition: pnglibconf.h:199
#define PNG_ZBUF_SIZE
Definition: pnglibconf.h:202
#define PNG_Z_DEFAULT_STRATEGY
Definition: pnglibconf.h:206
PNG_IMPEXP void() png_write_sig ( png_structrp  png_ptr)
52 {
53  png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
54 
55 #ifdef PNG_IO_STATE_SUPPORTED
56  /* Inform the I/O callback that the signature is being written */
57  png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE;
58 #endif
59 
60  /* Write the rest of the 8 byte signature */
61  png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
62  (png_size_t)(8 - png_ptr->sig_bytes));
63 
64  if (png_ptr->sig_bytes < 3)
65  png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
66 }
void png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
Definition: pngwio.c:33
#define PNG_IO_SIGNATURE
Definition: png.h:2577
#define PNG_IO_WRITING
Definition: png.h:2576
png_byte sig_bytes
Definition: pngstruct.h:260
png_uint_32 mode
Definition: pngstruct.h:179
size_t png_size_t
Definition: pngconf.h:543
#define PNG_HAVE_PNG_SIGNATURE
Definition: pngpriv.h:554
PNG_IMPEXP void() png_write_chunk ( png_structrp  png_ptr,
png_const_bytep  chunk_name,
png_const_bytep  data,
png_size_t  length 
)
195 {
196  png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data,
197  length);
198 }
static void png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, png_const_bytep data, png_size_t length)
Definition: pngwutil.c:176
#define PNG_CHUNK_FROM_STRING(s)
Definition: pngpriv.h:782
png_uint_32 length
Definition: png.c:2173
PNG_IMPEXP void() png_write_chunk_start ( png_structrp  png_ptr,
png_const_bytep  chunk_name,
png_uint_32  length 
)
117 {
118  png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length);
119 }
#define PNG_CHUNK_FROM_STRING(s)
Definition: pngpriv.h:782
png_uint_32 length
Definition: png.c:2173
static void png_write_chunk_header(png_structrp png_ptr, png_uint_32 chunk_name, png_uint_32 length)
Definition: pngwutil.c:73
PNG_IMPEXP void() png_write_chunk_data ( png_structrp  png_ptr,
png_const_bytep  data,
png_size_t  length 
)
129 {
130  /* Write the data, and run the CRC over it */
131  if (png_ptr == NULL)
132  return;
133 
134  if (data != NULL && length > 0)
135  {
136  png_write_data(png_ptr, data, length);
137 
138  /* Update the CRC after writing the data,
139  * in case the user I/O routine alters it.
140  */
141  png_calculate_crc(png_ptr, data, length);
142  }
143 }
void png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
Definition: pngwio.c:33
void png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
Definition: png.c:114
png_uint_32 length
Definition: png.c:2173
PNG_IMPEXP void() png_write_chunk_end ( png_structrp  png_ptr)
148 {
149  png_byte buf[4];
150 
151  if (png_ptr == NULL) return;
152 
153 #ifdef PNG_IO_STATE_SUPPORTED
154  /* Inform the I/O callback that the chunk CRC is being written.
155  * PNG_IO_CHUNK_CRC requires a single I/O function call.
156  */
157  png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC;
158 #endif
159 
160  /* Write the crc in a single operation */
161  png_save_uint_32(buf, png_ptr->crc);
162 
163  png_write_data(png_ptr, buf, (png_size_t)4);
164 }
void png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
Definition: pngwio.c:33
png_uint_32 crc
Definition: pngstruct.h:237
void png_save_uint_32(png_bytep buf, png_uint_32 i)
Definition: pngwutil.c:24
#define PNG_IO_CHUNK_CRC
Definition: png.h:2580
#define PNG_IO_WRITING
Definition: png.h:2576
size_t png_size_t
Definition: pngconf.h:543
char buf[128]
Definition: rw_test.cpp:40
PNG_IMPEXP png_infop() png_create_info_struct ( png_const_structrp  png_ptr)
328 {
329  png_inforp info_ptr;
330 
331  png_debug(1, "in png_create_info_struct");
332 
333  if (png_ptr == NULL)
334  return NULL;
335 
336  /* Use the internal API that does not (or at least should not) error out, so
337  * that this call always returns ok. The application typically sets up the
338  * error handling *after* creating the info_struct because this is the way it
339  * has always been done in 'example.c'.
340  */
341  info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr,
342  (sizeof *info_ptr)));
343 
344  if (info_ptr != NULL)
345  memset(info_ptr, 0, (sizeof *info_ptr));
346 
347  return info_ptr;
348 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define png_voidcast(type, value)
Definition: pngpriv.h:408
Definition: pnginfo.h:56
png_voidp png_malloc_base(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:69
PNG_DEPRECATED PNG_IMPEXP void() png_info_init_3 ( png_infopp  info_ptr,
png_size_t  png_info_struct_size 
)
399 {
400  png_inforp info_ptr = *ptr_ptr;
401 
402  png_debug(1, "in png_info_init_3");
403 
404  if (info_ptr == NULL)
405  return;
406 
407  if ((sizeof (png_info)) > png_info_struct_size)
408  {
409  *ptr_ptr = NULL;
410  /* The following line is why this API should not be used: */
411  free(info_ptr);
412  info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL,
413  (sizeof *info_ptr)));
414  *ptr_ptr = info_ptr;
415  }
416 
417  /* Set everything to 0 */
418  memset(info_ptr, 0, (sizeof *info_ptr));
419 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define png_voidcast(type, value)
Definition: pngpriv.h:408
Definition: pnginfo.h:56
png_voidp png_malloc_base(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:69
PNG_IMPEXP void() png_write_info_before_PLTE ( png_structrp  png_ptr,
png_const_inforp  info_ptr 
)
85 {
86  png_debug(1, "in png_write_info_before_PLTE");
87 
88  if (png_ptr == NULL || info_ptr == NULL)
89  return;
90 
91  if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
92  {
93  /* Write PNG signature */
94  png_write_sig(png_ptr);
95 
96 #ifdef PNG_MNG_FEATURES_SUPPORTED
97  if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
98  png_ptr->mng_features_permitted != 0)
99  {
100  png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
101  png_ptr->mng_features_permitted = 0;
102  }
103 #endif
104 
105  /* Write IHDR information. */
106  png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
107  info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
108  info_ptr->filter_type,
110  info_ptr->interlace_type
111 #else
112  0
113 #endif
114  );
115 
116  /* The rest of these check to see if the valid field has the appropriate
117  * flag set, and if it does, writes the chunk.
118  *
119  * 1.6.0: COLORSPACE support controls the writing of these chunks too, and
120  * the chunks will be written if the WRITE routine is there and information
121  * is available in the COLORSPACE. (See png_colorspace_sync_info in png.c
122  * for where the valid flags get set.)
123  *
124  * Under certain circumstances the colorspace can be invalidated without
125  * syncing the info_struct 'valid' flags; this happens if libpng detects and
126  * error and calls png_error while the color space is being set, yet the
127  * application continues writing the PNG. So check the 'invalid' flag here
128  * too.
129  */
130 #ifdef PNG_GAMMA_SUPPORTED
131 # ifdef PNG_WRITE_gAMA_SUPPORTED
132  if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
133  (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 &&
134  (info_ptr->valid & PNG_INFO_gAMA) != 0)
135  png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);
136 # endif
137 #endif
138 
139 #ifdef PNG_COLORSPACE_SUPPORTED
140  /* Write only one of sRGB or an ICC profile. If a profile was supplied
141  * and it matches one of the known sRGB ones issue a warning.
142  */
143 # ifdef PNG_WRITE_iCCP_SUPPORTED
144  if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
145  (info_ptr->valid & PNG_INFO_iCCP) != 0)
146  {
147 # ifdef PNG_WRITE_sRGB_SUPPORTED
148  if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
149  png_app_warning(png_ptr,
150  "profile matches sRGB but writing iCCP instead");
151 # endif
152 
153  png_write_iCCP(png_ptr, info_ptr->iccp_name,
154  info_ptr->iccp_profile);
155  }
156 # ifdef PNG_WRITE_sRGB_SUPPORTED
157  else
158 # endif
159 # endif
160 
161 # ifdef PNG_WRITE_sRGB_SUPPORTED
162  if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
163  (info_ptr->valid & PNG_INFO_sRGB) != 0)
164  png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
165 # endif /* WRITE_sRGB */
166 #endif /* COLORSPACE */
167 
168 #ifdef PNG_WRITE_sBIT_SUPPORTED
169  if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
170  png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
171 #endif
172 
173 #ifdef PNG_COLORSPACE_SUPPORTED
174 # ifdef PNG_WRITE_cHRM_SUPPORTED
175  if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
176  (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
177  (info_ptr->valid & PNG_INFO_cHRM) != 0)
178  png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
179 # endif
180 #endif
181 
182 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
183  write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);
184 #endif
185 
186  png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
187  }
188 }
png_byte filter_type
Definition: pnginfo.h:70
#define PNG_INFO_gAMA
Definition: png.h:873
#define PNG_INFO_sRGB
Definition: png.h:884
png_byte interlace_type
Definition: pnginfo.h:71
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_debug(l, m)
Definition: pngdebug.h:146
void png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)
Definition: pngwutil.c:1339
static void write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, unsigned int where)
Definition: pngwrite.c:24
void png_write_cHRM_fixed(png_structrp png_ptr, const png_xy *xy)
Definition: pngwutil.c:1398
png_byte compression_type
Definition: pnginfo.h:69
png_byte color_type
Definition: pnginfo.h:67
#define PNG_HAVE_IHDR
Definition: png.h:785
png_uint_32 height
Definition: pnginfo.h:60
void png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int compression_method, int filter_method, int interlace_method)
Definition: pngwutil.c:757
PNG_IMPEXP void() png_write_sig(png_structrp png_ptr)
Definition: pngwutil.c:51
#define PNG_INFO_sBIT
Definition: png.h:874
void png_write_gAMA_fixed(png_structrp png_ptr, png_fixed_point file_gamma)
Definition: pngwutil.c:1159
png_byte bit_depth
Definition: pnginfo.h:66
void png_write_sRGB(png_structrp png_ptr, int intent)
Definition: pngwutil.c:1174
png_uint_32 valid
Definition: pnginfo.h:61
png_uint_32 mode
Definition: pngstruct.h:179
#define PNG_WROTE_INFO_BEFORE_PLTE
Definition: pngpriv.h:552
void png_write_iCCP(png_structrp png_ptr, png_const_charp name, png_const_bytep profile)
Definition: pngwutil.c:1192
#define PNG_WRITE_INTERLACING_SUPPORTED
Definition: pnglibconf.h:137
void png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:392
png_uint_32 width
Definition: pnginfo.h:59
#define PNG_HAVE_PNG_SIGNATURE
Definition: pngpriv.h:554
#define PNG_INFO_cHRM
Definition: png.h:875
#define PNG_INFO_iCCP
Definition: png.h:885
PNG_IMPEXP void() png_write_info ( png_structrp  png_ptr,
png_const_inforp  info_ptr 
)
192 {
193 #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
194  int i;
195 #endif
196 
197  png_debug(1, "in png_write_info");
198 
199  if (png_ptr == NULL || info_ptr == NULL)
200  return;
201 
202  png_write_info_before_PLTE(png_ptr, info_ptr);
203 
204  if ((info_ptr->valid & PNG_INFO_PLTE) != 0)
205  png_write_PLTE(png_ptr, info_ptr->palette,
206  (png_uint_32)info_ptr->num_palette);
207 
208  else if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) !=0)
209  png_error(png_ptr, "Valid palette required for paletted images");
210 
211 #ifdef PNG_WRITE_tRNS_SUPPORTED
212  if ((info_ptr->valid & PNG_INFO_tRNS) !=0)
213  {
214 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
215  /* Invert the alpha channel (in tRNS) */
216  if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
217  info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
218  {
219  int j;
220  for (j = 0; j<(int)info_ptr->num_trans; j++)
221  info_ptr->trans_alpha[j] =
222  (png_byte)(255 - info_ptr->trans_alpha[j]);
223  }
224 #endif
225  png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color),
226  info_ptr->num_trans, info_ptr->color_type);
227  }
228 #endif
229 #ifdef PNG_WRITE_bKGD_SUPPORTED
230  if ((info_ptr->valid & PNG_INFO_bKGD) != 0)
231  png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
232 #endif
233 
234 #ifdef PNG_WRITE_hIST_SUPPORTED
235  if ((info_ptr->valid & PNG_INFO_hIST) != 0)
236  png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
237 #endif
238 
239 #ifdef PNG_WRITE_oFFs_SUPPORTED
240  if ((info_ptr->valid & PNG_INFO_oFFs) != 0)
241  png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset,
242  info_ptr->offset_unit_type);
243 #endif
244 
245 #ifdef PNG_WRITE_pCAL_SUPPORTED
246  if ((info_ptr->valid & PNG_INFO_pCAL) != 0)
247  png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,
248  info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,
249  info_ptr->pcal_units, info_ptr->pcal_params);
250 #endif
251 
252 #ifdef PNG_WRITE_sCAL_SUPPORTED
253  if ((info_ptr->valid & PNG_INFO_sCAL) != 0)
254  png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
255  info_ptr->scal_s_width, info_ptr->scal_s_height);
256 #endif /* sCAL */
257 
258 #ifdef PNG_WRITE_pHYs_SUPPORTED
259  if ((info_ptr->valid & PNG_INFO_pHYs) != 0)
260  png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
261  info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);
262 #endif /* pHYs */
263 
264 #ifdef PNG_WRITE_tIME_SUPPORTED
265  if ((info_ptr->valid & PNG_INFO_tIME) != 0)
266  {
267  png_write_tIME(png_ptr, &(info_ptr->mod_time));
268  png_ptr->mode |= PNG_WROTE_tIME;
269  }
270 #endif /* tIME */
271 
272 #ifdef PNG_WRITE_sPLT_SUPPORTED
273  if ((info_ptr->valid & PNG_INFO_sPLT) != 0)
274  for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
275  png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
276 #endif /* sPLT */
277 
278 #ifdef PNG_WRITE_TEXT_SUPPORTED
279  /* Check to see if we need to write text chunks */
280  for (i = 0; i < info_ptr->num_text; i++)
281  {
282  png_debug2(2, "Writing header text chunk %d, type %d", i,
283  info_ptr->text[i].compression);
284  /* An internationalized chunk? */
285  if (info_ptr->text[i].compression > 0)
286  {
287 #ifdef PNG_WRITE_iTXt_SUPPORTED
288  /* Write international chunk */
289  png_write_iTXt(png_ptr,
290  info_ptr->text[i].compression,
291  info_ptr->text[i].key,
292  info_ptr->text[i].lang,
293  info_ptr->text[i].lang_key,
294  info_ptr->text[i].text);
295  /* Mark this chunk as written */
296  if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
297  info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
298  else
299  info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
300 #else
301  png_warning(png_ptr, "Unable to write international text");
302 #endif
303  }
304 
305  /* If we want a compressed text chunk */
306  else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt)
307  {
308 #ifdef PNG_WRITE_zTXt_SUPPORTED
309  /* Write compressed chunk */
310  png_write_zTXt(png_ptr, info_ptr->text[i].key,
311  info_ptr->text[i].text, info_ptr->text[i].compression);
312  /* Mark this chunk as written */
313  info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
314 #else
315  png_warning(png_ptr, "Unable to write compressed text");
316 #endif
317  }
318 
319  else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
320  {
321 #ifdef PNG_WRITE_tEXt_SUPPORTED
322  /* Write uncompressed chunk */
323  png_write_tEXt(png_ptr, info_ptr->text[i].key,
324  info_ptr->text[i].text,
325  0);
326  /* Mark this chunk as written */
327  info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
328 #else
329  /* Can't get here */
330  png_warning(png_ptr, "Unable to write uncompressed text");
331 #endif
332  }
333  }
334 #endif /* tEXt */
335 
336 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
337  write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_PLTE);
338 #endif
339 }
void png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp palette)
Definition: pngwutil.c:1254
void png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
Definition: pngwutil.c:1916
#define PNG_INVERT_ALPHA
Definition: pngpriv.h:579
#define PNG_INFO_tIME
Definition: png.h:882
void png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngwrite.c:84
#define PNG_INFO_hIST
Definition: png.h:879
int i
Definition: rw_test.cpp:37
png_colorp palette
Definition: pnginfo.h:63
void png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)
Definition: pngwutil.c:1797
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:810
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_HAVE_PLTE
Definition: png.h:786
void png_write_hIST(png_structrp png_ptr, png_const_uint_16p hist, int num_hist)
Definition: pngwutil.c:1552
void png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, png_const_charp lang, png_const_charp lang_key, png_const_charp text)
Definition: pngwutil.c:1677
#define PNG_TEXT_COMPRESSION_NONE_WR
Definition: png.h:727
static void write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, unsigned int where)
Definition: pngwrite.c:24
#define PNG_INFO_oFFs
Definition: png.h:881
void png_write_tRNS(png_structrp png_ptr, png_const_bytep trans, png_const_color_16p values, int number, int color_type)
Definition: pngwutil.c:1424
void png_write_bKGD(png_structrp png_ptr, png_const_color_16p values, int color_type)
Definition: pngwutil.c:1490
void png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset, int unit_type)
Definition: pngwutil.c:1777
png_byte color_type
Definition: pnginfo.h:67
#define PNG_TEXT_COMPRESSION_zTXt
Definition: png.h:730
#define PNG_TEXT_COMPRESSION_NONE
Definition: png.h:729
void png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width, png_const_charp height)
Definition: pngwutil.c:1862
png_uint_16 num_palette
Definition: pnginfo.h:64
#define PNG_INFO_PLTE
Definition: png.h:876
#define PNG_WROTE_tIME
Definition: pngpriv.h:551
#define PNG_TEXT_COMPRESSION_zTXt_WR
Definition: png.h:728
#define PNG_INFO_tRNS
Definition: png.h:877
void png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, int compression)
Definition: pngwutil.c:1626
png_uint_32 valid
Definition: pnginfo.h:61
png_uint_32 mode
Definition: pngstruct.h:179
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
void png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, png_size_t text_len)
Definition: pngwutil.c:1583
#define PNG_INFO_sPLT
Definition: png.h:886
png_uint_16 num_trans
Definition: pnginfo.h:65
void png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, int unit_type)
Definition: pngwutil.c:1892
#define PNG_INFO_pHYs
Definition: png.h:880
#define PNG_INFO_pCAL
Definition: png.h:883
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_INFO_bKGD
Definition: png.h:878
#define PNG_INFO_sCAL
Definition: png.h:887
#define png_debug2(l, m, p1, p2)
Definition: pngdebug.h:152
void png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, png_uint_32 num_pal)
Definition: pngwutil.c:922
PNG_IMPEXP void() png_read_info ( png_structrp  png_ptr,
png_inforp  info_ptr 
)
93 {
94 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
95  int keep;
96 #endif
97 
98  png_debug(1, "in png_read_info");
99 
100  if (png_ptr == NULL || info_ptr == NULL)
101  return;
102 
103  /* Read and check the PNG file signature. */
104  png_read_sig(png_ptr, info_ptr);
105 
106  for (;;)
107  {
108  png_uint_32 length = png_read_chunk_header(png_ptr);
109  png_uint_32 chunk_name = png_ptr->chunk_name;
110 
111  /* IDAT logic needs to happen here to simplify getting the two flags
112  * right.
113  */
114  if (chunk_name == png_IDAT)
115  {
116  if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
117  png_chunk_error(png_ptr, "Missing IHDR before IDAT");
118 
119  else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
120  (png_ptr->mode & PNG_HAVE_PLTE) == 0)
121  png_chunk_error(png_ptr, "Missing PLTE before IDAT");
122 
123  else if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
124  png_chunk_benign_error(png_ptr, "Too many IDATs found");
125 
126  png_ptr->mode |= PNG_HAVE_IDAT;
127  }
128 
129  else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
130  png_ptr->mode |= PNG_AFTER_IDAT;
131 
132  /* This should be a binary subdivision search or a hash for
133  * matching the chunk name rather than a linear search.
134  */
135  if (chunk_name == png_IHDR)
136  png_handle_IHDR(png_ptr, info_ptr, length);
137 
138  else if (chunk_name == png_IEND)
139  png_handle_IEND(png_ptr, info_ptr, length);
140 
141 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
142  else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
143  {
144  png_handle_unknown(png_ptr, info_ptr, length, keep);
145 
146  if (chunk_name == png_PLTE)
147  png_ptr->mode |= PNG_HAVE_PLTE;
148 
149  else if (chunk_name == png_IDAT)
150  {
151  png_ptr->idat_size = 0; /* It has been consumed */
152  break;
153  }
154  }
155 #endif
156  else if (chunk_name == png_PLTE)
157  png_handle_PLTE(png_ptr, info_ptr, length);
158 
159  else if (chunk_name == png_IDAT)
160  {
161  png_ptr->idat_size = length;
162  break;
163  }
164 
165 #ifdef PNG_READ_bKGD_SUPPORTED
166  else if (chunk_name == png_bKGD)
167  png_handle_bKGD(png_ptr, info_ptr, length);
168 #endif
169 
170 #ifdef PNG_READ_cHRM_SUPPORTED
171  else if (chunk_name == png_cHRM)
172  png_handle_cHRM(png_ptr, info_ptr, length);
173 #endif
174 
175 #ifdef PNG_READ_gAMA_SUPPORTED
176  else if (chunk_name == png_gAMA)
177  png_handle_gAMA(png_ptr, info_ptr, length);
178 #endif
179 
180 #ifdef PNG_READ_hIST_SUPPORTED
181  else if (chunk_name == png_hIST)
182  png_handle_hIST(png_ptr, info_ptr, length);
183 #endif
184 
185 #ifdef PNG_READ_oFFs_SUPPORTED
186  else if (chunk_name == png_oFFs)
187  png_handle_oFFs(png_ptr, info_ptr, length);
188 #endif
189 
190 #ifdef PNG_READ_pCAL_SUPPORTED
191  else if (chunk_name == png_pCAL)
192  png_handle_pCAL(png_ptr, info_ptr, length);
193 #endif
194 
195 #ifdef PNG_READ_sCAL_SUPPORTED
196  else if (chunk_name == png_sCAL)
197  png_handle_sCAL(png_ptr, info_ptr, length);
198 #endif
199 
200 #ifdef PNG_READ_pHYs_SUPPORTED
201  else if (chunk_name == png_pHYs)
202  png_handle_pHYs(png_ptr, info_ptr, length);
203 #endif
204 
205 #ifdef PNG_READ_sBIT_SUPPORTED
206  else if (chunk_name == png_sBIT)
207  png_handle_sBIT(png_ptr, info_ptr, length);
208 #endif
209 
210 #ifdef PNG_READ_sRGB_SUPPORTED
211  else if (chunk_name == png_sRGB)
212  png_handle_sRGB(png_ptr, info_ptr, length);
213 #endif
214 
215 #ifdef PNG_READ_iCCP_SUPPORTED
216  else if (chunk_name == png_iCCP)
217  png_handle_iCCP(png_ptr, info_ptr, length);
218 #endif
219 
220 #ifdef PNG_READ_sPLT_SUPPORTED
221  else if (chunk_name == png_sPLT)
222  png_handle_sPLT(png_ptr, info_ptr, length);
223 #endif
224 
225 #ifdef PNG_READ_tEXt_SUPPORTED
226  else if (chunk_name == png_tEXt)
227  png_handle_tEXt(png_ptr, info_ptr, length);
228 #endif
229 
230 #ifdef PNG_READ_tIME_SUPPORTED
231  else if (chunk_name == png_tIME)
232  png_handle_tIME(png_ptr, info_ptr, length);
233 #endif
234 
235 #ifdef PNG_READ_tRNS_SUPPORTED
236  else if (chunk_name == png_tRNS)
237  png_handle_tRNS(png_ptr, info_ptr, length);
238 #endif
239 
240 #ifdef PNG_READ_zTXt_SUPPORTED
241  else if (chunk_name == png_zTXt)
242  png_handle_zTXt(png_ptr, info_ptr, length);
243 #endif
244 
245 #ifdef PNG_READ_iTXt_SUPPORTED
246  else if (chunk_name == png_iTXt)
247  png_handle_iTXt(png_ptr, info_ptr, length);
248 #endif
249 
250  else
251  png_handle_unknown(png_ptr, info_ptr, length,
253  }
254 }
PNG_IMPEXP void() png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:514
void png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1179
void png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length, int keep)
Definition: pngrutil.c:2765
#define png_PLTE
Definition: pngpriv.h:755
#define png_sCAL
Definition: pngpriv.h:770
#define png_iTXt
Definition: pngpriv.h:765
#define png_bKGD
Definition: pngpriv.h:756
void png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2447
#define png_tRNS
Definition: pngpriv.h:776
#define png_sRGB
Definition: pngpriv.h:772
void png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2098
void png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1954
#define png_iCCP
Definition: pngpriv.h:764
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:810
void png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2005
#define png_IEND
Definition: pngpriv.h:753
void png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1061
void png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1854
#define png_sPLT
Definition: pngpriv.h:771
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_HAVE_PLTE
Definition: png.h:786
void png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1251
void png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2320
void png_read_sig(png_structrp png_ptr, png_inforp info_ptr)
Definition: pngrutil.c:115
void png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2366
#define PNG_HANDLE_CHUNK_AS_DEFAULT
Definition: png.h:2497
void png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2051
png_byte color_type
Definition: pngstruct.h:252
png_uint_32 png_read_chunk_header(png_structrp png_ptr)
Definition: pngrutil.c:150
#define PNG_HAVE_IDAT
Definition: pngpriv.h:544
png_uint_32 chunk_name
Definition: pngstruct.h:221
#define PNG_HAVE_IHDR
Definition: png.h:785
#define png_IHDR
Definition: pngpriv.h:754
#define png_tEXt
Definition: pngpriv.h:774
void png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1751
PNG_IMPEXP void() png_chunk_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:481
void png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1099
#define png_IDAT
Definition: pngpriv.h:752
#define PNG_AFTER_IDAT
Definition: png.h:787
#define png_oFFs
Definition: pngpriv.h:766
#define png_gAMA
Definition: pngpriv.h:759
#define png_pCAL
Definition: pngpriv.h:767
png_uint_32 length
Definition: png.c:2173
#define png_cHRM
Definition: pngpriv.h:757
png_uint_32 mode
Definition: pngstruct.h:179
void png_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1041
void png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2556
png_uint_32 idat_size
Definition: pngstruct.h:236
void png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:793
int png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name)
Definition: png.c:919
#define png_sBIT
Definition: pngpriv.h:769
void png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1574
#define png_hIST
Definition: pngpriv.h:763
void png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2227
#define png_pHYs
Definition: pngpriv.h:768
void png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1301
#define png_tIME
Definition: pngpriv.h:775
void png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:867
#define png_zTXt
Definition: pngpriv.h:777
PNG_DEPRECATED PNG_IMPEXP png_const_charp() png_convert_to_rfc1123 ( png_structrp  png_ptr,
png_const_timep  ptime 
)
745 {
746  if (png_ptr != NULL)
747  {
748  /* The only failure above if png_ptr != NULL is from an invalid ptime */
749  if (png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime) == 0)
750  png_warning(png_ptr, "Ignoring invalid time value");
751 
752  else
753  return png_ptr->time_buffer;
754  }
755 
756  return NULL;
757 }
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
int png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
Definition: png.c:691
PNG_IMPEXP int() png_convert_to_rfc1123_buffer ( char  out[29],
png_const_timep  ptime 
)
692 {
693  static PNG_CONST char short_months[12][4] =
694  {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
695  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
696 
697  if (out == NULL)
698  return 0;
699 
700  if (ptime->year > 9999 /* RFC1123 limitation */ ||
701  ptime->month == 0 || ptime->month > 12 ||
702  ptime->day == 0 || ptime->day > 31 ||
703  ptime->hour > 23 || ptime->minute > 59 ||
704  ptime->second > 60)
705  return 0;
706 
707  {
708  size_t pos = 0;
709  char number_buf[5]; /* enough for a four-digit year */
710 
711 # define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string))
712 # define APPEND_NUMBER(format, value)\
713  APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value)))
714 # define APPEND(ch) if (pos < 28) out[pos++] = (ch)
715 
716  APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day);
717  APPEND(' ');
718  APPEND_STRING(short_months[(ptime->month - 1)]);
719  APPEND(' ');
721  APPEND(' ');
722  APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour);
723  APPEND(':');
724  APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute);
725  APPEND(':');
726  APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second);
727  APPEND_STRING(" +0000"); /* This reliably terminates the buffer */
728 
729 # undef APPEND
730 # undef APPEND_NUMBER
731 # undef APPEND_STRING
732  }
733 
734  return 1;
735 }
#define APPEND(ch)
#define PNG_NUMBER_FORMAT_02u
Definition: pngpriv.h:1588
png_byte hour
Definition: png.h:746
png_byte second
Definition: png.h:748
#define PNG_NUMBER_FORMAT_u
Definition: pngpriv.h:1587
#define PNG_CONST
Definition: pngconf.h:86
png_byte minute
Definition: png.h:747
#define APPEND_STRING(string)
png_byte day
Definition: png.h:745
png_byte month
Definition: png.h:744
#define APPEND_NUMBER(format, value)
png_uint_16 year
Definition: png.h:743
PNG_IMPEXP void() png_convert_from_struct_tm ( png_timep  ptime,
const struct tm *  ttime 
)
456 {
457  png_debug(1, "in png_convert_from_struct_tm");
458 
459  ptime->year = (png_uint_16)(1900 + ttime->tm_year);
460  ptime->month = (png_byte)(ttime->tm_mon + 1);
461  ptime->day = (png_byte)ttime->tm_mday;
462  ptime->hour = (png_byte)ttime->tm_hour;
463  ptime->minute = (png_byte)ttime->tm_min;
464  ptime->second = (png_byte)ttime->tm_sec;
465 }
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte hour
Definition: png.h:746
png_byte second
Definition: png.h:748
png_byte minute
Definition: png.h:747
png_byte day
Definition: png.h:745
png_byte month
Definition: png.h:744
png_uint_16 year
Definition: png.h:743
PNG_IMPEXP void() png_convert_from_time_t ( png_timep  ptime,
time_t  ttime 
)
469 {
470  struct tm *tbuf;
471 
472  png_debug(1, "in png_convert_from_time_t");
473 
474  tbuf = gmtime(&ttime);
475  png_convert_from_struct_tm(ptime, tbuf);
476 }
void png_convert_from_struct_tm(png_timep ptime, const struct tm *ttime)
Definition: pngwrite.c:455
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP void() png_set_expand ( png_structrp  png_ptr)
856 {
857  png_debug(1, "in png_set_expand");
858 
859  if (png_rtran_ok(png_ptr, 0) == 0)
860  return;
861 
863 }
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
#define PNG_EXPAND_tRNS
Definition: pngpriv.h:586
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_EXPAND
Definition: pngpriv.h:572
PNG_IMPEXP void() png_set_expand_gray_1_2_4_to_8 ( png_structrp  png_ptr)
898 {
899  png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
900 
901  if (png_rtran_ok(png_ptr, 0) == 0)
902  return;
903 
904  png_ptr->transformations |= PNG_EXPAND;
905 }
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_EXPAND
Definition: pngpriv.h:572
PNG_IMPEXP void() png_set_palette_to_rgb ( png_structrp  png_ptr)
886 {
887  png_debug(1, "in png_set_palette_to_rgb");
888 
889  if (png_rtran_ok(png_ptr, 0) == 0)
890  return;
891 
893 }
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
#define PNG_EXPAND_tRNS
Definition: pngpriv.h:586
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_EXPAND
Definition: pngpriv.h:572
PNG_IMPEXP void() png_set_tRNS_to_alpha ( png_structrp  png_ptr)
910 {
911  png_debug(1, "in png_set_tRNS_to_alpha");
912 
913  if (png_rtran_ok(png_ptr, 0) == 0)
914  return;
915 
917 }
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
#define PNG_EXPAND_tRNS
Definition: pngpriv.h:586
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_EXPAND
Definition: pngpriv.h:572
PNG_IMPEXP void() png_set_expand_16 ( png_structrp  png_ptr)
926 {
927  png_debug(1, "in png_set_expand_16");
928 
929  if (png_rtran_ok(png_ptr, 0) == 0)
930  return;
931 
933 }
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
#define PNG_EXPAND_tRNS
Definition: pngpriv.h:586
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_EXPAND_16
Definition: pngpriv.h:569
#define PNG_EXPAND
Definition: pngpriv.h:572
PNG_IMPEXP void() png_set_bgr ( png_structrp  png_ptr)
22 {
23  png_debug(1, "in png_set_bgr");
24 
25  if (png_ptr == NULL)
26  return;
27 
28  png_ptr->transformations |= PNG_BGR;
29 }
#define PNG_BGR
Definition: pngpriv.h:560
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_gray_to_rgb ( png_structrp  png_ptr)
939 {
940  png_debug(1, "in png_set_gray_to_rgb");
941 
942  if (png_rtran_ok(png_ptr, 0) == 0)
943  return;
944 
945  /* Because rgb must be 8 bits or more: */
947  png_ptr->transformations |= PNG_GRAY_TO_RGB;
948 }
#define PNG_GRAY_TO_RGB
Definition: pngpriv.h:574
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
void png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr)
Definition: pngrtran.c:897
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_rgb_to_gray ( png_structrp  png_ptr,
int  error_action,
double  red,
double  green 
)
1045 {
1046  png_set_rgb_to_gray_fixed(png_ptr, error_action,
1047  png_fixed(png_ptr, red, "rgb to gray red coefficient"),
1048  png_fixed(png_ptr, green, "rgb to gray green coefficient"));
1049 }
png_fixed_point png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
Definition: png.c:3219
void png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)
Definition: pngrtran.c:953
PNG_IMPEXP void() png_set_rgb_to_gray_fixed ( png_structrp  png_ptr,
int  error_action,
png_fixed_point  red,
png_fixed_point  green 
)
955 {
956  png_debug(1, "in png_set_rgb_to_gray");
957 
958  /* Need the IHDR here because of the check on color_type below. */
959  /* TODO: fix this */
960  if (png_rtran_ok(png_ptr, 1) == 0)
961  return;
962 
963  switch (error_action)
964  {
966  png_ptr->transformations |= PNG_RGB_TO_GRAY;
967  break;
968 
971  break;
972 
975  break;
976 
977  default:
978  png_error(png_ptr, "invalid error action to rgb_to_gray");
979  break;
980  }
981 
982  if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
983 #ifdef PNG_READ_EXPAND_SUPPORTED
984  png_ptr->transformations |= PNG_EXPAND;
985 #else
986  {
987  /* Make this an error in 1.6 because otherwise the application may assume
988  * that it just worked and get a memory overwrite.
989  */
990  png_error(png_ptr,
991  "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED");
992 
993  /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */
994  }
995 #endif
996  {
997  if (red >= 0 && green >= 0 && red + green <= PNG_FP_1)
998  {
999  png_uint_16 red_int, green_int;
1000 
1001  /* NOTE: this calculation does not round, but this behavior is retained
1002  * for consistency; the inaccuracy is very small. The code here always
1003  * overwrites the coefficients, regardless of whether they have been
1004  * defaulted or set already.
1005  */
1006  red_int = (png_uint_16)(((png_uint_32)red*32768)/100000);
1007  green_int = (png_uint_16)(((png_uint_32)green*32768)/100000);
1008 
1009  png_ptr->rgb_to_gray_red_coeff = red_int;
1010  png_ptr->rgb_to_gray_green_coeff = green_int;
1011  png_ptr->rgb_to_gray_coefficients_set = 1;
1012  }
1013 
1014  else
1015  {
1016  if (red >= 0 && green >= 0)
1017  png_app_warning(png_ptr,
1018  "ignoring out of range rgb_to_gray coefficients");
1019 
1020  /* Use the defaults, from the cHRM chunk if set, else the historical
1021  * values which are close to the sRGB/HDTV/ITU-Rec 709 values. See
1022  * png_do_rgb_to_gray for more discussion of the values. In this case
1023  * the coefficients are not marked as 'set' and are not overwritten if
1024  * something has already provided a default.
1025  */
1026  if (png_ptr->rgb_to_gray_red_coeff == 0 &&
1027  png_ptr->rgb_to_gray_green_coeff == 0)
1028  {
1029  png_ptr->rgb_to_gray_red_coeff = 6968;
1030  png_ptr->rgb_to_gray_green_coeff = 23434;
1031  /* png_ptr->rgb_to_gray_blue_coeff = 2366; */
1032  }
1033  }
1034  }
1035 }
#define PNG_ERROR_ACTION_ERROR
Definition: png.h:1216
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:810
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
#define PNG_RGB_TO_GRAY_ERR
Definition: pngpriv.h:581
png_byte color_type
Definition: pngstruct.h:252
#define PNG_RGB_TO_GRAY_WARN
Definition: pngpriv.h:582
#define PNG_ERROR_ACTION_NONE
Definition: png.h:1214
#define PNG_ERROR_ACTION_WARN
Definition: png.h:1215
#define PNG_FP_1
Definition: png.h:797
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
#define PNG_RGB_TO_GRAY
Definition: pngpriv.h:583
void png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:392
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_EXPAND
Definition: pngpriv.h:572
PNG_IMPEXP png_byte() png_get_rgb_to_gray_status ( png_const_structrp  png_ptr)
1119 {
1120  return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
1121 }
PNG_IMPEXP void() png_build_grayscale_palette ( int  bit_depth,
png_colorp  palette 
)
834 {
835  int num_palette;
836  int color_inc;
837  int i;
838  int v;
839 
840  png_debug(1, "in png_do_build_grayscale_palette");
841 
842  if (palette == NULL)
843  return;
844 
845  switch (bit_depth)
846  {
847  case 1:
848  num_palette = 2;
849  color_inc = 0xff;
850  break;
851 
852  case 2:
853  num_palette = 4;
854  color_inc = 0x55;
855  break;
856 
857  case 4:
858  num_palette = 16;
859  color_inc = 0x11;
860  break;
861 
862  case 8:
863  num_palette = 256;
864  color_inc = 1;
865  break;
866 
867  default:
868  num_palette = 0;
869  color_inc = 0;
870  break;
871  }
872 
873  for (i = 0, v = 0; i < num_palette; i++, v += color_inc)
874  {
875  palette[i].red = (png_byte)v;
876  palette[i].green = (png_byte)v;
877  palette[i].blue = (png_byte)v;
878  }
879 }
int i
Definition: rw_test.cpp:37
png_byte red
Definition: png.h:621
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte green
Definition: png.h:622
png_byte blue
Definition: png.h:623
PNG_IMPEXP void() png_set_alpha_mode ( png_structrp  png_ptr,
int  mode,
double  output_gamma 
)
386 {
387  png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,
388  output_gamma));
389 }
void png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, png_fixed_point output_gamma)
Definition: pngrtran.c:275
static png_fixed_point convert_gamma_value(png_structrp png_ptr, double output_gamma)
Definition: pngrtran.c:250
PNG_IMPEXP void() png_set_alpha_mode_fixed ( png_structrp  png_ptr,
int  mode,
png_fixed_point  output_gamma 
)
277 {
278  int compose = 0;
279  png_fixed_point file_gamma;
280 
281  png_debug(1, "in png_set_alpha_mode");
282 
283  if (png_rtran_ok(png_ptr, 0) == 0)
284  return;
285 
286  output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
287 
288  /* Validate the value to ensure it is in a reasonable range. The value
289  * is expected to be 1 or greater, but this range test allows for some
290  * viewing correction values. The intent is to weed out users of this API
291  * who use the inverse of the gamma value accidentally! Since some of these
292  * values are reasonable this may have to be changed.
293  */
294  if (output_gamma < 70000 || output_gamma > 300000)
295  png_error(png_ptr, "output gamma out of expected range");
296 
297  /* The default file gamma is the inverse of the output gamma; the output
298  * gamma may be changed below so get the file value first:
299  */
300  file_gamma = png_reciprocal(output_gamma);
301 
302  /* There are really 8 possibilities here, composed of any combination
303  * of:
304  *
305  * premultiply the color channels
306  * do not encode non-opaque pixels
307  * encode the alpha as well as the color channels
308  *
309  * The differences disappear if the input/output ('screen') gamma is 1.0,
310  * because then the encoding is a no-op and there is only the choice of
311  * premultiplying the color channels or not.
312  *
313  * png_set_alpha_mode and png_set_background interact because both use
314  * png_compose to do the work. Calling both is only useful when
315  * png_set_alpha_mode is used to set the default mode - PNG_ALPHA_PNG - along
316  * with a default gamma value. Otherwise PNG_COMPOSE must not be set.
317  */
318  switch (mode)
319  {
320  case PNG_ALPHA_PNG: /* default: png standard */
321  /* No compose, but it may be set by png_set_background! */
322  png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
323  png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
324  break;
325 
326  case PNG_ALPHA_ASSOCIATED: /* color channels premultiplied */
327  compose = 1;
328  png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
329  png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
330  /* The output is linear: */
331  output_gamma = PNG_FP_1;
332  break;
333 
334  case PNG_ALPHA_OPTIMIZED: /* associated, non-opaque pixels linear */
335  compose = 1;
336  png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
337  png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA;
338  /* output_gamma records the encoding of opaque pixels! */
339  break;
340 
341  case PNG_ALPHA_BROKEN: /* associated, non-linear, alpha encoded */
342  compose = 1;
343  png_ptr->transformations |= PNG_ENCODE_ALPHA;
344  png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
345  break;
346 
347  default:
348  png_error(png_ptr, "invalid alpha mode");
349  }
350 
351  /* Only set the default gamma if the file gamma has not been set (this has
352  * the side effect that the gamma in a second call to png_set_alpha_mode will
353  * be ignored.)
354  */
355  if (png_ptr->colorspace.gamma == 0)
356  {
357  png_ptr->colorspace.gamma = file_gamma;
358  png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
359  }
360 
361  /* But always set the output gamma: */
362  png_ptr->screen_gamma = output_gamma;
363 
364  /* Finally, if pre-multiplying, set the background fields to achieve the
365  * desired result.
366  */
367  if (compose != 0)
368  {
369  /* And obtain alpha pre-multiplication by composing on black: */
370  memset(&png_ptr->background, 0, (sizeof png_ptr->background));
371  png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */
372  png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
374 
375  if ((png_ptr->transformations & PNG_COMPOSE) != 0)
376  png_error(png_ptr,
377  "conflicting calls to set alpha mode and background");
378 
379  png_ptr->transformations |= PNG_COMPOSE;
380  }
381 }
#define PNG_COMPOSE
Definition: pngpriv.h:567
#define PNG_ALPHA_OPTIMIZED
Definition: png.h:1272
#define PNG_BACKGROUND_EXPAND
Definition: pngpriv.h:568
png_fixed_point png_reciprocal(png_fixed_point a)
Definition: png.c:3379
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_BACKGROUND_GAMMA_FILE
Definition: png.h:1447
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
#define PNG_ALPHA_PNG
Definition: png.h:1268
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_ALPHA_BROKEN
Definition: png.h:1273
#define PNG_ALPHA_ASSOCIATED
Definition: png.h:1270
#define PNG_FP_1
Definition: png.h:797
#define PNG_ENCODE_ALPHA
Definition: pngpriv.h:584
png_int_32 png_fixed_point
Definition: pngconf.h:595
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
png_uint_32 transformations
Definition: pngstruct.h:181
static png_fixed_point translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, int is_screen)
Definition: pngrtran.c:211
#define PNG_FLAG_OPTIMIZE_ALPHA
Definition: pngpriv.h:614
PNG_IMPEXP void() png_set_strip_alpha ( png_structrp  png_ptr)
199 {
200  png_debug(1, "in png_set_strip_alpha");
201 
202  if (png_rtran_ok(png_ptr, 0) == 0)
203  return;
204 
205  png_ptr->transformations |= PNG_STRIP_ALPHA;
206 }
#define PNG_STRIP_ALPHA
Definition: pngpriv.h:578
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_swap_alpha ( png_structrp  png_ptr)
223 {
224  png_debug(1, "in png_set_swap_alpha");
225 
226  if (png_ptr == NULL)
227  return;
228 
229  png_ptr->transformations |= PNG_SWAP_ALPHA;
230 }
#define PNG_SWAP_ALPHA
Definition: pngpriv.h:577
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_invert_alpha ( png_structrp  png_ptr)
237 {
238  png_debug(1, "in png_set_invert_alpha");
239 
240  if (png_ptr == NULL)
241  return;
242 
243  png_ptr->transformations |= PNG_INVERT_ALPHA;
244 }
#define PNG_INVERT_ALPHA
Definition: pngpriv.h:579
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_filler ( png_structrp  png_ptr,
png_uint_32  filler,
int  flags 
)
121 {
122  png_debug(1, "in png_set_filler");
123 
124  if (png_ptr == NULL)
125  return;
126 
127  /* In libpng 1.6 it is possible to determine whether this is a read or write
128  * operation and therefore to do more checking here for a valid call.
129  */
130  if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
131  {
132 # ifdef PNG_READ_FILLER_SUPPORTED
133  /* On read png_set_filler is always valid, regardless of the base PNG
134  * format, because other transformations can give a format where the
135  * filler code can execute (basically an 8 or 16-bit component RGB or G
136  * format.)
137  *
138  * NOTE: usr_channels is not used by the read code! (This has led to
139  * confusion in the past.) The filler is only used in the read code.
140  */
141  png_ptr->filler = (png_uint_16)filler;
142 # else
143  png_app_error(png_ptr, "png_set_filler not supported on read");
144  PNG_UNUSED(filler) /* not used in the write case */
145  return;
146 # endif
147  }
148 
149  else /* write */
150  {
151 # ifdef PNG_WRITE_FILLER_SUPPORTED
152  /* On write the usr_channels parameter must be set correctly at the
153  * start to record the number of channels in the app-supplied data.
154  */
155  switch (png_ptr->color_type)
156  {
157  case PNG_COLOR_TYPE_RGB:
158  png_ptr->usr_channels = 4;
159  break;
160 
161  case PNG_COLOR_TYPE_GRAY:
162  if (png_ptr->bit_depth >= 8)
163  {
164  png_ptr->usr_channels = 2;
165  break;
166  }
167 
168  else
169  {
170  /* There simply isn't any code in libpng to strip out bits
171  * from bytes when the components are less than a byte in
172  * size!
173  */
174  png_app_error(png_ptr,
175  "png_set_filler is invalid for low bit depth gray output");
176  return;
177  }
178 
179  default:
180  png_app_error(png_ptr,
181  "png_set_filler: inappropriate color type");
182  return;
183  }
184 # else
185  png_app_error(png_ptr, "png_set_filler not supported on write");
186  return;
187 # endif
188  }
189 
190  /* Here on success - libpng supports the operation, set the transformation
191  * and the flag to say where the filler channel is.
192  */
193  png_ptr->transformations |= PNG_FILLER;
194 
195  if (filler_loc == PNG_FILLER_AFTER)
196  png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
197 
198  else
199  png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
200 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_COLOR_TYPE_RGB
Definition: png.h:811
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_IS_READ_STRUCT
Definition: pngpriv.h:557
png_byte color_type
Definition: pngstruct.h:252
#define PNG_FILLER
Definition: pngpriv.h:575
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:809
png_byte bit_depth
Definition: pngstruct.h:253
png_uint_32 mode
Definition: pngstruct.h:179
#define PNG_FILLER_AFTER
Definition: png.h:1387
#define PNG_FLAG_FILLER_AFTER
Definition: pngpriv.h:608
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_add_alpha ( png_structrp  png_ptr,
png_uint_32  filler,
int  flags 
)
205 {
206  png_debug(1, "in png_set_add_alpha");
207 
208  if (png_ptr == NULL)
209  return;
210 
211  png_set_filler(png_ptr, filler, filler_loc);
212  /* The above may fail to do anything. */
213  if ((png_ptr->transformations & PNG_FILLER) != 0)
214  png_ptr->transformations |= PNG_ADD_ALPHA;
215 }
void png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
Definition: pngtrans.c:120
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_FILLER
Definition: pngpriv.h:575
#define PNG_ADD_ALPHA
Definition: pngpriv.h:585
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_swap ( png_structrp  png_ptr)
36 {
37  png_debug(1, "in png_set_swap");
38 
39  if (png_ptr == NULL)
40  return;
41 
42  if (png_ptr->bit_depth == 16)
43  png_ptr->transformations |= PNG_SWAP_BYTES;
44 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_SWAP_BYTES
Definition: pngpriv.h:564
png_byte bit_depth
Definition: pngstruct.h:253
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_packing ( png_structrp  png_ptr)
51 {
52  png_debug(1, "in png_set_packing");
53 
54  if (png_ptr == NULL)
55  return;
56 
57  if (png_ptr->bit_depth < 8)
58  {
59  png_ptr->transformations |= PNG_PACK;
60 # ifdef PNG_WRITE_SUPPORTED
61  png_ptr->usr_bit_depth = 8;
62 # endif
63  }
64 }
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte bit_depth
Definition: pngstruct.h:253
png_byte usr_bit_depth
Definition: pngstruct.h:254
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_PACK
Definition: pngpriv.h:562
PNG_IMPEXP void() png_set_packswap ( png_structrp  png_ptr)
71 {
72  png_debug(1, "in png_set_packswap");
73 
74  if (png_ptr == NULL)
75  return;
76 
77  if (png_ptr->bit_depth < 8)
78  png_ptr->transformations |= PNG_PACKSWAP;
79 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_PACKSWAP
Definition: pngpriv.h:576
png_byte bit_depth
Definition: pngstruct.h:253
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_shift ( png_structrp  png_ptr,
png_const_color_8p  true_bits 
)
85 {
86  png_debug(1, "in png_set_shift");
87 
88  if (png_ptr == NULL)
89  return;
90 
91  png_ptr->transformations |= PNG_SHIFT;
92  png_ptr->shift = *true_bits;
93 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_SHIFT
Definition: pngpriv.h:563
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP int() png_set_interlace_handling ( png_structrp  png_ptr)
100 {
101  png_debug(1, "in png_set_interlace handling");
102 
103  if (png_ptr != 0 && png_ptr->interlaced != 0)
104  {
105  png_ptr->transformations |= PNG_INTERLACE;
106  return (7);
107  }
108 
109  return (1);
110 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_INTERLACE
Definition: pngpriv.h:561
png_uint_32 transformations
Definition: pngstruct.h:181
png_byte interlaced
Definition: pngstruct.h:249
PNG_IMPEXP void() png_set_invert_mono ( png_structrp  png_ptr)
250 {
251  png_debug(1, "in png_set_invert_mono");
252 
253  if (png_ptr == NULL)
254  return;
255 
256  png_ptr->transformations |= PNG_INVERT_MONO;
257 }
#define PNG_INVERT_MONO
Definition: pngpriv.h:565
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_background ( png_structrp  png_ptr,
png_const_color_16p  background_color,
int  background_gamma_code,
int  need_expand,
double  background_gamma 
)
158 {
159  png_set_background_fixed(png_ptr, background_color, background_gamma_code,
160  need_expand, png_fixed(png_ptr, background_gamma, "png_set_background"));
161 }
void png_set_background_fixed(png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma)
Definition: pngrtran.c:125
png_fixed_point png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
Definition: png.c:3219
PNG_IMPEXP void() png_set_background_fixed ( png_structrp  png_ptr,
png_const_color_16p  background_color,
int  background_gamma_code,
int  need_expand,
png_fixed_point  background_gamma 
)
128 {
129  png_debug(1, "in png_set_background_fixed");
130 
131  if (png_rtran_ok(png_ptr, 0) == 0 || background_color == NULL)
132  return;
133 
134  if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
135  {
136  png_warning(png_ptr, "Application must supply a known background gamma");
137  return;
138  }
139 
141  png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
142  png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
143 
144  png_ptr->background = *background_color;
145  png_ptr->background_gamma = background_gamma;
146  png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
147  if (need_expand != 0)
149  else
151 }
#define PNG_STRIP_ALPHA
Definition: pngpriv.h:578
#define PNG_COMPOSE
Definition: pngpriv.h:567
#define PNG_BACKGROUND_EXPAND
Definition: pngpriv.h:568
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_ENCODE_ALPHA
Definition: pngpriv.h:584
#define PNG_BACKGROUND_GAMMA_UNKNOWN
Definition: png.h:1445
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_FLAG_OPTIMIZE_ALPHA
Definition: pngpriv.h:614
PNG_IMPEXP void() png_set_scale_16 ( png_structrp  png_ptr)
172 {
173  png_debug(1, "in png_set_scale_16");
174 
175  if (png_rtran_ok(png_ptr, 0) == 0)
176  return;
177 
179 }
#define PNG_SCALE_16_TO_8
Definition: pngpriv.h:587
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_strip_16 ( png_structrp  png_ptr)
186 {
187  png_debug(1, "in png_set_strip_16");
188 
189  if (png_rtran_ok(png_ptr, 0) == 0)
190  return;
191 
192  png_ptr->transformations |= PNG_16_TO_8;
193 }
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
#define PNG_16_TO_8
Definition: pngpriv.h:570
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_quantize ( png_structrp  png_ptr,
png_colorp  palette,
int  num_palette,
int  maximum_colors,
png_const_uint_16p  histogram,
int  full_quantize 
)
416 {
417  png_debug(1, "in png_set_quantize");
418 
419  if (png_rtran_ok(png_ptr, 0) == 0)
420  return;
421 
422  png_ptr->transformations |= PNG_QUANTIZE;
423 
424  if (full_quantize == 0)
425  {
426  int i;
427 
428  png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
429  (png_uint_32)(num_palette * (sizeof (png_byte))));
430  for (i = 0; i < num_palette; i++)
431  png_ptr->quantize_index[i] = (png_byte)i;
432  }
433 
434  if (num_palette > maximum_colors)
435  {
436  if (histogram != NULL)
437  {
438  /* This is easy enough, just throw out the least used colors.
439  * Perhaps not the best solution, but good enough.
440  */
441 
442  int i;
443 
444  /* Initialize an array to sort colors */
445  png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
446  (png_uint_32)(num_palette * (sizeof (png_byte))));
447 
448  /* Initialize the quantize_sort array */
449  for (i = 0; i < num_palette; i++)
450  png_ptr->quantize_sort[i] = (png_byte)i;
451 
452  /* Find the least used palette entries by starting a
453  * bubble sort, and running it until we have sorted
454  * out enough colors. Note that we don't care about
455  * sorting all the colors, just finding which are
456  * least used.
457  */
458 
459  for (i = num_palette - 1; i >= maximum_colors; i--)
460  {
461  int done; /* To stop early if the list is pre-sorted */
462  int j;
463 
464  done = 1;
465  for (j = 0; j < i; j++)
466  {
467  if (histogram[png_ptr->quantize_sort[j]]
468  < histogram[png_ptr->quantize_sort[j + 1]])
469  {
470  png_byte t;
471 
472  t = png_ptr->quantize_sort[j];
473  png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1];
474  png_ptr->quantize_sort[j + 1] = t;
475  done = 0;
476  }
477  }
478 
479  if (done != 0)
480  break;
481  }
482 
483  /* Swap the palette around, and set up a table, if necessary */
484  if (full_quantize != 0)
485  {
486  int j = num_palette;
487 
488  /* Put all the useful colors within the max, but don't
489  * move the others.
490  */
491  for (i = 0; i < maximum_colors; i++)
492  {
493  if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
494  {
495  do
496  j--;
497  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
498 
499  palette[i] = palette[j];
500  }
501  }
502  }
503  else
504  {
505  int j = num_palette;
506 
507  /* Move all the used colors inside the max limit, and
508  * develop a translation table.
509  */
510  for (i = 0; i < maximum_colors; i++)
511  {
512  /* Only move the colors we need to */
513  if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
514  {
515  png_color tmp_color;
516 
517  do
518  j--;
519  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
520 
521  tmp_color = palette[j];
522  palette[j] = palette[i];
523  palette[i] = tmp_color;
524  /* Indicate where the color went */
525  png_ptr->quantize_index[j] = (png_byte)i;
526  png_ptr->quantize_index[i] = (png_byte)j;
527  }
528  }
529 
530  /* Find closest color for those colors we are not using */
531  for (i = 0; i < num_palette; i++)
532  {
533  if ((int)png_ptr->quantize_index[i] >= maximum_colors)
534  {
535  int min_d, k, min_k, d_index;
536 
537  /* Find the closest color to one we threw out */
538  d_index = png_ptr->quantize_index[i];
539  min_d = PNG_COLOR_DIST(palette[d_index], palette[0]);
540  for (k = 1, min_k = 0; k < maximum_colors; k++)
541  {
542  int d;
543 
544  d = PNG_COLOR_DIST(palette[d_index], palette[k]);
545 
546  if (d < min_d)
547  {
548  min_d = d;
549  min_k = k;
550  }
551  }
552  /* Point to closest color */
553  png_ptr->quantize_index[i] = (png_byte)min_k;
554  }
555  }
556  }
557  png_free(png_ptr, png_ptr->quantize_sort);
558  png_ptr->quantize_sort = NULL;
559  }
560  else
561  {
562  /* This is much harder to do simply (and quickly). Perhaps
563  * we need to go through a median cut routine, but those
564  * don't always behave themselves with only a few colors
565  * as input. So we will just find the closest two colors,
566  * and throw out one of them (chosen somewhat randomly).
567  * [We don't understand this at all, so if someone wants to
568  * work on improving it, be our guest - AED, GRP]
569  */
570  int i;
571  int max_d;
572  int num_new_palette;
573  png_dsortp t;
574  png_dsortpp hash;
575 
576  t = NULL;
577 
578  /* Initialize palette index arrays */
579  png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
580  (png_uint_32)(num_palette * (sizeof (png_byte))));
581  png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
582  (png_uint_32)(num_palette * (sizeof (png_byte))));
583 
584  /* Initialize the sort array */
585  for (i = 0; i < num_palette; i++)
586  {
587  png_ptr->index_to_palette[i] = (png_byte)i;
588  png_ptr->palette_to_index[i] = (png_byte)i;
589  }
590 
591  hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
592  (sizeof (png_dsortp))));
593 
594  num_new_palette = num_palette;
595 
596  /* Initial wild guess at how far apart the farthest pixel
597  * pair we will be eliminating will be. Larger
598  * numbers mean more areas will be allocated, Smaller
599  * numbers run the risk of not saving enough data, and
600  * having to do this all over again.
601  *
602  * I have not done extensive checking on this number.
603  */
604  max_d = 96;
605 
606  while (num_new_palette > maximum_colors)
607  {
608  for (i = 0; i < num_new_palette - 1; i++)
609  {
610  int j;
611 
612  for (j = i + 1; j < num_new_palette; j++)
613  {
614  int d;
615 
616  d = PNG_COLOR_DIST(palette[i], palette[j]);
617 
618  if (d <= max_d)
619  {
620 
621  t = (png_dsortp)png_malloc_warn(png_ptr,
622  (png_uint_32)(sizeof (png_dsort)));
623 
624  if (t == NULL)
625  break;
626 
627  t->next = hash[d];
628  t->left = (png_byte)i;
629  t->right = (png_byte)j;
630  hash[d] = t;
631  }
632  }
633  if (t == NULL)
634  break;
635  }
636 
637  if (t != NULL)
638  for (i = 0; i <= max_d; i++)
639  {
640  if (hash[i] != NULL)
641  {
642  png_dsortp p;
643 
644  for (p = hash[i]; p; p = p->next)
645  {
646  if ((int)png_ptr->index_to_palette[p->left]
647  < num_new_palette &&
648  (int)png_ptr->index_to_palette[p->right]
649  < num_new_palette)
650  {
651  int j, next_j;
652 
653  if (num_new_palette & 0x01)
654  {
655  j = p->left;
656  next_j = p->right;
657  }
658  else
659  {
660  j = p->right;
661  next_j = p->left;
662  }
663 
664  num_new_palette--;
665  palette[png_ptr->index_to_palette[j]]
666  = palette[num_new_palette];
667  if (full_quantize == 0)
668  {
669  int k;
670 
671  for (k = 0; k < num_palette; k++)
672  {
673  if (png_ptr->quantize_index[k] ==
674  png_ptr->index_to_palette[j])
675  png_ptr->quantize_index[k] =
676  png_ptr->index_to_palette[next_j];
677 
678  if ((int)png_ptr->quantize_index[k] ==
679  num_new_palette)
680  png_ptr->quantize_index[k] =
681  png_ptr->index_to_palette[j];
682  }
683  }
684 
685  png_ptr->index_to_palette[png_ptr->palette_to_index
686  [num_new_palette]] = png_ptr->index_to_palette[j];
687 
688  png_ptr->palette_to_index[png_ptr->index_to_palette[j]]
689  = png_ptr->palette_to_index[num_new_palette];
690 
691  png_ptr->index_to_palette[j] =
692  (png_byte)num_new_palette;
693 
694  png_ptr->palette_to_index[num_new_palette] =
695  (png_byte)j;
696  }
697  if (num_new_palette <= maximum_colors)
698  break;
699  }
700  if (num_new_palette <= maximum_colors)
701  break;
702  }
703  }
704 
705  for (i = 0; i < 769; i++)
706  {
707  if (hash[i] != NULL)
708  {
709  png_dsortp p = hash[i];
710  while (p)
711  {
712  t = p->next;
713  png_free(png_ptr, p);
714  p = t;
715  }
716  }
717  hash[i] = 0;
718  }
719  max_d += 96;
720  }
721  png_free(png_ptr, hash);
722  png_free(png_ptr, png_ptr->palette_to_index);
723  png_free(png_ptr, png_ptr->index_to_palette);
724  png_ptr->palette_to_index = NULL;
725  png_ptr->index_to_palette = NULL;
726  }
727  num_palette = maximum_colors;
728  }
729  if (png_ptr->palette == NULL)
730  {
731  png_ptr->palette = palette;
732  }
733  png_ptr->num_palette = (png_uint_16)num_palette;
734 
735  if (full_quantize != 0)
736  {
737  int i;
738  png_bytep distance;
741  int num_red = (1 << PNG_QUANTIZE_RED_BITS);
742  int num_green = (1 << PNG_QUANTIZE_GREEN_BITS);
743  int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS);
744  png_size_t num_entries = ((png_size_t)1 << total_bits);
745 
746  png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
747  (png_uint_32)(num_entries * (sizeof (png_byte))));
748 
749  distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
750  (sizeof (png_byte))));
751 
752  memset(distance, 0xff, num_entries * (sizeof (png_byte)));
753 
754  for (i = 0; i < num_palette; i++)
755  {
756  int ir, ig, ib;
757  int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS));
758  int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS));
759  int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS));
760 
761  for (ir = 0; ir < num_red; ir++)
762  {
763  /* int dr = abs(ir - r); */
764  int dr = ((ir > r) ? ir - r : r - ir);
765  int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS +
767 
768  for (ig = 0; ig < num_green; ig++)
769  {
770  /* int dg = abs(ig - g); */
771  int dg = ((ig > g) ? ig - g : g - ig);
772  int dt = dr + dg;
773  int dm = ((dr > dg) ? dr : dg);
774  int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS);
775 
776  for (ib = 0; ib < num_blue; ib++)
777  {
778  int d_index = index_g | ib;
779  /* int db = abs(ib - b); */
780  int db = ((ib > b) ? ib - b : b - ib);
781  int dmax = ((dm > db) ? dm : db);
782  int d = dmax + dt + db;
783 
784  if (d < (int)distance[d_index])
785  {
786  distance[d_index] = (png_byte)d;
787  png_ptr->palette_lookup[d_index] = (png_byte)i;
788  }
789  }
790  }
791  }
792  }
793 
794  png_free(png_ptr, distance);
795  }
796 }
struct png_dsort_struct png_dsort
PNG_IMPEXP png_voidp() png_malloc(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:169
png_byte left
Definition: pngrtran.c:406
ElapsedTime dt
Definition: agent_file3.cpp:183
int i
Definition: rw_test.cpp:37
png_byte * png_bytep
Definition: pngconf.h:600
#define PNG_COLOR_DIST(c1, c2)
Definition: pngpriv.h:644
PNG_IMPEXP png_voidp() png_malloc_warn(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:210
png_byte red
Definition: png.h:621
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_QUANTIZE_BLUE_BITS
Definition: pnglibconf.h:196
png_dsort * png_dsortp
Definition: pngrtran.c:409
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
long b
Definition: jpegint.h:371
png_dsort ** png_dsortpp
Definition: pngrtran.c:410
static double * p
Definition: gauss_jackson_test.cpp:42
png_colorp palette
Definition: pngstruct.h:238
Definition: pngrtran.c:403
png_uint_16 num_palette
Definition: pngstruct.h:239
Definition: png.h:619
png_byte right
Definition: pngrtran.c:407
PNG_IMPEXP png_voidp() png_calloc(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:50
PNG_IMPEXP void() png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:229
#define PNG_QUANTIZE
Definition: pngpriv.h:566
size_t png_size_t
Definition: pngconf.h:543
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_QUANTIZE_RED_BITS
Definition: pnglibconf.h:198
#define PNG_QUANTIZE_GREEN_BITS
Definition: pnglibconf.h:197
png_byte green
Definition: png.h:622
png_byte blue
Definition: png.h:623
struct png_dsort_struct * next
Definition: pngrtran.c:405
PNG_IMPEXP void() png_set_gamma ( png_structrp  png_ptr,
double  screen_gamma,
double  override_file_gamma 
)
842 {
843  png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
844  convert_gamma_value(png_ptr, file_gamma));
845 }
void png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, png_fixed_point file_gamma)
Definition: pngrtran.c:801
static png_fixed_point convert_gamma_value(png_structrp png_ptr, double output_gamma)
Definition: pngrtran.c:250
PNG_IMPEXP void() png_set_gamma_fixed ( png_structrp  png_ptr,
png_fixed_point  screen_gamma,
png_fixed_point  override_file_gamma 
)
803 {
804  png_debug(1, "in png_set_gamma_fixed");
805 
806  if (png_rtran_ok(png_ptr, 0) == 0)
807  return;
808 
809  /* New in libpng-1.5.4 - reserve particular negative values as flags. */
810  scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);
811  file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);
812 
813  /* Checking the gamma values for being >0 was added in 1.5.4 along with the
814  * premultiplied alpha support; this actually hides an undocumented feature
815  * of the previous implementation which allowed gamma processing to be
816  * disabled in background handling. There is no evidence (so far) that this
817  * was being used; however, png_set_background itself accepted and must still
818  * accept '0' for the gamma value it takes, because it isn't always used.
819  *
820  * Since this is an API change (albeit a very minor one that removes an
821  * undocumented API feature) the following checks were only enabled in
822  * libpng-1.6.0.
823  */
824  if (file_gamma <= 0)
825  png_error(png_ptr, "invalid file gamma in png_set_gamma");
826 
827  if (scrn_gamma <= 0)
828  png_error(png_ptr, "invalid screen gamma in png_set_gamma");
829 
830  /* Set the gamma values unconditionally - this overrides the value in the PNG
831  * file if a gAMA chunk was present. png_set_alpha_mode provides a
832  * different, easier, way to default the file gamma.
833  */
834  png_ptr->colorspace.gamma = file_gamma;
835  png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
836  png_ptr->screen_gamma = scrn_gamma;
837 }
#define png_debug(l, m)
Definition: pngdebug.h:146
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:98
png_uint_32 flags
Definition: pngstruct.h:180
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
static png_fixed_point translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, int is_screen)
Definition: pngrtran.c:211
PNG_IMPEXP void() png_set_flush ( png_structrp  png_ptr,
int  nrows 
)
892 {
893  png_debug(1, "in png_set_flush");
894 
895  if (png_ptr == NULL)
896  return;
897 
898  png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
899 }
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP void() png_write_flush ( png_structrp  png_ptr)
904 {
905  png_debug(1, "in png_write_flush");
906 
907  if (png_ptr == NULL)
908  return;
909 
910  /* We have already written out all of the data */
911  if (png_ptr->row_number >= png_ptr->num_rows)
912  return;
913 
914  png_compress_IDAT(png_ptr, NULL, 0, Z_SYNC_FLUSH);
915  png_ptr->flush_rows = 0;
916  png_flush(png_ptr);
917 }
void png_flush(png_structrp png_ptr)
Definition: pngwio.c:71
png_uint_32 row_number
Definition: pngstruct.h:220
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 num_rows
Definition: pngstruct.h:216
#define Z_SYNC_FLUSH
Definition: zlib.h:166
void png_compress_IDAT(png_structrp png_ptr, png_const_bytep row_data, png_alloc_size_t row_data_length, int flush)
Definition: pngwutil.c:1008
PNG_IMPEXP void() png_start_read_image ( png_structrp  png_ptr)
291 {
292  png_debug(1, "in png_start_read_image");
293 
294  if (png_ptr != NULL)
295  {
296  if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
297  png_read_start_row(png_ptr);
298 
299  /* New in 1.6.0 this avoids the bug of doing the initializations twice */
300  else
301  png_app_error(png_ptr,
302  "png_start_read_image/png_read_update_info: duplicate call");
303  }
304 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_FLAG_ROW_INIT
Definition: pngpriv.h:607
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
png_uint_32 flags
Definition: pngstruct.h:180
void png_read_start_row(png_structrp png_ptr)
Definition: pngrutil.c:4184
PNG_IMPEXP void() png_read_update_info ( png_structrp  png_ptr,
png_inforp  info_ptr 
)
260 {
261  png_debug(1, "in png_read_update_info");
262 
263  if (png_ptr != NULL)
264  {
265  if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
266  {
267  png_read_start_row(png_ptr);
268 
269 # ifdef PNG_READ_TRANSFORMS_SUPPORTED
270  png_read_transform_info(png_ptr, info_ptr);
271 # else
272  PNG_UNUSED(info_ptr)
273 # endif
274  }
275 
276  /* New in 1.6.0 this avoids the bug of doing the initializations twice */
277  else
278  png_app_error(png_ptr,
279  "png_read_update_info/png_start_read_image: duplicate call");
280  }
281 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_FLAG_ROW_INIT
Definition: pngpriv.h:607
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
png_uint_32 flags
Definition: pngstruct.h:180
void png_read_start_row(png_structrp png_ptr)
Definition: pngrutil.c:4184
void png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
Definition: pngrtran.c:1924
PNG_IMPEXP void() png_read_rows ( png_structrp  png_ptr,
png_bytepp  row,
png_bytepp  display_row,
png_uint_32  num_rows 
)
638 {
639  png_uint_32 i;
640  png_bytepp rp;
641  png_bytepp dp;
642 
643  png_debug(1, "in png_read_rows");
644 
645  if (png_ptr == NULL)
646  return;
647 
648  rp = row;
649  dp = display_row;
650  if (rp != NULL && dp != NULL)
651  for (i = 0; i < num_rows; i++)
652  {
653  png_bytep rptr = *rp++;
654  png_bytep dptr = *dp++;
655 
656  png_read_row(png_ptr, rptr, dptr);
657  }
658 
659  else if (rp != NULL)
660  for (i = 0; i < num_rows; i++)
661  {
662  png_bytep rptr = *rp;
663  png_read_row(png_ptr, rptr, NULL);
664  rp++;
665  }
666 
667  else if (dp != NULL)
668  for (i = 0; i < num_rows; i++)
669  {
670  png_bytep dptr = *dp;
671  png_read_row(png_ptr, NULL, dptr);
672  dp++;
673  }
674 }
int i
Definition: rw_test.cpp:37
png_byte * png_bytep
Definition: pngconf.h:600
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte ** png_bytepp
Definition: pngconf.h:627
int JSAMPARRAY int int num_rows
Definition: jpegint.h:373
void png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
Definition: pngread.c:375
PNG_IMPEXP void() png_read_row ( png_structrp  png_ptr,
png_bytep  row,
png_bytep  display_row 
)
376 {
377  png_row_info row_info;
378 
379  if (png_ptr == NULL)
380  return;
381 
382  png_debug2(1, "in png_read_row (row %lu, pass %d)",
383  (unsigned long)png_ptr->row_number, png_ptr->pass);
384 
385  /* png_read_start_row sets the information (in particular iwidth) for this
386  * interlace pass.
387  */
388  if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
389  png_read_start_row(png_ptr);
390 
391  /* 1.5.6: row_info moved out of png_struct to a local here. */
392  row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */
393  row_info.color_type = png_ptr->color_type;
394  row_info.bit_depth = png_ptr->bit_depth;
395  row_info.channels = png_ptr->channels;
396  row_info.pixel_depth = png_ptr->pixel_depth;
397  row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
398 
399 #ifdef PNG_WARNINGS_SUPPORTED
400  if (png_ptr->row_number == 0 && png_ptr->pass == 0)
401  {
402  /* Check for transforms that have been set but were defined out */
403 #if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
404  if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
405  png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined");
406 #endif
407 
408 #if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)
409  if ((png_ptr->transformations & PNG_FILLER) != 0)
410  png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined");
411 #endif
412 
413 #if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
414  !defined(PNG_READ_PACKSWAP_SUPPORTED)
415  if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
416  png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined");
417 #endif
418 
419 #if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)
420  if ((png_ptr->transformations & PNG_PACK) != 0)
421  png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined");
422 #endif
423 
424 #if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)
425  if ((png_ptr->transformations & PNG_SHIFT) != 0)
426  png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined");
427 #endif
428 
429 #if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)
430  if ((png_ptr->transformations & PNG_BGR) != 0)
431  png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined");
432 #endif
433 
434 #if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)
435  if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
436  png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined");
437 #endif
438  }
439 #endif /* WARNINGS */
440 
441 #ifdef PNG_READ_INTERLACING_SUPPORTED
442  /* If interlaced and we do not need a new row, combine row and return.
443  * Notice that the pixels we have from previous rows have been transformed
444  * already; we can only combine like with like (transformed or
445  * untransformed) and, because of the libpng API for interlaced images, this
446  * means we must transform before de-interlacing.
447  */
448  if (png_ptr->interlaced != 0 &&
449  (png_ptr->transformations & PNG_INTERLACE) != 0)
450  {
451  switch (png_ptr->pass)
452  {
453  case 0:
454  if (png_ptr->row_number & 0x07)
455  {
456  if (dsp_row != NULL)
457  png_combine_row(png_ptr, dsp_row, 1/*display*/);
458  png_read_finish_row(png_ptr);
459  return;
460  }
461  break;
462 
463  case 1:
464  if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
465  {
466  if (dsp_row != NULL)
467  png_combine_row(png_ptr, dsp_row, 1/*display*/);
468 
469  png_read_finish_row(png_ptr);
470  return;
471  }
472  break;
473 
474  case 2:
475  if ((png_ptr->row_number & 0x07) != 4)
476  {
477  if (dsp_row != NULL && (png_ptr->row_number & 4))
478  png_combine_row(png_ptr, dsp_row, 1/*display*/);
479 
480  png_read_finish_row(png_ptr);
481  return;
482  }
483  break;
484 
485  case 3:
486  if ((png_ptr->row_number & 3) || png_ptr->width < 3)
487  {
488  if (dsp_row != NULL)
489  png_combine_row(png_ptr, dsp_row, 1/*display*/);
490 
491  png_read_finish_row(png_ptr);
492  return;
493  }
494  break;
495 
496  case 4:
497  if ((png_ptr->row_number & 3) != 2)
498  {
499  if (dsp_row != NULL && (png_ptr->row_number & 2))
500  png_combine_row(png_ptr, dsp_row, 1/*display*/);
501 
502  png_read_finish_row(png_ptr);
503  return;
504  }
505  break;
506 
507  case 5:
508  if ((png_ptr->row_number & 1) || png_ptr->width < 2)
509  {
510  if (dsp_row != NULL)
511  png_combine_row(png_ptr, dsp_row, 1/*display*/);
512 
513  png_read_finish_row(png_ptr);
514  return;
515  }
516  break;
517 
518  default:
519  case 6:
520  if ((png_ptr->row_number & 1) == 0)
521  {
522  png_read_finish_row(png_ptr);
523  return;
524  }
525  break;
526  }
527  }
528 #endif
529 
530  if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
531  png_error(png_ptr, "Invalid attempt to read row data");
532 
533  /* Fill the row with IDAT data: */
534  png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1);
535 
536  if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
537  {
538  if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)
539  png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,
540  png_ptr->prev_row + 1, png_ptr->row_buf[0]);
541  else
542  png_error(png_ptr, "bad adaptive filter value");
543  }
544 
545  /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before
546  * 1.5.6, while the buffer really is this big in current versions of libpng
547  * it may not be in the future, so this was changed just to copy the
548  * interlaced count:
549  */
550  memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
551 
552 #ifdef PNG_MNG_FEATURES_SUPPORTED
553  if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
554  (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
555  {
556  /* Intrapixel differencing */
557  png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1);
558  }
559 #endif
560 
561 #ifdef PNG_READ_TRANSFORMS_SUPPORTED
562  if (png_ptr->transformations)
563  png_do_read_transformations(png_ptr, &row_info);
564 #endif
565 
566  /* The transformed pixel depth should match the depth now in row_info. */
567  if (png_ptr->transformed_pixel_depth == 0)
568  {
569  png_ptr->transformed_pixel_depth = row_info.pixel_depth;
570  if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)
571  png_error(png_ptr, "sequential row overflow");
572  }
573 
574  else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)
575  png_error(png_ptr, "internal sequential row size calculation error");
576 
577 #ifdef PNG_READ_INTERLACING_SUPPORTED
578  /* Expand interlaced rows to full size */
579  if (png_ptr->interlaced != 0 &&
580  (png_ptr->transformations & PNG_INTERLACE) != 0)
581  {
582  if (png_ptr->pass < 6)
583  png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
584  png_ptr->transformations);
585 
586  if (dsp_row != NULL)
587  png_combine_row(png_ptr, dsp_row, 1/*display*/);
588 
589  if (row != NULL)
590  png_combine_row(png_ptr, row, 0/*row*/);
591  }
592 
593  else
594 #endif
595  {
596  if (row != NULL)
597  png_combine_row(png_ptr, row, -1/*ignored*/);
598 
599  if (dsp_row != NULL)
600  png_combine_row(png_ptr, dsp_row, -1/*ignored*/);
601  }
602  png_read_finish_row(png_ptr);
603 
604  if (png_ptr->read_row_fn != NULL)
605  (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
606 
607 }
void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_uint_32 transformations)
Definition: pngrutil.c:3486
#define PNG_BGR
Definition: pngpriv.h:560
void png_combine_row(png_const_structrp png_ptr, png_bytep row, int display)
Definition: pngrutil.c:3002
Definition: png.h:894
#define PNG_FILTER_VALUE_LAST
Definition: png.h:1617
#define PNG_INVERT_MONO
Definition: pngpriv.h:565
png_uint_32 iwidth
Definition: pngstruct.h:219
png_uint_32 row_number
Definition: pngstruct.h:220
png_uint_32 width
Definition: pngstruct.h:214
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
void png_read_IDAT_data(png_structrp png_ptr, png_bytep output, png_alloc_size_t avail_out)
Definition: pngrutil.c:3942
png_byte transformed_pixel_depth
Definition: pngstruct.h:263
png_byte color_type
Definition: pngstruct.h:252
#define PNG_FLAG_ROW_INIT
Definition: pngpriv.h:607
#define PNG_HAVE_IDAT
Definition: pngpriv.h:544
png_uint_32 width
Definition: png.h:896
#define PNG_FILLER
Definition: pngpriv.h:575
png_byte color_type
Definition: png.h:898
png_bytep prev_row
Definition: pngstruct.h:222
png_byte channels
Definition: png.h:900
png_uint_32 flags
Definition: pngstruct.h:180
png_bytep row_buf
Definition: pngstruct.h:225
#define PNG_SWAP_BYTES
Definition: pngpriv.h:564
#define PNG_PACKSWAP
Definition: pngpriv.h:576
png_byte pixel_depth
Definition: png.h:901
png_read_status_ptr read_row_fn
Definition: pngstruct.h:315
void png_read_start_row(png_structrp png_ptr)
Definition: pngrutil.c:4184
png_byte pixel_depth
Definition: pngstruct.h:255
#define PNG_FLAG_MNG_FILTER_64
Definition: png.h:996
png_size_t rowbytes
Definition: png.h:897
#define PNG_INTERLACE
Definition: pngpriv.h:561
png_byte bit_depth
Definition: pngstruct.h:253
png_byte channels
Definition: pngstruct.h:256
png_uint_32 mode
Definition: pngstruct.h:179
png_byte maximum_pixel_depth
Definition: pngstruct.h:261
#define PNG_SHIFT
Definition: pngpriv.h:563
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
#define PNG_FILTER_VALUE_NONE
Definition: png.h:1612
#define PNG_INTRAPIXEL_DIFFERENCING
Definition: png.h:824
void png_read_finish_row(png_structrp png_ptr)
Definition: pngrutil.c:4119
void png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
Definition: pngrtran.c:4701
#define PNG_ROWBYTES(pixel_bits, width)
Definition: pngpriv.h:660
png_uint_32 transformations
Definition: pngstruct.h:181
png_byte interlaced
Definition: pngstruct.h:249
png_byte pass
Definition: pngstruct.h:250
#define PNG_PACK
Definition: pngpriv.h:562
png_byte bit_depth
Definition: png.h:899
void png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, png_const_bytep prev_row, int filter)
Definition: pngrutil.c:3924
#define png_debug2(l, m, p1, p2)
Definition: pngdebug.h:152
static void png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
Definition: pngread.c:313
PNG_IMPEXP void() png_read_image ( png_structrp  png_ptr,
png_bytepp  image 
)
692 {
693  png_uint_32 i, image_height;
694  int pass, j;
695  png_bytepp rp;
696 
697  png_debug(1, "in png_read_image");
698 
699  if (png_ptr == NULL)
700  return;
701 
702 #ifdef PNG_READ_INTERLACING_SUPPORTED
703  if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
704  {
705  pass = png_set_interlace_handling(png_ptr);
706  /* And make sure transforms are initialized. */
707  png_start_read_image(png_ptr);
708  }
709  else
710  {
711  if (png_ptr->interlaced != 0 &&
712  (png_ptr->transformations & PNG_INTERLACE) == 0)
713  {
714  /* Caller called png_start_read_image or png_read_update_info without
715  * first turning on the PNG_INTERLACE transform. We can fix this here,
716  * but the caller should do it!
717  */
718  png_warning(png_ptr, "Interlace handling should be turned on when "
719  "using png_read_image");
720  /* Make sure this is set correctly */
721  png_ptr->num_rows = png_ptr->height;
722  }
723 
724  /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in
725  * the above error case.
726  */
727  pass = png_set_interlace_handling(png_ptr);
728  }
729 #else
730  if (png_ptr->interlaced)
731  png_error(png_ptr,
732  "Cannot read interlaced image -- interlace handler disabled");
733 
734  pass = 1;
735 #endif
736 
737  image_height=png_ptr->height;
738 
739  for (j = 0; j < pass; j++)
740  {
741  rp = image;
742  for (i = 0; i < image_height; i++)
743  {
744  png_read_row(png_ptr, *rp, NULL);
745  rp++;
746  }
747  }
748 }
uint8_t image[110000000]
Definition: gige_snap.cpp:38
int i
Definition: rw_test.cpp:37
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte ** png_bytepp
Definition: pngconf.h:627
void png_start_read_image(png_structrp png_ptr)
Definition: pngread.c:290
#define PNG_FLAG_ROW_INIT
Definition: pngpriv.h:607
png_uint_32 flags
Definition: pngstruct.h:180
PNG_IMPEXP int() png_set_interlace_handling(png_structrp png_ptr)
Definition: pngtrans.c:99
void png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
Definition: pngread.c:375
#define PNG_INTERLACE
Definition: pngpriv.h:561
png_uint_32 num_rows
Definition: pngstruct.h:216
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
png_uint_32 height
Definition: pngstruct.h:215
png_uint_32 transformations
Definition: pngstruct.h:181
png_byte interlaced
Definition: pngstruct.h:249
PNG_IMPEXP void() png_write_row ( png_structrp  png_ptr,
png_const_bytep  row 
)
682 {
683  /* 1.5.6: moved from png_struct to be a local structure: */
684  png_row_info row_info;
685 
686  if (png_ptr == NULL)
687  return;
688 
689  png_debug2(1, "in png_write_row (row %u, pass %d)",
690  png_ptr->row_number, png_ptr->pass);
691 
692  /* Initialize transformations and other stuff if first time */
693  if (png_ptr->row_number == 0 && png_ptr->pass == 0)
694  {
695  /* Make sure we wrote the header info */
696  if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
697  png_error(png_ptr,
698  "png_write_info was never called before png_write_row");
699 
700  /* Check for transforms that have been set but were defined out */
701 #if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
702  if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
703  png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined");
704 #endif
705 
706 #if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
707  if ((png_ptr->transformations & PNG_FILLER) != 0)
708  png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined");
709 #endif
710 #if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
711  defined(PNG_READ_PACKSWAP_SUPPORTED)
712  if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
713  png_warning(png_ptr,
714  "PNG_WRITE_PACKSWAP_SUPPORTED is not defined");
715 #endif
716 
717 #if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
718  if ((png_ptr->transformations & PNG_PACK) != 0)
719  png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined");
720 #endif
721 
722 #if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
723  if ((png_ptr->transformations & PNG_SHIFT) != 0)
724  png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined");
725 #endif
726 
727 #if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
728  if ((png_ptr->transformations & PNG_BGR) != 0)
729  png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined");
730 #endif
731 
732 #if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
733  if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
734  png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined");
735 #endif
736 
737  png_write_start_row(png_ptr);
738  }
739 
740 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
741  /* If interlaced and not interested in row, return */
742  if (png_ptr->interlaced != 0 &&
743  (png_ptr->transformations & PNG_INTERLACE) != 0)
744  {
745  switch (png_ptr->pass)
746  {
747  case 0:
748  if ((png_ptr->row_number & 0x07) != 0)
749  {
750  png_write_finish_row(png_ptr);
751  return;
752  }
753  break;
754 
755  case 1:
756  if ((png_ptr->row_number & 0x07) != 0 || png_ptr->width < 5)
757  {
758  png_write_finish_row(png_ptr);
759  return;
760  }
761  break;
762 
763  case 2:
764  if ((png_ptr->row_number & 0x07) != 4)
765  {
766  png_write_finish_row(png_ptr);
767  return;
768  }
769  break;
770 
771  case 3:
772  if ((png_ptr->row_number & 0x03) != 0 || png_ptr->width < 3)
773  {
774  png_write_finish_row(png_ptr);
775  return;
776  }
777  break;
778 
779  case 4:
780  if ((png_ptr->row_number & 0x03) != 2)
781  {
782  png_write_finish_row(png_ptr);
783  return;
784  }
785  break;
786 
787  case 5:
788  if ((png_ptr->row_number & 0x01) != 0 || png_ptr->width < 2)
789  {
790  png_write_finish_row(png_ptr);
791  return;
792  }
793  break;
794 
795  case 6:
796  if ((png_ptr->row_number & 0x01) == 0)
797  {
798  png_write_finish_row(png_ptr);
799  return;
800  }
801  break;
802 
803  default: /* error: ignore it */
804  break;
805  }
806  }
807 #endif
808 
809  /* Set up row info for transformations */
810  row_info.color_type = png_ptr->color_type;
811  row_info.width = png_ptr->usr_width;
812  row_info.channels = png_ptr->usr_channels;
813  row_info.bit_depth = png_ptr->usr_bit_depth;
814  row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels);
815  row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
816 
817  png_debug1(3, "row_info->color_type = %d", row_info.color_type);
818  png_debug1(3, "row_info->width = %u", row_info.width);
819  png_debug1(3, "row_info->channels = %d", row_info.channels);
820  png_debug1(3, "row_info->bit_depth = %d", row_info.bit_depth);
821  png_debug1(3, "row_info->pixel_depth = %d", row_info.pixel_depth);
822  png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes);
823 
824  /* Copy user's row into buffer, leaving room for filter byte. */
825  memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
826 
827 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
828  /* Handle interlacing */
829  if (png_ptr->interlaced && png_ptr->pass < 6 &&
830  (png_ptr->transformations & PNG_INTERLACE) != 0)
831  {
832  png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);
833  /* This should always get caught above, but still ... */
834  if (row_info.width == 0)
835  {
836  png_write_finish_row(png_ptr);
837  return;
838  }
839  }
840 #endif
841 
842 #ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
843  /* Handle other transformations */
844  if (png_ptr->transformations != 0)
845  png_do_write_transformations(png_ptr, &row_info);
846 #endif
847 
848  /* At this point the row_info pixel depth must match the 'transformed' depth,
849  * which is also the output depth.
850  */
851  if (row_info.pixel_depth != png_ptr->pixel_depth ||
852  row_info.pixel_depth != png_ptr->transformed_pixel_depth)
853  png_error(png_ptr, "internal write transform logic error");
854 
855 #ifdef PNG_MNG_FEATURES_SUPPORTED
856  /* Write filter_method 64 (intrapixel differencing) only if
857  * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
858  * 2. Libpng did not write a PNG signature (this filter_method is only
859  * used in PNG datastreams that are embedded in MNG datastreams) and
860  * 3. The application called png_permit_mng_features with a mask that
861  * included PNG_FLAG_MNG_FILTER_64 and
862  * 4. The filter_method is 64 and
863  * 5. The color_type is RGB or RGBA
864  */
865  if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
866  (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
867  {
868  /* Intrapixel differencing */
869  png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1);
870  }
871 #endif
872 
873 /* Added at libpng-1.5.10 */
874 #ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
875  /* Check for out-of-range palette index */
876  if (row_info.color_type == PNG_COLOR_TYPE_PALETTE &&
877  png_ptr->num_palette_max >= 0)
878  png_do_check_palette_indexes(png_ptr, &row_info);
879 #endif
880 
881  /* Find a filter if necessary, filter the row and write it out. */
882  png_write_find_filter(png_ptr, &row_info);
883 
884  if (png_ptr->write_row_fn != NULL)
885  (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
886 }
#define PNG_BGR
Definition: pngpriv.h:560
Definition: png.h:894
#define PNG_INVERT_MONO
Definition: pngpriv.h:565
png_uint_32 row_number
Definition: pngstruct.h:220
void png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
Definition: pngwutil.c:2141
png_write_status_ptr write_row_fn
Definition: pngstruct.h:316
png_uint_32 width
Definition: pngstruct.h:214
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:810
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
void png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
Definition: pngtrans.c:684
png_byte transformed_pixel_depth
Definition: pngstruct.h:263
png_byte color_type
Definition: pngstruct.h:252
png_uint_32 width
Definition: png.h:896
#define PNG_FILLER
Definition: pngpriv.h:575
png_byte color_type
Definition: png.h:898
png_byte channels
Definition: png.h:900
void png_write_start_row(png_structrp png_ptr)
Definition: pngwutil.c:1943
png_uint_32 usr_width
Definition: pngstruct.h:217
void png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
Definition: pngwtran.c:500
png_bytep row_buf
Definition: pngstruct.h:225
void png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
Definition: pngwutil.c:2326
#define PNG_SWAP_BYTES
Definition: pngpriv.h:564
#define PNG_PACKSWAP
Definition: pngpriv.h:576
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_byte pixel_depth
Definition: png.h:901
static void png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
Definition: pngwrite.c:617
png_byte pixel_depth
Definition: pngstruct.h:255
#define PNG_FLAG_MNG_FILTER_64
Definition: png.h:996
png_size_t rowbytes
Definition: png.h:897
#define PNG_INTERLACE
Definition: pngpriv.h:561
void png_write_finish_row(png_structrp png_ptr)
Definition: pngwutil.c:2050
png_uint_32 mode
Definition: pngstruct.h:179
#define PNG_WROTE_INFO_BEFORE_PLTE
Definition: pngpriv.h:552
#define PNG_SHIFT
Definition: pngpriv.h:563
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
png_byte usr_bit_depth
Definition: pngstruct.h:254
#define PNG_INTRAPIXEL_DIFFERENCING
Definition: png.h:824
#define PNG_ROWBYTES(pixel_bits, width)
Definition: pngpriv.h:660
png_uint_32 transformations
Definition: pngstruct.h:181
png_byte interlaced
Definition: pngstruct.h:249
png_byte pass
Definition: pngstruct.h:250
#define PNG_PACK
Definition: pngpriv.h:562
png_byte bit_depth
Definition: png.h:899
#define png_debug2(l, m, p1, p2)
Definition: pngdebug.h:152
PNG_IMPEXP void() png_write_rows ( png_structrp  png_ptr,
png_bytepp  row,
png_uint_32  num_rows 
)
564 {
565  png_uint_32 i; /* row counter */
566  png_bytepp rp; /* row pointer */
567 
568  png_debug(1, "in png_write_rows");
569 
570  if (png_ptr == NULL)
571  return;
572 
573  /* Loop through the rows */
574  for (i = 0, rp = row; i < num_rows; i++, rp++)
575  {
576  png_write_row(png_ptr, *rp);
577  }
578 }
int i
Definition: rw_test.cpp:37
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte ** png_bytepp
Definition: pngconf.h:627
void png_write_row(png_structrp png_ptr, png_const_bytep row)
Definition: pngwrite.c:681
int JSAMPARRAY int int num_rows
Definition: jpegint.h:373
PNG_IMPEXP void() png_write_image ( png_structrp  png_ptr,
png_bytepp  image 
)
585 {
586  png_uint_32 i; /* row index */
587  int pass, num_pass; /* pass variables */
588  png_bytepp rp; /* points to current row */
589 
590  if (png_ptr == NULL)
591  return;
592 
593  png_debug(1, "in png_write_image");
594 
595 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
596  /* Initialize interlace handling. If image is not interlaced,
597  * this will set pass to 1
598  */
599  num_pass = png_set_interlace_handling(png_ptr);
600 #else
601  num_pass = 1;
602 #endif
603  /* Loop through passes */
604  for (pass = 0; pass < num_pass; pass++)
605  {
606  /* Loop through image */
607  for (i = 0, rp = image; i < png_ptr->height; i++, rp++)
608  {
609  png_write_row(png_ptr, *rp);
610  }
611  }
612 }
uint8_t image[110000000]
Definition: gige_snap.cpp:38
int i
Definition: rw_test.cpp:37
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte ** png_bytepp
Definition: pngconf.h:627
void png_write_row(png_structrp png_ptr, png_const_bytep row)
Definition: pngwrite.c:681
PNG_IMPEXP int() png_set_interlace_handling(png_structrp png_ptr)
Definition: pngtrans.c:99
png_uint_32 height
Definition: pngstruct.h:215
PNG_IMPEXP void() png_write_end ( png_structrp  png_ptr,
png_inforp  info_ptr 
)
348 {
349  png_debug(1, "in png_write_end");
350 
351  if (png_ptr == NULL)
352  return;
353 
354  if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
355  png_error(png_ptr, "No IDATs written into file");
356 
357 #ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
358  if (png_ptr->num_palette_max > png_ptr->num_palette)
359  png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
360 #endif
361 
362  /* See if user wants us to write information chunks */
363  if (info_ptr != NULL)
364  {
365 #ifdef PNG_WRITE_TEXT_SUPPORTED
366  int i; /* local index variable */
367 #endif
368 #ifdef PNG_WRITE_tIME_SUPPORTED
369  /* Check to see if user has supplied a time chunk */
370  if ((info_ptr->valid & PNG_INFO_tIME) != 0 &&
371  (png_ptr->mode & PNG_WROTE_tIME) == 0)
372  png_write_tIME(png_ptr, &(info_ptr->mod_time));
373 
374 #endif
375 #ifdef PNG_WRITE_TEXT_SUPPORTED
376  /* Loop through comment chunks */
377  for (i = 0; i < info_ptr->num_text; i++)
378  {
379  png_debug2(2, "Writing trailer text chunk %d, type %d", i,
380  info_ptr->text[i].compression);
381  /* An internationalized chunk? */
382  if (info_ptr->text[i].compression > 0)
383  {
384 #ifdef PNG_WRITE_iTXt_SUPPORTED
385  /* Write international chunk */
386  png_write_iTXt(png_ptr,
387  info_ptr->text[i].compression,
388  info_ptr->text[i].key,
389  info_ptr->text[i].lang,
390  info_ptr->text[i].lang_key,
391  info_ptr->text[i].text);
392  /* Mark this chunk as written */
393  if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
394  info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
395  else
396  info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
397 #else
398  png_warning(png_ptr, "Unable to write international text");
399 #endif
400  }
401 
402  else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
403  {
404 #ifdef PNG_WRITE_zTXt_SUPPORTED
405  /* Write compressed chunk */
406  png_write_zTXt(png_ptr, info_ptr->text[i].key,
407  info_ptr->text[i].text, info_ptr->text[i].compression);
408  /* Mark this chunk as written */
409  info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
410 #else
411  png_warning(png_ptr, "Unable to write compressed text");
412 #endif
413  }
414 
415  else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
416  {
417 #ifdef PNG_WRITE_tEXt_SUPPORTED
418  /* Write uncompressed chunk */
419  png_write_tEXt(png_ptr, info_ptr->text[i].key,
420  info_ptr->text[i].text, 0);
421  /* Mark this chunk as written */
422  info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
423 #else
424  png_warning(png_ptr, "Unable to write uncompressed text");
425 #endif
426  }
427  }
428 #endif
429 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
430  write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT);
431 #endif
432  }
433 
434  png_ptr->mode |= PNG_AFTER_IDAT;
435 
436  /* Write end of PNG file */
437  png_write_IEND(png_ptr);
438 
439  /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03,
440  * and restored again in libpng-1.2.30, may cause some applications that
441  * do not set png_ptr->output_flush_fn to crash. If your application
442  * experiences a problem, please try building libpng with
443  * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to
444  * png-mng-implement at lists.sf.net .
445  */
446 #ifdef PNG_WRITE_FLUSH_SUPPORTED
447 # ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED
448  png_flush(png_ptr);
449 # endif
450 #endif
451 }
void png_write_IEND(png_structrp png_ptr)
Definition: pngwutil.c:1148
void png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
Definition: pngwutil.c:1916
#define PNG_INFO_tIME
Definition: png.h:882
void png_flush(png_structrp png_ptr)
Definition: pngwio.c:71
int i
Definition: rw_test.cpp:37
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_debug(l, m)
Definition: pngdebug.h:146
void png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, png_const_charp lang, png_const_charp lang_key, png_const_charp text)
Definition: pngwutil.c:1677
#define PNG_TEXT_COMPRESSION_NONE_WR
Definition: png.h:727
static void write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, unsigned int where)
Definition: pngwrite.c:24
#define PNG_HAVE_IDAT
Definition: pngpriv.h:544
#define PNG_TEXT_COMPRESSION_zTXt
Definition: png.h:730
#define PNG_TEXT_COMPRESSION_NONE
Definition: png.h:729
png_uint_16 num_palette
Definition: pngstruct.h:239
#define PNG_AFTER_IDAT
Definition: png.h:787
#define PNG_WROTE_tIME
Definition: pngpriv.h:551
#define PNG_TEXT_COMPRESSION_zTXt_WR
Definition: png.h:728
void png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, int compression)
Definition: pngwutil.c:1626
png_uint_32 valid
Definition: pnginfo.h:61
png_uint_32 mode
Definition: pngstruct.h:179
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
void png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, png_size_t text_len)
Definition: pngwutil.c:1583
PNG_IMPEXP void() png_benign_error(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:362
#define png_debug2(l, m, p1, p2)
Definition: pngdebug.h:152
PNG_IMPEXP void() png_read_end ( png_structrp  png_ptr,
png_inforp  info_ptr 
)
758 {
759 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
760  int keep;
761 #endif
762 
763  png_debug(1, "in png_read_end");
764 
765  if (png_ptr == NULL)
766  return;
767 
768  /* If png_read_end is called in the middle of reading the rows there may
769  * still be pending IDAT data and an owned zstream. Deal with this here.
770  */
771 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
772  if (png_chunk_unknown_handling(png_ptr, png_IDAT) == 0)
773 #endif
774  png_read_finish_IDAT(png_ptr);
775 
776 #ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
777  /* Report invalid palette index; added at libng-1.5.10 */
778  if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
779  png_ptr->num_palette_max > png_ptr->num_palette)
780  png_benign_error(png_ptr, "Read palette index exceeding num_palette");
781 #endif
782 
783  do
784  {
785  png_uint_32 length = png_read_chunk_header(png_ptr);
786  png_uint_32 chunk_name = png_ptr->chunk_name;
787 
788  if (chunk_name == png_IEND)
789  png_handle_IEND(png_ptr, info_ptr, length);
790 
791  else if (chunk_name == png_IHDR)
792  png_handle_IHDR(png_ptr, info_ptr, length);
793 
794  else if (info_ptr == NULL)
795  png_crc_finish(png_ptr, length);
796 
797 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
798  else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
799  {
800  if (chunk_name == png_IDAT)
801  {
802  if ((length > 0) ||
803  (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
804  png_benign_error(png_ptr, "Too many IDATs found");
805  }
806  png_handle_unknown(png_ptr, info_ptr, length, keep);
807  if (chunk_name == png_PLTE)
808  png_ptr->mode |= PNG_HAVE_PLTE;
809  }
810 #endif
811 
812  else if (chunk_name == png_IDAT)
813  {
814  /* Zero length IDATs are legal after the last IDAT has been
815  * read, but not after other chunks have been read.
816  */
817  if ((length > 0) ||
818  (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
819  png_benign_error(png_ptr, "Too many IDATs found");
820 
821  png_crc_finish(png_ptr, length);
822  }
823  else if (chunk_name == png_PLTE)
824  png_handle_PLTE(png_ptr, info_ptr, length);
825 
826 #ifdef PNG_READ_bKGD_SUPPORTED
827  else if (chunk_name == png_bKGD)
828  png_handle_bKGD(png_ptr, info_ptr, length);
829 #endif
830 
831 #ifdef PNG_READ_cHRM_SUPPORTED
832  else if (chunk_name == png_cHRM)
833  png_handle_cHRM(png_ptr, info_ptr, length);
834 #endif
835 
836 #ifdef PNG_READ_gAMA_SUPPORTED
837  else if (chunk_name == png_gAMA)
838  png_handle_gAMA(png_ptr, info_ptr, length);
839 #endif
840 
841 #ifdef PNG_READ_hIST_SUPPORTED
842  else if (chunk_name == png_hIST)
843  png_handle_hIST(png_ptr, info_ptr, length);
844 #endif
845 
846 #ifdef PNG_READ_oFFs_SUPPORTED
847  else if (chunk_name == png_oFFs)
848  png_handle_oFFs(png_ptr, info_ptr, length);
849 #endif
850 
851 #ifdef PNG_READ_pCAL_SUPPORTED
852  else if (chunk_name == png_pCAL)
853  png_handle_pCAL(png_ptr, info_ptr, length);
854 #endif
855 
856 #ifdef PNG_READ_sCAL_SUPPORTED
857  else if (chunk_name == png_sCAL)
858  png_handle_sCAL(png_ptr, info_ptr, length);
859 #endif
860 
861 #ifdef PNG_READ_pHYs_SUPPORTED
862  else if (chunk_name == png_pHYs)
863  png_handle_pHYs(png_ptr, info_ptr, length);
864 #endif
865 
866 #ifdef PNG_READ_sBIT_SUPPORTED
867  else if (chunk_name == png_sBIT)
868  png_handle_sBIT(png_ptr, info_ptr, length);
869 #endif
870 
871 #ifdef PNG_READ_sRGB_SUPPORTED
872  else if (chunk_name == png_sRGB)
873  png_handle_sRGB(png_ptr, info_ptr, length);
874 #endif
875 
876 #ifdef PNG_READ_iCCP_SUPPORTED
877  else if (chunk_name == png_iCCP)
878  png_handle_iCCP(png_ptr, info_ptr, length);
879 #endif
880 
881 #ifdef PNG_READ_sPLT_SUPPORTED
882  else if (chunk_name == png_sPLT)
883  png_handle_sPLT(png_ptr, info_ptr, length);
884 #endif
885 
886 #ifdef PNG_READ_tEXt_SUPPORTED
887  else if (chunk_name == png_tEXt)
888  png_handle_tEXt(png_ptr, info_ptr, length);
889 #endif
890 
891 #ifdef PNG_READ_tIME_SUPPORTED
892  else if (chunk_name == png_tIME)
893  png_handle_tIME(png_ptr, info_ptr, length);
894 #endif
895 
896 #ifdef PNG_READ_tRNS_SUPPORTED
897  else if (chunk_name == png_tRNS)
898  png_handle_tRNS(png_ptr, info_ptr, length);
899 #endif
900 
901 #ifdef PNG_READ_zTXt_SUPPORTED
902  else if (chunk_name == png_zTXt)
903  png_handle_zTXt(png_ptr, info_ptr, length);
904 #endif
905 
906 #ifdef PNG_READ_iTXt_SUPPORTED
907  else if (chunk_name == png_iTXt)
908  png_handle_iTXt(png_ptr, info_ptr, length);
909 #endif
910 
911  else
912  png_handle_unknown(png_ptr, info_ptr, length,
914  } while ((png_ptr->mode & PNG_HAVE_IEND) == 0);
915 }
void png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1179
void png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length, int keep)
Definition: pngrutil.c:2765
#define png_PLTE
Definition: pngpriv.h:755
#define png_sCAL
Definition: pngpriv.h:770
#define png_iTXt
Definition: pngpriv.h:765
#define png_bKGD
Definition: pngpriv.h:756
void png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2447
#define png_tRNS
Definition: pngpriv.h:776
#define png_sRGB
Definition: pngpriv.h:772
void png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2098
void png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1954
#define png_iCCP
Definition: pngpriv.h:764
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:810
void png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2005
#define png_IEND
Definition: pngpriv.h:753
void png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1061
void png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1854
#define png_sPLT
Definition: pngpriv.h:771
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_HAVE_PLTE
Definition: png.h:786
void png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1251
void png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2320
void png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2366
#define PNG_HANDLE_CHUNK_AS_DEFAULT
Definition: png.h:2497
void png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2051
png_byte color_type
Definition: pngstruct.h:252
png_uint_32 png_read_chunk_header(png_structrp png_ptr)
Definition: pngrutil.c:150
int png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
Definition: pngrutil.c:202
png_uint_32 chunk_name
Definition: pngstruct.h:221
#define png_IHDR
Definition: pngpriv.h:754
#define png_tEXt
Definition: pngpriv.h:774
void png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1751
#define PNG_HAVE_CHUNK_AFTER_IDAT
Definition: pngpriv.h:555
png_uint_16 num_palette
Definition: pngstruct.h:239
void png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1099
#define png_IDAT
Definition: pngpriv.h:752
#define png_oFFs
Definition: pngpriv.h:766
#define png_gAMA
Definition: pngpriv.h:759
#define png_pCAL
Definition: pngpriv.h:767
void png_read_finish_IDAT(png_structrp png_ptr)
Definition: pngrutil.c:4071
png_uint_32 length
Definition: png.c:2173
#define png_cHRM
Definition: pngpriv.h:757
png_uint_32 mode
Definition: pngstruct.h:179
#define PNG_HAVE_IEND
Definition: pngpriv.h:546
void png_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1041
void png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2556
void png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:793
int png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name)
Definition: png.c:919
#define png_sBIT
Definition: pngpriv.h:769
void png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1574
#define png_hIST
Definition: pngpriv.h:763
void png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:2227
#define png_pHYs
Definition: pngpriv.h:768
void png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:1301
#define png_tIME
Definition: pngpriv.h:775
void png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
Definition: pngrutil.c:867
#define png_zTXt
Definition: pngpriv.h:777
PNG_IMPEXP void() png_benign_error(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:362
PNG_IMPEXP void() png_destroy_info_struct ( png_const_structrp  png_ptr,
png_infopp  info_ptr_ptr 
)
360 {
361  png_inforp info_ptr = NULL;
362 
363  png_debug(1, "in png_destroy_info_struct");
364 
365  if (png_ptr == NULL)
366  return;
367 
368  if (info_ptr_ptr != NULL)
369  info_ptr = *info_ptr_ptr;
370 
371  if (info_ptr != NULL)
372  {
373  /* Do this first in case of an error below; if the app implements its own
374  * memory management this can lead to png_free calling png_error, which
375  * will abort this routine and return control to the app error handler.
376  * An infinite loop may result if it then tries to free the same info
377  * ptr.
378  */
379  *info_ptr_ptr = NULL;
380 
381  png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
382  memset(info_ptr, 0, (sizeof *info_ptr));
383  png_free(png_ptr, info_ptr);
384  }
385 }
#define png_debug(l, m)
Definition: pngdebug.h:146
Definition: pnginfo.h:56
void png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, int num)
Definition: png.c:442
#define PNG_FREE_ALL
Definition: png.h:1925
PNG_IMPEXP void() png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:229
PNG_IMPEXP void() png_destroy_read_struct ( png_structpp  png_ptr_ptr,
png_infopp  info_ptr_ptr,
png_infopp  end_info_ptr_ptr 
)
987 {
988  png_structrp png_ptr = NULL;
989 
990  png_debug(1, "in png_destroy_read_struct");
991 
992  if (png_ptr_ptr != NULL)
993  png_ptr = *png_ptr_ptr;
994 
995  if (png_ptr == NULL)
996  return;
997 
998  /* libpng 1.6.0: use the API to destroy info structs to ensure consistent
999  * behavior. Prior to 1.6.0 libpng did extra 'info' destruction in this API.
1000  * The extra was, apparently, unnecessary yet this hides memory leak bugs.
1001  */
1002  png_destroy_info_struct(png_ptr, end_info_ptr_ptr);
1003  png_destroy_info_struct(png_ptr, info_ptr_ptr);
1004 
1005  *png_ptr_ptr = NULL;
1006  png_read_destroy(png_ptr);
1007  png_destroy_png_struct(png_ptr);
1008 }
static void png_read_destroy(png_structrp png_ptr)
Definition: pngread.c:920
#define png_debug(l, m)
Definition: pngdebug.h:146
Definition: pngstruct.h:144
void png_destroy_png_struct(png_structrp png_ptr)
Definition: pngmem.c:25
void png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)
Definition: png.c:359
PNG_IMPEXP void() png_destroy_write_struct ( png_structpp  png_ptr_ptr,
png_infopp  info_ptr_ptr 
)
980 {
981  png_debug(1, "in png_destroy_write_struct");
982 
983  if (png_ptr_ptr != NULL)
984  {
985  png_structrp png_ptr = *png_ptr_ptr;
986 
987  if (png_ptr != NULL) /* added in libpng 1.6.0 */
988  {
989  png_destroy_info_struct(png_ptr, info_ptr_ptr);
990 
991  *png_ptr_ptr = NULL;
992  png_write_destroy(png_ptr);
993  png_destroy_png_struct(png_ptr);
994  }
995  }
996 }
#define png_debug(l, m)
Definition: pngdebug.h:146
Definition: pngstruct.h:144
static void png_write_destroy(png_structrp png_ptr)
Definition: pngwrite.c:926
void png_destroy_png_struct(png_structrp png_ptr)
Definition: pngmem.c:25
void png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)
Definition: png.c:359
PNG_IMPEXP void() png_set_crc_action ( png_structrp  png_ptr,
int  crit_action,
int  ancil_action 
)
26 {
27  png_debug(1, "in png_set_crc_action");
28 
29  if (png_ptr == NULL)
30  return;
31 
32  /* Tell libpng how we react to CRC errors in critical chunks */
33  switch (crit_action)
34  {
35  case PNG_CRC_NO_CHANGE: /* Leave setting as is */
36  break;
37 
38  case PNG_CRC_WARN_USE: /* Warn/use data */
39  png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
40  png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE;
41  break;
42 
43  case PNG_CRC_QUIET_USE: /* Quiet/use data */
44  png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
45  png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE |
47  break;
48 
49  case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */
50  png_warning(png_ptr,
51  "Can't discard critical data on CRC error");
52  case PNG_CRC_ERROR_QUIT: /* Error/quit */
53 
54  case PNG_CRC_DEFAULT:
55  default:
56  png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
57  break;
58  }
59 
60  /* Tell libpng how we react to CRC errors in ancillary chunks */
61  switch (ancil_action)
62  {
63  case PNG_CRC_NO_CHANGE: /* Leave setting as is */
64  break;
65 
66  case PNG_CRC_WARN_USE: /* Warn/use data */
69  break;
70 
71  case PNG_CRC_QUIET_USE: /* Quiet/use data */
73  png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE |
75  break;
76 
77  case PNG_CRC_ERROR_QUIT: /* Error/quit */
80  break;
81 
82  case PNG_CRC_WARN_DISCARD: /* Warn/discard data */
83 
84  case PNG_CRC_DEFAULT:
85  default:
87  break;
88  }
89 }
#define PNG_CRC_NO_CHANGE
Definition: png.h:1579
#define PNG_CRC_DEFAULT
Definition: png.h:1574
#define PNG_CRC_WARN_USE
Definition: png.h:1577
#define PNG_CRC_WARN_DISCARD
Definition: png.h:1576
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_FLAG_CRC_ANCILLARY_USE
Definition: pngpriv.h:609
#define PNG_FLAG_CRC_CRITICAL_IGNORE
Definition: pngpriv.h:612
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_CRC_QUIET_USE
Definition: png.h:1578
#define PNG_FLAG_CRC_CRITICAL_USE
Definition: pngpriv.h:611
#define PNG_FLAG_CRC_ANCILLARY_NOWARN
Definition: pngpriv.h:610
#define PNG_CRC_ERROR_QUIT
Definition: png.h:1575
#define PNG_FLAG_CRC_ANCILLARY_MASK
Definition: pngpriv.h:633
#define PNG_FLAG_CRC_CRITICAL_MASK
Definition: pngpriv.h:636
PNG_IMPEXP void() png_set_filter ( png_structrp  png_ptr,
int  method,
int  filters 
)
1001 {
1002  png_debug(1, "in png_set_filter");
1003 
1004  if (png_ptr == NULL)
1005  return;
1006 
1007 #ifdef PNG_MNG_FEATURES_SUPPORTED
1008  if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
1009  (method == PNG_INTRAPIXEL_DIFFERENCING))
1010  method = PNG_FILTER_TYPE_BASE;
1011 
1012 #endif
1013  if (method == PNG_FILTER_TYPE_BASE)
1014  {
1015  switch (filters & (PNG_ALL_FILTERS | 0x07))
1016  {
1017 #ifdef PNG_WRITE_FILTER_SUPPORTED
1018  case 5:
1019  case 6:
1020  case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
1021  /* FALL THROUGH */
1022 #endif /* WRITE_FILTER */
1023  case PNG_FILTER_VALUE_NONE:
1024  png_ptr->do_filter = PNG_FILTER_NONE; break;
1025 
1026 #ifdef PNG_WRITE_FILTER_SUPPORTED
1027  case PNG_FILTER_VALUE_SUB:
1028  png_ptr->do_filter = PNG_FILTER_SUB; break;
1029 
1030  case PNG_FILTER_VALUE_UP:
1031  png_ptr->do_filter = PNG_FILTER_UP; break;
1032 
1033  case PNG_FILTER_VALUE_AVG:
1034  png_ptr->do_filter = PNG_FILTER_AVG; break;
1035 
1037  png_ptr->do_filter = PNG_FILTER_PAETH; break;
1038 
1039  default:
1040  png_ptr->do_filter = (png_byte)filters; break;
1041 #else
1042  default:
1043  png_app_error(png_ptr, "Unknown row filter for method 0");
1044 #endif /* WRITE_FILTER */
1045  }
1046 
1047  /* If we have allocated the row_buf, this means we have already started
1048  * with the image and we should have allocated all of the filter buffers
1049  * that have been selected. If prev_row isn't already allocated, then
1050  * it is too late to start using the filters that need it, since we
1051  * will be missing the data in the previous row. If an application
1052  * wants to start and stop using particular filters during compression,
1053  * it should start out with all of the filters, and then add and
1054  * remove them after the start of compression.
1055  */
1056  if (png_ptr->row_buf != NULL)
1057  {
1058 #ifdef PNG_WRITE_FILTER_SUPPORTED
1059  if ((png_ptr->do_filter & PNG_FILTER_SUB) != 0 &&
1060  png_ptr->sub_row == NULL)
1061  {
1062  png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
1063  (png_ptr->rowbytes + 1));
1064  png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
1065  }
1066 
1067  if ((png_ptr->do_filter & PNG_FILTER_UP) != 0 &&
1068  png_ptr->up_row == NULL)
1069  {
1070  if (png_ptr->prev_row == NULL)
1071  {
1072  png_warning(png_ptr, "Can't add Up filter after starting");
1073  png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
1074  ~PNG_FILTER_UP);
1075  }
1076 
1077  else
1078  {
1079  png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
1080  (png_ptr->rowbytes + 1));
1081  png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
1082  }
1083  }
1084 
1085  if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0 &&
1086  png_ptr->avg_row == NULL)
1087  {
1088  if (png_ptr->prev_row == NULL)
1089  {
1090  png_warning(png_ptr, "Can't add Average filter after starting");
1091  png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
1092  ~PNG_FILTER_AVG);
1093  }
1094 
1095  else
1096  {
1097  png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
1098  (png_ptr->rowbytes + 1));
1099  png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
1100  }
1101  }
1102 
1103  if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0 &&
1104  png_ptr->paeth_row == NULL)
1105  {
1106  if (png_ptr->prev_row == NULL)
1107  {
1108  png_warning(png_ptr, "Can't add Paeth filter after starting");
1109  png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
1110  }
1111 
1112  else
1113  {
1114  png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
1115  (png_ptr->rowbytes + 1));
1116  png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
1117  }
1118  }
1119 
1120  if (png_ptr->do_filter == PNG_NO_FILTERS)
1121 #endif /* WRITE_FILTER */
1122  png_ptr->do_filter = PNG_FILTER_NONE;
1123  }
1124  }
1125  else
1126  png_error(png_ptr, "Unknown custom filter method");
1127 }
#define PNG_FILTER_VALUE_AVG
Definition: png.h:1615
PNG_IMPEXP png_voidp() png_malloc(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:169
#define PNG_FILTER_PAETH
Definition: png.h:1605
#define PNG_NO_FILTERS
Definition: png.h:1600
#define PNG_FILTER_SUB
Definition: png.h:1602
png_byte * png_bytep
Definition: pngconf.h:600
#define PNG_FILTER_VALUE_PAETH
Definition: png.h:1616
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte do_filter
Definition: pngstruct.h:251
png_bytep prev_row
Definition: pngstruct.h:222
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
#define PNG_FILTER_VALUE_SUB
Definition: png.h:1613
png_bytep row_buf
Definition: pngstruct.h:225
#define PNG_ALL_FILTERS
Definition: png.h:1606
#define PNG_FILTER_UP
Definition: png.h:1603
#define PNG_FILTER_AVG
Definition: png.h:1604
#define PNG_FILTER_VALUE_UP
Definition: png.h:1614
#define PNG_FLAG_MNG_FILTER_64
Definition: png.h:996
#define PNG_FILTER_TYPE_BASE
Definition: png.h:823
png_size_t rowbytes
Definition: pngstruct.h:218
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
#define PNG_FILTER_VALUE_NONE
Definition: png.h:1612
#define PNG_INTRAPIXEL_DIFFERENCING
Definition: png.h:824
#define PNG_FILTER_NONE
Definition: png.h:1601
PNG_IMPEXP void() png_set_filter_heuristics ( png_structrp  png_ptr,
int  heuristic_method,
int  num_weights,
png_const_doublep  filter_weights,
png_const_doublep  filter_costs 
)
1258 {
1259  png_debug(1, "in png_set_filter_heuristics");
1260 
1261  /* The internal API allocates all the arrays and ensures that the elements of
1262  * those arrays are set to the default value.
1263  */
1264  if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
1265  return;
1266 
1267  /* If using the weighted method copy in the weights. */
1268  if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
1269  {
1270  int i;
1271  for (i = 0; i < num_weights; i++)
1272  {
1273  if (filter_weights[i] <= 0.0)
1274  {
1275  png_ptr->inv_filter_weights[i] =
1276  png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
1277  }
1278 
1279  else
1280  {
1281  png_ptr->inv_filter_weights[i] =
1282  (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5);
1283 
1284  png_ptr->filter_weights[i] =
1285  (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5);
1286  }
1287  }
1288 
1289  /* Here is where we set the relative costs of the different filters. We
1290  * should take the desired compression level into account when setting
1291  * the costs, so that Paeth, for instance, has a high relative cost at low
1292  * compression levels, while it has a lower relative cost at higher
1293  * compression settings. The filter types are in order of increasing
1294  * relative cost, so it would be possible to do this with an algorithm.
1295  */
1296  for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0)
1297  {
1298  png_ptr->inv_filter_costs[i] =
1299  (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5);
1300 
1301  png_ptr->filter_costs[i] =
1302  (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5);
1303  }
1304  }
1305 }
#define PNG_FILTER_HEURISTIC_WEIGHTED
Definition: png.h:1662
int i
Definition: rw_test.cpp:37
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_COST_FACTOR
Definition: pngpriv.h:598
#define PNG_WEIGHT_FACTOR
Definition: pngpriv.h:597
static int png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method, int num_weights)
Definition: pngwrite.c:1172
PNG_IMPEXP void() png_set_filter_heuristics_fixed ( png_structrp  png_ptr,
int  heuristic_method,
int  num_weights,
png_const_fixed_point_p  filter_weights,
png_const_fixed_point_p  filter_costs 
)
1313 {
1314  png_debug(1, "in png_set_filter_heuristics_fixed");
1315 
1316  /* The internal API allocates all the arrays and ensures that the elements of
1317  * those arrays are set to the default value.
1318  */
1319  if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
1320  return;
1321 
1322  /* If using the weighted method copy in the weights. */
1323  if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
1324  {
1325  int i;
1326  for (i = 0; i < num_weights; i++)
1327  {
1328  if (filter_weights[i] <= 0)
1329  {
1330  png_ptr->inv_filter_weights[i] =
1331  png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
1332  }
1333 
1334  else
1335  {
1336  png_ptr->inv_filter_weights[i] = (png_uint_16)
1337  ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1);
1338 
1339  png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR*
1340  PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]);
1341  }
1342  }
1343 
1344  /* Here is where we set the relative costs of the different filters. We
1345  * should take the desired compression level into account when setting
1346  * the costs, so that Paeth, for instance, has a high relative cost at low
1347  * compression levels, while it has a lower relative cost at higher
1348  * compression settings. The filter types are in order of increasing
1349  * relative cost, so it would be possible to do this with an algorithm.
1350  */
1351  for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
1352  if (filter_costs[i] >= PNG_FP_1)
1353  {
1354  png_uint_32 tmp;
1355 
1356  /* Use a 32 bit unsigned temporary here because otherwise the
1357  * intermediate value will be a 32 bit *signed* integer (ANSI rules)
1358  * and this will get the wrong answer on division.
1359  */
1360  tmp = PNG_COST_FACTOR*PNG_FP_1 + (filter_costs[i]/2);
1361  tmp /= filter_costs[i];
1362 
1363  png_ptr->inv_filter_costs[i] = (png_uint_16)tmp;
1364 
1365  tmp = PNG_COST_FACTOR * filter_costs[i] + PNG_FP_HALF;
1366  tmp /= PNG_FP_1;
1367 
1368  png_ptr->filter_costs[i] = (png_uint_16)tmp;
1369  }
1370  }
1371 }
#define PNG_FILTER_VALUE_LAST
Definition: png.h:1617
#define PNG_FILTER_HEURISTIC_WEIGHTED
Definition: png.h:1662
int i
Definition: rw_test.cpp:37
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_FP_HALF
Definition: png.h:798
#define PNG_COST_FACTOR
Definition: pngpriv.h:598
#define PNG_WEIGHT_FACTOR
Definition: pngpriv.h:597
#define PNG_FP_1
Definition: png.h:797
static int png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method, int num_weights)
Definition: pngwrite.c:1172
PNG_IMPEXP void() png_set_compression_level ( png_structrp  png_ptr,
int  level 
)
1377 {
1378  png_debug(1, "in png_set_compression_level");
1379 
1380  if (png_ptr == NULL)
1381  return;
1382 
1383  png_ptr->zlib_level = level;
1384 }
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP void() png_set_compression_mem_level ( png_structrp  png_ptr,
int  mem_level 
)
1388 {
1389  png_debug(1, "in png_set_compression_mem_level");
1390 
1391  if (png_ptr == NULL)
1392  return;
1393 
1394  png_ptr->zlib_mem_level = mem_level;
1395 }
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP void() png_set_compression_strategy ( png_structrp  png_ptr,
int  strategy 
)
1399 {
1400  png_debug(1, "in png_set_compression_strategy");
1401 
1402  if (png_ptr == NULL)
1403  return;
1404 
1405  /* The flag setting here prevents the libpng dynamic selection of strategy.
1406  */
1408  png_ptr->zlib_strategy = strategy;
1409 }
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 flags
Definition: pngstruct.h:180
const JsonParse strategy
Definition: json11.cpp:364
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY
Definition: pngpriv.h:601
PNG_IMPEXP void() png_set_compression_window_bits ( png_structrp  png_ptr,
int  window_bits 
)
1416 {
1417  if (png_ptr == NULL)
1418  return;
1419 
1420  /* Prior to 1.6.0 this would warn but then set the window_bits value, this
1421  * meant that negative window bits values could be selected which would cause
1422  * libpng to write a non-standard PNG file with raw deflate or gzip
1423  * compressed IDAT or ancillary chunks. Such files can be read and there is
1424  * no warning on read, so this seems like a very bad idea.
1425  */
1426  if (window_bits > 15)
1427  {
1428  png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
1429  window_bits = 15;
1430  }
1431 
1432  else if (window_bits < 8)
1433  {
1434  png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
1435  window_bits = 8;
1436  }
1437 
1438  png_ptr->zlib_window_bits = window_bits;
1439 }
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
PNG_IMPEXP void() png_set_compression_method ( png_structrp  png_ptr,
int  method 
)
1443 {
1444  png_debug(1, "in png_set_compression_method");
1445 
1446  if (png_ptr == NULL)
1447  return;
1448 
1449  /* This would produce an invalid PNG file if it worked, but it doesn't and
1450  * deflate will fault it, so it is harmless to just warn here.
1451  */
1452  if (method != 8)
1453  png_warning(png_ptr, "Only compression method 8 is supported by PNG");
1454 
1455  png_ptr->zlib_method = method;
1456 }
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP void() png_set_text_compression_level ( png_structrp  png_ptr,
int  level 
)
1462 {
1463  png_debug(1, "in png_set_text_compression_level");
1464 
1465  if (png_ptr == NULL)
1466  return;
1467 
1468  png_ptr->zlib_text_level = level;
1469 }
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP void() png_set_text_compression_mem_level ( png_structrp  png_ptr,
int  mem_level 
)
1473 {
1474  png_debug(1, "in png_set_text_compression_mem_level");
1475 
1476  if (png_ptr == NULL)
1477  return;
1478 
1479  png_ptr->zlib_text_mem_level = mem_level;
1480 }
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP void() png_set_text_compression_strategy ( png_structrp  png_ptr,
int  strategy 
)
1484 {
1485  png_debug(1, "in png_set_text_compression_strategy");
1486 
1487  if (png_ptr == NULL)
1488  return;
1489 
1490  png_ptr->zlib_text_strategy = strategy;
1491 }
#define png_debug(l, m)
Definition: pngdebug.h:146
const JsonParse strategy
Definition: json11.cpp:364
PNG_IMPEXP void() png_set_text_compression_window_bits ( png_structrp  png_ptr,
int  window_bits 
)
1498 {
1499  if (png_ptr == NULL)
1500  return;
1501 
1502  if (window_bits > 15)
1503  {
1504  png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
1505  window_bits = 15;
1506  }
1507 
1508  else if (window_bits < 8)
1509  {
1510  png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
1511  window_bits = 8;
1512  }
1513 
1514  png_ptr->zlib_text_window_bits = window_bits;
1515 }
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
PNG_IMPEXP void() png_set_text_compression_method ( png_structrp  png_ptr,
int  method 
)
1519 {
1520  png_debug(1, "in png_set_text_compression_method");
1521 
1522  if (png_ptr == NULL)
1523  return;
1524 
1525  if (method != 8)
1526  png_warning(png_ptr, "Only compression method 8 is supported by PNG");
1527 
1528  png_ptr->zlib_text_method = method;
1529 }
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP void() png_init_io ( png_structrp  png_ptr,
png_FILE_p  fp 
)
659 {
660  png_debug(1, "in png_init_io");
661 
662  if (png_ptr == NULL)
663  return;
664 
665  png_ptr->io_ptr = (png_voidp)fp;
666 }
void * png_voidp
Definition: pngconf.h:598
#define png_debug(l, m)
Definition: pngdebug.h:146
png_voidp io_ptr
Definition: pngstruct.h:159
FILE * fp
Definition: rw_test.cpp:38
PNG_IMPEXP void() png_set_error_fn ( png_structrp  png_ptr,
png_voidp  error_ptr,
png_error_ptr  error_fn,
png_error_ptr  warning_fn 
)
837 {
838  if (png_ptr == NULL)
839  return;
840 
841  png_ptr->error_ptr = error_ptr;
842  png_ptr->error_fn = error_fn;
843 #ifdef PNG_WARNINGS_SUPPORTED
844  png_ptr->warning_fn = warning_fn;
845 #else
846  PNG_UNUSED(warning_fn)
847 #endif
848 }
png_error_ptr error_fn
Definition: pngstruct.h:152
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
png_voidp error_ptr
Definition: pngstruct.h:156
PNG_IMPEXP png_voidp() png_get_error_ptr ( png_const_structrp  png_ptr)
857 {
858  if (png_ptr == NULL)
859  return NULL;
860 
861  return ((png_voidp)png_ptr->error_ptr);
862 }
void * png_voidp
Definition: pngconf.h:598
png_voidp error_ptr
Definition: pngstruct.h:156
PNG_IMPEXP void() png_set_write_fn ( png_structrp  png_ptr,
png_voidp  io_ptr,
png_rw_ptr  write_data_fn,
png_flush_ptr  output_flush_fn 
)
124 {
125  if (png_ptr == NULL)
126  return;
127 
128  png_ptr->io_ptr = io_ptr;
129 
130 #ifdef PNG_STDIO_SUPPORTED
131  if (write_data_fn != NULL)
132  png_ptr->write_data_fn = write_data_fn;
133 
134  else
136 #else
137  png_ptr->write_data_fn = write_data_fn;
138 #endif
139 
140 #ifdef PNG_WRITE_FLUSH_SUPPORTED
141 # ifdef PNG_STDIO_SUPPORTED
142 
143  if (output_flush_fn != NULL)
144  png_ptr->output_flush_fn = output_flush_fn;
145 
146  else
147  png_ptr->output_flush_fn = png_default_flush;
148 
149 # else
150  png_ptr->output_flush_fn = output_flush_fn;
151 # endif
152 #else
153  PNG_UNUSED(output_flush_fn)
154 #endif /* WRITE_FLUSH */
155 
156 #ifdef PNG_READ_SUPPORTED
157  /* It is an error to read while writing a png file */
158  if (png_ptr->read_data_fn != NULL)
159  {
160  png_ptr->read_data_fn = NULL;
161 
162  png_warning(png_ptr,
163  "Can't set both read_data_fn and write_data_fn in the"
164  " same structure");
165  }
166 #endif
167 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
png_rw_ptr read_data_fn
Definition: pngstruct.h:158
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
png_rw_ptr write_data_fn
Definition: pngstruct.h:157
void png_default_flush(png_structp png_ptr)
Definition: pngwio.c:79
png_voidp io_ptr
Definition: pngstruct.h:159
void png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
Definition: pngwio.c:51
PNG_IMPEXP void() png_set_read_fn ( png_structrp  png_ptr,
png_voidp  io_ptr,
png_rw_ptr  read_data_fn 
)
89 {
90  if (png_ptr == NULL)
91  return;
92 
93  png_ptr->io_ptr = io_ptr;
94 
95 #ifdef PNG_STDIO_SUPPORTED
96  if (read_data_fn != NULL)
97  png_ptr->read_data_fn = read_data_fn;
98 
99  else
101 #else
102  png_ptr->read_data_fn = read_data_fn;
103 #endif
104 
105 #ifdef PNG_WRITE_SUPPORTED
106  /* It is an error to write to a read device */
107  if (png_ptr->write_data_fn != NULL)
108  {
109  png_ptr->write_data_fn = NULL;
110  png_warning(png_ptr,
111  "Can't set both read_data_fn and write_data_fn in the"
112  " same structure");
113  }
114 #endif
115 
116 #ifdef PNG_WRITE_FLUSH_SUPPORTED
117  png_ptr->output_flush_fn = NULL;
118 #endif
119 }
png_rw_ptr read_data_fn
Definition: pngstruct.h:158
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
void png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
Definition: pngrio.c:50
png_rw_ptr write_data_fn
Definition: pngstruct.h:157
png_voidp io_ptr
Definition: pngstruct.h:159
PNG_IMPEXP png_voidp() png_get_io_ptr ( png_const_structrp  png_ptr)
642 {
643  if (png_ptr == NULL)
644  return (NULL);
645 
646  return (png_ptr->io_ptr);
647 }
png_voidp io_ptr
Definition: pngstruct.h:159
PNG_IMPEXP void() png_set_read_status_fn ( png_structrp  png_ptr,
png_read_status_ptr  read_row_fn 
)
1012 {
1013  if (png_ptr == NULL)
1014  return;
1015 
1016  png_ptr->read_row_fn = read_row_fn;
1017 }
png_read_status_ptr read_row_fn
Definition: pngstruct.h:315
PNG_IMPEXP void() png_set_write_status_fn ( png_structrp  png_ptr,
png_write_status_ptr  write_row_fn 
)
1535 {
1536  if (png_ptr == NULL)
1537  return;
1538 
1539  png_ptr->write_row_fn = write_row_fn;
1540 }
png_write_status_ptr write_row_fn
Definition: pngstruct.h:316
PNG_IMPEXP void() png_set_mem_fn ( png_structrp  png_ptr,
png_voidp  mem_ptr,
png_malloc_ptr  malloc_fn,
png_free_ptr  free_fn 
)
259 {
260  if (png_ptr != NULL)
261  {
262  png_ptr->mem_ptr = mem_ptr;
263  png_ptr->malloc_fn = malloc_fn;
264  png_ptr->free_fn = free_fn;
265  }
266 }
PNG_IMPEXP png_voidp() png_get_mem_ptr ( png_const_structrp  png_ptr)
274 {
275  if (png_ptr == NULL)
276  return NULL;
277 
278  return png_ptr->mem_ptr;
279 }
PNG_IMPEXP void() png_set_read_user_transform_fn ( png_structrp  png_ptr,
png_user_transform_ptr  read_user_transform_fn 
)
1059 {
1060  png_debug(1, "in png_set_read_user_transform_fn");
1061 
1062 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
1063  png_ptr->transformations |= PNG_USER_TRANSFORM;
1064  png_ptr->read_user_transform_fn = read_user_transform_fn;
1065 #endif
1066 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_USER_TRANSFORM
Definition: pngpriv.h:580
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_write_user_transform_fn ( png_structrp  png_ptr,
png_user_transform_ptr  write_user_transform_fn 
)
1546 {
1547  png_debug(1, "in png_set_write_user_transform_fn");
1548 
1549  if (png_ptr == NULL)
1550  return;
1551 
1552  png_ptr->transformations |= PNG_USER_TRANSFORM;
1553  png_ptr->write_user_transform_fn = write_user_transform_fn;
1554 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_USER_TRANSFORM
Definition: pngpriv.h:580
png_uint_32 transformations
Definition: pngstruct.h:181
PNG_IMPEXP void() png_set_user_transform_info ( png_structrp  png_ptr,
png_voidp  user_transform_ptr,
int  user_transform_depth,
int  user_transform_channels 
)
789 {
790  png_debug(1, "in png_set_user_transform_info");
791 
792  if (png_ptr == NULL)
793  return;
794 
795 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
796  if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
797  (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
798  {
799  png_app_error(png_ptr,
800  "info change after png_start_read_image or png_read_update_info");
801  return;
802  }
803 #endif
804 
805  png_ptr->user_transform_ptr = user_transform_ptr;
806  png_ptr->user_transform_depth = (png_byte)user_transform_depth;
807  png_ptr->user_transform_channels = (png_byte)user_transform_channels;
808 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_IS_READ_STRUCT
Definition: pngpriv.h:557
#define PNG_FLAG_ROW_INIT
Definition: pngpriv.h:607
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
png_uint_32 flags
Definition: pngstruct.h:180
png_uint_32 mode
Definition: pngstruct.h:179
PNG_IMPEXP png_voidp() png_get_user_transform_ptr ( png_const_structrp  png_ptr)
819 {
820  if (png_ptr == NULL)
821  return (NULL);
822 
823  return png_ptr->user_transform_ptr;
824 }
PNG_IMPEXP png_uint_32() png_get_current_row_number ( png_const_structrp  )
830 {
831  /* See the comments in png.h - this is the sub-image row when reading an
832  * interlaced image.
833  */
834  if (png_ptr != NULL)
835  return png_ptr->row_number;
836 
837  return PNG_UINT_32_MAX; /* help the app not to fail silently */
838 }
#define PNG_UINT_32_MAX
Definition: png.h:791
PNG_IMPEXP png_byte() png_get_current_pass_number ( png_const_structrp  )
842 {
843  if (png_ptr != NULL)
844  return png_ptr->pass;
845  return 8; /* invalid */
846 }
PNG_IMPEXP void() png_set_read_user_chunk_fn ( png_structrp  png_ptr,
png_voidp  user_chunk_ptr,
png_user_chunk_ptr  read_user_chunk_fn 
)
1439 {
1440  png_debug(1, "in png_set_read_user_chunk_fn");
1441 
1442  if (png_ptr == NULL)
1443  return;
1444 
1445  png_ptr->read_user_chunk_fn = read_user_chunk_fn;
1446  png_ptr->user_chunk_ptr = user_chunk_ptr;
1447 }
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP png_voidp() png_get_user_chunk_ptr ( png_const_structrp  png_ptr)
1127 {
1128  return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
1129 }
PNG_IMPEXP void() png_set_progressive_read_fn ( png_structrp  png_ptr,
png_voidp  progressive_ptr,
png_progressive_info_ptr  info_fn,
png_progressive_row_ptr  row_fn,
png_progressive_end_ptr  end_fn 
)
1149 {
1150  if (png_ptr == NULL)
1151  return;
1152 
1153  png_ptr->info_fn = info_fn;
1154  png_ptr->row_fn = row_fn;
1155  png_ptr->end_fn = end_fn;
1156 
1157  png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
1158 }
void png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
Definition: pngpread.c:506
PNG_IMPEXP void() png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)
Definition: pngrio.c:87
PNG_IMPEXP png_voidp() png_get_progressive_ptr ( png_const_structrp  png_ptr)
1162 {
1163  if (png_ptr == NULL)
1164  return (NULL);
1165 
1166  return png_ptr->io_ptr;
1167 }
png_voidp io_ptr
Definition: pngstruct.h:159
PNG_IMPEXP void() png_process_data ( png_structrp  png_ptr,
png_inforp  info_ptr,
png_bytep  buffer,
png_size_t  buffer_size 
)
39 {
40  if (png_ptr == NULL || info_ptr == NULL)
41  return;
42 
43  png_push_restore_buffer(png_ptr, buffer, buffer_size);
44 
45  while (png_ptr->buffer_size)
46  {
47  png_process_some_data(png_ptr, info_ptr);
48  }
49 }
static char buffer[255]
Definition: propagator_simple.cpp:60
void png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
Definition: pngpread.c:113
void png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer, png_size_t buffer_length)
Definition: pngpread.c:608
PNG_IMPEXP png_size_t() png_process_data_pause ( png_structrp  ,
int  save 
)
53 {
54  if (png_ptr != NULL)
55  {
56  /* It's easiest for the caller if we do the save; then the caller doesn't
57  * have to supply the same data again:
58  */
59  if (save != 0)
60  png_push_save_buffer(png_ptr);
61  else
62  {
63  /* This includes any pending saved bytes: */
64  png_size_t remaining = png_ptr->buffer_size;
65  png_ptr->buffer_size = 0;
66 
67  /* So subtract the saved buffer size, unless all the data
68  * is actually 'saved', in which case we just return 0
69  */
70  if (png_ptr->save_buffer_size < remaining)
71  return remaining - png_ptr->save_buffer_size;
72  }
73  }
74 
75  return 0;
76 }
void png_push_save_buffer(png_structrp png_ptr)
Definition: pngpread.c:549
size_t png_size_t
Definition: pngconf.h:543
PNG_IMPEXP png_uint_32() png_process_data_skip ( png_structrp  )
80 {
81  png_uint_32 remaining = 0;
82 
83  if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE &&
84  png_ptr->skip_length > 0)
85  {
86  /* At the end of png_process_data the buffer size must be 0 (see the loop
87  * above) so we can detect a broken call here:
88  */
89  if (png_ptr->buffer_size != 0)
90  png_error(png_ptr,
91  "png_process_data_skip called inside png_process_data");
92 
93  /* If is impossible for there to be a saved buffer at this point -
94  * otherwise we could not be in SKIP mode. This will also happen if
95  * png_process_skip is called inside png_process_data (but only very
96  * rarely.)
97  */
98  if (png_ptr->save_buffer_size != 0)
99  png_error(png_ptr, "png_process_data_skip called with saved data");
100 
101  remaining = png_ptr->skip_length;
102  png_ptr->skip_length = 0;
103  png_ptr->process_mode = PNG_READ_CHUNK_MODE;
104  }
105 
106  return remaining;
107 }
#define PNG_SKIP_MODE
Definition: pngpread.c:22
#define PNG_READ_CHUNK_MODE
Definition: pngpread.c:20
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
PNG_IMPEXP void() png_progressive_combine_row ( png_const_structrp  png_ptr,
png_bytep  old_row,
png_const_bytep  new_row 
)
1133 {
1134  if (png_ptr == NULL)
1135  return;
1136 
1137  /* new_row is a flag here - if it is NULL then the app callback was called
1138  * from an empty row (see the calls to png_struct::row_fn below), otherwise
1139  * it must be png_ptr->row_buf+1
1140  */
1141  if (new_row != NULL)
1142  png_combine_row(png_ptr, old_row, 1/*blocky display*/);
1143 }
void png_combine_row(png_const_structrp png_ptr, png_bytep row, int display)
Definition: pngrutil.c:3002
PNG_IMPEXP png_voidp() png_malloc ( png_const_structrp  png_ptr,
png_alloc_size_t  size 
)
170 {
171  png_voidp ret;
172 
173  if (png_ptr == NULL)
174  return NULL;
175 
176  ret = png_malloc_base(png_ptr, size);
177 
178  if (ret == NULL)
179  png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */
180 
181  return ret;
182 }
void * png_voidp
Definition: pngconf.h:598
png_voidp png_malloc_base(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:69
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
PNG_IMPEXP png_voidp() png_calloc ( png_const_structrp  png_ptr,
png_alloc_size_t  size 
)
51 {
52  png_voidp ret;
53 
54  ret = png_malloc(png_ptr, size);
55 
56  if (ret != NULL)
57  memset(ret, 0, size);
58 
59  return ret;
60 }
void * png_voidp
Definition: pngconf.h:598
png_voidp png_malloc(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:169
PNG_IMPEXP png_voidp() png_malloc_warn ( png_const_structrp  png_ptr,
png_alloc_size_t  size 
)
211 {
212  if (png_ptr != NULL)
213  {
214  png_voidp ret = png_malloc_base(png_ptr, size);
215 
216  if (ret != NULL)
217  return ret;
218 
219  png_warning(png_ptr, "Out of memory");
220  }
221 
222  return NULL;
223 }
void * png_voidp
Definition: pngconf.h:598
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
png_voidp png_malloc_base(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:69
PNG_IMPEXP void() png_free ( png_const_structrp  png_ptr,
png_voidp  ptr 
)
230 {
231  if (png_ptr == NULL || ptr == NULL)
232  return;
233 
234 #ifdef PNG_USER_MEM_SUPPORTED
235  if (png_ptr->free_fn != NULL)
236  png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
237 
238  else
239  png_free_default(png_ptr, ptr);
240 }
Definition: pngstruct.h:144
void png_free_default(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:243
#define png_constcast(type, value)
Definition: pngpriv.h:409
PNG_IMPEXP void() png_free_data ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_uint_32  free_me,
int  num 
)
444 {
445  png_debug(1, "in png_free_data");
446 
447  if (png_ptr == NULL || info_ptr == NULL)
448  return;
449 
450 #ifdef PNG_TEXT_SUPPORTED
451  /* Free text item num or (if num == -1) all text items */
452  if (info_ptr->text != 0 &&
453  ((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0)
454  {
455  if (num != -1)
456  {
457  png_free(png_ptr, info_ptr->text[num].key);
458  info_ptr->text[num].key = NULL;
459  }
460 
461  else
462  {
463  int i;
464 
465  for (i = 0; i < info_ptr->num_text; i++)
466  png_free(png_ptr, info_ptr->text[i].key);
467 
468  png_free(png_ptr, info_ptr->text);
469  info_ptr->text = NULL;
470  info_ptr->num_text = 0;
471  }
472  }
473 #endif
474 
475 #ifdef PNG_tRNS_SUPPORTED
476  /* Free any tRNS entry */
477  if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0)
478  {
479  png_free(png_ptr, info_ptr->trans_alpha);
480  info_ptr->trans_alpha = NULL;
481  info_ptr->valid &= ~PNG_INFO_tRNS;
482  }
483 #endif
484 
485 #ifdef PNG_sCAL_SUPPORTED
486  /* Free any sCAL entry */
487  if (((mask & PNG_FREE_SCAL) & info_ptr->free_me) != 0)
488  {
489  png_free(png_ptr, info_ptr->scal_s_width);
490  png_free(png_ptr, info_ptr->scal_s_height);
491  info_ptr->scal_s_width = NULL;
492  info_ptr->scal_s_height = NULL;
493  info_ptr->valid &= ~PNG_INFO_sCAL;
494  }
495 #endif
496 
497 #ifdef PNG_pCAL_SUPPORTED
498  /* Free any pCAL entry */
499  if (((mask & PNG_FREE_PCAL) & info_ptr->free_me) != 0)
500  {
501  png_free(png_ptr, info_ptr->pcal_purpose);
502  png_free(png_ptr, info_ptr->pcal_units);
503  info_ptr->pcal_purpose = NULL;
504  info_ptr->pcal_units = NULL;
505 
506  if (info_ptr->pcal_params != NULL)
507  {
508  int i;
509 
510  for (i = 0; i < info_ptr->pcal_nparams; i++)
511  png_free(png_ptr, info_ptr->pcal_params[i]);
512 
513  png_free(png_ptr, info_ptr->pcal_params);
514  info_ptr->pcal_params = NULL;
515  }
516  info_ptr->valid &= ~PNG_INFO_pCAL;
517  }
518 #endif
519 
520 #ifdef PNG_iCCP_SUPPORTED
521  /* Free any profile entry */
522  if (((mask & PNG_FREE_ICCP) & info_ptr->free_me) != 0)
523  {
524  png_free(png_ptr, info_ptr->iccp_name);
525  png_free(png_ptr, info_ptr->iccp_profile);
526  info_ptr->iccp_name = NULL;
527  info_ptr->iccp_profile = NULL;
528  info_ptr->valid &= ~PNG_INFO_iCCP;
529  }
530 #endif
531 
532 #ifdef PNG_sPLT_SUPPORTED
533  /* Free a given sPLT entry, or (if num == -1) all sPLT entries */
534  if (info_ptr->splt_palettes != 0 &&
535  ((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0)
536  {
537  if (num != -1)
538  {
539  png_free(png_ptr, info_ptr->splt_palettes[num].name);
540  png_free(png_ptr, info_ptr->splt_palettes[num].entries);
541  info_ptr->splt_palettes[num].name = NULL;
542  info_ptr->splt_palettes[num].entries = NULL;
543  }
544 
545  else
546  {
547  if (info_ptr->splt_palettes_num != 0)
548  {
549  int i;
550 
551  for (i = 0; i < info_ptr->splt_palettes_num; i++)
552  {
553  png_free(png_ptr, info_ptr->splt_palettes[i].name);
554  png_free(png_ptr, info_ptr->splt_palettes[i].entries);
555  }
556 
557  png_free(png_ptr, info_ptr->splt_palettes);
558  info_ptr->splt_palettes = NULL;
559  info_ptr->splt_palettes_num = 0;
560  }
561  info_ptr->valid &= ~PNG_INFO_sPLT;
562  }
563  }
564 #endif
565 
566 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
567  if (info_ptr->unknown_chunks != 0 &&
568  ((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0)
569  {
570  if (num != -1)
571  {
572  png_free(png_ptr, info_ptr->unknown_chunks[num].data);
573  info_ptr->unknown_chunks[num].data = NULL;
574  }
575 
576  else
577  {
578  int i;
579 
580  if (info_ptr->unknown_chunks_num != 0)
581  {
582  for (i = 0; i < info_ptr->unknown_chunks_num; i++)
583  png_free(png_ptr, info_ptr->unknown_chunks[i].data);
584 
585  png_free(png_ptr, info_ptr->unknown_chunks);
586  info_ptr->unknown_chunks = NULL;
587  info_ptr->unknown_chunks_num = 0;
588  }
589  }
590  }
591 #endif
592 
593 #ifdef PNG_hIST_SUPPORTED
594  /* Free any hIST entry */
595  if (((mask & PNG_FREE_HIST) & info_ptr->free_me) != 0)
596  {
597  png_free(png_ptr, info_ptr->hist);
598  info_ptr->hist = NULL;
599  info_ptr->valid &= ~PNG_INFO_hIST;
600  }
601 #endif
602 
603  /* Free any PLTE entry that was internally allocated */
604  if (((mask & PNG_FREE_PLTE) & info_ptr->free_me) != 0)
605  {
606  png_free(png_ptr, info_ptr->palette);
607  info_ptr->palette = NULL;
608  info_ptr->valid &= ~PNG_INFO_PLTE;
609  info_ptr->num_palette = 0;
610  }
611 
612 #ifdef PNG_INFO_IMAGE_SUPPORTED
613  /* Free any image bits attached to the info structure */
614  if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0)
615  {
616  if (info_ptr->row_pointers != 0)
617  {
618  png_uint_32 row;
619  for (row = 0; row < info_ptr->height; row++)
620  png_free(png_ptr, info_ptr->row_pointers[row]);
621 
622  png_free(png_ptr, info_ptr->row_pointers);
623  info_ptr->row_pointers = NULL;
624  }
625  info_ptr->valid &= ~PNG_INFO_IDAT;
626  }
627 #endif
628 
629  if (num != -1)
630  mask &= ~PNG_FREE_MUL;
631 
632  info_ptr->free_me &= ~mask;
633 }
#define PNG_FREE_TEXT
Definition: png.h:1924
#define PNG_FREE_HIST
Definition: png.h:1912
#define PNG_INFO_hIST
Definition: png.h:879
int i
Definition: rw_test.cpp:37
png_colorp palette
Definition: pnginfo.h:63
#define PNG_FREE_PLTE
Definition: png.h:1922
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_FREE_ICCP
Definition: png.h:1913
#define PNG_FREE_ROWS
Definition: png.h:1915
png_uint_32 height
Definition: pnginfo.h:60
#define PNG_FREE_SPLT
Definition: png.h:1914
png_uint_16 num_palette
Definition: pnginfo.h:64
#define PNG_FREE_UNKN
Definition: png.h:1919
#define PNG_INFO_PLTE
Definition: png.h:876
#define PNG_INFO_IDAT
Definition: png.h:888
#define PNG_INFO_tRNS
Definition: png.h:877
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_FREE_PCAL
Definition: png.h:1916
PNG_IMPEXP void() png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:229
#define PNG_FREE_MUL
Definition: png.h:1926
#define PNG_INFO_sPLT
Definition: png.h:886
png_uint_32 free_me
Definition: pnginfo.h:221
#define PNG_INFO_pCAL
Definition: png.h:883
#define PNG_FREE_SCAL
Definition: png.h:1917
#define PNG_INFO_iCCP
Definition: png.h:885
#define PNG_FREE_TRNS
Definition: png.h:1923
#define PNG_INFO_sCAL
Definition: png.h:887
PNG_IMPEXP void() png_data_freer ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
int  freer,
png_uint_32  mask 
)
425 {
426  png_debug(1, "in png_data_freer");
427 
428  if (png_ptr == NULL || info_ptr == NULL)
429  return;
430 
431  if (freer == PNG_DESTROY_WILL_FREE_DATA)
432  info_ptr->free_me |= mask;
433 
434  else if (freer == PNG_USER_WILL_FREE_DATA)
435  info_ptr->free_me &= ~mask;
436 
437  else
438  png_error(png_ptr, "Unknown freer parameter in png_data_freer");
439 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_USER_WILL_FREE_DATA
Definition: png.h:1910
#define PNG_DESTROY_WILL_FREE_DATA
Definition: png.h:1908
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
png_uint_32 free_me
Definition: pnginfo.h:221
PNG_DEPRECATED PNG_IMPEXP png_voidp() png_malloc_default ( png_const_structrp  png_ptr,
png_alloc_size_t  size 
)
188 {
189  png_voidp ret;
190 
191  if (png_ptr == NULL)
192  return NULL;
193 
194  /* Passing 'NULL' here bypasses the application provided memory handler. */
195  ret = png_malloc_base(NULL/*use malloc*/, size);
196 
197  if (ret == NULL)
198  png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */
199 
200  return ret;
201 }
void * png_voidp
Definition: pngconf.h:598
png_voidp png_malloc_base(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:69
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
PNG_DEPRECATED PNG_IMPEXP void() png_free_default ( png_const_structrp  png_ptr,
png_voidp  ptr 
)
244 {
245  if (png_ptr == NULL || ptr == NULL)
246  return;
247 #endif /* USER_MEM */
248 
249  free(ptr);
250 }
PNG_IMPEXP void() png_error ( png_const_structrp  png_ptr,
png_const_charp  error_message 
)
41 {
42 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
43  char msg[16];
44  if (png_ptr != NULL)
45  {
46  if ((png_ptr->flags &
48  {
49  if (*error_message == PNG_LITERAL_SHARP)
50  {
51  /* Strip "#nnnn " from beginning of error message. */
52  int offset;
53  for (offset = 1; offset<15; offset++)
54  if (error_message[offset] == ' ')
55  break;
56 
57  if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
58  {
59  int i;
60  for (i = 0; i < offset - 1; i++)
61  msg[i] = error_message[i + 1];
62  msg[i - 1] = '\0';
63  error_message = msg;
64  }
65 
66  else
67  error_message += offset;
68  }
69 
70  else
71  {
72  if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
73  {
74  msg[0] = '0';
75  msg[1] = '\0';
76  error_message = msg;
77  }
78  }
79  }
80  }
81 #endif
82  if (png_ptr != NULL && png_ptr->error_fn != NULL)
83  (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
84  error_message);
85 
86  /* If the custom handler doesn't exist, or if it returns,
87  use the default handler, which will not return. */
88  png_default_error(png_ptr, error_message);
89 }
png_error_ptr error_fn
Definition: pngstruct.h:152
#define PNG_FLAG_STRIP_ERROR_TEXT
Definition: pngpriv.h:620
#define PNG_FLAG_STRIP_ERROR_NUMBERS
Definition: pngpriv.h:619
Definition: pngstruct.h:144
png_uint_32 flags
Definition: pngstruct.h:180
static void png_default_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:712
#define png_constcast(type, value)
Definition: pngpriv.h:409
PNG_IMPEXP void() png_chunk_error ( png_const_structrp  png_ptr,
png_const_charp  error_message 
)
482 {
483  char msg[18+PNG_MAX_ERROR_TEXT];
484  if (png_ptr == NULL)
485  png_error(png_ptr, error_message);
486 
487  else
488  {
489  png_format_buffer(png_ptr, msg, error_message);
490  png_error(png_ptr, msg);
491  }
492 }
void png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
static void png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp error_message)
Definition: pngerror.c:434
#define PNG_MAX_ERROR_TEXT
Definition: pngerror.c:418
PNG_IMPEXP void() png_warning ( png_const_structrp  png_ptr,
png_const_charp  warning_message 
)
217 {
218  int offset = 0;
219  if (png_ptr != NULL)
220  {
221 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
222  if ((png_ptr->flags &
224 #endif
225  {
226  if (*warning_message == PNG_LITERAL_SHARP)
227  {
228  for (offset = 1; offset < 15; offset++)
229  if (warning_message[offset] == ' ')
230  break;
231  }
232  }
233  }
234  if (png_ptr != NULL && png_ptr->warning_fn != NULL)
235  (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
236  warning_message + offset);
237  else
238  png_default_warning(png_ptr, warning_message + offset);
239 }
#define PNG_FLAG_STRIP_ERROR_TEXT
Definition: pngpriv.h:620
#define PNG_FLAG_STRIP_ERROR_NUMBERS
Definition: pngpriv.h:619
#define PNG_LITERAL_SHARP
Definition: pngdebug.h:40
Definition: pngstruct.h:144
png_uint_32 flags
Definition: pngstruct.h:180
#define png_constcast(type, value)
Definition: pngpriv.h:409
static void png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:785
PNG_IMPEXP void() png_chunk_warning ( png_const_structrp  png_ptr,
png_const_charp  warning_message 
)
498 {
499  char msg[18+PNG_MAX_ERROR_TEXT];
500  if (png_ptr == NULL)
501  png_warning(png_ptr, warning_message);
502 
503  else
504  {
505  png_format_buffer(png_ptr, msg, warning_message);
506  png_warning(png_ptr, msg);
507  }
508 }
static void png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp error_message)
Definition: pngerror.c:434
void png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define PNG_MAX_ERROR_TEXT
Definition: pngerror.c:418
PNG_IMPEXP void() png_benign_error ( png_const_structrp  png_ptr,
png_const_charp  warning_message 
)
363 {
364  if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
365  {
366 # ifdef PNG_READ_SUPPORTED
367  if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
368  png_ptr->chunk_name != 0)
369  png_chunk_warning(png_ptr, error_message);
370  else
371 # endif
372  png_warning(png_ptr, error_message);
373  }
374 
375  else
376  {
377 # ifdef PNG_READ_SUPPORTED
378  if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
379  png_ptr->chunk_name != 0)
380  png_chunk_error(png_ptr, error_message);
381  else
382 # endif
383  png_error(png_ptr, error_message);
384  }
385 
386 # ifndef PNG_ERROR_TEXT_SUPPORTED
387  PNG_UNUSED(error_message)
388 # endif
389 }
void png_chunk_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:481
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_IS_READ_STRUCT
Definition: pngpriv.h:557
png_uint_32 chunk_name
Definition: pngstruct.h:221
void png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_FLAG_BENIGN_ERRORS_WARN
Definition: pngpriv.h:621
void png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:497
png_uint_32 mode
Definition: pngstruct.h:179
void png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
PNG_IMPEXP void() png_chunk_benign_error ( png_const_structrp  png_ptr,
png_const_charp  warning_message 
)
516 {
517  if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
518  png_chunk_warning(png_ptr, error_message);
519 
520  else
521  png_chunk_error(png_ptr, error_message);
522 
523 # ifndef PNG_ERROR_TEXT_SUPPORTED
524  PNG_UNUSED(error_message)
525 # endif
526 }
void png_chunk_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:481
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_FLAG_BENIGN_ERRORS_WARN
Definition: pngpriv.h:621
void png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:497
PNG_IMPEXP void() png_set_benign_errors ( png_structrp  png_ptr,
int  allowed 
)
1571 {
1572  png_debug(1, "in png_set_benign_errors");
1573 
1574  /* If allowed is 1, png_benign_error() is treated as a warning.
1575  *
1576  * If allowed is 0, png_benign_error() is treated as an error (which
1577  * is the default behavior if png_set_benign_errors() is not called).
1578  */
1579 
1580  if (allowed != 0)
1581  png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN |
1583 
1584  else
1585  png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN |
1587 }
#define PNG_FLAG_APP_WARNINGS_WARN
Definition: pngpriv.h:622
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_FLAG_BENIGN_ERRORS_WARN
Definition: pngpriv.h:621
#define PNG_FLAG_APP_ERRORS_WARN
Definition: pngpriv.h:623
PNG_IMPEXP png_uint_32() png_get_valid ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
png_uint_32  flag 
)
22 {
23  if (png_ptr != NULL && info_ptr != NULL)
24  return(info_ptr->valid & flag);
25 
26  return(0);
27 }
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP png_size_t() png_get_rowbytes ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
31 {
32  if (png_ptr != NULL && info_ptr != NULL)
33  return(info_ptr->rowbytes);
34 
35  return(0);
36 }
png_size_t rowbytes
Definition: pnginfo.h:62
PNG_IMPEXP png_bytepp() png_get_rows ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
41 {
42  if (png_ptr != NULL && info_ptr != NULL)
43  return(info_ptr->row_pointers);
44 
45  return(0);
46 }
PNG_IMPEXP void() png_set_rows ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_bytepp  row_pointers 
)
1454 {
1455  png_debug1(1, "in %s storage function", "rows");
1456 
1457  if (png_ptr == NULL || info_ptr == NULL)
1458  return;
1459 
1460  if (info_ptr->row_pointers != NULL &&
1461  (info_ptr->row_pointers != row_pointers))
1462  png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
1463 
1464  info_ptr->row_pointers = row_pointers;
1465 
1466  if (row_pointers != NULL)
1467  info_ptr->valid |= PNG_INFO_IDAT;
1468 }
void png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, int num)
Definition: png.c:442
#define PNG_FREE_ROWS
Definition: png.h:1915
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_INFO_IDAT
Definition: png.h:888
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP png_byte() png_get_channels ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
468 {
469  if (png_ptr != NULL && info_ptr != NULL)
470  return(info_ptr->channels);
471 
472  return (0);
473 }
png_byte channels
Definition: pnginfo.h:76
PNG_IMPEXP png_uint_32() png_get_image_width ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
53 {
54  if (png_ptr != NULL && info_ptr != NULL)
55  return info_ptr->width;
56 
57  return (0);
58 }
png_uint_32 width
Definition: pnginfo.h:59
PNG_IMPEXP png_uint_32() png_get_image_height ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
62 {
63  if (png_ptr != NULL && info_ptr != NULL)
64  return info_ptr->height;
65 
66  return (0);
67 }
png_uint_32 height
Definition: pnginfo.h:60
PNG_IMPEXP png_byte() png_get_bit_depth ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
71 {
72  if (png_ptr != NULL && info_ptr != NULL)
73  return info_ptr->bit_depth;
74 
75  return (0);
76 }
png_byte bit_depth
Definition: pnginfo.h:66
PNG_IMPEXP png_byte() png_get_color_type ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
80 {
81  if (png_ptr != NULL && info_ptr != NULL)
82  return info_ptr->color_type;
83 
84  return (0);
85 }
png_byte color_type
Definition: pnginfo.h:67
PNG_IMPEXP png_byte() png_get_filter_type ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
89 {
90  if (png_ptr != NULL && info_ptr != NULL)
91  return info_ptr->filter_type;
92 
93  return (0);
94 }
png_byte filter_type
Definition: pnginfo.h:70
PNG_IMPEXP png_byte() png_get_interlace_type ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
98 {
99  if (png_ptr != NULL && info_ptr != NULL)
100  return info_ptr->interlace_type;
101 
102  return (0);
103 }
png_byte interlace_type
Definition: pnginfo.h:71
PNG_IMPEXP png_byte() png_get_compression_type ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
107 {
108  if (png_ptr != NULL && info_ptr != NULL)
109  return info_ptr->compression_type;
110 
111  return (0);
112 }
png_byte compression_type
Definition: pnginfo.h:69
PNG_IMPEXP png_uint_32() png_get_pixels_per_meter ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
160 {
161 #ifdef PNG_pHYs_SUPPORTED
162  if (png_ptr != NULL && info_ptr != NULL &&
163  (info_ptr->valid & PNG_INFO_pHYs) != 0)
164  {
165  png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
166 
167  if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
168  info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
169  return (info_ptr->x_pixels_per_unit);
170  }
171 #else
172  PNG_UNUSED(png_ptr)
173  PNG_UNUSED(info_ptr)
174 #endif
175 
176  return (0);
177 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_RESOLUTION_METER
Definition: png.h:852
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_pHYs
Definition: png.h:880
PNG_IMPEXP png_uint_32() png_get_x_pixels_per_meter ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
117 {
118 #ifdef PNG_pHYs_SUPPORTED
119  if (png_ptr != NULL && info_ptr != NULL &&
120  (info_ptr->valid & PNG_INFO_pHYs) != 0)
121  {
122  png_debug1(1, "in %s retrieval function",
123  "png_get_x_pixels_per_meter");
124 
125  if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
126  return (info_ptr->x_pixels_per_unit);
127  }
128 #else
129  PNG_UNUSED(png_ptr)
130  PNG_UNUSED(info_ptr)
131 #endif
132 
133  return (0);
134 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_RESOLUTION_METER
Definition: png.h:852
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_pHYs
Definition: png.h:880
PNG_IMPEXP png_uint_32() png_get_y_pixels_per_meter ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
139 {
140 #ifdef PNG_pHYs_SUPPORTED
141  if (png_ptr != NULL && info_ptr != NULL &&
142  (info_ptr->valid & PNG_INFO_pHYs) != 0)
143  {
144  png_debug1(1, "in %s retrieval function",
145  "png_get_y_pixels_per_meter");
146 
147  if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
148  return (info_ptr->y_pixels_per_unit);
149  }
150 #else
151  PNG_UNUSED(png_ptr)
152  PNG_UNUSED(info_ptr)
153 #endif
154 
155  return (0);
156 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_RESOLUTION_METER
Definition: png.h:852
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_pHYs
Definition: png.h:880
PNG_IMPEXP float() png_get_pixel_aspect_ratio ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
183 {
184 #ifdef PNG_READ_pHYs_SUPPORTED
185  if (png_ptr != NULL && info_ptr != NULL &&
186  (info_ptr->valid & PNG_INFO_pHYs) != 0)
187  {
188  png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
189 
190  if (info_ptr->x_pixels_per_unit != 0)
191  return ((float)((float)info_ptr->y_pixels_per_unit
192  /(float)info_ptr->x_pixels_per_unit));
193  }
194 #else
195  PNG_UNUSED(png_ptr)
196  PNG_UNUSED(info_ptr)
197 #endif
198 
199  return ((float)0.0);
200 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_pHYs
Definition: png.h:880
PNG_IMPEXP png_fixed_point() png_get_pixel_aspect_ratio_fixed ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
207 {
208 #ifdef PNG_READ_pHYs_SUPPORTED
209  if (png_ptr != NULL && info_ptr != NULL &&
210  (info_ptr->valid & PNG_INFO_pHYs) != 0 &&
211  info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
212  info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX &&
213  info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
214  {
215  png_fixed_point res;
216 
217  png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");
218 
219  /* The following casts work because a PNG 4 byte integer only has a valid
220  * range of 0..2^31-1; otherwise the cast might overflow.
221  */
222  if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
223  (png_int_32)info_ptr->x_pixels_per_unit) != 0)
224  return res;
225  }
226 #else
227  PNG_UNUSED(png_ptr)
228  PNG_UNUSED(info_ptr)
229 #endif
230 
231  return 0;
232 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_UINT_31_MAX
Definition: png.h:790
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
int png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, png_int_32 divisor)
Definition: png.c:3243
#define PNG_FP_1
Definition: png.h:797
png_uint_32 valid
Definition: pnginfo.h:61
png_int_32 png_fixed_point
Definition: pngconf.h:595
#define PNG_INFO_pHYs
Definition: png.h:880
PNG_IMPEXP png_int_32() png_get_x_offset_pixels ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
277 {
278 #ifdef PNG_oFFs_SUPPORTED
279  if (png_ptr != NULL && info_ptr != NULL &&
280  (info_ptr->valid & PNG_INFO_oFFs) != 0)
281  {
282  png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
283 
284  if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
285  return (info_ptr->x_offset);
286  }
287 #else
288  PNG_UNUSED(png_ptr)
289  PNG_UNUSED(info_ptr)
290 #endif
291 
292  return (0);
293 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_INFO_oFFs
Definition: png.h:881
#define PNG_OFFSET_PIXEL
Definition: png.h:833
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP png_int_32() png_get_y_offset_pixels ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
297 {
298 #ifdef PNG_oFFs_SUPPORTED
299  if (png_ptr != NULL && info_ptr != NULL &&
300  (info_ptr->valid & PNG_INFO_oFFs) != 0)
301  {
302  png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
303 
304  if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
305  return (info_ptr->y_offset);
306  }
307 #else
308  PNG_UNUSED(png_ptr)
309  PNG_UNUSED(info_ptr)
310 #endif
311 
312  return (0);
313 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_INFO_oFFs
Definition: png.h:881
#define PNG_OFFSET_PIXEL
Definition: png.h:833
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP png_int_32() png_get_x_offset_microns ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
237 {
238 #ifdef PNG_oFFs_SUPPORTED
239  if (png_ptr != NULL && info_ptr != NULL &&
240  (info_ptr->valid & PNG_INFO_oFFs) != 0)
241  {
242  png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
243 
244  if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
245  return (info_ptr->x_offset);
246  }
247 #else
248  PNG_UNUSED(png_ptr)
249  PNG_UNUSED(info_ptr)
250 #endif
251 
252  return (0);
253 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_INFO_oFFs
Definition: png.h:881
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_OFFSET_MICROMETER
Definition: png.h:834
PNG_IMPEXP png_int_32() png_get_y_offset_microns ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
257 {
258 #ifdef PNG_oFFs_SUPPORTED
259  if (png_ptr != NULL && info_ptr != NULL &&
260  (info_ptr->valid & PNG_INFO_oFFs) != 0)
261  {
262  png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
263 
264  if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
265  return (info_ptr->y_offset);
266  }
267 #else
268  PNG_UNUSED(png_ptr)
269  PNG_UNUSED(info_ptr)
270 #endif
271 
272  return (0);
273 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_INFO_oFFs
Definition: png.h:881
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_OFFSET_MICROMETER
Definition: png.h:834
PNG_IMPEXP png_const_bytep() png_get_signature ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
478 {
479  if (png_ptr != NULL && info_ptr != NULL)
480  return(info_ptr->signature);
481 
482  return (NULL);
483 }
PNG_IMPEXP png_uint_32() png_get_bKGD ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_color_16p background 
)
490 {
491  if (png_ptr != NULL && info_ptr != NULL &&
492  (info_ptr->valid & PNG_INFO_bKGD) != 0 &&
493  background != NULL)
494  {
495  png_debug1(1, "in %s retrieval function", "bKGD");
496 
497  *background = &(info_ptr->background);
498  return (PNG_INFO_bKGD);
499  }
500 
501  return (0);
502 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_bKGD
Definition: png.h:878
PNG_IMPEXP void() png_set_bKGD ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_const_color_16p  background 
)
27 {
28  png_debug1(1, "in %s storage function", "bKGD");
29 
30  if (png_ptr == NULL || info_ptr == NULL || background == NULL)
31  return;
32 
33  info_ptr->background = *background;
34  info_ptr->valid |= PNG_INFO_bKGD;
35 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_bKGD
Definition: png.h:878
PNG_IMPEXP png_uint_32() png_get_cHRM ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
double *  white_x,
double *  white_y,
double *  red_x,
double *  red_y,
double *  green_x,
double *  green_y,
double *  blue_x,
double *  blue_y 
)
515 {
516  /* Quiet API change: this code used to only return the end points if a cHRM
517  * chunk was present, but the end points can also come from iCCP or sRGB
518  * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
519  * the png_set_ APIs merely check that set end points are mutually
520  * consistent.
521  */
522  if (png_ptr != NULL && info_ptr != NULL &&
523  (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
524  {
525  png_debug1(1, "in %s retrieval function", "cHRM");
526 
527  if (white_x != NULL)
528  *white_x = png_float(png_ptr,
529  info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
530  if (white_y != NULL)
531  *white_y = png_float(png_ptr,
532  info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
533  if (red_x != NULL)
534  *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
535  "cHRM red X");
536  if (red_y != NULL)
537  *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
538  "cHRM red Y");
539  if (green_x != NULL)
540  *green_x = png_float(png_ptr,
541  info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
542  if (green_y != NULL)
543  *green_y = png_float(png_ptr,
544  info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
545  if (blue_x != NULL)
546  *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
547  "cHRM blue X");
548  if (blue_y != NULL)
549  *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
550  "cHRM blue Y");
551  return (PNG_INFO_cHRM);
552  }
553 
554  return (0);
555 }
#define png_float(png_ptr, fixed, s)
Definition: pngpriv.h:685
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_INFO_cHRM
Definition: png.h:875
PNG_IMPEXP png_uint_32() png_get_cHRM_XYZ ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
double *  red_X,
double *  red_Y,
double *  red_Z,
double *  green_X,
double *  green_Y,
double *  green_Z,
double *  blue_X,
double *  blue_Y,
double *  blue_Z 
)
562 {
563  if (png_ptr != NULL && info_ptr != NULL &&
564  (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
565  {
566  png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
567 
568  if (red_X != NULL)
569  *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
570  "cHRM red X");
571  if (red_Y != NULL)
572  *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
573  "cHRM red Y");
574  if (red_Z != NULL)
575  *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
576  "cHRM red Z");
577  if (green_X != NULL)
578  *green_X = png_float(png_ptr,
579  info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
580  if (green_Y != NULL)
581  *green_Y = png_float(png_ptr,
582  info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
583  if (green_Z != NULL)
584  *green_Z = png_float(png_ptr,
585  info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
586  if (blue_X != NULL)
587  *blue_X = png_float(png_ptr,
588  info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
589  if (blue_Y != NULL)
590  *blue_Y = png_float(png_ptr,
591  info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
592  if (blue_Z != NULL)
593  *blue_Z = png_float(png_ptr,
594  info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
595  return (PNG_INFO_cHRM);
596  }
597 
598  return (0);
599 }
#define png_float(png_ptr, fixed, s)
Definition: pngpriv.h:685
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_INFO_cHRM
Definition: png.h:875
PNG_IMPEXP png_uint_32() png_get_cHRM_fixed ( png_const_structrp  png_ptr,
png_const_inforp  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 
)
645 {
646  png_debug1(1, "in %s retrieval function", "cHRM");
647 
648  if (png_ptr != NULL && info_ptr != NULL &&
649  (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
650  {
651  if (white_x != NULL)
652  *white_x = info_ptr->colorspace.end_points_xy.whitex;
653  if (white_y != NULL)
654  *white_y = info_ptr->colorspace.end_points_xy.whitey;
655  if (red_x != NULL)
656  *red_x = info_ptr->colorspace.end_points_xy.redx;
657  if (red_y != NULL)
658  *red_y = info_ptr->colorspace.end_points_xy.redy;
659  if (green_x != NULL)
660  *green_x = info_ptr->colorspace.end_points_xy.greenx;
661  if (green_y != NULL)
662  *green_y = info_ptr->colorspace.end_points_xy.greeny;
663  if (blue_x != NULL)
664  *blue_x = info_ptr->colorspace.end_points_xy.bluex;
665  if (blue_y != NULL)
666  *blue_y = info_ptr->colorspace.end_points_xy.bluey;
667  return (PNG_INFO_cHRM);
668  }
669 
670  return (0);
671 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_INFO_cHRM
Definition: png.h:875
PNG_IMPEXP png_uint_32() png_get_cHRM_XYZ_fixed ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
png_fixed_point int_red_X,
png_fixed_point int_red_Y,
png_fixed_point int_red_Z,
png_fixed_point int_green_X,
png_fixed_point int_green_Y,
png_fixed_point int_green_Z,
png_fixed_point int_blue_X,
png_fixed_point int_blue_Y,
png_fixed_point int_blue_Z 
)
610 {
611  if (png_ptr != NULL && info_ptr != NULL &&
612  (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
613  {
614  png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
615 
616  if (int_red_X != NULL)
617  *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
618  if (int_red_Y != NULL)
619  *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
620  if (int_red_Z != NULL)
621  *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
622  if (int_green_X != NULL)
623  *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
624  if (int_green_Y != NULL)
625  *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
626  if (int_green_Z != NULL)
627  *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
628  if (int_blue_X != NULL)
629  *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
630  if (int_blue_Y != NULL)
631  *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
632  if (int_blue_Z != NULL)
633  *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
634  return (PNG_INFO_cHRM);
635  }
636 
637  return (0);
638 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_INFO_cHRM
Definition: png.h:875
PNG_IMPEXP void() png_set_cHRM ( png_const_structrp  png_ptr,
png_inforp  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 
)
105 {
106  png_set_cHRM_fixed(png_ptr, info_ptr,
107  png_fixed(png_ptr, white_x, "cHRM White X"),
108  png_fixed(png_ptr, white_y, "cHRM White Y"),
109  png_fixed(png_ptr, red_x, "cHRM Red X"),
110  png_fixed(png_ptr, red_y, "cHRM Red Y"),
111  png_fixed(png_ptr, green_x, "cHRM Green X"),
112  png_fixed(png_ptr, green_y, "cHRM Green Y"),
113  png_fixed(png_ptr, blue_x, "cHRM Blue X"),
114  png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
115 }
png_fixed_point png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
Definition: png.c:3219
void png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y)
Definition: pngset.c:40
PNG_IMPEXP void() png_set_cHRM_XYZ ( png_const_structrp  png_ptr,
png_inforp  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 
)
121 {
122  png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
123  png_fixed(png_ptr, red_X, "cHRM Red X"),
124  png_fixed(png_ptr, red_Y, "cHRM Red Y"),
125  png_fixed(png_ptr, red_Z, "cHRM Red Z"),
126  png_fixed(png_ptr, green_X, "cHRM Red X"),
127  png_fixed(png_ptr, green_Y, "cHRM Red Y"),
128  png_fixed(png_ptr, green_Z, "cHRM Red Z"),
129  png_fixed(png_ptr, blue_X, "cHRM Red X"),
130  png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
131  png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
132 }
png_fixed_point png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
Definition: png.c:3219
void png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, png_fixed_point int_blue_X, png_fixed_point int_blue_Y, png_fixed_point int_blue_Z)
Definition: pngset.c:69
PNG_IMPEXP void() png_set_cHRM_fixed ( png_const_structrp  png_ptr,
png_inforp  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 
)
44 {
45  png_xy xy;
46 
47  png_debug1(1, "in %s storage function", "cHRM fixed");
48 
49  if (png_ptr == NULL || info_ptr == NULL)
50  return;
51 
52  xy.redx = red_x;
53  xy.redy = red_y;
54  xy.greenx = green_x;
55  xy.greeny = green_y;
56  xy.bluex = blue_x;
57  xy.bluey = blue_y;
58  xy.whitex = white_x;
59  xy.whitey = white_y;
60 
61  if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy,
62  2/* override with app values*/) != 0)
63  info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
64 
65  png_colorspace_sync_info(png_ptr, info_ptr);
66 }
void png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
Definition: png.c:1129
int png_colorspace_set_chromaticities(png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy, int preferred)
Definition: png.c:1679
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
PNG_IMPEXP void() png_set_cHRM_XYZ_fixed ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_fixed_point  int_red_X,
png_fixed_point  int_red_Y,
png_fixed_point  int_red_Z,
png_fixed_point  int_green_X,
png_fixed_point  int_green_Y,
png_fixed_point  int_green_Z,
png_fixed_point  int_blue_X,
png_fixed_point  int_blue_Y,
png_fixed_point  int_blue_Z 
)
75 {
76  png_XYZ XYZ;
77 
78  png_debug1(1, "in %s storage function", "cHRM XYZ fixed");
79 
80  if (png_ptr == NULL || info_ptr == NULL)
81  return;
82 
83  XYZ.red_X = int_red_X;
84  XYZ.red_Y = int_red_Y;
85  XYZ.red_Z = int_red_Z;
86  XYZ.green_X = int_green_X;
87  XYZ.green_Y = int_green_Y;
88  XYZ.green_Z = int_green_Z;
89  XYZ.blue_X = int_blue_X;
90  XYZ.blue_Y = int_blue_Y;
91  XYZ.blue_Z = int_blue_Z;
92 
93  if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace,
94  &XYZ, 2) != 0)
95  info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
96 
97  png_colorspace_sync_info(png_ptr, info_ptr);
98 }
void png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
Definition: png.c:1129
int png_colorspace_set_endpoints(png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)
Definition: png.c:1717
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
PNG_IMPEXP png_uint_32() png_get_gAMA ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
double *  file_gamma 
)
699 {
700  png_debug1(1, "in %s retrieval function", "gAMA(float)");
701 
702  if (png_ptr != NULL && info_ptr != NULL &&
703  (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
704  file_gamma != NULL)
705  {
706  *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
707  "png_get_gAMA");
708  return (PNG_INFO_gAMA);
709  }
710 
711  return (0);
712 }
#define PNG_INFO_gAMA
Definition: png.h:873
#define png_float(png_ptr, fixed, s)
Definition: pngpriv.h:685
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
PNG_IMPEXP png_uint_32() png_get_gAMA_fixed ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
png_fixed_point int_file_gamma 
)
680 {
681  png_debug1(1, "in %s retrieval function", "gAMA");
682 
683  if (png_ptr != NULL && info_ptr != NULL &&
684  (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
685  file_gamma != NULL)
686  {
687  *file_gamma = info_ptr->colorspace.gamma;
688  return (PNG_INFO_gAMA);
689  }
690 
691  return (0);
692 }
#define PNG_INFO_gAMA
Definition: png.h:873
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
PNG_IMPEXP void() png_set_gAMA ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
double  file_gamma 
)
154 {
155  png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma,
156  "png_set_gAMA"));
157 }
png_fixed_point png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
Definition: png.c:3219
void png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point file_gamma)
Definition: pngset.c:139
PNG_IMPEXP void() png_set_gAMA_fixed ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_fixed_point  int_file_gamma 
)
141 {
142  png_debug1(1, "in %s storage function", "gAMA");
143 
144  if (png_ptr == NULL || info_ptr == NULL)
145  return;
146 
147  png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma);
148  png_colorspace_sync_info(png_ptr, info_ptr);
149 }
void png_colorspace_set_gamma(png_const_structrp png_ptr, png_colorspacerp colorspace, png_fixed_point gAMA)
Definition: png.c:1074
void png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
Definition: png.c:1129
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
PNG_IMPEXP png_uint_32() png_get_hIST ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_uint_16p hist 
)
780 {
781  png_debug1(1, "in %s retrieval function", "hIST");
782 
783  if (png_ptr != NULL && info_ptr != NULL &&
784  (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
785  {
786  *hist = info_ptr->hist;
787  return (PNG_INFO_hIST);
788  }
789 
790  return (0);
791 }
#define PNG_INFO_hIST
Definition: png.h:879
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_set_hIST ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_const_uint_16p  hist 
)
165 {
166  int i;
167 
168  png_debug1(1, "in %s storage function", "hIST");
169 
170  if (png_ptr == NULL || info_ptr == NULL)
171  return;
172 
173  if (info_ptr->num_palette == 0 || info_ptr->num_palette
175  {
176  png_warning(png_ptr,
177  "Invalid palette size, hIST allocation skipped");
178 
179  return;
180  }
181 
182  png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
183 
184  /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in
185  * version 1.2.1
186  */
187  info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr,
188  PNG_MAX_PALETTE_LENGTH * (sizeof (png_uint_16))));
189 
190  if (info_ptr->hist == NULL)
191  {
192  png_warning(png_ptr, "Insufficient memory for hIST chunk data");
193  return;
194  }
195 
196  info_ptr->free_me |= PNG_FREE_HIST;
197 
198  for (i = 0; i < info_ptr->num_palette; i++)
199  info_ptr->hist[i] = hist[i];
200 
201  info_ptr->valid |= PNG_INFO_hIST;
202 }
#define PNG_FREE_HIST
Definition: png.h:1912
#define PNG_INFO_hIST
Definition: png.h:879
int i
Definition: rw_test.cpp:37
#define PNG_MAX_PALETTE_LENGTH
Definition: png.h:866
PNG_IMPEXP png_voidp() png_malloc_warn(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:210
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_voidcast(type, value)
Definition: pngpriv.h:408
void png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, int num)
Definition: png.c:442
png_uint_16 num_palette
Definition: pnginfo.h:64
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_16 * png_uint_16p
Definition: pngconf.h:606
png_uint_32 valid
Definition: pnginfo.h:61
png_uint_32 free_me
Definition: pnginfo.h:221
PNG_IMPEXP png_uint_32() png_get_IHDR ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
png_uint_32 *  width,
png_uint_32 *  height,
int *  bit_depth,
int *  color_type,
int *  interlace_method,
int *  compression_method,
int *  filter_method 
)
799 {
800  png_debug1(1, "in %s retrieval function", "IHDR");
801 
802  if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
803  height == NULL || bit_depth == NULL || color_type == NULL)
804  return (0);
805 
806  *width = info_ptr->width;
807  *height = info_ptr->height;
808  *bit_depth = info_ptr->bit_depth;
809  *color_type = info_ptr->color_type;
810 
811  if (compression_type != NULL)
812  *compression_type = info_ptr->compression_type;
813 
814  if (filter_type != NULL)
815  *filter_type = info_ptr->filter_type;
816 
817  if (interlace_type != NULL)
818  *interlace_type = info_ptr->interlace_type;
819 
820  /* This is redundant if we can be sure that the info_ptr values were all
821  * assigned in png_set_IHDR(). We do the check anyhow in case an
822  * application has ignored our advice not to mess with the members
823  * of info_ptr directly.
824  */
825  png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height,
826  info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
827  info_ptr->compression_type, info_ptr->filter_type);
828 
829  return (1);
830 }
png_byte filter_type
Definition: pnginfo.h:70
png_byte interlace_type
Definition: pnginfo.h:71
png_byte compression_type
Definition: pnginfo.h:69
png_byte color_type
Definition: pnginfo.h:67
png_uint_32 height
Definition: pnginfo.h:60
void png_check_IHDR(png_const_structrp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type)
Definition: png.c:2476
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_byte bit_depth
Definition: pnginfo.h:66
png_uint_32 width
Definition: pnginfo.h:59
PNG_IMPEXP void() png_set_IHDR ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_uint_32  width,
png_uint_32  height,
int  bit_depth,
int  color_type,
int  interlace_method,
int  compression_method,
int  filter_method 
)
210 {
211  png_debug1(1, "in %s storage function", "IHDR");
212 
213  if (png_ptr == NULL || info_ptr == NULL)
214  return;
215 
216  info_ptr->width = width;
217  info_ptr->height = height;
218  info_ptr->bit_depth = (png_byte)bit_depth;
219  info_ptr->color_type = (png_byte)color_type;
220  info_ptr->compression_type = (png_byte)compression_type;
221  info_ptr->filter_type = (png_byte)filter_type;
222  info_ptr->interlace_type = (png_byte)interlace_type;
223 
224  png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
225  info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
226  info_ptr->compression_type, info_ptr->filter_type);
227 
228  if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
229  info_ptr->channels = 1;
230 
231  else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
232  info_ptr->channels = 3;
233 
234  else
235  info_ptr->channels = 1;
236 
237  if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
238  info_ptr->channels++;
239 
240  info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
241 
242  info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
243 }
png_byte filter_type
Definition: pnginfo.h:70
png_size_t rowbytes
Definition: pnginfo.h:62
png_byte interlace_type
Definition: pnginfo.h:71
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:810
png_byte compression_type
Definition: pnginfo.h:69
png_byte color_type
Definition: pnginfo.h:67
png_byte channels
Definition: pnginfo.h:76
#define PNG_COLOR_MASK_COLOR
Definition: png.h:805
png_uint_32 height
Definition: pnginfo.h:60
void png_check_IHDR(png_const_structrp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type)
Definition: png.c:2476
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_byte bit_depth
Definition: pnginfo.h:66
#define PNG_COLOR_MASK_ALPHA
Definition: png.h:806
png_byte pixel_depth
Definition: pnginfo.h:77
png_uint_32 width
Definition: pnginfo.h:59
#define PNG_ROWBYTES(pixel_bits, width)
Definition: pngpriv.h:660
PNG_IMPEXP png_uint_32() png_get_oFFs ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
png_int_32 *  offset_x,
png_int_32 *  offset_y,
int *  unit_type 
)
836 {
837  png_debug1(1, "in %s retrieval function", "oFFs");
838 
839  if (png_ptr != NULL && info_ptr != NULL &&
840  (info_ptr->valid & PNG_INFO_oFFs) != 0 &&
841  offset_x != NULL && offset_y != NULL && unit_type != NULL)
842  {
843  *offset_x = info_ptr->x_offset;
844  *offset_y = info_ptr->y_offset;
845  *unit_type = (int)info_ptr->offset_unit_type;
846  return (PNG_INFO_oFFs);
847  }
848 
849  return (0);
850 }
#define PNG_INFO_oFFs
Definition: png.h:881
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_set_oFFs ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_int_32  offset_x,
png_int_32  offset_y,
int  unit_type 
)
249 {
250  png_debug1(1, "in %s storage function", "oFFs");
251 
252  if (png_ptr == NULL || info_ptr == NULL)
253  return;
254 
255  info_ptr->x_offset = offset_x;
256  info_ptr->y_offset = offset_y;
257  info_ptr->offset_unit_type = (png_byte)unit_type;
258  info_ptr->valid |= PNG_INFO_oFFs;
259 }
#define PNG_INFO_oFFs
Definition: png.h:881
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP png_uint_32() png_get_pCAL ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_charp purpose,
png_int_32 *  X0,
png_int_32 *  X1,
int *  type,
int *  nparams,
png_charp units,
png_charpp params 
)
858 {
859  png_debug1(1, "in %s retrieval function", "pCAL");
860 
861  if (png_ptr != NULL && info_ptr != NULL &&
862  (info_ptr->valid & PNG_INFO_pCAL) != 0 &&
863  purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
864  nparams != NULL && units != NULL && params != NULL)
865  {
866  *purpose = info_ptr->pcal_purpose;
867  *X0 = info_ptr->pcal_X0;
868  *X1 = info_ptr->pcal_X1;
869  *type = (int)info_ptr->pcal_type;
870  *nparams = (int)info_ptr->pcal_nparams;
871  *units = info_ptr->pcal_units;
872  *params = info_ptr->pcal_params;
873  return (PNG_INFO_pCAL);
874  }
875 
876  return (0);
877 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_pCAL
Definition: png.h:883
PNG_IMPEXP void() png_set_pCAL ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_const_charp  purpose,
png_int_32  X0,
png_int_32  X1,
int  type,
int  nparams,
png_const_charp  units,
png_charpp  params 
)
267 {
269  int i;
270 
271  png_debug1(1, "in %s storage function", "pCAL");
272 
273  if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL
274  || (nparams > 0 && params == NULL))
275  return;
276 
277  length = strlen(purpose) + 1;
278  png_debug1(3, "allocating purpose for info (%lu bytes)",
279  (unsigned long)length);
280 
281  /* TODO: validate format of calibration name and unit name */
282 
283  /* Check that the type matches the specification. */
284  if (type < 0 || type > 3)
285  png_error(png_ptr, "Invalid pCAL equation type");
286 
287  if (nparams < 0 || nparams > 255)
288  png_error(png_ptr, "Invalid pCAL parameter count");
289 
290  /* Validate params[nparams] */
291  for (i=0; i<nparams; ++i)
292  {
293  if (params[i] == NULL ||
294  !png_check_fp_string(params[i], strlen(params[i])))
295  png_error(png_ptr, "Invalid format for pCAL parameter");
296  }
297 
298  info_ptr->pcal_purpose = png_voidcast(png_charp,
299  png_malloc_warn(png_ptr, length));
300 
301  if (info_ptr->pcal_purpose == NULL)
302  {
303  png_warning(png_ptr, "Insufficient memory for pCAL purpose");
304  return;
305  }
306 
307  memcpy(info_ptr->pcal_purpose, purpose, length);
308 
309  png_debug(3, "storing X0, X1, type, and nparams in info");
310  info_ptr->pcal_X0 = X0;
311  info_ptr->pcal_X1 = X1;
312  info_ptr->pcal_type = (png_byte)type;
313  info_ptr->pcal_nparams = (png_byte)nparams;
314 
315  length = strlen(units) + 1;
316  png_debug1(3, "allocating units for info (%lu bytes)",
317  (unsigned long)length);
318 
319  info_ptr->pcal_units = png_voidcast(png_charp,
320  png_malloc_warn(png_ptr, length));
321 
322  if (info_ptr->pcal_units == NULL)
323  {
324  png_warning(png_ptr, "Insufficient memory for pCAL units");
325  return;
326  }
327 
328  memcpy(info_ptr->pcal_units, units, length);
329 
330  info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
331  (png_size_t)((nparams + 1) * (sizeof (png_charp)))));
332 
333  if (info_ptr->pcal_params == NULL)
334  {
335  png_warning(png_ptr, "Insufficient memory for pCAL params");
336  return;
337  }
338 
339  memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp)));
340 
341  for (i = 0; i < nparams; i++)
342  {
343  length = strlen(params[i]) + 1;
344  png_debug2(3, "allocating parameter %d for info (%lu bytes)", i,
345  (unsigned long)length);
346 
347  info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
348 
349  if (info_ptr->pcal_params[i] == NULL)
350  {
351  png_warning(png_ptr, "Insufficient memory for pCAL parameter");
352  return;
353  }
354 
355  memcpy(info_ptr->pcal_params[i], params[i], length);
356  }
357 
358  info_ptr->valid |= PNG_INFO_pCAL;
359  info_ptr->free_me |= PNG_FREE_PCAL;
360 }
int i
Definition: rw_test.cpp:37
PNG_IMPEXP png_voidp() png_malloc_warn(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:210
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
char * png_charp
Definition: pngconf.h:610
#define png_debug(l, m)
Definition: pngdebug.h:146
#define png_voidcast(type, value)
Definition: pngpriv.h:408
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
char ** png_charpp
Definition: pngconf.h:633
png_uint_32 length
Definition: png.c:2173
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_FREE_PCAL
Definition: png.h:1916
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
size_t png_size_t
Definition: pngconf.h:543
int png_check_fp_string(png_const_charp string, png_size_t size)
Definition: png.c:2770
png_uint_32 free_me
Definition: pnginfo.h:221
#define PNG_INFO_pCAL
Definition: png.h:883
#define png_debug2(l, m, p1, p2)
Definition: pngdebug.h:152
PNG_IMPEXP png_uint_32() png_get_pHYs ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
png_uint_32 *  res_x,
png_uint_32 *  res_y,
int *  unit_type 
)
944 {
945  png_uint_32 retval = 0;
946 
947  png_debug1(1, "in %s retrieval function", "pHYs");
948 
949  if (png_ptr != NULL && info_ptr != NULL &&
950  (info_ptr->valid & PNG_INFO_pHYs) != 0)
951  {
952  if (res_x != NULL)
953  {
954  *res_x = info_ptr->x_pixels_per_unit;
955  retval |= PNG_INFO_pHYs;
956  }
957 
958  if (res_y != NULL)
959  {
960  *res_y = info_ptr->y_pixels_per_unit;
961  retval |= PNG_INFO_pHYs;
962  }
963 
964  if (unit_type != NULL)
965  {
966  *unit_type = (int)info_ptr->phys_unit_type;
967  retval |= PNG_INFO_pHYs;
968  }
969  }
970 
971  return (retval);
972 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_pHYs
Definition: png.h:880
PNG_IMPEXP void() png_set_pHYs ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_uint_32  res_x,
png_uint_32  res_y,
int  unit_type 
)
491 {
492  png_debug1(1, "in %s storage function", "pHYs");
493 
494  if (png_ptr == NULL || info_ptr == NULL)
495  return;
496 
497  info_ptr->x_pixels_per_unit = res_x;
498  info_ptr->y_pixels_per_unit = res_y;
499  info_ptr->phys_unit_type = (png_byte)unit_type;
500  info_ptr->valid |= PNG_INFO_pHYs;
501 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_pHYs
Definition: png.h:880
PNG_IMPEXP png_uint_32() png_get_PLTE ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_colorp palette,
int *  num_palette 
)
978 {
979  png_debug1(1, "in %s retrieval function", "PLTE");
980 
981  if (png_ptr != NULL && info_ptr != NULL &&
982  (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL)
983  {
984  *palette = info_ptr->palette;
985  *num_palette = info_ptr->num_palette;
986  png_debug1(3, "num_palette = %d", *num_palette);
987  return (PNG_INFO_PLTE);
988  }
989 
990  return (0);
991 }
png_colorp palette
Definition: pnginfo.h:63
png_uint_16 num_palette
Definition: pnginfo.h:64
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_INFO_PLTE
Definition: png.h:876
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_set_PLTE ( png_structrp  png_ptr,
png_inforp  info_ptr,
png_const_colorp  palette,
int  num_palette 
)
507 {
508 
509  png_debug1(1, "in %s storage function", "PLTE");
510 
511  if (png_ptr == NULL || info_ptr == NULL)
512  return;
513 
514  if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
515  {
516  if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
517  png_error(png_ptr, "Invalid palette length");
518 
519  else
520  {
521  png_warning(png_ptr, "Invalid palette length");
522  return;
523  }
524  }
525 
526  if ((num_palette > 0 && palette == NULL) ||
527  (num_palette == 0
529  && (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0
530 # endif
531  ))
532  {
533  png_error(png_ptr, "Invalid palette");
534  return;
535  }
536 
537  /* It may not actually be necessary to set png_ptr->palette here;
538  * we do it for backward compatibility with the way the png_handle_tRNS
539  * function used to do the allocation.
540  *
541  * 1.6.0: the above statement appears to be incorrect; something has to set
542  * the palette inside png_struct on read.
543  */
544  png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
545 
546  /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
547  * of num_palette entries, in case of an invalid PNG file that has
548  * too-large sample values.
549  */
550  png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
551  PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
552 
553  if (num_palette > 0)
554  memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
555  info_ptr->palette = png_ptr->palette;
556  info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
557 
558  info_ptr->free_me |= PNG_FREE_PLTE;
559 
560  info_ptr->valid |= PNG_INFO_PLTE;
561 }
#define PNG_MAX_PALETTE_LENGTH
Definition: png.h:866
png_colorp palette
Definition: pnginfo.h:63
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:810
#define PNG_FREE_PLTE
Definition: png.h:1922
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_voidcast(type, value)
Definition: pngpriv.h:408
void png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, int num)
Definition: png.c:442
#define PNG_MNG_FEATURES_SUPPORTED
Definition: pnglibconf.h:45
png_byte color_type
Definition: pnginfo.h:67
png_colorp palette
Definition: pngstruct.h:238
png_uint_16 num_palette
Definition: pngstruct.h:239
png_uint_16 num_palette
Definition: pnginfo.h:64
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
Definition: png.h:619
#define PNG_INFO_PLTE
Definition: png.h:876
PNG_IMPEXP png_voidp() png_calloc(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:50
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
#define PNG_FLAG_MNG_EMPTY_PLTE
Definition: png.h:995
png_uint_32 free_me
Definition: pnginfo.h:221
PNG_IMPEXP png_uint_32() png_get_sBIT ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_color_8p sig_bit 
)
997 {
998  png_debug1(1, "in %s retrieval function", "sBIT");
999 
1000  if (png_ptr != NULL && info_ptr != NULL &&
1001  (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
1002  {
1003  *sig_bit = &(info_ptr->sig_bit);
1004  return (PNG_INFO_sBIT);
1005  }
1006 
1007  return (0);
1008 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_INFO_sBIT
Definition: png.h:874
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_set_sBIT ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_const_color_8p  sig_bit 
)
567 {
568  png_debug1(1, "in %s storage function", "sBIT");
569 
570  if (png_ptr == NULL || info_ptr == NULL || sig_bit == NULL)
571  return;
572 
573  info_ptr->sig_bit = *sig_bit;
574  info_ptr->valid |= PNG_INFO_sBIT;
575 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_INFO_sBIT
Definition: png.h:874
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP png_uint_32() png_get_sRGB ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
int *  file_srgb_intent 
)
720 {
721  png_debug1(1, "in %s retrieval function", "sRGB");
722 
723  if (png_ptr != NULL && info_ptr != NULL &&
724  (info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
725  {
726  *file_srgb_intent = info_ptr->colorspace.rendering_intent;
727  return (PNG_INFO_sRGB);
728  }
729 
730  return (0);
731 }
#define PNG_INFO_sRGB
Definition: png.h:884
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_set_sRGB ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
int  srgb_intent 
)
581 {
582  png_debug1(1, "in %s storage function", "sRGB");
583 
584  if (png_ptr == NULL || info_ptr == NULL)
585  return;
586 
587  (void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent);
588  png_colorspace_sync_info(png_ptr, info_ptr);
589 }
void png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
Definition: png.c:1129
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
int png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, int intent)
Definition: png.c:1833
PNG_IMPEXP void() png_set_sRGB_gAMA_and_cHRM ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
int  srgb_intent 
)
594 {
595  png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
596 
597  if (png_ptr == NULL || info_ptr == NULL)
598  return;
599 
600  if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace,
601  srgb_intent) != 0)
602  {
603  /* This causes the gAMA and cHRM to be written too */
604  info_ptr->colorspace.flags |=
605  PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
606  }
607 
608  png_colorspace_sync_info(png_ptr, info_ptr);
609 }
void png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
Definition: png.c:1129
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
int png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, int intent)
Definition: png.c:1833
PNG_IMPEXP png_uint_32() png_get_iCCP ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_charpp  name,
int *  compression_type,
png_bytepp  profile,
png_uint_32 *  proflen 
)
739 {
740  png_debug1(1, "in %s retrieval function", "iCCP");
741 
742  if (png_ptr != NULL && info_ptr != NULL &&
743  (info_ptr->valid & PNG_INFO_iCCP) != 0 &&
744  name != NULL && compression_type != NULL && profile != NULL &&
745  proflen != NULL)
746  {
747  *name = info_ptr->iccp_name;
748  *profile = info_ptr->iccp_profile;
749  *proflen = png_get_uint_32(info_ptr->iccp_profile);
750  /* This is somewhat irrelevant since the profile data returned has
751  * actually been uncompressed.
752  */
753  *compression_type = PNG_COMPRESSION_TYPE_BASE;
754  return (PNG_INFO_iCCP);
755  }
756 
757  return (0);
758 }
#define png_get_uint_32(buf)
Definition: png.h:2744
string name
Definition: cubesat2obj.cpp:6
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_COMPRESSION_TYPE_BASE
Definition: png.h:819
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_iCCP
Definition: png.h:885
PNG_IMPEXP void() png_set_iCCP ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_const_charp  name,
int  compression_type,
png_const_bytep  profile,
png_uint_32  proflen 
)
618 {
619  png_charp new_iccp_name;
620  png_bytep new_iccp_profile;
622 
623  png_debug1(1, "in %s storage function", "iCCP");
624 
625  if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
626  return;
627 
628  if (compression_type != PNG_COMPRESSION_TYPE_BASE)
629  png_app_error(png_ptr, "Invalid iCCP compression method");
630 
631  /* Set the colorspace first because this validates the profile; do not
632  * override previously set app cHRM or gAMA here (because likely as not the
633  * application knows better than libpng what the correct values are.) Pass
634  * the info_ptr color_type field to png_colorspace_set_ICC because in the
635  * write case it has not yet been stored in png_ptr.
636  */
637  {
638  int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name,
639  proflen, profile, info_ptr->color_type);
640 
641  png_colorspace_sync_info(png_ptr, info_ptr);
642 
643  /* Don't do any of the copying if the profile was bad, or inconsistent. */
644  if (result == 0)
645  return;
646 
647  /* But do write the gAMA and cHRM chunks from the profile. */
648  info_ptr->colorspace.flags |=
649  PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
650  }
651 
652  length = strlen(name)+1;
653  new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
654 
655  if (new_iccp_name == NULL)
656  {
657  png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk");
658  return;
659  }
660 
661  memcpy(new_iccp_name, name, length);
662  new_iccp_profile = png_voidcast(png_bytep,
663  png_malloc_warn(png_ptr, proflen));
664 
665  if (new_iccp_profile == NULL)
666  {
667  png_free(png_ptr, new_iccp_name);
668  new_iccp_name = NULL;
669  png_benign_error(png_ptr,
670  "Insufficient memory to process iCCP profile");
671  return;
672  }
673 
674  memcpy(new_iccp_profile, profile, proflen);
675 
676  png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
677 
678  info_ptr->iccp_proflen = proflen;
679  info_ptr->iccp_name = new_iccp_name;
680  info_ptr->iccp_profile = new_iccp_profile;
681  info_ptr->free_me |= PNG_FREE_ICCP;
682  info_ptr->valid |= PNG_INFO_iCCP;
683 }
int png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace, png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, int color_type)
Definition: png.c:2371
png_byte * png_bytep
Definition: pngconf.h:600
PNG_IMPEXP png_voidp() png_malloc_warn(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:210
char * png_charp
Definition: pngconf.h:610
#define PNG_FREE_ICCP
Definition: png.h:1913
#define png_voidcast(type, value)
Definition: pngpriv.h:408
void png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
Definition: png.c:1129
void png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, int num)
Definition: png.c:442
png_byte color_type
Definition: pnginfo.h:67
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
string name
Definition: cubesat2obj.cpp:6
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 length
Definition: png.c:2173
#define PNG_COMPRESSION_TYPE_BASE
Definition: png.h:819
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:229
size_t png_size_t
Definition: pngconf.h:543
png_uint_32 free_me
Definition: pnginfo.h:221
#define PNG_INFO_iCCP
Definition: png.h:885
PNG_IMPEXP void() png_benign_error(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:362
PNG_IMPEXP int() png_get_sPLT ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_sPLT_tpp  entries 
)
765 {
766  if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
767  {
768  *spalettes = info_ptr->splt_palettes;
769  return info_ptr->splt_palettes_num;
770  }
771 
772  return (0);
773 }
PNG_IMPEXP void() png_set_sPLT ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_const_sPLT_tp  entries,
int  nentries 
)
987 {
988  png_sPLT_tp np;
989 
990  if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL)
991  return;
992 
993  /* Use the internal realloc function, which checks for all the possible
994  * overflows. Notice that the parameters are (int) and (size_t)
995  */
997  info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
998  sizeof *np));
999 
1000  if (np == NULL)
1001  {
1002  /* Out of memory or too many chunks */
1003  png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
1004  return;
1005  }
1006 
1007  png_free(png_ptr, info_ptr->splt_palettes);
1008  info_ptr->splt_palettes = np;
1009  info_ptr->free_me |= PNG_FREE_SPLT;
1010 
1011  np += info_ptr->splt_palettes_num;
1012 
1013  do
1014  {
1016 
1017  /* Skip invalid input entries */
1018  if (entries->name == NULL || entries->entries == NULL)
1019  {
1020  /* png_handle_sPLT doesn't do this, so this is an app error */
1021  png_app_error(png_ptr, "png_set_sPLT: invalid sPLT");
1022  /* Just skip the invalid entry */
1023  continue;
1024  }
1025 
1026  np->depth = entries->depth;
1027 
1028  /* In the event of out-of-memory just return - there's no point keeping
1029  * on trying to add sPLT chunks.
1030  */
1031  length = strlen(entries->name) + 1;
1032  np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));
1033 
1034  if (np->name == NULL)
1035  break;
1036 
1037  memcpy(np->name, entries->name, length);
1038 
1039  /* IMPORTANT: we have memory now that won't get freed if something else
1040  * goes wrong; this code must free it. png_malloc_array produces no
1041  * warnings; use a png_chunk_report (below) if there is an error.
1042  */
1044  entries->nentries, sizeof (png_sPLT_entry)));
1045 
1046  if (np->entries == NULL)
1047  {
1048  png_free(png_ptr, np->name);
1049  np->name = NULL;
1050  break;
1051  }
1052 
1053  np->nentries = entries->nentries;
1054  /* This multiply can't overflow because png_malloc_array has already
1055  * checked it when doing the allocation.
1056  */
1057  memcpy(np->entries, entries->entries,
1058  entries->nentries * sizeof (png_sPLT_entry));
1059 
1060  /* Note that 'continue' skips the advance of the out pointer and out
1061  * count, so an invalid entry is not added.
1062  */
1063  info_ptr->valid |= PNG_INFO_sPLT;
1064  ++(info_ptr->splt_palettes_num);
1065  ++np;
1066  }
1067  while (++entries, --nentries);
1068 
1069  if (nentries > 0)
1070  png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
1071 }
png_int_32 nentries
Definition: png.h:679
char * png_charp
Definition: pngconf.h:610
png_voidp png_realloc_array(png_const_structrp png_ptr, png_const_voidp old_array, int old_elements, int add_elements, size_t element_size)
Definition: pngmem.c:130
#define png_voidcast(type, value)
Definition: pngpriv.h:408
png_voidp png_malloc_base(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:69
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
png_byte depth
Definition: png.h:677
#define PNG_FREE_SPLT
Definition: png.h:1914
png_sPLT_entryp entries
Definition: png.h:678
Definition: png.h:657
#define PNG_CHUNK_WRITE_ERROR
Definition: pngpriv.h:1673
png_voidp png_malloc_array(png_const_structrp png_ptr, int nelements, size_t element_size)
Definition: pngmem.c:120
Definition: png.h:674
png_uint_32 length
Definition: png.c:2173
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:229
void png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
Definition: pngerror.c:531
size_t png_size_t
Definition: pngconf.h:543
#define PNG_INFO_sPLT
Definition: png.h:886
png_uint_32 free_me
Definition: pnginfo.h:221
png_charp name
Definition: png.h:676
PNG_IMPEXP int() png_get_text ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_textp text_ptr,
int *  num_text 
)
1015 {
1016  if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
1017  {
1018  png_debug1(1, "in 0x%lx retrieval function",
1019  (unsigned long)png_ptr->chunk_name);
1020 
1021  if (text_ptr != NULL)
1022  *text_ptr = info_ptr->text;
1023 
1024  if (num_text != NULL)
1025  *num_text = info_ptr->num_text;
1026 
1027  return info_ptr->num_text;
1028  }
1029 
1030  if (num_text != NULL)
1031  *num_text = 0;
1032 
1033  return(0);
1034 }
png_uint_32 chunk_name
Definition: pngstruct.h:221
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
PNG_IMPEXP void() png_set_text ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_const_textp  text_ptr,
int  num_text 
)
690 {
691  int ret;
692  ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
693 
694  if (ret != 0)
695  png_error(png_ptr, "Insufficient memory to store text");
696 }
int png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)
Definition: pngset.c:699
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
PNG_IMPEXP png_uint_32() png_get_tIME ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_timep mod_time 
)
1041 {
1042  png_debug1(1, "in %s retrieval function", "tIME");
1043 
1044  if (png_ptr != NULL && info_ptr != NULL &&
1045  (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
1046  {
1047  *mod_time = &(info_ptr->mod_time);
1048  return (PNG_INFO_tIME);
1049  }
1050 
1051  return (0);
1052 }
#define PNG_INFO_tIME
Definition: png.h:882
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_set_tIME ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_const_timep  mod_time 
)
894 {
895  png_debug1(1, "in %s storage function", "tIME");
896 
897  if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL ||
898  (png_ptr->mode & PNG_WROTE_tIME) != 0)
899  return;
900 
901  if (mod_time->month == 0 || mod_time->month > 12 ||
902  mod_time->day == 0 || mod_time->day > 31 ||
903  mod_time->hour > 23 || mod_time->minute > 59 ||
904  mod_time->second > 60)
905  {
906  png_warning(png_ptr, "Ignoring invalid time value");
907  return;
908  }
909 
910  info_ptr->mod_time = *mod_time;
911  info_ptr->valid |= PNG_INFO_tIME;
912 }
#define PNG_INFO_tIME
Definition: png.h:882
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
png_byte hour
Definition: png.h:746
png_byte second
Definition: png.h:748
png_byte minute
Definition: png.h:747
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_WROTE_tIME
Definition: pngpriv.h:551
png_byte day
Definition: png.h:745
png_uint_32 valid
Definition: pnginfo.h:61
png_uint_32 mode
Definition: pngstruct.h:179
png_byte month
Definition: png.h:744
PNG_IMPEXP png_uint_32() png_get_tRNS ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_bytep trans_alpha,
int *  num_trans,
png_color_16p trans_color 
)
1059 {
1060  png_uint_32 retval = 0;
1061  if (png_ptr != NULL && info_ptr != NULL &&
1062  (info_ptr->valid & PNG_INFO_tRNS) != 0)
1063  {
1064  png_debug1(1, "in %s retrieval function", "tRNS");
1065 
1066  if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
1067  {
1068  if (trans_alpha != NULL)
1069  {
1070  *trans_alpha = info_ptr->trans_alpha;
1071  retval |= PNG_INFO_tRNS;
1072  }
1073 
1074  if (trans_color != NULL)
1075  *trans_color = &(info_ptr->trans_color);
1076  }
1077 
1078  else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
1079  {
1080  if (trans_color != NULL)
1081  {
1082  *trans_color = &(info_ptr->trans_color);
1083  retval |= PNG_INFO_tRNS;
1084  }
1085 
1086  if (trans_alpha != NULL)
1087  *trans_alpha = NULL;
1088  }
1089 
1090  if (num_trans != NULL)
1091  {
1092  *num_trans = info_ptr->num_trans;
1093  retval |= PNG_INFO_tRNS;
1094  }
1095  }
1096 
1097  return (retval);
1098 }
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:810
png_byte color_type
Definition: pnginfo.h:67
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_INFO_tRNS
Definition: png.h:877
png_uint_32 valid
Definition: pnginfo.h:61
png_uint_16 num_trans
Definition: pnginfo.h:65
PNG_IMPEXP void() png_set_tRNS ( png_structrp  png_ptr,
png_inforp  info_ptr,
png_const_bytep  trans_alpha,
int  num_trans,
png_const_color_16p  trans_color 
)
919 {
920  png_debug1(1, "in %s storage function", "tRNS");
921 
922  if (png_ptr == NULL || info_ptr == NULL)
923  return;
924 
925  if (trans_alpha != NULL)
926  {
927  /* It may not actually be necessary to set png_ptr->trans_alpha here;
928  * we do it for backward compatibility with the way the png_handle_tRNS
929  * function used to do the allocation.
930  *
931  * 1.6.0: The above statement is incorrect; png_handle_tRNS effectively
932  * relies on png_set_tRNS storing the information in png_struct
933  * (otherwise it won't be there for the code in pngrtran.c).
934  */
935 
936  png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
937 
938  /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
939  png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep,
941 
942  if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
943  memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
944  }
945 
946  if (trans_color != NULL)
947  {
948  int sample_max = (1 << info_ptr->bit_depth);
949 
950  if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
951  trans_color->gray > sample_max) ||
952  (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
953  (trans_color->red > sample_max ||
954  trans_color->green > sample_max ||
955  trans_color->blue > sample_max)))
956  png_warning(png_ptr,
957  "tRNS chunk has out-of-range samples for bit_depth");
958 
959  info_ptr->trans_color = *trans_color;
960 
961  if (num_trans == 0)
962  num_trans = 1;
963  }
964 
965  info_ptr->num_trans = (png_uint_16)num_trans;
966 
967  if (num_trans != 0)
968  {
969  info_ptr->valid |= PNG_INFO_tRNS;
970  info_ptr->free_me |= PNG_FREE_TRNS;
971  }
972 }
PNG_IMPEXP png_voidp() png_malloc(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:169
#define PNG_MAX_PALETTE_LENGTH
Definition: png.h:866
#define PNG_COLOR_TYPE_RGB
Definition: png.h:811
png_uint_16 blue
Definition: png.h:634
png_byte * png_bytep
Definition: pngconf.h:600
png_uint_16 gray
Definition: png.h:635
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
#define png_voidcast(type, value)
Definition: pngpriv.h:408
void png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, int num)
Definition: png.c:442
png_byte color_type
Definition: pnginfo.h:67
png_uint_16 green
Definition: png.h:633
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:809
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_byte bit_depth
Definition: pnginfo.h:66
#define PNG_INFO_tRNS
Definition: png.h:877
png_uint_32 valid
Definition: pnginfo.h:61
size_t png_size_t
Definition: pngconf.h:543
png_uint_16 red
Definition: png.h:632
png_uint_32 free_me
Definition: pnginfo.h:221
png_uint_16 num_trans
Definition: pnginfo.h:65
#define PNG_FREE_TRNS
Definition: png.h:1923
PNG_IMPEXP png_uint_32() png_get_sCAL ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
int *  unit,
double *  width,
double *  height 
)
910 {
911  if (png_ptr != NULL && info_ptr != NULL &&
912  (info_ptr->valid & PNG_INFO_sCAL) != 0)
913  {
914  *unit = info_ptr->scal_unit;
915  *width = atof(info_ptr->scal_s_width);
916  *height = atof(info_ptr->scal_s_height);
917  return (PNG_INFO_sCAL);
918  }
919 
920  return(0);
921 }
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_sCAL
Definition: png.h:887
PNG_IMPEXP png_uint_32() png_get_sCAL_fixed ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
int *  unit,
png_fixed_point width,
png_fixed_point height 
)
887 {
888  if (png_ptr != NULL && info_ptr != NULL &&
889  (info_ptr->valid & PNG_INFO_sCAL) != 0)
890  {
891  *unit = info_ptr->scal_unit;
892  /*TODO: make this work without FP support; the API is currently eliminated
893  * if neither floating point APIs nor internal floating point arithmetic
894  * are enabled.
895  */
896  *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
897  *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
898  "sCAL height");
899  return (PNG_INFO_sCAL);
900  }
901 
902  return(0);
903 }
png_fixed_point png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
Definition: png.c:3219
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_sCAL
Definition: png.h:887
PNG_IMPEXP png_uint_32() png_get_sCAL_s ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
int *  unit,
png_charpp  swidth,
png_charpp  sheight 
)
926 {
927  if (png_ptr != NULL && info_ptr != NULL &&
928  (info_ptr->valid & PNG_INFO_sCAL) != 0)
929  {
930  *unit = info_ptr->scal_unit;
931  *width = info_ptr->scal_s_width;
932  *height = info_ptr->scal_s_height;
933  return (PNG_INFO_sCAL);
934  }
935 
936  return(0);
937 }
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_sCAL
Definition: png.h:887
PNG_IMPEXP void() png_set_sCAL ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
int  unit,
double  width,
double  height 
)
432 {
433  png_debug1(1, "in %s storage function", "sCAL");
434 
435  /* Check the arguments. */
436  if (width <= 0)
437  png_warning(png_ptr, "Invalid sCAL width ignored");
438 
439  else if (height <= 0)
440  png_warning(png_ptr, "Invalid sCAL height ignored");
441 
442  else
443  {
444  /* Convert 'width' and 'height' to ASCII. */
445  char swidth[PNG_sCAL_MAX_DIGITS+1];
446  char sheight[PNG_sCAL_MAX_DIGITS+1];
447 
448  png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width,
450  png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height,
452 
453  png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
454  }
455 }
#define PNG_sCAL_PRECISION
Definition: pnglibconf.h:207
void png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, double fp, unsigned int precision)
Definition: png.c:2826
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
void png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)
Definition: pngset.c:365
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_sCAL_MAX_DIGITS
Definition: pngpriv.h:1685
PNG_IMPEXP void() png_set_sCAL_fixed ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
int  unit,
png_fixed_point  width,
png_fixed_point  height 
)
462 {
463  png_debug1(1, "in %s storage function", "sCAL");
464 
465  /* Check the arguments. */
466  if (width <= 0)
467  png_warning(png_ptr, "Invalid sCAL width ignored");
468 
469  else if (height <= 0)
470  png_warning(png_ptr, "Invalid sCAL height ignored");
471 
472  else
473  {
474  /* Convert 'width' and 'height' to ASCII. */
475  char swidth[PNG_sCAL_MAX_DIGITS+1];
476  char sheight[PNG_sCAL_MAX_DIGITS+1];
477 
478  png_ascii_from_fixed(png_ptr, swidth, (sizeof swidth), width);
479  png_ascii_from_fixed(png_ptr, sheight, (sizeof sheight), height);
480 
481  png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
482  }
483 }
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
void png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)
Definition: pngset.c:365
void png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii, png_size_t size, png_fixed_point fp)
Definition: png.c:3141
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
#define PNG_sCAL_MAX_DIGITS
Definition: pngpriv.h:1685
PNG_IMPEXP void() png_set_sCAL_s ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
int  unit,
png_const_charp  swidth,
png_const_charp  sheight 
)
367 {
368  png_size_t lengthw = 0, lengthh = 0;
369 
370  png_debug1(1, "in %s storage function", "sCAL");
371 
372  if (png_ptr == NULL || info_ptr == NULL)
373  return;
374 
375  /* Double check the unit (should never get here with an invalid
376  * unit unless this is an API call.)
377  */
378  if (unit != 1 && unit != 2)
379  png_error(png_ptr, "Invalid sCAL unit");
380 
381  if (swidth == NULL || (lengthw = strlen(swidth)) == 0 ||
382  swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw))
383  png_error(png_ptr, "Invalid sCAL width");
384 
385  if (sheight == NULL || (lengthh = strlen(sheight)) == 0 ||
386  sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh))
387  png_error(png_ptr, "Invalid sCAL height");
388 
389  info_ptr->scal_unit = (png_byte)unit;
390 
391  ++lengthw;
392 
393  png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw);
394 
395  info_ptr->scal_s_width = png_voidcast(png_charp,
396  png_malloc_warn(png_ptr, lengthw));
397 
398  if (info_ptr->scal_s_width == NULL)
399  {
400  png_warning(png_ptr, "Memory allocation failed while processing sCAL");
401  return;
402  }
403 
404  memcpy(info_ptr->scal_s_width, swidth, lengthw);
405 
406  ++lengthh;
407 
408  png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh);
409 
410  info_ptr->scal_s_height = png_voidcast(png_charp,
411  png_malloc_warn(png_ptr, lengthh));
412 
413  if (info_ptr->scal_s_height == NULL)
414  {
415  png_free (png_ptr, info_ptr->scal_s_width);
416  info_ptr->scal_s_width = NULL;
417 
418  png_warning(png_ptr, "Memory allocation failed while processing sCAL");
419  return;
420  }
421 
422  memcpy(info_ptr->scal_s_height, sheight, lengthh);
423 
424  info_ptr->valid |= PNG_INFO_sCAL;
425  info_ptr->free_me |= PNG_FREE_SCAL;
426 }
PNG_IMPEXP png_voidp() png_malloc_warn(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:210
PNG_IMPEXP void() png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
char * png_charp
Definition: pngconf.h:610
#define png_voidcast(type, value)
Definition: pngpriv.h:408
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:229
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
size_t png_size_t
Definition: pngconf.h:543
int png_check_fp_string(png_const_charp string, png_size_t size)
Definition: png.c:2770
png_uint_32 free_me
Definition: pnginfo.h:221
#define PNG_FREE_SCAL
Definition: png.h:1917
#define PNG_INFO_sCAL
Definition: png.h:887
PNG_IMPEXP void() png_set_keep_unknown_chunks ( png_structrp  png_ptr,
int  keep,
png_const_bytep  chunk_list,
int  num_chunks 
)
1284 {
1285  png_bytep new_list;
1286  unsigned int num_chunks, old_num_chunks;
1287 
1288  if (png_ptr == NULL)
1289  return;
1290 
1291  if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)
1292  {
1293  png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
1294  return;
1295  }
1296 
1297  if (num_chunks_in <= 0)
1298  {
1299  png_ptr->unknown_default = keep;
1300 
1301  /* '0' means just set the flags, so stop here */
1302  if (num_chunks_in == 0)
1303  return;
1304  }
1305 
1306  if (num_chunks_in < 0)
1307  {
1308  /* Ignore all unknown chunks and all chunks recognized by
1309  * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
1310  */
1311  static PNG_CONST png_byte chunks_to_ignore[] = {
1312  98, 75, 71, 68, '\0', /* bKGD */
1313  99, 72, 82, 77, '\0', /* cHRM */
1314  103, 65, 77, 65, '\0', /* gAMA */
1315  104, 73, 83, 84, '\0', /* hIST */
1316  105, 67, 67, 80, '\0', /* iCCP */
1317  105, 84, 88, 116, '\0', /* iTXt */
1318  111, 70, 70, 115, '\0', /* oFFs */
1319  112, 67, 65, 76, '\0', /* pCAL */
1320  112, 72, 89, 115, '\0', /* pHYs */
1321  115, 66, 73, 84, '\0', /* sBIT */
1322  115, 67, 65, 76, '\0', /* sCAL */
1323  115, 80, 76, 84, '\0', /* sPLT */
1324  115, 84, 69, 82, '\0', /* sTER */
1325  115, 82, 71, 66, '\0', /* sRGB */
1326  116, 69, 88, 116, '\0', /* tEXt */
1327  116, 73, 77, 69, '\0', /* tIME */
1328  122, 84, 88, 116, '\0' /* zTXt */
1329  };
1330 
1331  chunk_list = chunks_to_ignore;
1332  num_chunks = (unsigned int)/*SAFE*/(sizeof chunks_to_ignore)/5U;
1333  }
1334 
1335  else /* num_chunks_in > 0 */
1336  {
1337  if (chunk_list == NULL)
1338  {
1339  /* Prior to 1.6.0 this was silently ignored, now it is an app_error
1340  * which can be switched off.
1341  */
1342  png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list");
1343  return;
1344  }
1345 
1346  num_chunks = num_chunks_in;
1347  }
1348 
1349  old_num_chunks = png_ptr->num_chunk_list;
1350  if (png_ptr->chunk_list == NULL)
1351  old_num_chunks = 0;
1352 
1353  /* Since num_chunks is always restricted to UINT_MAX/5 this can't overflow.
1354  */
1355  if (num_chunks + old_num_chunks > UINT_MAX/5)
1356  {
1357  png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks");
1358  return;
1359  }
1360 
1361  /* If these chunks are being reset to the default then no more memory is
1362  * required because add_one_chunk above doesn't extend the list if the 'keep'
1363  * parameter is the default.
1364  */
1365  if (keep != 0)
1366  {
1367  new_list = png_voidcast(png_bytep, png_malloc(png_ptr,
1368  5 * (num_chunks + old_num_chunks)));
1369 
1370  if (old_num_chunks > 0)
1371  memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);
1372  }
1373 
1374  else if (old_num_chunks > 0)
1375  new_list = png_ptr->chunk_list;
1376 
1377  else
1378  new_list = NULL;
1379 
1380  /* Add the new chunks together with each one's handling code. If the chunk
1381  * already exists the code is updated, otherwise the chunk is added to the
1382  * end. (In libpng 1.6.0 order no longer matters because this code enforces
1383  * the earlier convention that the last setting is the one that is used.)
1384  */
1385  if (new_list != NULL)
1386  {
1387  png_const_bytep inlist;
1388  png_bytep outlist;
1389  unsigned int i;
1390 
1391  for (i=0; i<num_chunks; ++i)
1392  {
1393  old_num_chunks = add_one_chunk(new_list, old_num_chunks,
1394  chunk_list+5*i, keep);
1395  }
1396 
1397  /* Now remove any spurious 'default' entries. */
1398  num_chunks = 0;
1399  for (i=0, inlist=outlist=new_list; i<old_num_chunks; ++i, inlist += 5)
1400  {
1401  if (inlist[4])
1402  {
1403  if (outlist != inlist)
1404  memcpy(outlist, inlist, 5);
1405  outlist += 5;
1406  ++num_chunks;
1407  }
1408  }
1409 
1410  /* This means the application has removed all the specialized handling. */
1411  if (num_chunks == 0)
1412  {
1413  if (png_ptr->chunk_list != new_list)
1414  png_free(png_ptr, new_list);
1415 
1416  new_list = NULL;
1417  }
1418  }
1419 
1420  else
1421  num_chunks = 0;
1422 
1423  png_ptr->num_chunk_list = num_chunks;
1424 
1425  if (png_ptr->chunk_list != new_list)
1426  {
1427  if (png_ptr->chunk_list != NULL)
1428  png_free(png_ptr, png_ptr->chunk_list);
1429 
1430  png_ptr->chunk_list = new_list;
1431  }
1432 }
PNG_IMPEXP png_voidp() png_malloc(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:169
#define PNG_HANDLE_CHUNK_LAST
Definition: png.h:2501
int i
Definition: rw_test.cpp:37
png_byte * png_bytep
Definition: pngconf.h:600
#define png_voidcast(type, value)
Definition: pngpriv.h:408
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
#define PNG_CONST
Definition: pngconf.h:86
const png_byte * png_const_bytep
Definition: pngconf.h:601
PNG_IMPEXP void() png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:229
static unsigned int add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)
Definition: pngset.c:1255
PNG_IMPEXP int() png_handle_as_unknown ( png_const_structrp  png_ptr,
png_const_bytep  chunk_name 
)
885 {
886  /* Check chunk_name and return "keep" value if it's on the list, else 0 */
887  png_const_bytep p, p_end;
888 
889  if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list == 0)
891 
892  p_end = png_ptr->chunk_list;
893  p = p_end + png_ptr->num_chunk_list*5; /* beyond end */
894 
895  /* The code is the fifth byte after each four byte string. Historically this
896  * code was always searched from the end of the list, this is no longer
897  * necessary because the 'set' routine handles duplicate entries correcty.
898  */
899  do /* num_chunk_list > 0, so at least one */
900  {
901  p -= 5;
902 
903  if (memcmp(chunk_name, p, 4) == 0)
904  return p[4];
905  }
906  while (p > p_end);
907 
908  /* This means that known chunks should be processed and unknown chunks should
909  * be handled according to the value of png_ptr->unknown_default; this can be
910  * confusing because, as a result, there are two levels of defaulting for
911  * unknown chunks.
912  */
914 }
#define PNG_HANDLE_CHUNK_AS_DEFAULT
Definition: png.h:2497
static double * p
Definition: gauss_jackson_test.cpp:42
const png_byte * png_const_bytep
Definition: pngconf.h:601
PNG_IMPEXP void() png_set_unknown_chunks ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_const_unknown_chunkp  unknowns,
int  num_unknowns 
)
1115 {
1116  png_unknown_chunkp np;
1117 
1118  if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 ||
1119  unknowns == NULL)
1120  return;
1121 
1122  /* Check for the failure cases where support has been disabled at compile
1123  * time. This code is hardly ever compiled - it's here because
1124  * STORE_UNKNOWN_CHUNKS is set by both read and write code (compiling in this
1125  * code) but may be meaningless if the read or write handling of unknown
1126  * chunks is not compiled in.
1127  */
1128 # if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
1129  defined(PNG_READ_SUPPORTED)
1130  if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
1131  {
1132  png_app_error(png_ptr, "no unknown chunk support on read");
1133  return;
1134  }
1135 # endif
1136 # if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
1137  defined(PNG_WRITE_SUPPORTED)
1138  if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
1139  {
1140  png_app_error(png_ptr, "no unknown chunk support on write");
1141  return;
1142  }
1143 # endif
1144 
1145  /* Prior to 1.6.0 this code used png_malloc_warn; however, this meant that
1146  * unknown critical chunks could be lost with just a warning resulting in
1147  * undefined behavior. Now png_chunk_report is used to provide behavior
1148  * appropriate to read or write.
1149  */
1151  info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns,
1152  sizeof *np));
1153 
1154  if (np == NULL)
1155  {
1156  png_chunk_report(png_ptr, "too many unknown chunks",
1158  return;
1159  }
1160 
1161  png_free(png_ptr, info_ptr->unknown_chunks);
1162  info_ptr->unknown_chunks = np; /* safe because it is initialized */
1163  info_ptr->free_me |= PNG_FREE_UNKN;
1164 
1165  np += info_ptr->unknown_chunks_num;
1166 
1167  /* Increment unknown_chunks_num each time round the loop to protect the
1168  * just-allocated chunk data.
1169  */
1170  for (; num_unknowns > 0; --num_unknowns, ++unknowns)
1171  {
1172  memcpy(np->name, unknowns->name, (sizeof np->name));
1173  np->name[(sizeof np->name)-1] = '\0';
1174  np->location = check_location(png_ptr, unknowns->location);
1175 
1176  if (unknowns->size == 0)
1177  {
1178  np->data = NULL;
1179  np->size = 0;
1180  }
1181 
1182  else
1183  {
1184  np->data = png_voidcast(png_bytep,
1185  png_malloc_base(png_ptr, unknowns->size));
1186 
1187  if (np->data == NULL)
1188  {
1189  png_chunk_report(png_ptr, "unknown chunk: out of memory",
1191  /* But just skip storing the unknown chunk */
1192  continue;
1193  }
1194 
1195  memcpy(np->data, unknowns->data, unknowns->size);
1196  np->size = unknowns->size;
1197  }
1198 
1199  /* These increments are skipped on out-of-memory for the data - the
1200  * unknown chunk entry gets overwritten if the png_chunk_report returns.
1201  * This is correct in the read case (the chunk is just dropped.)
1202  */
1203  ++np;
1204  ++(info_ptr->unknown_chunks_num);
1205  }
1206 }
png_byte * png_bytep
Definition: pngconf.h:600
png_voidp png_realloc_array(png_const_structrp png_ptr, png_const_voidp old_array, int old_elements, int add_elements, size_t element_size)
Definition: pngmem.c:130
#define png_voidcast(type, value)
Definition: pngpriv.h:408
#define PNG_IS_READ_STRUCT
Definition: pngpriv.h:557
png_voidp png_malloc_base(png_const_structrp png_ptr, png_alloc_size_t size)
Definition: pngmem.c:69
png_byte name[5]
Definition: png.h:765
Definition: png.h:763
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
#define PNG_FREE_UNKN
Definition: png.h:1919
png_byte location
Definition: png.h:775
#define PNG_CHUNK_WRITE_ERROR
Definition: pngpriv.h:1673
png_uint_32 mode
Definition: pngstruct.h:179
PNG_IMPEXP void() png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:229
void png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
Definition: pngerror.c:531
png_byte * data
Definition: png.h:766
png_uint_32 free_me
Definition: pnginfo.h:221
static png_byte check_location(png_const_structrp png_ptr, int location)
Definition: pngset.c:1076
png_size_t size
Definition: png.h:767
PNG_IMPEXP void() png_set_unknown_chunk_location ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
int  chunk,
int  location 
)
1211 {
1212  /* This API is pretty pointless in 1.6.0 because the location can be set
1213  * before the call to png_set_unknown_chunks.
1214  *
1215  * TODO: add a png_app_warning in 1.7
1216  */
1217  if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 &&
1218  chunk < info_ptr->unknown_chunks_num)
1219  {
1220  if ((location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0)
1221  {
1222  png_app_error(png_ptr, "invalid unknown chunk location");
1223  /* Fake out the pre 1.6.0 behavior: */
1224  if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */
1225  location = PNG_AFTER_IDAT;
1226 
1227  else
1228  location = PNG_HAVE_IHDR; /* also undocumented */
1229  }
1230 
1231  info_ptr->unknown_chunks[chunk].location =
1232  check_location(png_ptr, location);
1233  }
1234 }
#define PNG_HAVE_PLTE
Definition: png.h:786
#define PNG_HAVE_IDAT
Definition: pngpriv.h:544
#define PNG_HAVE_IHDR
Definition: png.h:785
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
#define PNG_AFTER_IDAT
Definition: png.h:787
static png_byte check_location(png_const_structrp png_ptr, int location)
Definition: pngset.c:1076
PNG_IMPEXP int() png_get_unknown_chunks ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
png_unknown_chunkpp  entries 
)
1105 {
1106  if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
1107  {
1108  *unknowns = info_ptr->unknown_chunks;
1109  return info_ptr->unknown_chunks_num;
1110  }
1111 
1112  return (0);
1113 }
PNG_IMPEXP void() png_set_invalid ( png_const_structrp  png_ptr,
png_inforp  info_ptr,
int  mask 
)
1526 {
1527  if (png_ptr != NULL && info_ptr != NULL)
1528  info_ptr->valid &= ~mask;
1529 }
png_uint_32 valid
Definition: pnginfo.h:61
PNG_IMPEXP void() png_read_png ( png_structrp  png_ptr,
png_inforp  info_ptr,
int  transforms,
png_voidp  params 
)
PNG_IMPEXP void() png_write_png ( png_structrp  png_ptr,
png_inforp  info_ptr,
int  transforms,
png_voidp  params 
)
PNG_IMPEXP png_const_charp() png_get_copyright ( png_const_structrp  png_ptr)
765 {
766  PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
767 #ifdef PNG_STRING_COPYRIGHT
768  return PNG_STRING_COPYRIGHT
769 #else
770 # ifdef __STDC__
771  return PNG_STRING_NEWLINE \
772  "libpng version 1.6.16 - December 22, 2014" PNG_STRING_NEWLINE \
773  "Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
774  "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
775  "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
777 # else
778  return "libpng version 1.6.16 - December 22, 2014\
779  Copyright (c) 1998-2014 Glenn Randers-Pehrson\
780  Copyright (c) 1996-1997 Andreas Dilger\
781  Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
782 # endif
783 #endif
784 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_STRING_NEWLINE
Definition: pngdebug.h:49
PNG_IMPEXP png_const_charp() png_get_header_ver ( png_const_structrp  png_ptr)
803 {
804  /* Version of *.h files used when building libpng */
805  PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
806  return PNG_LIBPNG_VER_STRING;
807 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_LIBPNG_VER_STRING
Definition: png.h:426
PNG_IMPEXP png_const_charp() png_get_header_version ( png_const_structrp  png_ptr)
811 {
812  /* Returns longer string containing both version and date */
813  PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
814 #ifdef __STDC__
816 # ifndef PNG_READ_SUPPORTED
817  " (NO READ SUPPORT)"
818 # endif
820 #else
822 #endif
823 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_STRING_NEWLINE
Definition: pngdebug.h:49
#define PNG_HEADER_VERSION_STRING
Definition: png.h:427
PNG_IMPEXP png_const_charp() png_get_libpng_ver ( png_const_structrp  png_ptr)
796 {
797  /* Version of *.c files used when building libpng */
798  return png_get_header_ver(png_ptr);
799 }
png_const_charp png_get_header_ver(png_const_structrp png_ptr)
Definition: png.c:802
PNG_IMPEXP png_uint_32() png_permit_mng_features ( png_structrp  png_ptr,
png_uint_32  mng_features_permitted 
)
1241 {
1242  png_debug(1, "in png_permit_mng_features");
1243 
1244  if (png_ptr == NULL)
1245  return 0;
1246 
1247  png_ptr->mng_features_permitted = mng_features & PNG_ALL_MNG_FEATURES;
1248 
1249  return png_ptr->mng_features_permitted;
1250 }
#define PNG_ALL_MNG_FEATURES
Definition: png.h:997
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP void() png_set_user_limits ( png_structrp  png_ptr,
png_uint_32  user_width_max,
png_uint_32  user_height_max 
)
1537 {
1538  /* Images with dimensions larger than these limits will be
1539  * rejected by png_set_IHDR(). To accept any PNG datastream
1540  * regardless of dimensions, set both limits to 0x7ffffffL.
1541  */
1542  if (png_ptr == NULL)
1543  return;
1544 
1545  png_ptr->user_width_max = user_width_max;
1546  png_ptr->user_height_max = user_height_max;
1547 }
PNG_IMPEXP png_uint_32() png_get_user_width_max ( png_const_structrp  png_ptr)
1160 {
1161  return (png_ptr ? png_ptr->user_width_max : 0);
1162 }
PNG_IMPEXP png_uint_32() png_get_user_height_max ( png_const_structrp  png_ptr)
1166 {
1167  return (png_ptr ? png_ptr->user_height_max : 0);
1168 }
PNG_IMPEXP void() png_set_chunk_cache_max ( png_structrp  png_ptr,
png_uint_32  user_chunk_cache_max 
)
1552 {
1553  if (png_ptr != NULL)
1554  png_ptr->user_chunk_cache_max = user_chunk_cache_max;
1555 }
PNG_IMPEXP png_uint_32() png_get_chunk_cache_max ( png_const_structrp  png_ptr)
1173 {
1174  return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
1175 }
PNG_IMPEXP void() png_set_chunk_malloc_max ( png_structrp  png_ptr,
png_alloc_size_t  user_chunk_cache_max 
)
1561 {
1562  if (png_ptr != NULL)
1563  png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
1564 }
PNG_IMPEXP png_alloc_size_t() png_get_chunk_malloc_max ( png_const_structrp  png_ptr)
1180 {
1181  return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
1182 }
PNG_IMPEXP png_uint_32() png_get_pixels_per_inch ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
350 {
351  return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
352 }
static png_uint_32 ppi_from_ppm(png_uint_32 ppm)
Definition: pngget.c:317
png_uint_32 png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:159
PNG_IMPEXP png_uint_32() png_get_x_pixels_per_inch ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
356 {
357  return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
358 }
static png_uint_32 ppi_from_ppm(png_uint_32 ppm)
Definition: pngget.c:317
png_uint_32 png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:115
PNG_IMPEXP png_uint_32() png_get_y_pixels_per_inch ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
362 {
363  return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
364 }
static png_uint_32 ppi_from_ppm(png_uint_32 ppm)
Definition: pngget.c:317
png_uint_32 png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:137
PNG_IMPEXP float() png_get_x_offset_inches ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
400 {
401  /* To avoid the overflow do the conversion directly in floating
402  * point.
403  */
404  return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);
405 }
png_int_32 png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:236
PNG_IMPEXP png_fixed_point() png_get_x_offset_inches_fixed ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
381 {
382  return png_fixed_inches_from_microns(png_ptr,
383  png_get_x_offset_microns(png_ptr, info_ptr));
384 }
png_int_32 png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:236
static png_fixed_point png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
Definition: pngget.c:368
PNG_IMPEXP float() png_get_y_offset_inches ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
411 {
412  /* To avoid the overflow do the conversion directly in floating
413  * point.
414  */
415  return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);
416 }
png_int_32 png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:256
PNG_IMPEXP png_fixed_point() png_get_y_offset_inches_fixed ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr 
)
391 {
392  return png_fixed_inches_from_microns(png_ptr,
393  png_get_y_offset_microns(png_ptr, info_ptr));
394 }
png_int_32 png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:256
static png_fixed_point png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
Definition: pngget.c:368
PNG_IMPEXP png_uint_32() png_get_pHYs_dpi ( png_const_structrp  png_ptr,
png_const_inforp  info_ptr,
png_uint_32 *  res_x,
png_uint_32 *  res_y,
int *  unit_type 
)
423 {
424  png_uint_32 retval = 0;
425 
426  if (png_ptr != NULL && info_ptr != NULL &&
427  (info_ptr->valid & PNG_INFO_pHYs) != 0)
428  {
429  png_debug1(1, "in %s retrieval function", "pHYs");
430 
431  if (res_x != NULL)
432  {
433  *res_x = info_ptr->x_pixels_per_unit;
434  retval |= PNG_INFO_pHYs;
435  }
436 
437  if (res_y != NULL)
438  {
439  *res_y = info_ptr->y_pixels_per_unit;
440  retval |= PNG_INFO_pHYs;
441  }
442 
443  if (unit_type != NULL)
444  {
445  *unit_type = (int)info_ptr->phys_unit_type;
446  retval |= PNG_INFO_pHYs;
447 
448  if (*unit_type == 1)
449  {
450  if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
451  if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
452  }
453  }
454  }
455 
456  return (retval);
457 }
#define png_debug1(l, m, p1)
Definition: pngdebug.h:149
png_uint_32 valid
Definition: pnginfo.h:61
#define PNG_INFO_pHYs
Definition: png.h:880
PNG_IMPEXP png_uint_32() png_get_io_state ( png_const_structrp  png_ptr)
1189 {
1190  return png_ptr->io_state;
1191 }
PNG_IMPEXP png_uint_32() png_get_io_chunk_type ( png_const_structrp  png_ptr)
1195 {
1196  return png_ptr->chunk_name;
1197 }
png_uint_32 chunk_name
Definition: pngstruct.h:221
PNG_IMPEXP png_uint_32() png_get_uint_32 ( png_const_bytep  buf)
69 {
70  png_uint_32 uval =
71  ((png_uint_32)(*(buf )) << 24) +
72  ((png_uint_32)(*(buf + 1)) << 16) +
73  ((png_uint_32)(*(buf + 2)) << 8) +
74  ((png_uint_32)(*(buf + 3)) ) ;
75 
76  return uval;
77 }
char buf[128]
Definition: rw_test.cpp:40
PNG_IMPEXP png_uint_16() png_get_uint_16 ( png_const_bytep  buf)
98 {
99  /* ANSI-C requires an int value to accomodate at least 16 bits so this
100  * works and allows the compiler not to worry about possible narrowing
101  * on 32 bit systems. (Pre-ANSI systems did not make integers smaller
102  * than 16 bits either.)
103  */
104  unsigned int val =
105  ((unsigned int)(*buf) << 8) +
106  ((unsigned int)(*(buf + 1)));
107 
108  return (png_uint_16)val;
109 }
char buf[128]
Definition: rw_test.cpp:40
PNG_IMPEXP png_int_32() png_get_int_32 ( png_const_bytep  buf)
86 {
87  png_uint_32 uval = png_get_uint_32(buf);
88  if ((uval & 0x80000000) == 0) /* non-negative */
89  return uval;
90 
91  uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
92  return -(png_int_32)uval;
93 }
png_uint_32() png_get_uint_32(png_const_bytep buf)
Definition: pngrutil.c:68
char buf[128]
Definition: rw_test.cpp:40
PNG_IMPEXP png_uint_32() png_get_uint_31 ( png_const_structrp  png_ptr,
png_const_bytep  buf 
)
23 {
24  png_uint_32 uval = png_get_uint_32(buf);
25 
26  if (uval > PNG_UINT_31_MAX)
27  png_error(png_ptr, "PNG unsigned integer out of range");
28 
29  return (uval);
30 }
#define PNG_UINT_31_MAX
Definition: png.h:790
png_uint_32() png_get_uint_32(png_const_bytep buf)
Definition: pngrutil.c:68
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
char buf[128]
Definition: rw_test.cpp:40
PNG_IMPEXP void() png_save_uint_32 ( png_bytep  buf,
png_uint_32  i 
)
25 {
26  buf[0] = (png_byte)((i >> 24) & 0xff);
27  buf[1] = (png_byte)((i >> 16) & 0xff);
28  buf[2] = (png_byte)((i >> 8) & 0xff);
29  buf[3] = (png_byte)(i & 0xff);
30 }
int i
Definition: rw_test.cpp:37
char buf[128]
Definition: rw_test.cpp:40
PNG_IMPEXP void() png_save_int_32 ( png_bytep  buf,
png_int_32  i 
)
678 {
679  buf[0] = (png_byte)((i >> 24) & 0xff);
680  buf[1] = (png_byte)((i >> 16) & 0xff);
681  buf[2] = (png_byte)((i >> 8) & 0xff);
682  buf[3] = (png_byte)(i & 0xff);
683 }
int i
Definition: rw_test.cpp:37
char buf[128]
Definition: rw_test.cpp:40
PNG_IMPEXP void() png_save_uint_16 ( png_bytep  buf,
unsigned int  i 
)
38 {
39  buf[0] = (png_byte)((i >> 8) & 0xff);
40  buf[1] = (png_byte)(i & 0xff);
41 }
int i
Definition: rw_test.cpp:37
char buf[128]
Definition: rw_test.cpp:40
PNG_IMPEXP int() png_image_begin_read_from_file ( png_imagep  image,
const char *  file_name 
)
1476 {
1477  if (image != NULL && image->version == PNG_IMAGE_VERSION)
1478  {
1479  if (file_name != NULL)
1480  {
1481  FILE *fp = fopen(file_name, "rb");
1482 
1483  if (fp != NULL)
1484  {
1485  if (png_image_read_init(image) != 0)
1486  {
1487  image->opaque->png_ptr->io_ptr = fp;
1488  image->opaque->owned_file = 1;
1489  return png_safe_execute(image, png_image_read_header, image);
1490  }
1491 
1492  /* Clean up: just the opened file. */
1493  (void)fclose(fp);
1494  }
1495 
1496  else
1497  return png_image_error(image, strerror(errno));
1498  }
1499 
1500  else
1501  return png_image_error(image,
1502  "png_image_begin_read_from_file: invalid argument");
1503  }
1504 
1505  else if (image != NULL)
1506  return png_image_error(image,
1507  "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION");
1508 
1509  return 0;
1510 }
png_controlp opaque
Definition: png.h:2809
int png_image_error(png_imagep image, png_const_charp error_message)
Definition: png.c:4483
static int png_image_read_init(png_imagep image)
Definition: pngread.c:1281
int png_safe_execute(png_imagep image_in, int(*function)(png_voidp), png_voidp arg)
Definition: pngerror.c:936
static int png_image_read_header(png_voidp argument)
Definition: pngread.c:1382
png_uint_32 version
Definition: png.h:2810
png_structp png_ptr
Definition: pngpriv.h:1867
png_voidp io_ptr
Definition: pngstruct.h:159
#define PNG_IMAGE_VERSION
Definition: png.h:2804
unsigned int owned_file
Definition: pngpriv.h:1875
FILE * fp
Definition: rw_test.cpp:38
PNG_IMPEXP int() png_image_begin_read_from_stdio ( png_imagep  image,
FILE *  file 
)
1446 {
1447  if (image != NULL && image->version == PNG_IMAGE_VERSION)
1448  {
1449  if (file != NULL)
1450  {
1451  if (png_image_read_init(image) != 0)
1452  {
1453  /* This is slightly evil, but png_init_io doesn't do anything other
1454  * than this and we haven't changed the standard IO functions so
1455  * this saves a 'safe' function.
1456  */
1457  image->opaque->png_ptr->io_ptr = file;
1458  return png_safe_execute(image, png_image_read_header, image);
1459  }
1460  }
1461 
1462  else
1463  return png_image_error(image,
1464  "png_image_begin_read_from_stdio: invalid argument");
1465  }
1466 
1467  else if (image != NULL)
1468  return png_image_error(image,
1469  "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION");
1470 
1471  return 0;
1472 }
png_controlp opaque
Definition: png.h:2809
int png_image_error(png_imagep image, png_const_charp error_message)
Definition: png.c:4483
static int png_image_read_init(png_imagep image)
Definition: pngread.c:1281
int png_safe_execute(png_imagep image_in, int(*function)(png_voidp), png_voidp arg)
Definition: pngerror.c:936
static int png_image_read_header(png_voidp argument)
Definition: pngread.c:1382
png_uint_32 version
Definition: png.h:2810
png_structp png_ptr
Definition: pngpriv.h:1867
png_voidp io_ptr
Definition: pngstruct.h:159
#define PNG_IMAGE_VERSION
Definition: png.h:2804
PNG_IMPEXP int() png_image_begin_read_from_memory ( png_imagep  image,
png_const_voidp  memory,
png_size_t  size 
)
1545 {
1546  if (image != NULL && image->version == PNG_IMAGE_VERSION)
1547  {
1548  if (memory != NULL && size > 0)
1549  {
1550  if (png_image_read_init(image) != 0)
1551  {
1552  /* Now set the IO functions to read from the memory buffer and
1553  * store it into io_ptr. Again do this in-place to avoid calling a
1554  * libpng function that requires error handling.
1555  */
1556  image->opaque->memory = png_voidcast(png_const_bytep, memory);
1557  image->opaque->size = size;
1558  image->opaque->png_ptr->io_ptr = image;
1560 
1561  return png_safe_execute(image, png_image_read_header, image);
1562  }
1563  }
1564 
1565  else
1566  return png_image_error(image,
1567  "png_image_begin_read_from_memory: invalid argument");
1568  }
1569 
1570  else if (image != NULL)
1571  return png_image_error(image,
1572  "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION");
1573 
1574  return 0;
1575 }
uint8_t image[110000000]
Definition: gige_snap.cpp:38
png_const_bytep memory
Definition: pngpriv.h:1871
png_rw_ptr read_data_fn
Definition: pngstruct.h:158
png_controlp opaque
Definition: png.h:2809
#define png_voidcast(type, value)
Definition: pngpriv.h:408
int png_image_error(png_imagep image, png_const_charp error_message)
Definition: png.c:4483
static int png_image_read_init(png_imagep image)
Definition: pngread.c:1281
int png_safe_execute(png_imagep image_in, int(*function)(png_voidp), png_voidp arg)
Definition: pngerror.c:936
static int png_image_read_header(png_voidp argument)
Definition: pngread.c:1382
png_uint_32 version
Definition: png.h:2810
const png_byte * png_const_bytep
Definition: pngconf.h:601
png_size_t size
Definition: pngpriv.h:1872
png_structp png_ptr
Definition: pngpriv.h:1867
png_voidp io_ptr
Definition: pngstruct.h:159
#define PNG_IMAGE_VERSION
Definition: png.h:2804
static void png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)
Definition: pngread.c:1514
PNG_IMPEXP int() png_image_finish_read ( png_imagep  image,
png_const_colorp  background,
void *  buffer,
png_int_32  row_stride,
void *  colormap 
)
4056 {
4057  if (image != NULL && image->version == PNG_IMAGE_VERSION)
4058  {
4059  png_uint_32 check;
4060 
4061  if (row_stride == 0)
4062  row_stride = PNG_IMAGE_ROW_STRIDE(*image);
4063 
4064  if (row_stride < 0)
4065  check = -row_stride;
4066 
4067  else
4068  check = row_stride;
4069 
4070  if (image->opaque != NULL && buffer != NULL &&
4071  check >= PNG_IMAGE_ROW_STRIDE(*image))
4072  {
4073  if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
4074  (image->colormap_entries > 0 && colormap != NULL))
4075  {
4076  int result;
4077  png_image_read_control display;
4078 
4079  memset(&display, 0, (sizeof display));
4080  display.image = image;
4081  display.buffer = buffer;
4082  display.row_stride = row_stride;
4083  display.colormap = colormap;
4084  display.background = background;
4085  display.local_row = NULL;
4086 
4087  /* Choose the correct 'end' routine; for the color-map case all the
4088  * setup has already been done.
4089  */
4090  if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
4091  result =
4092  png_safe_execute(image, png_image_read_colormap, &display) &&
4093  png_safe_execute(image, png_image_read_colormapped, &display);
4094 
4095  else
4096  result =
4097  png_safe_execute(image, png_image_read_direct, &display);
4098 
4099  png_image_free(image);
4100  return result;
4101  }
4102 
4103  else
4104  return png_image_error(image,
4105  "png_image_finish_read[color-map]: no color-map");
4106  }
4107 
4108  else
4109  return png_image_error(image,
4110  "png_image_finish_read: invalid argument");
4111  }
4112 
4113  else if (image != NULL)
4114  return png_image_error(image,
4115  "png_image_finish_read: damaged PNG_IMAGE_VERSION");
4116 
4117  return 0;
4118 }
png_voidp buffer
Definition: pngread.c:1262
uint8_t image[110000000]
Definition: gige_snap.cpp:38
static int png_image_read_direct(png_voidp argument)
Definition: pngread.c:3628
png_controlp opaque
Definition: png.h:2809
png_int_32 row_stride
Definition: pngread.c:1263
static int png_image_read_colormapped(png_voidp argument)
Definition: pngread.c:3089
png_voidp local_row
Definition: pngread.c:1267
static int png_image_read_colormap(png_voidp argument)
Definition: pngread.c:2059
png_voidp colormap
Definition: pngread.c:1264
Definition: pngread.c:1258
int png_image_error(png_imagep image, png_const_charp error_message)
Definition: png.c:4483
png_const_colorp background
Definition: pngread.c:1265
int png_safe_execute(png_imagep image_in, int(*function)(png_voidp), png_voidp arg)
Definition: pngerror.c:936
png_uint_32 format
Definition: png.h:2813
static char buffer[255]
Definition: propagator_simple.cpp:60
png_imagep image
Definition: pngread.c:1261
png_uint_32 version
Definition: png.h:2810
#define PNG_IMAGE_ROW_STRIDE(image)
Definition: png.h:3031
#define PNG_FORMAT_FLAG_COLORMAP
Definition: png.h:2916
void png_image_free(png_imagep image)
Definition: png.c:4467
#define PNG_IMAGE_VERSION
Definition: png.h:2804
png_uint_32 colormap_entries
Definition: png.h:2815
PNG_IMPEXP void() png_image_free ( png_imagep  image)
4468 {
4469  /* Safely call the real function, but only if doing so is safe at this point
4470  * (if not inside an error handling context). Otherwise assume
4471  * png_safe_execute will call this API after the return.
4472  */
4473  if (image != NULL && image->opaque != NULL &&
4474  image->opaque->error_buf == NULL)
4475  {
4476  /* Ignore errors here: */
4477  (void)png_safe_execute(image, png_image_free_function, image);
4478  image->opaque = NULL;
4479  }
4480 }
static int png_image_free_function(png_voidp argument)
Definition: png.c:4407
png_controlp opaque
Definition: png.h:2809
int png_safe_execute(png_imagep image_in, int(*function)(png_voidp), png_voidp arg)
Definition: pngerror.c:936
png_voidp error_buf
Definition: pngpriv.h:1869
PNG_IMPEXP int() png_image_write_to_file ( png_imagep  image,
const char *  file,
int  convert_to_8bit,
const void *  buffer,
png_int_32  row_stride,
const void *  colormap 
)
2391 {
2392  /* Write the image to the named file. */
2393  if (image != NULL && image->version == PNG_IMAGE_VERSION)
2394  {
2395  if (file_name != NULL)
2396  {
2397  FILE *fp = fopen(file_name, "wb");
2398 
2399  if (fp != NULL)
2400  {
2401  if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer,
2402  row_stride, colormap) != 0)
2403  {
2404  int error; /* from fflush/fclose */
2405 
2406  /* Make sure the file is flushed correctly. */
2407  if (fflush(fp) == 0 && ferror(fp) == 0)
2408  {
2409  if (fclose(fp) == 0)
2410  return 1;
2411 
2412  error = errno; /* from fclose */
2413  }
2414 
2415  else
2416  {
2417  error = errno; /* from fflush or ferror */
2418  (void)fclose(fp);
2419  }
2420 
2421  (void)remove(file_name);
2422  /* The image has already been cleaned up; this is just used to
2423  * set the error (because the original write succeeded).
2424  */
2425  return png_image_error(image, strerror(error));
2426  }
2427 
2428  else
2429  {
2430  /* Clean up: just the opened file. */
2431  (void)fclose(fp);
2432  (void)remove(file_name);
2433  return 0;
2434  }
2435  }
2436 
2437  else
2438  return png_image_error(image, strerror(errno));
2439  }
2440 
2441  else
2442  return png_image_error(image,
2443  "png_image_write_to_file: invalid argument");
2444  }
2445 
2446  else if (image != NULL)
2447  return png_image_error(image,
2448  "png_image_write_to_file: incorrect PNG_IMAGE_VERSION");
2449 
2450  else
2451  return 0;
2452 }
int png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap)
Definition: pngwrite.c:2339
int png_image_error(png_imagep image, png_const_charp error_message)
Definition: png.c:4483
static char buffer[255]
Definition: propagator_simple.cpp:60
png_uint_32 version
Definition: png.h:2810
#define PNG_IMAGE_VERSION
Definition: png.h:2804
FILE * fp
Definition: rw_test.cpp:38
PNG_IMPEXP int() png_image_write_to_stdio ( png_imagep  image,
FILE *  file,
int  convert_to_8_bit,
const void *  buffer,
png_int_32  row_stride,
const void *  colormap 
)
2341 {
2342  /* Write the image to the given (FILE*). */
2343  if (image != NULL && image->version == PNG_IMAGE_VERSION)
2344  {
2345  if (file != NULL)
2346  {
2347  if (png_image_write_init(image) != 0)
2348  {
2349  png_image_write_control display;
2350  int result;
2351 
2352  /* This is slightly evil, but png_init_io doesn't do anything other
2353  * than this and we haven't changed the standard IO functions so
2354  * this saves a 'safe' function.
2355  */
2356  image->opaque->png_ptr->io_ptr = file;
2357 
2358  memset(&display, 0, (sizeof display));
2359  display.image = image;
2360  display.buffer = buffer;
2361  display.row_stride = row_stride;
2362  display.colormap = colormap;
2363  display.convert_to_8bit = convert_to_8bit;
2364 
2365  result = png_safe_execute(image, png_image_write_main, &display);
2366  png_image_free(image);
2367  return result;
2368  }
2369 
2370  else
2371  return 0;
2372  }
2373 
2374  else
2375  return png_image_error(image,
2376  "png_image_write_to_stdio: invalid argument");
2377  }
2378 
2379  else if (image != NULL)
2380  return png_image_error(image,
2381  "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION");
2382 
2383  else
2384  return 0;
2385 }
png_const_voidp buffer
Definition: pngwrite.c:1727
uint8_t image[110000000]
Definition: gige_snap.cpp:38
png_controlp opaque
Definition: png.h:2809
int png_image_error(png_imagep image, png_const_charp error_message)
Definition: png.c:4483
png_const_voidp colormap
Definition: pngwrite.c:1729
int png_safe_execute(png_imagep image_in, int(*function)(png_voidp), png_voidp arg)
Definition: pngerror.c:936
static int png_image_write_init(png_imagep image)
Definition: pngwrite.c:1686
Definition: pngwrite.c:1723
static char buffer[255]
Definition: propagator_simple.cpp:60
png_imagep image
Definition: pngwrite.c:1726
png_int_32 row_stride
Definition: pngwrite.c:1728
int convert_to_8bit
Definition: pngwrite.c:1730
png_uint_32 version
Definition: png.h:2810
png_structp png_ptr
Definition: pngpriv.h:1867
png_voidp io_ptr
Definition: pngstruct.h:159
void png_image_free(png_imagep image)
Definition: png.c:4467
#define PNG_IMAGE_VERSION
Definition: png.h:2804
static int png_image_write_main(png_voidp argument)
Definition: pngwrite.c:2141
PNG_IMPEXP void() png_set_check_for_invalid_index ( png_structrp  png_ptr,
int  allowed 
)
1601 {
1602  png_debug(1, "in png_set_check_for_invalid_index");
1603 
1604  if (allowed > 0)
1605  png_ptr->num_palette_max = 0;
1606 
1607  else
1608  png_ptr->num_palette_max = -1;
1609 }
#define png_debug(l, m)
Definition: pngdebug.h:146
PNG_IMPEXP int() png_get_palette_max ( png_const_structp  png_ptr,
png_const_infop  info_ptr 
)
1204 {
1205  if (png_ptr != NULL && info_ptr != NULL)
1206  return png_ptr->num_palette_max;
1207 
1208  return (-1);
1209 }
PNG_IMPEXP int() png_set_option ( png_structrp  png_ptr,
int  option,
int  onoff 
)
4218 {
4219  if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
4220  (option & 1) == 0)
4221  {
4222  int mask = 3 << option;
4223  int setting = (2 + (onoff != 0)) << option;
4224  int current = png_ptr->options;
4225 
4226  png_ptr->options = (png_byte)((current & ~mask) | setting);
4227 
4228  return (current & mask) >> option;
4229  }
4230 
4231  return PNG_OPTION_INVALID;
4232 }
#define PNG_OPTION_NEXT
Definition: png.h:3249
JCOPY_OPTION option
Definition: transupp.h:131
static antstruc current
Definition: agent_antenna.cpp:161
#define PNG_OPTION_INVALID
Definition: png.h:3253