📄 png.h
字号:
#include "pngconf.h"/* Inhibit C++ name-mangling for libpng functions but not for system calls. */#ifdef __cplusplusextern "C" {#endif /* __cplusplus *//* This file is arranged in several sections. The first section contains * structure and type definitions. The second section contains the external * library functions, while the third has the internal library functions, * which applications aren't expected to use directly. *//* variables declared in png.c - only it needs to define PNG_NO_EXTERN */#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)/* Version information for C files, stored in png.c. This had better match * the version above. */#ifdef PNG_USE_GLOBAL_ARRAYSPNG_EXPORT_VAR (const char) png_libpng_ver[18]; /* need room for 99.99.99beta99z*/#else#define png_libpng_ver png_get_header_ver(NULL)#endif#ifdef PNG_USE_GLOBAL_ARRAYS/* This was removed in version 1.0.5c *//* Structures to facilitate easy interlacing. See png.c for more details */PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7];PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7];PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7];PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7];PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7];PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7];#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROWPNG_EXPORT_VAR (const int FARDATA) png_pass_width[7];#endif/* This isn't currently used. If you need it, see png.c for more details.PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7];*/#endif#endif /* PNG_NO_EXTERN *//* Three color definitions. The order of the red, green, and blue, (and the * exact size) is not important, although the size of the fields need to * be png_byte or png_uint_16 (as defined below). */typedef struct png_color_struct{ png_byte red; png_byte green; png_byte blue;} png_color;typedef png_color FAR * png_colorp;typedef png_color FAR * FAR * png_colorpp;typedef struct png_color_16_struct{ png_byte index; /* used for palette files */ png_uint_16 red; /* for use in red green blue files */ png_uint_16 green; png_uint_16 blue; png_uint_16 gray; /* for use in grayscale files */} png_color_16;typedef png_color_16 FAR * png_color_16p;typedef png_color_16 FAR * FAR * png_color_16pp;typedef struct png_color_8_struct{ png_byte red; /* for use in red green blue files */ png_byte green; png_byte blue; png_byte gray; /* for use in grayscale files */ png_byte alpha; /* for alpha channel files */} png_color_8;typedef png_color_8 FAR * png_color_8p;typedef png_color_8 FAR * FAR * png_color_8pp;/* * The following two structures are used for the in-core representation * of sPLT chunks. */typedef struct png_sPLT_entry_struct{ png_uint_16 red; png_uint_16 green; png_uint_16 blue; png_uint_16 alpha; png_uint_16 frequency;} png_sPLT_entry;typedef png_sPLT_entry FAR * png_sPLT_entryp;typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;/* When the depth of the sPLT palette is 8 bits, the color and alpha samples * occupy the LSB of their respective members, and the MSB of each member * is zero-filled. The frequency member always occupies the full 16 bits. */typedef struct png_sPLT_struct{ png_charp name; /* palette name */ png_byte depth; /* depth of palette samples */ png_sPLT_entryp entries; /* palette entries */ png_int_32 nentries; /* number of palette entries */} png_sPLT_t;typedef png_sPLT_t FAR * png_sPLT_tp;typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;#ifdef PNG_TEXT_SUPPORTED/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, * and whether that contents is compressed or not. The "key" field * points to a regular zero-terminated C string. The "text", "lang", and * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. * However, the * structure returned by png_get_text() will always contain * regular zero-terminated C strings (possibly empty), never NULL pointers, * so they can be safely used in printf() and other string-handling functions. */typedef struct png_text_struct{ int compression; /* compression value: -1: tEXt, none 0: zTXt, deflate 1: iTXt, none 2: iTXt, deflate */ png_charp key; /* keyword, 1-79 character description of "text" */ png_charp text; /* comment, may be an empty string (ie "") or a NULL pointer */ png_size_t text_length; /* length of the text string */#ifdef PNG_iTXt_SUPPORTED png_size_t itxt_length; /* length of the itxt string */ png_charp lang; /* language code, 0-79 characters or a NULL pointer */ png_charp lang_key; /* keyword translated UTF-8 string, 0 or more chars or a NULL pointer */#endif} png_text;typedef png_text FAR * png_textp;typedef png_text FAR * FAR * png_textpp;#endif/* Supported compression types for text in PNG files (tEXt, and zTXt). * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */#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 *//* png_time is a way to hold the time in an machine independent way. * Two conversions are provided, both from time_t and struct tm. There * is no portable way to convert to either of these structures, as far * as I know. If you know of a portable way, send it to me. As a side * note - PNG has always been Year 2000 compliant! */typedef struct png_time_struct{ png_uint_16 year; /* full year, as in, 1995 */ png_byte month; /* month of year, 1 - 12 */ png_byte day; /* day of month, 1 - 31 */ png_byte hour; /* hour of day, 0 - 23 */ png_byte minute; /* minute of hour, 0 - 59 */ png_byte second; /* second of minute, 0 - 60 (for leap seconds) */} png_time;typedef png_time FAR * png_timep;typedef png_time FAR * FAR * png_timepp;#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)/* png_unknown_chunk is a structure to hold queued chunks for which there is * no specific support. The idea is that we can use this to queue * up private chunks for output even though the library doesn't actually * know about their semantics. */typedef struct png_unknown_chunk_t{ png_byte name[5]; png_byte *data; png_size_t size; /* libpng-using applications should NOT directly modify this byte. */ png_byte location; /* mode of operation at read time */}png_unknown_chunk;typedef png_unknown_chunk FAR * png_unknown_chunkp;typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;#endif/* png_info is a structure that holds the information in a PNG file so * that the application can find out the characteristics of the image. * If you are reading the file, this structure will tell you what is * in the PNG file. If you are writing the file, fill in the information * you want to put into the PNG file, then call png_write_info(). * The names chosen should be very close to the PNG specification, so * consult that document for information about the meaning of each field. * * With libpng < 0.95, it was only possible to directly set and read the * the values in the png_info_struct, which meant that the contents and * order of the values had to remain fixed. With libpng 0.95 and later, * however, there are now functions that abstract the contents of * png_info_struct from the application, so this makes it easier to use * libpng with dynamic libraries, and even makes it possible to use * libraries that don't have all of the libpng ancillary chunk-handing * functionality. * * In any case, the order of the parameters in png_info_struct should NOT * be changed for as long as possible to keep compatibility with applications * that use the old direct-access method with png_info_struct. * * The following members may have allocated storage attached that should be * cleaned up before the structure is discarded: palette, trans, text, * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these * are automatically freed when the info structure is deallocated, if they were * allocated internally by libpng. This behavior can be changed by means * of the png_data_freer() function. * * More allocation details: all the chunk-reading functions that * change these members go through the corresponding png_set_* * functions. A function to clear these members is available: see * png_free_data(). The png_set_* functions do not depend on being * able to point info structure members to any of the storage they are * passed (they make their own copies), EXCEPT that the png_set_text * functions use the same storage passed to them in the text_ptr or * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns * functions do not make their own copies. */typedef struct png_info_struct{ /* the following are necessary for every PNG file */ png_uint_32 width; /* width of image in pixels (from IHDR) */ png_uint_32 height; /* height of image in pixels (from IHDR) */ png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ /* The following three should have been named *_method not *_type */ png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ /* The following is informational only on read, and not used on writes. */ png_byte channels; /* number of data channels per pixel (1, 2, 3, 4)*/ png_byte pixel_depth; /* number of bits per pixel */ png_byte spare_byte; /* to align the data, and for future use */ png_byte signature[8]; /* magic bytes read by libpng from start of file */ /* The rest of the data is optional. If you are reading, check the * valid field to see if the information in these are valid. If you * are writing, set the valid field to those chunks you want written, * and initialize the appropriate fields below. */#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) /* The gAMA chunk describes the gamma characteristics of the system * on which the image was created, normally in the range [1.0, 2.5]. * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. */ float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */#endif#if defined(PNG_sRGB_SUPPORTED) /* GR-P, 0.96a */ /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */#endif#if defined(PNG_TEXT_SUPPORTED) /* The tEXt, and zTXt chunks contain human-readable textual data in * uncompressed, compressed, and optionally compressed forms, respectively. * The data in "text" is an array of pointers to uncompressed, * null-terminated C strings. Each chunk has a keyword that describes the * textual data contained in that chunk. Keywords are not required to be * unique, and the text string may be empty. Any number of text chunks may * be in an image. */ int num_text; /* number of comments read/to write */ int max_text; /* current size of text array */ png_textp text; /* array of comments read/to write */#endif /* PNG_TEXT_SUPPORTED */#if defined(PNG_tIME_SUPPORTED) /* The tIME chunk holds the last time the displayed image data was * modified. See the png_time struct for the contents of this struct. */ png_time mod_time;#endif#if defined(PNG_sBIT_SUPPORTED) /* The sBIT chunk specifies the number of significant high-order bits * in the pixel data. Values are in the range [1, bit_depth], and are * only specified for the channels in the pixel data. The contents of * the low-order bits is not specified. Data is valid if * (valid & PNG_INFO_sBIT) is non-zero. */ png_color_8 sig_bit; /* significant bits in color channels */#endif#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \defined(PNG_READ_BACKGROUND_SUPPORTED)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -