📄 png.h
字号:
/* png.h - header file for png reference library
libpng 1.0 beta 3 - version 0.89
May 25, 1996
Note: This is a beta version. It reads and writes valid files
on the platforms I have, and has had a wide testing program.
You may have to modify the includes below to get it to work on
your system, and you may have to supply the correct compiler
flags in the makefile, if you can't find a makefile suitable for
your operating system/compiler combination. Read the libpng.txt
for more information, and how to contact me if you have any
problems, or if you want your compiler/platform to be supported
in the next official libpng release.
See libpng.txt for more information
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
Contributing Authors:
Andreas Dilger
Dave Martindale
Guy Eric Schalnat
Paul Schmidt
Tim Wegner
The contributing authors would like to thank all those who helped
with testing, bug fixes, and patience. You know who you are. This
wouldn't have been possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation
The PNG Reference Library is supplied "AS IS". The Contributing Authors
and Group 42, Inc. disclaim all warranties, expressed or implied,
including, without limitation, the warranties of merchantability and of
fitness for any purpose. The Contributing Authors and Group 42, Inc.
assume no liability for direct, indirect, incidental, special, exemplary,
or consequential damages, which may result from the use of the PNG
Reference Library, even if advised of the possibility of such damage.
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:
1. The origin of this source code must not be misrepresented.
2. Altered versions must be plainly marked as such and must not be
misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any source or
altered source distribution.
The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.
*/
#ifndef _PNG_H
#define _PNG_H
/* This is not the place to learn how to use libpng. The file libpng.txt
describes how to use libpng, and the file example.c summarizes it
with some code to build around. This file is useful for looking
at the actual function definitions and structure components. */
/* include the compression library's header */
#include "zlib.h"
/* include all user configurable info */
#include "pngconf.h"
/* This file is arranged in several sections. The first section details
the functions most users will use. The third section describes the
stub files that users will most likely need to change. The last
section contains functions used internally by the code.
*/
/* version information for png.h - this should match the version
number in png.c */
#define PNG_LIBPNG_VER_STRING "0.89"
/* careful here. I wanted to use 089, but that would be octal. Version
1.0 will be 100 here, etc. */
#define PNG_LIBPNG_VER 89
/* variables defined in png.c - only it needs to define PNG_NO_EXTERN */
#ifndef PNG_NO_EXTERN
/* version information for c files, stored in png.c. This better match
the version above. */
extern char png_libpng_ver[];
#endif
/* 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;
/* png_text holds the text in a png file, and whether they are compressed
or not. If compression is -1, the text is not compressed. */
typedef struct png_text_struct
{
int compression; /* compression value, -1 if uncompressed */
png_charp key; /* keyword */
png_charp text; /* comment */
png_uint_32 text_length; /* length of text field */
} png_text;
typedef png_text FAR * png_textp;
typedef png_text FAR * FAR * png_textpp;
/* 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. */
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;
/* png_info is a structure that holds the information in a png file.
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. */
typedef struct png_info_struct
{
/* the following are necessary for every png file */
png_uint_32 width; /* with of file */
png_uint_32 height; /* height of file */
png_uint_32 valid; /* the PNG_INFO_ defines, OR'd together */
png_uint_32 rowbytes; /* bytes needed for untransformed row */
png_colorp palette; /* palette of file */
png_uint_16 num_palette; /* number of values in palette */
png_uint_16 num_trans; /* number of trans values */
png_byte bit_depth; /* 1, 2, 4, 8, or 16 */
png_byte color_type; /* use the PNG_COLOR_TYPE_ defines */
png_byte compression_type; /* must be 0 */
png_byte filter_type; /* must be 0 */
png_byte interlace_type; /* 0 for non-interlaced, 1 for interlaced */
/* the following is informational only on read, and not used on
writes */
png_byte channels; /* number of channels of data per pixel */
png_byte pixel_depth; /* number of bits per pixel */
png_byte spare_byte; /* To align the data, and for future use */
/* the rest are 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_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
float gamma; /* gamma value of file, if gAMA chunk is valid */
#endif
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
int num_text; /* number of comments */
int max_text; /* size of text array */
png_textp text; /* array of comments */
#endif
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
png_time mod_time; /* modification time */
#endif
#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
png_color_8 sig_bit; /* significant bits */
#endif
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
png_bytep trans; /* tRNS values for palette image */
png_color_16 trans_values; /* tRNS values for non-palette image */
#endif
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
png_color_16 background; /* background color of image */
#endif
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
png_uint_32 x_offset; /* x offset on page */
png_uint_32 y_offset; /* y offset on page */
png_byte offset_unit_type; /* offset units type */
#endif
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
png_uint_32 x_pixels_per_unit; /* x resolution */
png_uint_32 y_pixels_per_unit; /* y resolution */
png_byte phys_unit_type; /* resolution type */
#endif
#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
png_uint_16p hist; /* histogram of palette usage */
#endif
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
float x_white; /* cHRM chunk values */
float y_white;
float x_red;
float y_red;
float x_green;
float y_green;
float x_blue;
float y_blue;
#endif
} png_info;
typedef png_info FAR * png_infop;
typedef png_info FAR * FAR * png_infopp;
#define PNG_RESOLUTION_UNKNOWN 0
#define PNG_RESOLUTION_METER 1
#define PNG_RESOLUTION_LAST 2
#define PNG_OFFSET_PIXEL 0
#define PNG_OFFSET_MICROMETER 1
#define PNG_OFFSET_LAST 2
/* these describe the color_type field in png_info */
/* color type masks */
#define PNG_COLOR_MASK_PALETTE 1
#define PNG_COLOR_MASK_COLOR 2
#define PNG_COLOR_MASK_ALPHA 4
/* color types. Note that not all combinations are legal */
#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)
/* These determine if a chunks information is present in a read operation, or
if the chunk should be written in a write operation. */
#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
/* this is used for the transformation routines, as some of them
change these values for the row. It also should enable using
the routines for other uses. */
typedef struct png_row_info_struct
{
png_uint_32 width; /* width of row */
png_uint_32 rowbytes; /* number of bytes in row */
png_byte color_type; /* color type of row */
png_byte bit_depth; /* bit depth of row */
png_byte channels; /* number of channels (1, 2, 3, or 4) */
png_byte pixel_depth; /* bits per pixel (depth * channels) */
} png_row_info;
typedef png_row_info FAR * png_row_infop;
typedef png_row_info FAR * FAR * png_row_infopp;
/* These are the function types for the I/O functions, and the functions which
* modify the default I/O functions to user I/O functions. The png_error_ptr
* type should match that of user supplied warning and error functions, while
* the png_rw_ptr type should match that of the user read/write data functions.
*/
typedef struct png_struct_def png_struct;
typedef png_struct FAR * png_structp;
typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp));
typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_uint_32));
typedef void (*png_flush_ptr) PNGARG((png_structp));
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop));
typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
png_uint_32, int));
#endif
/* The structure that holds the information to read and write png files.
The only people who need to care about what is inside of this are the
people who will be modifying the library for their own special needs.
*/
struct png_struct_def
{
jmp_buf jmpbuf; /* used in png_error */
png_error_ptr error_fn; /* Function for printing errors and aborting */
png_error_ptr warning_fn; /* Function for printing warnings */
png_voidp error_ptr; /* user supplied struct for error functions */
png_rw_ptr write_data_fn; /* Function for writing output data */
png_rw_ptr read_data_fn; /* Function for reading input data */
png_voidp io_ptr; /* Pointer to user supplied struct for I/O functions */
png_byte mode; /* used to determine where we are in the png file */
png_uint_32 do_free; /* flags indicating if libpng should free memory */
png_uint_32 flags; /* flags indicating various things to libpng */
png_uint_32 transformations; /* which transformations to perform */
z_stream * zstream; /* pointer to decompression structure (below) */
png_bytep zbuf; /* buffer for zlib */
png_uint_32 zbuf_size; /* size of zbuf */
int zlib_level; /* holds zlib compression level */
int zlib_method; /* holds zlib compression method */
int zlib_window_bits; /* holds zlib compression window bits */
int zlib_mem_level; /* holds zlib compression memory level */
int zlib_strategy; /* holds zlib compression strategy */
png_uint_32 width; /* width of file */
png_uint_32 height; /* height of file */
png_uint_32 num_rows; /* number of rows in current pass */
png_uint_32 rowbytes; /* size of row in bytes */
png_uint_32 usr_width; /* width of row at start of write */
png_uint_32 iwidth; /* interlaced width */
png_uint_32 irowbytes; /* interlaced rowbytes */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -