1 /* $MirOS: src/lib/libpng/png.h,v 1.11 2013/08/06 18:49:27 tg Exp $ */
2 
3 /* png.h - header file for MirOS in-tree PNG library
4  *
5  * See png.5 or libpng.3 for more information.
6  */
7 
8 /*
9  * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
10  *
11  * libpng-MirOS is distributed according to the terms set forth below,
12  * the Licensor being the MirOS Project and Thorsten Glaser as leader,
13  * with the following copyright holders:
14  *
15  * Copyright (c) 2004-2009 Thorsten Glaser, The MirOS Project
16  * Copyright (c) 1998-2012 Glenn Randers-Pehrson
17  * Copyright (c) 1996, 1997 Andreas Dilger
18  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
19  *
20  * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
21  * the utmost extent permitted by applicable law, neither express nor
22  * implied; without malicious intent or gross negligence. In no event
23  * may a licensor, author or contributor be held liable for indirect,
24  * direct, other damage, loss, or other issues arising in any way out
25  * of dealing in the work, even if advised of the possibility of such
26  * damage or existence of a defect, except proven that it results out
27  * of said person's immediate fault when using the work as intended.
28  *
29  * For the purposes of this copyright and license, "Contributing Authors"
30  * is defined as the following set of individuals:
31  *
32  *    Andreas Dilger
33  *    Dave Martindale
34  *    Guy Eric Schalnat
35  *    Paul Schmidt
36  *    Tim Wegner
37  *    Cosmin Truta
38  *    Simon-Pierre Cadieux
39  *    Eric S. Raymond
40  *    Gilles Vollant
41  *    Tom Lane
42  *    Glenn Randers-Pehrson
43  *    Willem van Schaik
44  *    John Bowler
45  *    Kevin Bracey
46  *    Sam Bushell
47  *    Magnus Holmgren
48  *    Greg Roelofs
49  *    Tom Tanner
50  *
51  * The PNG Reference Library is supplied "AS IS".  The Contributing Authors
52  * (as well as The MirOS Project as publisher of this modified version)
53  * and Group 42, Inc. disclaim all warranties, expressed or implied,
54  * including, without limitation, the warranties of merchantability and of
55  * fitness for any purpose.  The Contributing Authors and Group 42, Inc.
56  * assume no liability for direct, indirect, incidental, special, exemplary,
57  * or consequential damages, which may result from the use of the PNG
58  * Reference Library, even if advised of the possibility of such damage.
59  *
60  * There is no warranty against interference with your enjoyment of the
61  * library or against infringement.  There is no warranty that our
62  * efforts or the library will fulfill any of your particular purposes
63  * or needs.  This library is provided with all faults, and the entire
64  * risk of satisfactory quality, performance, accuracy, and effort is with
65  * the user.
66  *
67  * Permission is hereby granted to use, copy, modify, and distribute this
68  * source code, or portions hereof, for any purpose, without fee, subject
69  * to the following restrictions:
70  *
71  * 1. The origin of this source code must not be misrepresented.
72  *
73  * 2. Altered versions must be plainly marked as such and
74  * must not be misrepresented as being the original source.
75  *
76  * 3. This Copyright notice may not be removed or altered from
77  *    any source or altered source distribution.
78  *
79  * The Contributing Authors and Group 42, Inc. specifically permit, without
80  * fee, and encourage the use of this source code as a component to
81  * supporting the PNG file format in commercial products.  If you use this
82  * source code in a product, acknowledgment is not required but would be
83  * appreciated.
84  */
85 
86 /*
87  * Libpng is OSI Certified Open Source Software.  OSI Certified is a
88  * certification mark of the Open Source Initiative.
89  */
90 
91 /*
92  * The contributing authors would like to thank all those who helped
93  * with testing, bug fixes, and patience.  This wouldn't have been
94  * possible without all of you.
95  *
96  * Thanks to Frank J. T. Wojcik for helping with the documentation.
97  */
98 
99 /*
100  * The PNG Specification (Second Edition) is
101  * Copyright (c) 2003 W3C. (MIT, ERCIM, Keio), All Rights Reserved.
102  * Portable Network Graphics (PNG) Specification (Second Edition)
103  * Information technology - Computer graphics and image processing -
104  * Portable Network Graphics (PNG): Functional specification.
105  * ISO/IEC 15948:2003 (E) (November 10, 2003): David Duce and others.
106  */
107 
108 #ifndef PNG_H
109 #define PNG_H
110 
111 /* This is not the place to learn how to use libpng.  The manual libpng.3
112  * describes how to use libpng, and the file example.c summarizes it
113  * with some code on which to build.  This file is useful for looking
114  * at the actual function definitions and structure components.
115  */
116 
117 /* Version information for png.h - this should match the version in png.c */
118 #define PNG_LIBPNG_VER_STRING "1.2.50-MirOS"
119 #define PNG_HEADER_VERSION_STRING \
120    " libpng version 1.2.50-MirOS - July 10, 2012\n"
121 
122 #define PNG_LIBPNG_VER_SONUM   0
123 #define PNG_LIBPNG_VER_DLLNUM  13
124 
125 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
126 #define PNG_LIBPNG_VER_MAJOR   1
127 #define PNG_LIBPNG_VER_MINOR   2
128 #define PNG_LIBPNG_VER_RELEASE 50
129 /* This should match the numeric part of the final component of
130  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
131  */
132 
133 #define PNG_LIBPNG_VER_BUILD  0
134 
135 /* Release Status */
136 #define PNG_LIBPNG_BUILD_ALPHA    1
137 #define PNG_LIBPNG_BUILD_BETA     2
138 #define PNG_LIBPNG_BUILD_RC       3
139 #define PNG_LIBPNG_BUILD_STABLE   4
140 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
141 
142 /* Release-Specific Flags */
143 #define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with
144                                        PNG_LIBPNG_BUILD_STABLE only */
145 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
146                                        PNG_LIBPNG_BUILD_SPECIAL */
147 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
148                                        PNG_LIBPNG_BUILD_PRIVATE */
149 
150 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
151 
152 /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
153  * We must not include leading zeros.
154  * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
155  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
156  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
157  */
158 #define PNG_LIBPNG_VER 10250 /* 1.2.50 */
159 
160 #ifndef PNG_VERSION_INFO_ONLY
161 /* Include the compression library's header */
162 #include "zlib.h"
163 #endif
164 
165 /* Include all user configurable info, including optional assembler routines */
166 #include "pngconf.h"
167 
168 /*
169  * Added at libpng-1.2.8 */
170 /* Ref MSDN: Private as priority over Special
171  * VS_FF_PRIVATEBUILD File *was not* built using standard release
172  * procedures. If this value is given, the StringFileInfo block must
173  * contain a PrivateBuild string.
174  *
175  * VS_FF_SPECIALBUILD File *was* built by the original company using
176  * standard release procedures but is a variation of the standard
177  * file of the same version number. If this value is given, the
178  * StringFileInfo block must contain a SpecialBuild string.
179  */
180 
181 #ifdef PNG_USER_PRIVATEBUILD
182 #  define PNG_LIBPNG_BUILD_TYPE \
183           (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
184 #else
185 #  ifdef PNG_LIBPNG_SPECIALBUILD
186 #    define PNG_LIBPNG_BUILD_TYPE \
187             (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
188 #  else
189 #    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
190 #  endif
191 #endif
192 
193 #ifndef PNG_VERSION_INFO_ONLY
194 
195 /* Inhibit C++ name-mangling for libpng functions but not for system calls. */
196 #ifdef __cplusplus
197 extern "C" {
198 #endif /* __cplusplus */
199 
200 /* This file is arranged in several sections.  The first section contains
201  * structure and type definitions.  The second section contains the external
202  * library functions, while the third has the internal library functions,
203  * which applications aren't expected to use directly.
204  */
205 
206 #ifndef PNG_NO_TYPECAST_NULL
207 #define int_p_NULL                (int *)NULL
208 #define png_bytep_NULL            (png_bytep)NULL
209 #define png_bytepp_NULL           (png_bytepp)NULL
210 #define png_doublep_NULL          (png_doublep)NULL
211 #define png_error_ptr_NULL        (png_error_ptr)NULL
212 #define png_flush_ptr_NULL        (png_flush_ptr)NULL
213 #define png_free_ptr_NULL         (png_free_ptr)NULL
214 #define png_infopp_NULL           (png_infopp)NULL
215 #define png_malloc_ptr_NULL       (png_malloc_ptr)NULL
216 #define png_read_status_ptr_NULL  (png_read_status_ptr)NULL
217 #define png_rw_ptr_NULL           (png_rw_ptr)NULL
218 #define png_structp_NULL          (png_structp)NULL
219 #define png_uint_16p_NULL         (png_uint_16p)NULL
220 #define png_voidp_NULL            (png_voidp)NULL
221 #define png_write_status_ptr_NULL (png_write_status_ptr)NULL
222 #else
223 #define int_p_NULL                NULL
224 #define png_bytep_NULL            NULL
225 #define png_bytepp_NULL           NULL
226 #define png_doublep_NULL          NULL
227 #define png_error_ptr_NULL        NULL
228 #define png_flush_ptr_NULL        NULL
229 #define png_free_ptr_NULL         NULL
230 #define png_infopp_NULL           NULL
231 #define png_malloc_ptr_NULL       NULL
232 #define png_read_status_ptr_NULL  NULL
233 #define png_rw_ptr_NULL           NULL
234 #define png_structp_NULL          NULL
235 #define png_uint_16p_NULL         NULL
236 #define png_voidp_NULL            NULL
237 #define png_write_status_ptr_NULL NULL
238 #endif
239 
240 /* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */
241 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
242 /* Version information for C files, stored in png.c.  This had better match
243  * the version above.
244  */
245 #ifdef PNG_USE_GLOBAL_ARRAYS
246 PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18];
247   /* Need room for 99.99.99beta99z */
248 #else
249 #define png_libpng_ver png_get_header_ver(NULL)
250 #endif
251 
252 #ifdef PNG_USE_GLOBAL_ARRAYS
253 /* This was removed in version 1.0.5c */
254 /* Structures to facilitate easy interlacing.  See png.c for more details */
255 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_start[7];
256 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_inc[7];
257 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_ystart[7];
258 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_yinc[7];
259 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_mask[7];
260 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_dsp_mask[7];
261 /* This isn't currently used.  If you need it, see png.c for more details.
262 PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_height[7];
263 */
264 #endif
265 
266 #endif /* PNG_NO_EXTERN */
267 
268 /* Three color definitions.  The order of the red, green, and blue, (and the
269  * exact size) is not important, although the size of the fields need to
270  * be png_byte or png_uint_16 (as defined below).
271  */
272 typedef struct png_color_struct
273 {
274    png_byte red;
275    png_byte green;
276    png_byte blue;
277 } png_color;
278 typedef png_color FAR * png_colorp;
279 typedef png_color FAR * FAR * png_colorpp;
280 
281 typedef struct png_color_16_struct
282 {
283    png_byte index;    /* used for palette files */
284    png_uint_16 red;   /* for use in red green blue files */
285    png_uint_16 green;
286    png_uint_16 blue;
287    png_uint_16 gray;  /* for use in grayscale files */
288 } png_color_16;
289 typedef png_color_16 FAR * png_color_16p;
290 typedef png_color_16 FAR * FAR * png_color_16pp;
291 
292 typedef struct png_color_8_struct
293 {
294    png_byte red;   /* for use in red green blue files */
295    png_byte green;
296    png_byte blue;
297    png_byte gray;  /* for use in grayscale files */
298    png_byte alpha; /* for alpha channel files */
299 } png_color_8;
300 typedef png_color_8 FAR * png_color_8p;
301 typedef png_color_8 FAR * FAR * png_color_8pp;
302 
303 /*
304  * The following two structures are used for the in-core representation
305  * of sPLT chunks.
306  */
307 typedef struct png_sPLT_entry_struct
308 {
309    png_uint_16 red;
310    png_uint_16 green;
311    png_uint_16 blue;
312    png_uint_16 alpha;
313    png_uint_16 frequency;
314 } png_sPLT_entry;
315 typedef png_sPLT_entry FAR * png_sPLT_entryp;
316 typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
317 
318 /*  When the depth of the sPLT palette is 8 bits, the color and alpha samples
319  *  occupy the LSB of their respective members, and the MSB of each member
320  *  is zero-filled.  The frequency member always occupies the full 16 bits.
321  */
322 
323 typedef struct png_sPLT_struct
324 {
325    png_charp name;           /* palette name */
326    png_byte depth;           /* depth of palette samples */
327    png_sPLT_entryp entries;  /* palette entries */
328    png_int_32 nentries;      /* number of palette entries */
329 } png_sPLT_t;
330 typedef png_sPLT_t FAR * png_sPLT_tp;
331 typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
332 
333 #ifdef PNG_TEXT_SUPPORTED
334 /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
335  * and whether that contents is compressed or not.  The "key" field
336  * points to a regular zero-terminated C string.  The "text", "lang", and
337  * "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
338  * However, the * structure returned by png_get_text() will always contain
339  * regular zero-terminated C strings (possibly empty), never NULL pointers,
340  * so they can be safely used in printf() and other string-handling functions.
341  */
342 typedef struct png_text_struct
343 {
344    int  compression;       /* compression value:
345                              -1: tEXt, none
346                               0: zTXt, deflate
347                               1: iTXt, none
348                               2: iTXt, deflate  */
349    png_charp key;          /* keyword, 1-79 character description of "text" */
350    png_charp text;         /* comment, may be an empty string (ie "")
351                               or a NULL pointer */
352    png_size_t text_length; /* length of the text string */
353 #ifdef PNG_iTXt_SUPPORTED
354    png_size_t itxt_length; /* length of the itxt string */
355    png_charp lang;         /* language code, 0-79 characters
356                               or a NULL pointer */
357    png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more
358                               chars or a NULL pointer */
359 #endif
360 } png_text;
361 typedef png_text FAR * png_textp;
362 typedef png_text FAR * FAR * png_textpp;
363 #endif
364 
365 /* Supported compression types for text in PNG files (tEXt, and zTXt).
366  * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed.
367  */
368 #define PNG_TEXT_COMPRESSION_NONE_WR -3
369 #define PNG_TEXT_COMPRESSION_zTXt_WR -2
370 #define PNG_TEXT_COMPRESSION_NONE    -1
371 #define PNG_TEXT_COMPRESSION_zTXt     0
372 #define PNG_ITXT_COMPRESSION_NONE     1
373 #define PNG_ITXT_COMPRESSION_zTXt     2
374 #define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */
375 
376 /* png_time is a way to hold the time in an machine independent way.
377  * Two conversions are provided, both from time_t and struct tm.  There
378  * is no portable way to convert to either of these structures, as far
379  * as I know.  If you know of a portable way, send it to me.  As a side
380  * note - PNG has always been Year 2000 compliant!
381  */
382 typedef struct png_time_struct
383 {
384    png_uint_16 year; /* full year, as in, 1995 */
385    png_byte month;   /* month of year, 1 - 12 */
386    png_byte day;     /* day of month, 1 - 31 */
387    png_byte hour;    /* hour of day, 0 - 23 */
388    png_byte minute;  /* minute of hour, 0 - 59 */
389    png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */
390 } png_time;
391 typedef png_time FAR * png_timep;
392 typedef png_time FAR * FAR * png_timepp;
393 
394 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
395  defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
396 /* png_unknown_chunk is a structure to hold queued chunks for which there is
397  * no specific support.  The idea is that we can use this to queue
398  * up private chunks for output even though the library doesn't actually
399  * know about their semantics.
400  */
401 #define PNG_CHUNK_NAME_LENGTH 5
402 typedef struct png_unknown_chunk_t
403 {
404     png_byte name[PNG_CHUNK_NAME_LENGTH];
405     png_byte *data;
406     png_size_t size;
407 
408     /* libpng-using applications should NOT directly modify this byte. */
409     png_byte location; /* mode of operation at read time */
410 }
411 png_unknown_chunk;
412 typedef png_unknown_chunk FAR * png_unknown_chunkp;
413 typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
414 #endif
415 
416 /* png_info is a structure that holds the information in a PNG file so
417  * that the application can find out the characteristics of the image.
418  * If you are reading the file, this structure will tell you what is
419  * in the PNG file.  If you are writing the file, fill in the information
420  * you want to put into the PNG file, then call png_write_info().
421  * The names chosen should be very close to the PNG specification, so
422  * consult that document for information about the meaning of each field.
423  *
424  * With libpng < 0.95, it was only possible to directly set and read the
425  * the values in the png_info_struct, which meant that the contents and
426  * order of the values had to remain fixed.  With libpng 0.95 and later,
427  * however, there are now functions that abstract the contents of
428  * png_info_struct from the application, so this makes it easier to use
429  * libpng with dynamic libraries, and even makes it possible to use
430  * libraries that don't have all of the libpng ancillary chunk-handing
431  * functionality.
432  *
433  * In any case, the order of the parameters in png_info_struct should NOT
434  * be changed for as long as possible to keep compatibility with applications
435  * that use the old direct-access method with png_info_struct.
436  *
437  * The following members may have allocated storage attached that should be
438  * cleaned up before the structure is discarded: palette, trans, text,
439  * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
440  * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these
441  * are automatically freed when the info structure is deallocated, if they were
442  * allocated internally by libpng.  This behavior can be changed by means
443  * of the png_data_freer() function.
444  *
445  * More allocation details: all the chunk-reading functions that
446  * change these members go through the corresponding png_set_*
447  * functions.  A function to clear these members is available: see
448  * png_free_data().  The png_set_* functions do not depend on being
449  * able to point info structure members to any of the storage they are
450  * passed (they make their own copies), EXCEPT that the png_set_text
451  * functions use the same storage passed to them in the text_ptr or
452  * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
453  * functions do not make their own copies.
454  */
455 typedef struct png_info_struct
456 {
457    /* The following are necessary for every PNG file */
458    png_uint_32 width PNG_DEPSTRUCT;       /* width of image in pixels (from IHDR) */
459    png_uint_32 height PNG_DEPSTRUCT;      /* height of image in pixels (from IHDR) */
460    png_uint_32 valid PNG_DEPSTRUCT;       /* valid chunk data (see PNG_INFO_ below) */
461    png_uint_32 rowbytes PNG_DEPSTRUCT;    /* bytes needed to hold an untransformed row */
462    png_colorp palette PNG_DEPSTRUCT;      /* array of color values (valid & PNG_INFO_PLTE) */
463    png_uint_16 num_palette PNG_DEPSTRUCT; /* number of color entries in "palette" (PLTE) */
464    png_uint_16 num_trans PNG_DEPSTRUCT;   /* number of transparent palette color (tRNS) */
465    png_byte bit_depth PNG_DEPSTRUCT;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
466    png_byte color_type PNG_DEPSTRUCT;     /* see PNG_COLOR_TYPE_ below (from IHDR) */
467    /* The following three should have been named *_method not *_type */
468    png_byte compression_type PNG_DEPSTRUCT; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
469    png_byte filter_type PNG_DEPSTRUCT;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
470    png_byte interlace_type PNG_DEPSTRUCT; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
471 
472    /* The following is informational only on read, and not used on writes. */
473    png_byte channels PNG_DEPSTRUCT;       /* number of data channels per pixel (1, 2, 3, 4) */
474    png_byte pixel_depth PNG_DEPSTRUCT;    /* number of bits per pixel */
475    png_byte spare_byte PNG_DEPSTRUCT;     /* to align the data, and for future use */
476    png_byte signature[8] PNG_DEPSTRUCT;   /* magic bytes read by libpng from start of file */
477 
478    /* The rest of the data is optional.  If you are reading, check the
479     * valid field to see if the information in these are valid.  If you
480     * are writing, set the valid field to those chunks you want written,
481     * and initialize the appropriate fields below.
482     */
483 
484 #if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
485    /* The gAMA chunk describes the gamma characteristics of the system
486     * on which the image was created, normally in the range [1.0, 2.5].
487     * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
488     */
489    float gamma PNG_DEPSTRUCT; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
490 #endif
491 
492 #ifdef PNG_sRGB_SUPPORTED
493     /* GR-P, 0.96a */
494     /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
495    png_byte srgb_intent PNG_DEPSTRUCT; /* sRGB rendering intent [0, 1, 2, or 3] */
496 #endif
497 
498 #ifdef PNG_TEXT_SUPPORTED
499    /* The tEXt, and zTXt chunks contain human-readable textual data in
500     * uncompressed, compressed, and optionally compressed forms, respectively.
501     * The data in "text" is an array of pointers to uncompressed,
502     * null-terminated C strings. Each chunk has a keyword that describes the
503     * textual data contained in that chunk.  Keywords are not required to be
504     * unique, and the text string may be empty.  Any number of text chunks may
505     * be in an image.
506     */
507    int num_text PNG_DEPSTRUCT; /* number of comments read/to write */
508    int max_text PNG_DEPSTRUCT; /* current size of text array */
509    png_textp text PNG_DEPSTRUCT; /* array of comments read/to write */
510 #endif /* PNG_TEXT_SUPPORTED */
511 
512 #ifdef PNG_tIME_SUPPORTED
513    /* The tIME chunk holds the last time the displayed image data was
514     * modified.  See the png_time struct for the contents of this struct.
515     */
516    png_time mod_time PNG_DEPSTRUCT;
517 #endif
518 
519 #ifdef PNG_sBIT_SUPPORTED
520    /* The sBIT chunk specifies the number of significant high-order bits
521     * in the pixel data.  Values are in the range [1, bit_depth], and are
522     * only specified for the channels in the pixel data.  The contents of
523     * the low-order bits is not specified.  Data is valid if
524     * (valid & PNG_INFO_sBIT) is non-zero.
525     */
526    png_color_8 sig_bit PNG_DEPSTRUCT; /* significant bits in color channels */
527 #endif
528 
529 #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
530 defined(PNG_READ_BACKGROUND_SUPPORTED)
531    /* The tRNS chunk supplies transparency data for paletted images and
532     * other image types that don't need a full alpha channel.  There are
533     * "num_trans" transparency values for a paletted image, stored in the
534     * same order as the palette colors, starting from index 0.  Values
535     * for the data are in the range [0, 255], ranging from fully transparent
536     * to fully opaque, respectively.  For non-paletted images, there is a
537     * single color specified that should be treated as fully transparent.
538     * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
539     */
540    png_bytep trans PNG_DEPSTRUCT; /* transparent values for paletted image */
541    png_color_16 trans_values PNG_DEPSTRUCT; /* transparent color for non-palette image */
542 #endif
543 
544 #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
545    /* The bKGD chunk gives the suggested image background color if the
546     * display program does not have its own background color and the image
547     * is needs to composited onto a background before display.  The colors
548     * in "background" are normally in the same color space/depth as the
549     * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
550     */
551    png_color_16 background PNG_DEPSTRUCT;
552 #endif
553 
554 #ifdef PNG_oFFs_SUPPORTED
555    /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
556     * and downwards from the top-left corner of the display, page, or other
557     * application-specific co-ordinate space.  See the PNG_OFFSET_ defines
558     * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.
559     */
560    png_int_32 x_offset PNG_DEPSTRUCT; /* x offset on page */
561    png_int_32 y_offset PNG_DEPSTRUCT; /* y offset on page */
562    png_byte offset_unit_type PNG_DEPSTRUCT; /* offset units type */
563 #endif
564 
565 #ifdef PNG_pHYs_SUPPORTED
566    /* The pHYs chunk gives the physical pixel density of the image for
567     * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
568     * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
569     */
570    png_uint_32 x_pixels_per_unit PNG_DEPSTRUCT; /* horizontal pixel density */
571    png_uint_32 y_pixels_per_unit PNG_DEPSTRUCT; /* vertical pixel density */
572    png_byte phys_unit_type PNG_DEPSTRUCT; /* resolution type (see PNG_RESOLUTION_ below) */
573 #endif
574 
575 #ifdef PNG_hIST_SUPPORTED
576    /* The hIST chunk contains the relative frequency or importance of the
577     * various palette entries, so that a viewer can intelligently select a
578     * reduced-color palette, if required.  Data is an array of "num_palette"
579     * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
580     * is non-zero.
581     */
582    png_uint_16p hist PNG_DEPSTRUCT;
583 #endif
584 
585 #ifdef PNG_cHRM_SUPPORTED
586    /* The cHRM chunk describes the CIE color characteristics of the monitor
587     * on which the PNG was created.  This data allows the viewer to do gamut
588     * mapping of the input image to ensure that the viewer sees the same
589     * colors in the image as the creator.  Values are in the range
590     * [0.0, 0.8].  Data valid if (valid & PNG_INFO_cHRM) non-zero.
591     */
592 #ifdef PNG_FLOATING_POINT_SUPPORTED
593    float x_white PNG_DEPSTRUCT;
594    float y_white PNG_DEPSTRUCT;
595    float x_red PNG_DEPSTRUCT;
596    float y_red PNG_DEPSTRUCT;
597    float x_green PNG_DEPSTRUCT;
598    float y_green PNG_DEPSTRUCT;
599    float x_blue PNG_DEPSTRUCT;
600    float y_blue PNG_DEPSTRUCT;
601 #endif
602 #endif
603 
604 #ifdef PNG_pCAL_SUPPORTED
605    /* The pCAL chunk describes a transformation between the stored pixel
606     * values and original physical data values used to create the image.
607     * The integer range [0, 2^bit_depth - 1] maps to the floating-point
608     * range given by [pcal_X0, pcal_X1], and are further transformed by a
609     * (possibly non-linear) transformation function given by "pcal_type"
610     * and "pcal_params" into "pcal_units".  Please see the PNG_EQUATION_
611     * defines below, and the PNG-Group's PNG extensions document for a
612     * complete description of the transformations and how they should be
613     * implemented, and for a description of the ASCII parameter strings.
614     * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
615     */
616    png_charp pcal_purpose PNG_DEPSTRUCT;  /* pCAL chunk description string */
617    png_int_32 pcal_X0 PNG_DEPSTRUCT;      /* minimum value */
618    png_int_32 pcal_X1 PNG_DEPSTRUCT;      /* maximum value */
619    png_charp pcal_units PNG_DEPSTRUCT;    /* Latin-1 string giving physical units */
620    png_charpp pcal_params PNG_DEPSTRUCT;  /* ASCII strings containing parameter values */
621    png_byte pcal_type PNG_DEPSTRUCT;      /* equation type (see PNG_EQUATION_ below) */
622    png_byte pcal_nparams PNG_DEPSTRUCT;   /* number of parameters given in pcal_params */
623 #endif
624 
625 /* New members added in libpng-1.0.6 */
626 #ifdef PNG_FREE_ME_SUPPORTED
627    png_uint_32 free_me PNG_DEPSTRUCT;     /* flags items libpng is responsible for freeing */
628 #endif
629 
630 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
631  defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
632    /* Storage for unknown chunks that the library doesn't recognize. */
633    png_unknown_chunkp unknown_chunks PNG_DEPSTRUCT;
634    png_size_t unknown_chunks_num PNG_DEPSTRUCT;
635 #endif
636 
637 #ifdef PNG_iCCP_SUPPORTED
638    /* iCCP chunk data. */
639    png_charp iccp_name PNG_DEPSTRUCT;     /* profile name */
640    png_charp iccp_profile PNG_DEPSTRUCT;  /* International Color Consortium profile data */
641                             /* Note to maintainer: should be png_bytep */
642    png_uint_32 iccp_proflen PNG_DEPSTRUCT;  /* ICC profile data length */
643    png_byte iccp_compression PNG_DEPSTRUCT; /* Always zero */
644 #endif
645 
646 #ifdef PNG_sPLT_SUPPORTED
647    /* Data on sPLT chunks (there may be more than one). */
648    png_sPLT_tp splt_palettes PNG_DEPSTRUCT;
649    png_uint_32 splt_palettes_num PNG_DEPSTRUCT;
650 #endif
651 
652 #ifdef PNG_sCAL_SUPPORTED
653    /* The sCAL chunk describes the actual physical dimensions of the
654     * subject matter of the graphic.  The chunk contains a unit specification
655     * a byte value, and two ASCII strings representing floating-point
656     * values.  The values are width and height corresponsing to one pixel
657     * in the image.  This external representation is converted to double
658     * here.  Data values are valid if (valid & PNG_INFO_sCAL) is non-zero.
659     */
660    png_byte scal_unit PNG_DEPSTRUCT;         /* unit of physical scale */
661 #ifdef PNG_FLOATING_POINT_SUPPORTED
662    double scal_pixel_width PNG_DEPSTRUCT;    /* width of one pixel */
663    double scal_pixel_height PNG_DEPSTRUCT;   /* height of one pixel */
664 #endif
665 #ifdef PNG_FIXED_POINT_SUPPORTED
666    png_charp scal_s_width PNG_DEPSTRUCT;     /* string containing height */
667    png_charp scal_s_height PNG_DEPSTRUCT;    /* string containing width */
668 #endif
669 #endif
670 
671 #ifdef PNG_INFO_IMAGE_SUPPORTED
672    /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */
673    /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
674    png_bytepp row_pointers PNG_DEPSTRUCT;        /* the image bits */
675 #endif
676 
677 #if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED)
678    png_fixed_point int_gamma PNG_DEPSTRUCT; /* gamma of image, if (valid & PNG_INFO_gAMA) */
679 #endif
680 
681 #if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED)
682    png_fixed_point int_x_white PNG_DEPSTRUCT;
683    png_fixed_point int_y_white PNG_DEPSTRUCT;
684    png_fixed_point int_x_red PNG_DEPSTRUCT;
685    png_fixed_point int_y_red PNG_DEPSTRUCT;
686    png_fixed_point int_x_green PNG_DEPSTRUCT;
687    png_fixed_point int_y_green PNG_DEPSTRUCT;
688    png_fixed_point int_x_blue PNG_DEPSTRUCT;
689    png_fixed_point int_y_blue PNG_DEPSTRUCT;
690 #endif
691 
692 } png_info;
693 
694 typedef png_info FAR * png_infop;
695 typedef png_info FAR * FAR * png_infopp;
696 
697 /* Maximum positive integer used in PNG is (2^31)-1 */
698 #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
699 #define PNG_UINT_32_MAX ((png_uint_32)(-1))
700 #define PNG_SIZE_MAX ((png_size_t)(-1))
701 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
702 /* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
703 #define PNG_MAX_UINT PNG_UINT_31_MAX
704 #endif
705 
706 /* These describe the color_type field in png_info. */
707 /* color type masks */
708 #define PNG_COLOR_MASK_PALETTE    1
709 #define PNG_COLOR_MASK_COLOR      2
710 #define PNG_COLOR_MASK_ALPHA      4
711 
712 /* color types.  Note that not all combinations are legal */
713 #define PNG_COLOR_TYPE_GRAY 0
714 #define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
715 #define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
716 #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
717 #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
718 /* aliases */
719 #define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA
720 #define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA
721 
722 /* This is for compression type. PNG 1.0-1.2 only define the single type. */
723 #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
724 #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
725 
726 /* This is for filter type. PNG 1.0-1.2 only define the single type. */
727 #define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */
728 #define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
729 #define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE
730 
731 /* These are for the interlacing type.  These values should NOT be changed. */
732 #define PNG_INTERLACE_NONE        0 /* Non-interlaced image */
733 #define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */
734 #define PNG_INTERLACE_LAST        2 /* Not a valid value */
735 
736 /* These are for the oFFs chunk.  These values should NOT be changed. */
737 #define PNG_OFFSET_PIXEL          0 /* Offset in pixels */
738 #define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */
739 #define PNG_OFFSET_LAST           2 /* Not a valid value */
740 
741 /* These are for the pCAL chunk.  These values should NOT be changed. */
742 #define PNG_EQUATION_LINEAR       0 /* Linear transformation */
743 #define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */
744 #define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */
745 #define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */
746 #define PNG_EQUATION_LAST         4 /* Not a valid value */
747 
748 /* These are for the sCAL chunk.  These values should NOT be changed. */
749 #define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */
750 #define PNG_SCALE_METER           1 /* meters per pixel */
751 #define PNG_SCALE_RADIAN          2 /* radians per pixel */
752 #define PNG_SCALE_LAST            3 /* Not a valid value */
753 
754 /* These are for the pHYs chunk.  These values should NOT be changed. */
755 #define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */
756 #define PNG_RESOLUTION_METER      1 /* pixels/meter */
757 #define PNG_RESOLUTION_LAST       2 /* Not a valid value */
758 
759 /* These are for the sRGB chunk.  These values should NOT be changed. */
760 #define PNG_sRGB_INTENT_PERCEPTUAL 0
761 #define PNG_sRGB_INTENT_RELATIVE   1
762 #define PNG_sRGB_INTENT_SATURATION 2
763 #define PNG_sRGB_INTENT_ABSOLUTE   3
764 #define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */
765 
766 /* This is for text chunks */
767 #define PNG_KEYWORD_MAX_LENGTH     79
768 
769 /* Maximum number of entries in PLTE/sPLT/tRNS arrays */
770 #define PNG_MAX_PALETTE_LENGTH    256
771 
772 /* These determine if an ancillary chunk's data has been successfully read
773  * from the PNG header, or if the application has filled in the corresponding
774  * data in the info_struct to be written into the output file.  The values
775  * of the PNG_INFO_<chunk> defines should NOT be changed.
776  */
777 #define PNG_INFO_gAMA 0x0001
778 #define PNG_INFO_sBIT 0x0002
779 #define PNG_INFO_cHRM 0x0004
780 #define PNG_INFO_PLTE 0x0008
781 #define PNG_INFO_tRNS 0x0010
782 #define PNG_INFO_bKGD 0x0020
783 #define PNG_INFO_hIST 0x0040
784 #define PNG_INFO_pHYs 0x0080
785 #define PNG_INFO_oFFs 0x0100
786 #define PNG_INFO_tIME 0x0200
787 #define PNG_INFO_pCAL 0x0400
788 #define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */
789 #define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */
790 #define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
791 #define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
792 #define PNG_INFO_IDAT 0x8000L  /* ESR, 1.0.6 */
793 
794 /* This is used for the transformation routines, as some of them
795  * change these values for the row.  It also should enable using
796  * the routines for other purposes.
797  */
798 typedef struct png_row_info_struct
799 {
800    png_uint_32 width; /* width of row */
801    png_uint_32 rowbytes; /* number of bytes in row */
802    png_byte color_type; /* color type of row */
803    png_byte bit_depth; /* bit depth of row */
804    png_byte channels; /* number of channels (1, 2, 3, or 4) */
805    png_byte pixel_depth; /* bits per pixel (depth * channels) */
806 } png_row_info;
807 
808 typedef png_row_info FAR * png_row_infop;
809 typedef png_row_info FAR * FAR * png_row_infopp;
810 
811 /* These are the function types for the I/O functions and for the functions
812  * that allow the user to override the default I/O functions with his or her
813  * own.  The png_error_ptr type should match that of user-supplied warning
814  * and error functions, while the png_rw_ptr type should match that of the
815  * user read/write data functions.
816  */
817 typedef struct png_struct_def png_struct;
818 typedef png_struct FAR * png_structp;
819 
820 typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp));
821 typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
822 typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp));
823 typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32,
824    int));
825 typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32,
826    int));
827 
828 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
829 typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop));
830 typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
831 typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
832    png_uint_32, int));
833 #endif
834 
835 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
836     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
837     defined(PNG_LEGACY_SUPPORTED)
838 typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp,
839     png_row_infop, png_bytep));
840 #endif
841 
842 #ifdef PNG_USER_CHUNKS_SUPPORTED
843 typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp));
844 #endif
845 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
846 typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
847 #endif
848 
849 /* Transform masks for the high-level interface */
850 #define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */
851 #define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */
852 #define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */
853 #define PNG_TRANSFORM_PACKING        0x0004    /* read and write */
854 #define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */
855 #define PNG_TRANSFORM_EXPAND         0x0010    /* read only */
856 #define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */
857 #define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */
858 #define PNG_TRANSFORM_BGR            0x0080    /* read and write */
859 #define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */
860 #define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */
861 #define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */
862 #define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only, deprecated */
863 /* Added to libpng-1.2.34 */
864 #define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800  /* write only */
865 #define PNG_TRANSFORM_STRIP_FILLER_AFTER  0x1000  /* write only */
866 /* Added to libpng-1.2.41 */
867 #define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */
868 
869 /* Flags for MNG supported features */
870 #define PNG_FLAG_MNG_EMPTY_PLTE     0x01
871 #define PNG_FLAG_MNG_FILTER_64      0x04
872 #define PNG_ALL_MNG_FEATURES        0x05
873 
874 typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
875 typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
876 
877 /* The structure that holds the information to read and write PNG files.
878  * The only people who need to care about what is inside of this are the
879  * people who will be modifying the library for their own special needs.
880  * It should NOT be accessed directly by an application, except to store
881  * the jmp_buf.
882  */
883 
884 struct png_struct_def
885 {
886 #ifdef PNG_SETJMP_SUPPORTED
887    jmp_buf jmpbuf;            /* used in png_error */
888 #endif
889    png_error_ptr error_fn PNG_DEPSTRUCT;    /* function for printing errors and aborting */
890    png_error_ptr warning_fn PNG_DEPSTRUCT;  /* function for printing warnings */
891    png_voidp error_ptr PNG_DEPSTRUCT;       /* user supplied struct for error functions */
892    png_rw_ptr write_data_fn PNG_DEPSTRUCT;  /* function for writing output data */
893    png_rw_ptr read_data_fn PNG_DEPSTRUCT;   /* function for reading input data */
894    png_voidp io_ptr PNG_DEPSTRUCT;          /* ptr to application struct for I/O functions */
895 
896 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
897    png_user_transform_ptr read_user_transform_fn PNG_DEPSTRUCT; /* user read transform */
898 #endif
899 
900 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
901    png_user_transform_ptr write_user_transform_fn PNG_DEPSTRUCT; /* user write transform */
902 #endif
903 
904 /* These were added in libpng-1.0.2 */
905 #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
906 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
907     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
908    png_voidp user_transform_ptr PNG_DEPSTRUCT; /* user supplied struct for user transform */
909    png_byte user_transform_depth PNG_DEPSTRUCT;    /* bit depth of user transformed pixels */
910    png_byte user_transform_channels PNG_DEPSTRUCT; /* channels in user transformed pixels */
911 #endif
912 #endif
913 
914    png_uint_32 mode PNG_DEPSTRUCT;          /* tells us where we are in the PNG file */
915    png_uint_32 flags PNG_DEPSTRUCT;         /* flags indicating various things to libpng */
916    png_uint_32 transformations PNG_DEPSTRUCT; /* which transformations to perform */
917 
918    z_stream zstream PNG_DEPSTRUCT;          /* pointer to decompression structure (below) */
919    png_bytep zbuf PNG_DEPSTRUCT;            /* buffer for zlib */
920    png_size_t zbuf_size PNG_DEPSTRUCT;      /* size of zbuf */
921    int zlib_level PNG_DEPSTRUCT;            /* holds zlib compression level */
922    int zlib_method PNG_DEPSTRUCT;           /* holds zlib compression method */
923    int zlib_window_bits PNG_DEPSTRUCT;      /* holds zlib compression window bits */
924    int zlib_mem_level PNG_DEPSTRUCT;        /* holds zlib compression memory level */
925    int zlib_strategy PNG_DEPSTRUCT;         /* holds zlib compression strategy */
926 
927    png_uint_32 width PNG_DEPSTRUCT;         /* width of image in pixels */
928    png_uint_32 height PNG_DEPSTRUCT;        /* height of image in pixels */
929    png_uint_32 num_rows PNG_DEPSTRUCT;      /* number of rows in current pass */
930    png_uint_32 usr_width PNG_DEPSTRUCT;     /* width of row at start of write */
931    png_uint_32 rowbytes PNG_DEPSTRUCT;      /* size of row in bytes */
932 #if 0 /* Replaced with the following in libpng-1.2.43 */
933    png_size_t irowbytes PNG_DEPSTRUCT;
934 #endif
935 /* Added in libpng-1.2.43 */
936 #ifdef PNG_USER_LIMITS_SUPPORTED
937    /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
938     * chunks that can be stored (0 means unlimited).
939     */
940    png_uint_32 user_chunk_cache_max PNG_DEPSTRUCT;
941 #endif
942    png_uint_32 iwidth PNG_DEPSTRUCT;        /* width of current interlaced row in pixels */
943    png_uint_32 row_number PNG_DEPSTRUCT;    /* current row in interlace pass */
944    png_bytep prev_row PNG_DEPSTRUCT;        /* buffer to save previous (unfiltered) row */
945    png_bytep row_buf PNG_DEPSTRUCT;         /* buffer to save current (unfiltered) row */
946 #ifndef PNG_NO_WRITE_FILTER
947    png_bytep sub_row PNG_DEPSTRUCT;         /* buffer to save "sub" row when filtering */
948    png_bytep up_row PNG_DEPSTRUCT;          /* buffer to save "up" row when filtering */
949    png_bytep avg_row PNG_DEPSTRUCT;         /* buffer to save "avg" row when filtering */
950    png_bytep paeth_row PNG_DEPSTRUCT;       /* buffer to save "Paeth" row when filtering */
951 #endif
952    png_row_info row_info PNG_DEPSTRUCT;     /* used for transformation routines */
953 
954    png_uint_32 idat_size PNG_DEPSTRUCT;     /* current IDAT size for read */
955    png_uint_32 crc PNG_DEPSTRUCT;           /* current chunk CRC value */
956    png_colorp palette PNG_DEPSTRUCT;        /* palette from the input file */
957    png_uint_16 num_palette PNG_DEPSTRUCT;   /* number of color entries in palette */
958    png_uint_16 num_trans PNG_DEPSTRUCT;     /* number of transparency values */
959    png_byte chunk_name[5] PNG_DEPSTRUCT;    /* null-terminated name of current chunk */
960    png_byte compression PNG_DEPSTRUCT;      /* file compression type (always 0) */
961    png_byte filter PNG_DEPSTRUCT;           /* file filter type (always 0) */
962    png_byte interlaced PNG_DEPSTRUCT;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
963    png_byte pass PNG_DEPSTRUCT;             /* current interlace pass (0 - 6) */
964    png_byte do_filter PNG_DEPSTRUCT;        /* row filter flags (see PNG_FILTER_ below ) */
965    png_byte color_type PNG_DEPSTRUCT;       /* color type of file */
966    png_byte bit_depth PNG_DEPSTRUCT;        /* bit depth of file */
967    png_byte usr_bit_depth PNG_DEPSTRUCT;    /* bit depth of users row */
968    png_byte pixel_depth PNG_DEPSTRUCT;      /* number of bits per pixel */
969    png_byte channels PNG_DEPSTRUCT;         /* number of channels in file */
970    png_byte usr_channels PNG_DEPSTRUCT;     /* channels at start of write */
971    png_byte sig_bytes PNG_DEPSTRUCT;        /* magic bytes read/written from start of file */
972 
973 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
974 #ifdef PNG_LEGACY_SUPPORTED
975    png_byte filler PNG_DEPSTRUCT;           /* filler byte for pixel expansion */
976 #else
977    png_uint_16 filler PNG_DEPSTRUCT;           /* filler bytes for pixel expansion */
978 #endif
979 #endif
980 
981 #ifdef PNG_bKGD_SUPPORTED
982    png_byte background_gamma_type PNG_DEPSTRUCT;
983 #  ifdef PNG_FLOATING_POINT_SUPPORTED
984    float background_gamma PNG_DEPSTRUCT;
985 #  endif
986    png_color_16 background PNG_DEPSTRUCT;   /* background color in screen gamma space */
987 #ifdef PNG_READ_GAMMA_SUPPORTED
988    png_color_16 background_1 PNG_DEPSTRUCT; /* background normalized to gamma 1.0 */
989 #endif
990 #endif /* PNG_bKGD_SUPPORTED */
991 
992 #ifdef PNG_WRITE_FLUSH_SUPPORTED
993    png_flush_ptr output_flush_fn PNG_DEPSTRUCT; /* Function for flushing output */
994    png_uint_32 flush_dist PNG_DEPSTRUCT;    /* how many rows apart to flush, 0 - no flush */
995    png_uint_32 flush_rows PNG_DEPSTRUCT;    /* number of rows written since last flush */
996 #endif
997 
998 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
999    int gamma_shift PNG_DEPSTRUCT;      /* number of "insignificant" bits 16-bit gamma */
1000 #ifdef PNG_FLOATING_POINT_SUPPORTED
1001    float gamma PNG_DEPSTRUCT;          /* file gamma value */
1002    float screen_gamma PNG_DEPSTRUCT;   /* screen gamma value (display_exponent) */
1003 #endif
1004 #endif
1005 
1006 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
1007    png_bytep gamma_table PNG_DEPSTRUCT;     /* gamma table for 8-bit depth files */
1008    png_bytep gamma_from_1 PNG_DEPSTRUCT;    /* converts from 1.0 to screen */
1009    png_bytep gamma_to_1 PNG_DEPSTRUCT;      /* converts from file to 1.0 */
1010    png_uint_16pp gamma_16_table PNG_DEPSTRUCT; /* gamma table for 16-bit depth files */
1011    png_uint_16pp gamma_16_from_1 PNG_DEPSTRUCT; /* converts from 1.0 to screen */
1012    png_uint_16pp gamma_16_to_1 PNG_DEPSTRUCT; /* converts from file to 1.0 */
1013 #endif
1014 
1015 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
1016    png_color_8 sig_bit PNG_DEPSTRUCT;       /* significant bits in each available channel */
1017 #endif
1018 
1019 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
1020    png_color_8 shift PNG_DEPSTRUCT;         /* shift for significant bit tranformation */
1021 #endif
1022 
1023 #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
1024  || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
1025    png_bytep trans PNG_DEPSTRUCT;           /* transparency values for paletted files */
1026    png_color_16 trans_values PNG_DEPSTRUCT; /* transparency values for non-paletted files */
1027 #endif
1028 
1029    png_read_status_ptr read_row_fn PNG_DEPSTRUCT;   /* called after each row is decoded */
1030    png_write_status_ptr write_row_fn PNG_DEPSTRUCT; /* called after each row is encoded */
1031 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
1032    png_progressive_info_ptr info_fn PNG_DEPSTRUCT; /* called after header data fully read */
1033    png_progressive_row_ptr row_fn PNG_DEPSTRUCT;   /* called after each prog. row is decoded */
1034    png_progressive_end_ptr end_fn PNG_DEPSTRUCT;   /* called after image is complete */
1035    png_bytep save_buffer_ptr PNG_DEPSTRUCT;        /* current location in save_buffer */
1036    png_bytep save_buffer PNG_DEPSTRUCT;            /* buffer for previously read data */
1037    png_bytep current_buffer_ptr PNG_DEPSTRUCT;     /* current location in current_buffer */
1038    png_bytep current_buffer PNG_DEPSTRUCT;         /* buffer for recently used data */
1039    png_uint_32 push_length PNG_DEPSTRUCT;          /* size of current input chunk */
1040    png_uint_32 skip_length PNG_DEPSTRUCT;          /* bytes to skip in input data */
1041    png_size_t save_buffer_size PNG_DEPSTRUCT;      /* amount of data now in save_buffer */
1042    png_size_t save_buffer_max PNG_DEPSTRUCT;       /* total size of save_buffer */
1043    png_size_t buffer_size PNG_DEPSTRUCT;           /* total amount of available input data */
1044    png_size_t current_buffer_size PNG_DEPSTRUCT;   /* amount of data now in current_buffer */
1045    int process_mode PNG_DEPSTRUCT;                 /* what push library is currently doing */
1046    int cur_palette PNG_DEPSTRUCT;                  /* current push library palette index */
1047 
1048 #  ifdef PNG_TEXT_SUPPORTED
1049      png_size_t current_text_size PNG_DEPSTRUCT;   /* current size of text input data */
1050      png_size_t current_text_left PNG_DEPSTRUCT;   /* how much text left to read in input */
1051      png_charp current_text PNG_DEPSTRUCT;         /* current text chunk buffer */
1052      png_charp current_text_ptr PNG_DEPSTRUCT;     /* current location in current_text */
1053 #  endif /* PNG_TEXT_SUPPORTED */
1054 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
1055 
1056 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
1057 /* for the Borland special 64K segment handler */
1058    png_bytepp offset_table_ptr PNG_DEPSTRUCT;
1059    png_bytep offset_table PNG_DEPSTRUCT;
1060    png_uint_16 offset_table_number PNG_DEPSTRUCT;
1061    png_uint_16 offset_table_count PNG_DEPSTRUCT;
1062    png_uint_16 offset_table_count_free PNG_DEPSTRUCT;
1063 #endif
1064 
1065 #ifdef PNG_READ_DITHER_SUPPORTED
1066    png_bytep palette_lookup PNG_DEPSTRUCT;         /* lookup table for dithering */
1067    png_bytep dither_index PNG_DEPSTRUCT;           /* index translation for palette files */
1068 #endif
1069 
1070 #if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
1071    png_uint_16p hist PNG_DEPSTRUCT;                /* histogram */
1072 #endif
1073 
1074 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
1075    png_byte heuristic_method PNG_DEPSTRUCT;        /* heuristic for row filter selection */
1076    png_byte num_prev_filters PNG_DEPSTRUCT;        /* number of weights for previous rows */
1077    png_bytep prev_filters PNG_DEPSTRUCT;           /* filter type(s) of previous row(s) */
1078    png_uint_16p filter_weights PNG_DEPSTRUCT;      /* weight(s) for previous line(s) */
1079    png_uint_16p inv_filter_weights PNG_DEPSTRUCT;  /* 1/weight(s) for previous line(s) */
1080    png_uint_16p filter_costs PNG_DEPSTRUCT;        /* relative filter calculation cost */
1081    png_uint_16p inv_filter_costs PNG_DEPSTRUCT;    /* 1/relative filter calculation cost */
1082 #endif
1083 
1084 #ifdef PNG_TIME_RFC1123_SUPPORTED
1085    png_charp time_buffer PNG_DEPSTRUCT;            /* String to hold RFC 1123 time text */
1086 #endif
1087 
1088 /* New members added in libpng-1.0.6 */
1089 
1090 #ifdef PNG_FREE_ME_SUPPORTED
1091    png_uint_32 free_me PNG_DEPSTRUCT;   /* flags items libpng is responsible for freeing */
1092 #endif
1093 
1094 #ifdef PNG_USER_CHUNKS_SUPPORTED
1095    png_voidp user_chunk_ptr PNG_DEPSTRUCT;
1096    png_user_chunk_ptr read_user_chunk_fn PNG_DEPSTRUCT; /* user read chunk handler */
1097 #endif
1098 
1099 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1100    int num_chunk_list PNG_DEPSTRUCT;
1101    png_bytep chunk_list PNG_DEPSTRUCT;
1102 #endif
1103 
1104 /* New members added in libpng-1.0.3 */
1105 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1106    png_byte rgb_to_gray_status PNG_DEPSTRUCT;
1107    /* These were changed from png_byte in libpng-1.0.6 */
1108    png_uint_16 rgb_to_gray_red_coeff PNG_DEPSTRUCT;
1109    png_uint_16 rgb_to_gray_green_coeff PNG_DEPSTRUCT;
1110    png_uint_16 rgb_to_gray_blue_coeff PNG_DEPSTRUCT;
1111 #endif
1112 
1113 /* New member added in libpng-1.0.4 (renamed in 1.0.9) */
1114 #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
1115     defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
1116     defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
1117 /* Changed from png_byte to png_uint_32 at version 1.2.0 */
1118 #ifdef PNG_1_0_X
1119    png_byte mng_features_permitted PNG_DEPSTRUCT;
1120 #else
1121    png_uint_32 mng_features_permitted PNG_DEPSTRUCT;
1122 #endif /* PNG_1_0_X */
1123 #endif
1124 
1125 /* New member added in libpng-1.0.7 */
1126 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
1127    png_fixed_point int_gamma PNG_DEPSTRUCT;
1128 #endif
1129 
1130 /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
1131 #ifdef PNG_MNG_FEATURES_SUPPORTED
1132    png_byte filter_type PNG_DEPSTRUCT;
1133 #endif
1134 
1135 #ifdef PNG_1_0_X
1136 /* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
1137    png_uint_32 row_buf_size PNG_DEPSTRUCT;
1138 #endif
1139 
1140 /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
1141 #ifdef PNG_USER_MEM_SUPPORTED
1142    png_voidp mem_ptr PNG_DEPSTRUCT;            /* user supplied struct for mem functions */
1143    png_malloc_ptr malloc_fn PNG_DEPSTRUCT;     /* function for allocating memory */
1144    png_free_ptr free_fn PNG_DEPSTRUCT;         /* function for freeing memory */
1145 #endif
1146 
1147 /* New member added in libpng-1.0.13 and 1.2.0 */
1148    png_bytep big_row_buf PNG_DEPSTRUCT;        /* buffer to save current (unfiltered) row */
1149 
1150 #ifdef PNG_READ_DITHER_SUPPORTED
1151 /* The following three members were added at version 1.0.14 and 1.2.4 */
1152    png_bytep dither_sort PNG_DEPSTRUCT;        /* working sort array */
1153    png_bytep index_to_palette PNG_DEPSTRUCT;   /* where the original index currently is */
1154                                  /* in the palette */
1155    png_bytep palette_to_index PNG_DEPSTRUCT;   /* which original index points to this */
1156                                  /* palette color */
1157 #endif
1158 
1159 /* New members added in libpng-1.0.16 and 1.2.6 */
1160    png_byte compression_type PNG_DEPSTRUCT;
1161 
1162 #ifdef PNG_USER_LIMITS_SUPPORTED
1163    png_uint_32 user_width_max PNG_DEPSTRUCT;
1164    png_uint_32 user_height_max PNG_DEPSTRUCT;
1165 #endif
1166 
1167 /* New member added in libpng-1.0.25 and 1.2.17 */
1168 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
1169    /* Storage for unknown chunk that the library doesn't recognize. */
1170    png_unknown_chunk unknown_chunk PNG_DEPSTRUCT;
1171 #endif
1172 
1173 /* New members added in libpng-1.2.26 */
1174   png_uint_32 old_big_row_buf_size PNG_DEPSTRUCT;
1175   png_uint_32 old_prev_row_size PNG_DEPSTRUCT;
1176 
1177 /* New member added in libpng-1.2.30 */
1178   png_charp chunkdata PNG_DEPSTRUCT;  /* buffer for reading chunk data */
1179 
1180 
1181 };
1182 
1183 
1184 /* This triggers a compiler error in png.c, if png.c and png.h
1185  * do not agree upon the version number.
1186  */
1187 typedef png_structp version_1_2_50;
1188 
1189 typedef png_struct FAR * FAR * png_structpp;
1190 
1191 /* Here are the function definitions most commonly used.  This is not
1192  * the place to find out how to use libpng.  See libpng.txt for the
1193  * full explanation, see example.c for the summary.  This just provides
1194  * a simple one line description of the use of each function.
1195  */
1196 
1197 /* Returns the version number of the library */
1198 extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void));
1199 
1200 /* Tell lib we have already handled the first <num_bytes> magic bytes.
1201  * Handling more than 8 bytes from the beginning of the file is an error.
1202  */
1203 extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
1204    int num_bytes));
1205 
1206 /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
1207  * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG
1208  * signature, and non-zero otherwise.  Having num_to_check == 0 or
1209  * start > 7 will always fail (ie return non-zero).
1210  */
1211 extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
1212    png_size_t num_to_check));
1213 
1214 /* Simple signature checking function.  This is the same as calling
1215  * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
1216  */
1217 extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)) PNG_DEPRECATED;
1218 
1219 /* Allocate and initialize png_ptr struct for reading, and any other memory. */
1220 extern PNG_EXPORT(png_structp,png_create_read_struct)
1221    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
1222    png_error_ptr error_fn, png_error_ptr warn_fn)) PNG_ALLOCATED;
1223 
1224 /* Allocate and initialize png_ptr struct for writing, and any other memory */
1225 extern PNG_EXPORT(png_structp,png_create_write_struct)
1226    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
1227    png_error_ptr error_fn, png_error_ptr warn_fn)) PNG_ALLOCATED;
1228 
1229 #ifdef PNG_WRITE_SUPPORTED
1230 extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size)
1231    PNGARG((png_structp png_ptr));
1232 #endif
1233 
1234 #ifdef PNG_WRITE_SUPPORTED
1235 extern PNG_EXPORT(void,png_set_compression_buffer_size)
1236    PNGARG((png_structp png_ptr, png_uint_32 size));
1237 #endif
1238 
1239 /* Reset the compression stream */
1240 extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
1241 
1242 /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
1243 #ifdef PNG_USER_MEM_SUPPORTED
1244 extern PNG_EXPORT(png_structp,png_create_read_struct_2)
1245    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
1246    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
1247    png_malloc_ptr malloc_fn, png_free_ptr free_fn)) PNG_ALLOCATED;
1248 extern PNG_EXPORT(png_structp,png_create_write_struct_2)
1249    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
1250    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
1251    png_malloc_ptr malloc_fn, png_free_ptr free_fn)) PNG_ALLOCATED;
1252 #endif
1253 
1254 /* Write a PNG chunk - size, type, (optional) data, CRC. */
1255 extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
1256    png_bytep chunk_name, png_bytep data, png_size_t length));
1257 
1258 /* Write the start of a PNG chunk - length and chunk name. */
1259 extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
1260    png_bytep chunk_name, png_uint_32 length));
1261 
1262 /* Write the data of a PNG chunk started with png_write_chunk_start(). */
1263 extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
1264    png_bytep data, png_size_t length));
1265 
1266 /* Finish a chunk started with png_write_chunk_start() (includes CRC). */
1267 extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
1268 
1269 /* Allocate and initialize the info structure */
1270 extern PNG_EXPORT(png_infop,png_create_info_struct)
1271    PNGARG((png_structp png_ptr)) PNG_ALLOCATED;
1272 
1273 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
1274 /* Initialize the info structure (old interface - DEPRECATED) */
1275 extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr))
1276     PNG_DEPRECATED;
1277 #undef png_info_init
1278 #define png_info_init(info_ptr) png_info_init_3(&info_ptr,\
1279     png_sizeof(png_info));
1280 #endif
1281 
1282 extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
1283     png_size_t png_info_struct_size));
1284 
1285 /* Writes all the PNG information before the image. */
1286 extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr,
1287    png_infop info_ptr));
1288 extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
1289    png_infop info_ptr));
1290 
1291 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1292 /* Read the information before the actual image data. */
1293 extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
1294    png_infop info_ptr));
1295 #endif
1296 
1297 #ifdef PNG_TIME_RFC1123_SUPPORTED
1298 extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
1299    PNGARG((png_structp png_ptr, png_timep ptime));
1300 #endif
1301 
1302 #ifdef PNG_CONVERT_tIME_SUPPORTED
1303 /* Convert from a struct tm to png_time */
1304 extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
1305    struct tm FAR * ttime));
1306 
1307 /* Convert from time_t to png_time.  Uses gmtime() */
1308 extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
1309    time_t ttime));
1310 #endif /* PNG_CONVERT_tIME_SUPPORTED */
1311 
1312 #ifdef PNG_READ_EXPAND_SUPPORTED
1313 /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
1314 extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
1315 #ifndef PNG_1_0_X
1316 extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp
1317   png_ptr));
1318 #endif
1319 extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
1320 extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
1321 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
1322 /* Deprecated */
1323 extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp
1324     png_ptr)) PNG_DEPRECATED;
1325 #endif
1326 #endif
1327 
1328 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
1329 /* Use blue, green, red order for pixels. */
1330 extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
1331 #endif
1332 
1333 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
1334 /* Expand the grayscale to 24-bit RGB if necessary. */
1335 extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
1336 #endif
1337 
1338 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1339 /* Reduce RGB to grayscale. */
1340 #ifdef PNG_FLOATING_POINT_SUPPORTED
1341 extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
1342    int error_action, double red, double green ));
1343 #endif
1344 extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr,
1345    int error_action, png_fixed_point red, png_fixed_point green ));
1346 extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
1347    png_ptr));
1348 #endif
1349 
1350 extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
1351    png_colorp palette));
1352 
1353 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
1354 extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
1355 #endif
1356 
1357 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
1358     defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
1359 extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
1360 #endif
1361 
1362 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
1363     defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
1364 extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
1365 #endif
1366 
1367 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
1368 /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
1369 extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
1370    png_uint_32 filler, int flags));
1371 /* The values of the PNG_FILLER_ defines should NOT be changed */
1372 #define PNG_FILLER_BEFORE 0
1373 #define PNG_FILLER_AFTER 1
1374 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
1375 #ifndef PNG_1_0_X
1376 extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr,
1377    png_uint_32 filler, int flags));
1378 #endif
1379 #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
1380 
1381 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
1382 /* Swap bytes in 16-bit depth files. */
1383 extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
1384 #endif
1385 
1386 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
1387 /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
1388 extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
1389 #endif
1390 
1391 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
1392 /* Swap packing order of pixels in bytes. */
1393 extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
1394 #endif
1395 
1396 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
1397 /* Converts files to legal bit depths. */
1398 extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
1399    png_color_8p true_bits));
1400 #endif
1401 
1402 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
1403     defined(PNG_WRITE_INTERLACING_SUPPORTED)
1404 /* Have the code handle the interlacing.  Returns the number of passes. */
1405 extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
1406 #endif
1407 
1408 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
1409 /* Invert monochrome files */
1410 extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
1411 #endif
1412 
1413 #ifdef PNG_READ_BACKGROUND_SUPPORTED
1414 /* Handle alpha and tRNS by replacing with a background color. */
1415 #ifdef PNG_FLOATING_POINT_SUPPORTED
1416 extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
1417    png_color_16p background_color, int background_gamma_code,
1418    int need_expand, double background_gamma));
1419 #endif
1420 #define PNG_BACKGROUND_GAMMA_UNKNOWN 0
1421 #define PNG_BACKGROUND_GAMMA_SCREEN  1
1422 #define PNG_BACKGROUND_GAMMA_FILE    2
1423 #define PNG_BACKGROUND_GAMMA_UNIQUE  3
1424 #endif
1425 
1426 #ifdef PNG_READ_16_TO_8_SUPPORTED
1427 /* Strip the second byte of information from a 16-bit depth file. */
1428 extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
1429 #endif
1430 
1431 #ifdef PNG_READ_DITHER_SUPPORTED
1432 /* Turn on dithering, and reduce the palette to the number of colors available. */
1433 extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
1434    png_colorp palette, int num_palette, int maximum_colors,
1435    png_uint_16p histogram, int full_dither));
1436 #endif
1437 
1438 #ifdef PNG_READ_GAMMA_SUPPORTED
1439 /* Handle gamma correction. Screen_gamma=(display_exponent) */
1440 #ifdef PNG_FLOATING_POINT_SUPPORTED
1441 extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
1442    double screen_gamma, double default_file_gamma));
1443 #endif
1444 #endif
1445 
1446 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
1447 #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
1448     defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
1449 /* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
1450 /* Deprecated and will be removed.  Use png_permit_mng_features() instead. */
1451 extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
1452    int empty_plte_permitted)) PNG_DEPRECATED;
1453 #endif
1454 #endif
1455 
1456 #ifdef PNG_WRITE_FLUSH_SUPPORTED
1457 /* Set how many lines between output flushes - 0 for no flushing */
1458 extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
1459 /* Flush the current PNG output buffer */
1460 extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
1461 #endif
1462 
1463 /* Optional update palette with requested transformations */
1464 extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
1465 
1466 /* Optional call to update the users info structure */
1467 extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
1468    png_infop info_ptr));
1469 
1470 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
1471 /* Read one or more rows of image data. */
1472 extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
1473    png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
1474 #endif
1475 
1476 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
1477 /* Read a row of data. */
1478 extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
1479    png_bytep row,
1480    png_bytep display_row));
1481 #endif
1482 
1483 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
1484 /* Read the whole image into memory at once. */
1485 extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
1486    png_bytepp image));
1487 #endif
1488 
1489 /* Write a row of image data */
1490 extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
1491    png_bytep row));
1492 
1493 /* Write a few rows of image data */
1494 extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
1495    png_bytepp row, png_uint_32 num_rows));
1496 
1497 /* Write the image data */
1498 extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
1499    png_bytepp image));
1500 
1501 /* Writes the end of the PNG file. */
1502 extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
1503    png_infop info_ptr));
1504 
1505 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
1506 /* Read the end of the PNG file. */
1507 extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
1508    png_infop info_ptr));
1509 #endif
1510 
1511 /* Free any memory associated with the png_info_struct */
1512 extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
1513    png_infopp info_ptr_ptr));
1514 
1515 /* Free any memory associated with the png_struct and the png_info_structs */
1516 extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
1517    png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
1518 
1519 /* Free all memory used by the read (old method - NOT DLL EXPORTED) */
1520 extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
1521    png_infop end_info_ptr)) PNG_DEPRECATED;
1522 
1523 /* Free any memory associated with the png_struct and the png_info_structs */
1524 extern PNG_EXPORT(void,png_destroy_write_struct)
1525    PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
1526 
1527 /* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
1528 extern void png_write_destroy PNGARG((png_structp png_ptr)) PNG_DEPRECATED;
1529 
1530 /* Set the libpng method of handling chunk CRC errors */
1531 extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
1532    int crit_action, int ancil_action));
1533 
1534 /* Values for png_set_crc_action() to say how to handle CRC errors in
1535  * ancillary and critical chunks, and whether to use the data contained
1536  * therein.  Note that it is impossible to "discard" data in a critical
1537  * chunk.  For versions prior to 0.90, the action was always error/quit,
1538  * whereas in version 0.90 and later, the action for CRC errors in ancillary
1539  * chunks is warn/discard.  These values should NOT be changed.
1540  *
1541  *      value                       action:critical     action:ancillary
1542  */
1543 #define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */
1544 #define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */
1545 #define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */
1546 #define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */
1547 #define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */
1548 #define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */
1549 
1550 /* These functions give the user control over the scan-line filtering in
1551  * libpng and the compression methods used by zlib.  These functions are
1552  * mainly useful for testing, as the defaults should work with most users.
1553  * Those users who are tight on memory or want faster performance at the
1554  * expense of compression can modify them.  See the compression library
1555  * header file (zlib.h) for an explination of the compression functions.
1556  */
1557 
1558 /* Set the filtering method(s) used by libpng.  Currently, the only valid
1559  * value for "method" is 0.
1560  */
1561 extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
1562    int filters));
1563 
1564 /* Flags for png_set_filter() to say which filters to use.  The flags
1565  * are chosen so that they don't conflict with real filter types
1566  * below, in case they are supplied instead of the #defined constants.
1567  * These values should NOT be changed.
1568  */
1569 #define PNG_NO_FILTERS     0x00
1570 #define PNG_FILTER_NONE    0x08
1571 #define PNG_FILTER_SUB     0x10
1572 #define PNG_FILTER_UP      0x20
1573 #define PNG_FILTER_AVG     0x40
1574 #define PNG_FILTER_PAETH   0x80
1575 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
1576                          PNG_FILTER_AVG | PNG_FILTER_PAETH)
1577 
1578 /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
1579  * These defines should NOT be changed.
1580  */
1581 #define PNG_FILTER_VALUE_NONE  0
1582 #define PNG_FILTER_VALUE_SUB   1
1583 #define PNG_FILTER_VALUE_UP    2
1584 #define PNG_FILTER_VALUE_AVG   3
1585 #define PNG_FILTER_VALUE_PAETH 4
1586 #define PNG_FILTER_VALUE_LAST  5
1587 
1588 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
1589 /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
1590  * defines, either the default (minimum-sum-of-absolute-differences), or
1591  * the experimental method (weighted-minimum-sum-of-absolute-differences).
1592  *
1593  * Weights are factors >= 1.0, indicating how important it is to keep the
1594  * filter type consistent between rows.  Larger numbers mean the current
1595  * filter is that many times as likely to be the same as the "num_weights"
1596  * previous filters.  This is cumulative for each previous row with a weight.
1597  * There needs to be "num_weights" values in "filter_weights", or it can be
1598  * NULL if the weights aren't being specified.  Weights have no influence on
1599  * the selection of the first row filter.  Well chosen weights can (in theory)
1600  * improve the compression for a given image.
1601  *
1602  * Costs are factors >= 1.0 indicating the relative decoding costs of a
1603  * filter type.  Higher costs indicate more decoding expense, and are
1604  * therefore less likely to be selected over a filter with lower computational
1605  * costs.  There needs to be a value in "filter_costs" for each valid filter
1606  * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
1607  * setting the costs.  Costs try to improve the speed of decompression without
1608  * unduly increasing the compressed image size.
1609  *
1610  * A negative weight or cost indicates the default value is to be used, and
1611  * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
1612  * The default values for both weights and costs are currently 1.0, but may
1613  * change if good general weighting/cost heuristics can be found.  If both
1614  * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
1615  * to the UNWEIGHTED method, but with added encoding time/computation.
1616  */
1617 #ifdef PNG_FLOATING_POINT_SUPPORTED
1618 extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
1619    int heuristic_method, int num_weights, png_doublep filter_weights,
1620    png_doublep filter_costs));
1621 #endif
1622 #endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
1623 
1624 /* Heuristic used for row filter selection.  These defines should NOT be
1625  * changed.
1626  */
1627 #define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently "UNWEIGHTED" */
1628 #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */
1629 #define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */
1630 #define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */
1631 
1632 /* Set the library compression level.  Currently, valid values range from
1633  * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
1634  * (0 - no compression, 9 - "maximal" compression).  Note that tests have
1635  * shown that zlib compression levels 3-6 usually perform as well as level 9
1636  * for PNG images, and do considerably fewer caclulations.  In the future,
1637  * these values may not correspond directly to the zlib compression levels.
1638  */
1639 extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
1640    int level));
1641 
1642 extern PNG_EXPORT(void,png_set_compression_mem_level)
1643    PNGARG((png_structp png_ptr, int mem_level));
1644 
1645 extern PNG_EXPORT(void,png_set_compression_strategy)
1646    PNGARG((png_structp png_ptr, int strategy));
1647 
1648 extern PNG_EXPORT(void,png_set_compression_window_bits)
1649    PNGARG((png_structp png_ptr, int window_bits));
1650 
1651 extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
1652    int method));
1653 
1654 /* These next functions are called for input/output, memory, and error
1655  * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,
1656  * and call standard C I/O routines such as fread(), fwrite(), and
1657  * fprintf().  These functions can be made to use other I/O routines
1658  * at run time for those applications that need to handle I/O in a
1659  * different manner by calling png_set_???_fn().  See libpng.txt for
1660  * more information.
1661  */
1662 
1663 #ifdef PNG_STDIO_SUPPORTED
1664 /* Initialize the input/output for the PNG file to the default functions. */
1665 extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp));
1666 #endif
1667 
1668 /* Replace the (error and abort), and warning functions with user
1669  * supplied functions.  If no messages are to be printed you must still
1670  * write and use replacement functions. The replacement error_fn should
1671  * still do a longjmp to the last setjmp location if you are using this
1672  * method of error handling.  If error_fn or warning_fn is NULL, the
1673  * default function will be used.
1674  */
1675 
1676 extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
1677    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
1678 
1679 /* Return the user pointer associated with the error functions */
1680 extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
1681 
1682 /* Replace the default data output functions with a user supplied one(s).
1683  * If buffered output is not used, then output_flush_fn can be set to NULL.
1684  * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
1685  * output_flush_fn will be ignored (and thus can be NULL).
1686  * It is probably a mistake to use NULL for output_flush_fn if
1687  * write_data_fn is not also NULL unless you have built libpng with
1688  * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
1689  * default flush function, which uses the standard *FILE structure, will
1690  * be used.
1691  */
1692 extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
1693    png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
1694 
1695 /* Replace the default data input function with a user supplied one. */
1696 extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
1697    png_voidp io_ptr, png_rw_ptr read_data_fn));
1698 
1699 /* Return the user pointer associated with the I/O functions */
1700 extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
1701 
1702 extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
1703    png_read_status_ptr read_row_fn));
1704 
1705 extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
1706    png_write_status_ptr write_row_fn));
1707 
1708 #ifdef PNG_USER_MEM_SUPPORTED
1709 /* Replace the default memory allocation functions with user supplied one(s). */
1710 extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
1711    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
1712 /* Return the user pointer associated with the memory functions */
1713 extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
1714 #endif
1715 
1716 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
1717     defined(PNG_LEGACY_SUPPORTED)
1718 extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
1719    png_ptr, png_user_transform_ptr read_user_transform_fn));
1720 #endif
1721 
1722 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
1723     defined(PNG_LEGACY_SUPPORTED)
1724 extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
1725    png_ptr, png_user_transform_ptr write_user_transform_fn));
1726 #endif
1727 
1728 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
1729     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
1730     defined(PNG_LEGACY_SUPPORTED)
1731 extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
1732    png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
1733    int user_transform_channels));
1734 /* Return the user pointer associated with the user transform functions */
1735 extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
1736    PNGARG((png_structp png_ptr));
1737 #endif
1738 
1739 #ifdef PNG_USER_CHUNKS_SUPPORTED
1740 extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr,
1741    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
1742 extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp
1743    png_ptr));
1744 #endif
1745 
1746 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
1747 /* Sets the function callbacks for the push reader, and a pointer to a
1748  * user-defined structure available to the callback functions.
1749  */
1750 extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
1751    png_voidp progressive_ptr,
1752    png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
1753    png_progressive_end_ptr end_fn));
1754 
1755 /* Returns the user pointer associated with the push read functions */
1756 extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
1757    PNGARG((png_structp png_ptr));
1758 
1759 /* Function to be called when data becomes available */
1760 extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
1761    png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
1762 
1763 /* Function that combines rows.  Not very much different than the
1764  * png_combine_row() call.  Is this even used?????
1765  */
1766 extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
1767    png_bytep old_row, png_bytep new_row));
1768 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
1769 
1770 extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
1771    png_uint_32 size)) PNG_ALLOCATED;
1772 
1773 #ifdef PNG_1_0_X
1774 #  define png_malloc_warn png_malloc
1775 #else
1776 /* Added at libpng version 1.2.4 */
1777 extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr,
1778    png_uint_32 size)) PNG_ALLOCATED;
1779 #endif
1780 
1781 /* Frees a pointer allocated by png_malloc() */
1782 extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
1783 
1784 #ifdef PNG_1_0_X
1785 /* Function to allocate memory for zlib. */
1786 extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items,
1787    uInt size));
1788 
1789 /* Function to free memory for zlib */
1790 extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr));
1791 #endif
1792 
1793 /* Free data that was allocated internally */
1794 extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
1795    png_infop info_ptr, png_uint_32 free_me, int num));
1796 #ifdef PNG_FREE_ME_SUPPORTED
1797 /* Reassign responsibility for freeing existing data, whether allocated
1798  * by libpng or by the application
1799  */
1800 extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr,
1801    png_infop info_ptr, int freer, png_uint_32 mask));
1802 #endif
1803 /* Assignments for png_data_freer */
1804 #define PNG_DESTROY_WILL_FREE_DATA 1
1805 #define PNG_SET_WILL_FREE_DATA 1
1806 #define PNG_USER_WILL_FREE_DATA 2
1807 /* Flags for png_ptr->free_me and info_ptr->free_me */
1808 #define PNG_FREE_HIST 0x0008
1809 #define PNG_FREE_ICCP 0x0010
1810 #define PNG_FREE_SPLT 0x0020
1811 #define PNG_FREE_ROWS 0x0040
1812 #define PNG_FREE_PCAL 0x0080
1813 #define PNG_FREE_SCAL 0x0100
1814 #define PNG_FREE_UNKN 0x0200
1815 #define PNG_FREE_LIST 0x0400
1816 #define PNG_FREE_PLTE 0x1000
1817 #define PNG_FREE_TRNS 0x2000
1818 #define PNG_FREE_TEXT 0x4000
1819 #define PNG_FREE_ALL  0x7fff
1820 #define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
1821 
1822 #ifdef PNG_USER_MEM_SUPPORTED
1823 extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
1824    png_uint_32 size)) PNG_ALLOCATED;
1825 extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
1826    png_voidp ptr));
1827 #endif
1828 
1829 extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
1830    png_voidp s1, png_voidp s2, png_uint_32 size)) PNG_DEPRECATED;
1831 
1832 extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr,
1833    png_voidp s1, int value, png_uint_32 size)) PNG_DEPRECATED;
1834 
1835 #if defined(USE_FAR_KEYWORD)  /* memory model conversion function */
1836 extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
1837    int check));
1838 #endif /* USE_FAR_KEYWORD */
1839 
1840 #ifndef PNG_NO_ERROR_TEXT
1841 /* Fatal error in PNG image of libpng - can't continue */
1842 extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
1843    png_const_charp error_message)) PNG_NORETURN;
1844 
1845 /* The same, but the chunk name is prepended to the error string. */
1846 extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
1847    png_const_charp error_message)) PNG_NORETURN;
1848 #else
1849 /* Fatal error in PNG image of libpng - can't continue */
1850 extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr)) PNG_NORETURN;
1851 #endif
1852 
1853 #ifndef PNG_NO_WARNINGS
1854 /* Non-fatal error in libpng.  Can continue, but may have a problem. */
1855 extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
1856    png_const_charp warning_message));
1857 
1858 #ifdef PNG_READ_SUPPORTED
1859 /* Non-fatal error in libpng, chunk name is prepended to message. */
1860 extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
1861    png_const_charp warning_message));
1862 #endif /* PNG_READ_SUPPORTED */
1863 #endif /* PNG_NO_WARNINGS */
1864 
1865 /* The png_set_<chunk> functions are for storing values in the png_info_struct.
1866  * Similarly, the png_get_<chunk> calls are used to read values from the
1867  * png_info_struct, either storing the parameters in the passed variables, or
1868  * setting pointers into the png_info_struct where the data is stored.  The
1869  * png_get_<chunk> functions return a non-zero value if the data was available
1870  * in info_ptr, or return zero and do not change any of the parameters if the
1871  * data was not available.
1872  *
1873  * These functions should be used instead of directly accessing png_info
1874  * to avoid problems with future changes in the size and internal layout of
1875  * png_info_struct.
1876  */
1877 /* Returns "flag" if chunk data is valid in info_ptr. */
1878 extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
1879 png_infop info_ptr, png_uint_32 flag));
1880 
1881 /* Returns number of bytes needed to hold a transformed row. */
1882 extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
1883 png_infop info_ptr));
1884 
1885 #ifdef PNG_INFO_IMAGE_SUPPORTED
1886 /* Returns row_pointers, which is an array of pointers to scanlines that was
1887  * returned from png_read_png().
1888  */
1889 extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr,
1890 png_infop info_ptr));
1891 /* Set row_pointers, which is an array of pointers to scanlines for use
1892  * by png_write_png().
1893  */
1894 extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr,
1895    png_infop info_ptr, png_bytepp row_pointers));
1896 #endif
1897 
1898 /* Returns number of color channels in image. */
1899 extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
1900 png_infop info_ptr));
1901 
1902 #ifdef PNG_EASY_ACCESS_SUPPORTED
1903 /* Returns image width in pixels. */
1904 extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
1905 png_ptr, png_infop info_ptr));
1906 
1907 /* Returns image height in pixels. */
1908 extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
1909 png_ptr, png_infop info_ptr));
1910 
1911 /* Returns image bit_depth. */
1912 extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
1913 png_ptr, png_infop info_ptr));
1914 
1915 /* Returns image color_type. */
1916 extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
1917 png_ptr, png_infop info_ptr));
1918 
1919 /* Returns image filter_type. */
1920 extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
1921 png_ptr, png_infop info_ptr));
1922 
1923 /* Returns image interlace_type. */
1924 extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
1925 png_ptr, png_infop info_ptr));
1926 
1927 /* Returns image compression_type. */
1928 extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
1929 png_ptr, png_infop info_ptr));
1930 
1931 /* Returns image resolution in pixels per meter, from pHYs chunk data. */
1932 extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
1933 png_ptr, png_infop info_ptr));
1934 extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
1935 png_ptr, png_infop info_ptr));
1936 extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
1937 png_ptr, png_infop info_ptr));
1938 
1939 /* Returns pixel aspect ratio, computed from pHYs chunk data.  */
1940 #ifdef PNG_FLOATING_POINT_SUPPORTED
1941 extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
1942 png_ptr, png_infop info_ptr));
1943 #endif
1944 
1945 /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
1946 extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp
1947 png_ptr, png_infop info_ptr));
1948 extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp
1949 png_ptr, png_infop info_ptr));
1950 extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp
1951 png_ptr, png_infop info_ptr));
1952 extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp
1953 png_ptr, png_infop info_ptr));
1954 
1955 #endif /* PNG_EASY_ACCESS_SUPPORTED */
1956 
1957 /* Returns pointer to signature string read from PNG header */
1958 extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
1959 png_infop info_ptr));
1960 
1961 #ifdef PNG_bKGD_SUPPORTED
1962 extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
1963    png_infop info_ptr, png_color_16p *background));
1964 #endif
1965 
1966 #ifdef PNG_bKGD_SUPPORTED
1967 extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
1968    png_infop info_ptr, png_color_16p background));
1969 #endif
1970 
1971 #ifdef PNG_cHRM_SUPPORTED
1972 #ifdef PNG_FLOATING_POINT_SUPPORTED
1973 extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
1974    png_infop info_ptr, double *white_x, double *white_y, double *red_x,
1975    double *red_y, double *green_x, double *green_y, double *blue_x,
1976    double *blue_y));
1977 #endif
1978 #ifdef PNG_FIXED_POINT_SUPPORTED
1979 extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr,
1980    png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point
1981    *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y,
1982    png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point
1983    *int_blue_x, png_fixed_point *int_blue_y));
1984 #endif
1985 #endif
1986 
1987 #ifdef PNG_cHRM_SUPPORTED
1988 #ifdef PNG_FLOATING_POINT_SUPPORTED
1989 extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
1990    png_infop info_ptr, double white_x, double white_y, double red_x,
1991    double red_y, double green_x, double green_y, double blue_x, double blue_y));
1992 #endif
1993 #ifdef PNG_FIXED_POINT_SUPPORTED
1994 extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr,
1995    png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y,
1996    png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
1997    int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
1998    png_fixed_point int_blue_y));
1999 #endif
2000 #endif
2001 
2002 #ifdef PNG_gAMA_SUPPORTED
2003 #ifdef PNG_FLOATING_POINT_SUPPORTED
2004 extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
2005    png_infop info_ptr, double *file_gamma));
2006 #endif
2007 extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr,
2008    png_infop info_ptr, png_fixed_point *int_file_gamma));
2009 #endif
2010 
2011 #ifdef PNG_gAMA_SUPPORTED
2012 #ifdef PNG_FLOATING_POINT_SUPPORTED
2013 extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
2014    png_infop info_ptr, double file_gamma));
2015 #endif
2016 extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr,
2017    png_infop info_ptr, png_fixed_point int_file_gamma));
2018 #endif
2019 
2020 #ifdef PNG_hIST_SUPPORTED
2021 extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
2022    png_infop info_ptr, png_uint_16p *hist));
2023 #endif
2024 
2025 #ifdef PNG_hIST_SUPPORTED
2026 extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
2027    png_infop info_ptr, png_uint_16p hist));
2028 #endif
2029 
2030 extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
2031    png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
2032    int *bit_depth, int *color_type, int *interlace_method,
2033    int *compression_method, int *filter_method));
2034 
2035 extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
2036    png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
2037    int color_type, int interlace_method, int compression_method,
2038    int filter_method));
2039 
2040 #ifdef PNG_oFFs_SUPPORTED
2041 extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
2042    png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
2043    int *unit_type));
2044 #endif
2045 
2046 #ifdef PNG_oFFs_SUPPORTED
2047 extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
2048    png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y,
2049    int unit_type));
2050 #endif
2051 
2052 #ifdef PNG_pCAL_SUPPORTED
2053 extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
2054    png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
2055    int *type, int *nparams, png_charp *units, png_charpp *params));
2056 #endif
2057 
2058 #ifdef PNG_pCAL_SUPPORTED
2059 extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
2060    png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
2061    int type, int nparams, png_charp units, png_charpp params));
2062 #endif
2063 
2064 #ifdef PNG_pHYs_SUPPORTED
2065 extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
2066    png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
2067 #endif
2068 
2069 #ifdef PNG_pHYs_SUPPORTED
2070 extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
2071    png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
2072 #endif
2073 
2074 extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
2075    png_infop info_ptr, png_colorp *palette, int *num_palette));
2076 
2077 extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
2078    png_infop info_ptr, png_colorp palette, int num_palette));
2079 
2080 #ifdef PNG_sBIT_SUPPORTED
2081 extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
2082    png_infop info_ptr, png_color_8p *sig_bit));
2083 #endif
2084 
2085 #ifdef PNG_sBIT_SUPPORTED
2086 extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
2087    png_infop info_ptr, png_color_8p sig_bit));
2088 #endif
2089 
2090 #ifdef PNG_sRGB_SUPPORTED
2091 extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
2092    png_infop info_ptr, int *intent));
2093 #endif
2094 
2095 #ifdef PNG_sRGB_SUPPORTED
2096 extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
2097    png_infop info_ptr, int intent));
2098 extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
2099    png_infop info_ptr, int intent));
2100 #endif
2101 
2102 #ifdef PNG_iCCP_SUPPORTED
2103 extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
2104    png_infop info_ptr, png_charpp name, int *compression_type,
2105    png_charpp profile, png_uint_32 *proflen));
2106    /* Note to maintainer: profile should be png_bytepp */
2107 #endif
2108 
2109 #ifdef PNG_iCCP_SUPPORTED
2110 extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
2111    png_infop info_ptr, png_charp name, int compression_type,
2112    png_charp profile, png_uint_32 proflen));
2113    /* Note to maintainer: profile should be png_bytep */
2114 #endif
2115 
2116 #ifdef PNG_sPLT_SUPPORTED
2117 extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr,
2118    png_infop info_ptr, png_sPLT_tpp entries));
2119 #endif
2120 
2121 #ifdef PNG_sPLT_SUPPORTED
2122 extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr,
2123    png_infop info_ptr, png_sPLT_tp entries, int nentries));
2124 #endif
2125 
2126 #ifdef PNG_TEXT_SUPPORTED
2127 /* png_get_text also returns the number of text chunks in *num_text */
2128 extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
2129    png_infop info_ptr, png_textp *text_ptr, int *num_text));
2130 #endif
2131 
2132 /*
2133  *  Note while png_set_text() will accept a structure whose text,
2134  *  language, and  translated keywords are NULL pointers, the structure
2135  *  returned by png_get_text will always contain regular
2136  *  zero-terminated C strings.  They might be empty strings but
2137  *  they will never be NULL pointers.
2138  */
2139 
2140 #ifdef PNG_TEXT_SUPPORTED
2141 extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
2142    png_infop info_ptr, png_textp text_ptr, int num_text));
2143 #endif
2144 
2145 #ifdef PNG_tIME_SUPPORTED
2146 extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
2147    png_infop info_ptr, png_timep *mod_time));
2148 #endif
2149 
2150 #ifdef PNG_tIME_SUPPORTED
2151 extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
2152    png_infop info_ptr, png_timep mod_time));
2153 #endif
2154 
2155 #ifdef PNG_tRNS_SUPPORTED
2156 extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
2157    png_infop info_ptr, png_bytep *trans, int *num_trans,
2158    png_color_16p *trans_values));
2159 #endif
2160 
2161 #ifdef PNG_tRNS_SUPPORTED
2162 extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
2163    png_infop info_ptr, png_bytep trans, int num_trans,
2164    png_color_16p trans_values));
2165 #endif
2166 
2167 #ifdef PNG_tRNS_SUPPORTED
2168 #endif
2169 
2170 #ifdef PNG_sCAL_SUPPORTED
2171 #ifdef PNG_FLOATING_POINT_SUPPORTED
2172 extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr,
2173    png_infop info_ptr, int *unit, double *width, double *height));
2174 #else
2175 #ifdef PNG_FIXED_POINT_SUPPORTED
2176 extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr,
2177    png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
2178 #endif
2179 #endif
2180 #endif /* PNG_sCAL_SUPPORTED */
2181 
2182 #ifdef PNG_sCAL_SUPPORTED
2183 #ifdef PNG_FLOATING_POINT_SUPPORTED
2184 extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
2185    png_infop info_ptr, int unit, double width, double height));
2186 #else
2187 #ifdef PNG_FIXED_POINT_SUPPORTED
2188 extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
2189    png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
2190 #endif
2191 #endif
2192 #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
2193 
2194 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
2195 /* Provide a list of chunks and how they are to be handled, if the built-in
2196    handling or default unknown chunk handling is not desired.  Any chunks not
2197    listed will be handled in the default manner.  The IHDR and IEND chunks
2198    must not be listed.
2199       keep = 0: follow default behaviour
2200            = 1: do not keep
2201            = 2: keep only if safe-to-copy
2202            = 3: keep even if unsafe-to-copy
2203 */
2204 extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
2205    png_ptr, int keep, png_bytep chunk_list, int num_chunks));
2206 PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
2207    chunk_name));
2208 #endif
2209 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
2210 extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
2211    png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
2212 extern PNG_EXPORT(void, png_set_unknown_chunk_location)
2213    PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location));
2214 extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
2215    png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
2216 #endif
2217 
2218 /* Png_free_data() will turn off the "valid" flag for anything it frees.
2219  * If you need to turn it off for a chunk that your application has freed,
2220  * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);
2221  */
2222 extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr,
2223    png_infop info_ptr, int mask));
2224 
2225 #ifdef PNG_INFO_IMAGE_SUPPORTED
2226 /* The "params" pointer is currently not used and is for future expansion. */
2227 extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
2228                         png_infop info_ptr,
2229                         int transforms,
2230                         png_voidp params));
2231 extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
2232                         png_infop info_ptr,
2233                         int transforms,
2234                         png_voidp params));
2235 #endif
2236 
2237 /* Define PNG_DEBUG at compile time for debugging information.  Higher
2238  * numbers for PNG_DEBUG mean more debugging information.  This has
2239  * only been added since version 0.95 so it is not implemented throughout
2240  * libpng yet, but more support will be added as needed.
2241  */
2242 #ifdef PNG_DEBUG
2243 #if (PNG_DEBUG > 0)
2244 #if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
2245 #include <crtdbg.h>
2246 #if (PNG_DEBUG > 1)
2247 #ifndef _DEBUG
2248 #  define _DEBUG
2249 #endif
2250 #ifndef png_debug
2251 #define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
2252 #endif
2253 #ifndef png_debug1
2254 #define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
2255 #endif
2256 #ifndef png_debug2
2257 #define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
2258 #endif
2259 #endif
2260 #else /* PNG_DEBUG_FILE || !_MSC_VER */
2261 #ifndef PNG_DEBUG_FILE
2262 #define PNG_DEBUG_FILE stderr
2263 #endif /* PNG_DEBUG_FILE */
2264 
2265 #if (PNG_DEBUG > 1)
2266 /* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on non-ISO
2267  * compilers.
2268  */
2269 #  ifdef __STDC__
2270 #    ifndef png_debug
2271 #      define png_debug(l,m) \
2272        { \
2273        int num_tabs=l; \
2274        fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
2275          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
2276        }
2277 #    endif
2278 #    ifndef png_debug1
2279 #      define png_debug1(l,m,p1) \
2280        { \
2281        int num_tabs=l; \
2282        fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
2283          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
2284        }
2285 #    endif
2286 #    ifndef png_debug2
2287 #      define png_debug2(l,m,p1,p2) \
2288        { \
2289        int num_tabs=l; \
2290        fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
2291          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
2292        }
2293 #    endif
2294 #  else /* __STDC __ */
2295 #    ifndef png_debug
2296 #      define png_debug(l,m) \
2297        { \
2298        int num_tabs=l; \
2299        char format[256]; \
2300        snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
2301          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
2302          m,PNG_STRING_NEWLINE); \
2303        fprintf(PNG_DEBUG_FILE,format); \
2304        }
2305 #    endif
2306 #    ifndef png_debug1
2307 #      define png_debug1(l,m,p1) \
2308        { \
2309        int num_tabs=l; \
2310        char format[256]; \
2311        snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
2312          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
2313          m,PNG_STRING_NEWLINE); \
2314        fprintf(PNG_DEBUG_FILE,format,p1); \
2315        }
2316 #    endif
2317 #    ifndef png_debug2
2318 #      define png_debug2(l,m,p1,p2) \
2319        { \
2320        int num_tabs=l; \
2321        char format[256]; \
2322        snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
2323          (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
2324          m,PNG_STRING_NEWLINE); \
2325        fprintf(PNG_DEBUG_FILE,format,p1,p2); \
2326        }
2327 #    endif
2328 #  endif /* __STDC __ */
2329 #endif /* (PNG_DEBUG > 1) */
2330 
2331 #endif /* _MSC_VER */
2332 #endif /* (PNG_DEBUG > 0) */
2333 #endif /* PNG_DEBUG */
2334 #ifndef png_debug
2335 #define png_debug(l, m)
2336 #endif
2337 #ifndef png_debug1
2338 #define png_debug1(l, m, p1)
2339 #endif
2340 #ifndef png_debug2
2341 #define png_debug2(l, m, p1, p2)
2342 #endif
2343 
2344 extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
2345 extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
2346 extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
2347 extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
2348 
2349 #ifdef PNG_MNG_FEATURES_SUPPORTED
2350 extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
2351    png_ptr, png_uint_32 mng_features_permitted));
2352 #endif
2353 
2354 /* For use in png_set_keep_unknown, added to version 1.2.6 */
2355 #define PNG_HANDLE_CHUNK_AS_DEFAULT   0
2356 #define PNG_HANDLE_CHUNK_NEVER        1
2357 #define PNG_HANDLE_CHUNK_IF_SAFE      2
2358 #define PNG_HANDLE_CHUNK_ALWAYS       3
2359 
2360 /* Added to version 1.2.0 */
2361 
2362 /* Strip the prepended error numbers ("#nnn ") from error and warning
2363  * messages before passing them to the error or warning handler.
2364  */
2365 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
2366 extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp
2367    png_ptr, png_uint_32 strip_mode));
2368 #endif
2369 
2370 /* Added at libpng-1.2.6 */
2371 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
2372 extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp
2373    png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max));
2374 extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp
2375    png_ptr));
2376 extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp
2377    png_ptr));
2378 #endif
2379 /* Maintainer: Put new public prototypes here ^, in libpng.3, and in
2380  * project defs
2381  */
2382 
2383 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
2384 /* With these routines we avoid an integer divide, which will be slower on
2385  * most machines.  However, it does take more operations than the corresponding
2386  * divide method, so it may be slower on a few RISC systems.  There are two
2387  * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
2388  *
2389  * Note that the rounding factors are NOT supposed to be the same!  128 and
2390  * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
2391  * standard method.
2392  *
2393  * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
2394  */
2395 
2396  /* fg and bg should be in `gamma 1.0' space; alpha is the opacity          */
2397 
2398 #  define png_composite(composite, fg, alpha, bg)                            \
2399      { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \
2400                         +        (png_uint_16)(bg)*(png_uint_16)(255 -       \
2401                         (png_uint_16)(alpha)) + (png_uint_16)128);           \
2402        (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
2403 
2404 #  define png_composite_16(composite, fg, alpha, bg)                         \
2405      { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \
2406                         + (png_uint_32)(bg)*(png_uint_32)(65535L -           \
2407                         (png_uint_32)(alpha)) + (png_uint_32)32768L);        \
2408        (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
2409 
2410 #else  /* Standard method using integer division */
2411 
2412 #  define png_composite(composite, fg, alpha, bg)                            \
2413      (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +    \
2414        (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \
2415        (png_uint_16)127) / 255)
2416 
2417 #  define png_composite_16(composite, fg, alpha, bg)                         \
2418      (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
2419        (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) +      \
2420        (png_uint_32)32767) / (png_uint_32)65535L)
2421 
2422 #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
2423 
2424 /* Inline macros to do direct reads of bytes from the input buffer.  These
2425  * require that you are using an architecture that uses PNG byte ordering
2426  * (MSB first) and supports unaligned data storage.  I think that PowerPC
2427  * in big-endian mode and 680x0 are the only ones that will support this.
2428  * The x86 line of processors definitely do not.  The png_get_int_32()
2429  * routine also assumes we are using two's complement format for negative
2430  * values, which is almost certainly true.
2431  */
2432 #ifdef PNG_READ_BIG_ENDIAN_SUPPORTED
2433 #  define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
2434 #  define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
2435 #  define png_get_int_32(buf)  ( *((png_int_32p)  (buf)))
2436 #else
2437 extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf));
2438 extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf));
2439 extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf));
2440 #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
2441 extern PNG_EXPORT(png_uint_32,png_get_uint_31)
2442   PNGARG((png_structp png_ptr, png_bytep buf));
2443 /* No png_get_int_16 -- may be added if there's a real need for it. */
2444 
2445 /* Place a 32-bit number into a buffer in PNG byte order (big-endian).
2446  */
2447 extern PNG_EXPORT(void,png_save_uint_32)
2448    PNGARG((png_bytep buf, png_uint_32 i));
2449 extern PNG_EXPORT(void,png_save_int_32)
2450    PNGARG((png_bytep buf, png_int_32 i));
2451 
2452 /* Place a 16-bit number into a buffer in PNG byte order.
2453  * The parameter is declared unsigned int, not png_uint_16,
2454  * just to avoid potential problems on pre-ANSI C compilers.
2455  */
2456 extern PNG_EXPORT(void,png_save_uint_16)
2457    PNGARG((png_bytep buf, unsigned int i));
2458 /* No png_save_int_16 -- may be added if there's a real need for it. */
2459 
2460 /* ************************************************************************* */
2461 
2462 /* These next functions are used internally in the code.  They generally
2463  * shouldn't be used unless you are writing code to add or replace some
2464  * functionality in libpng.  More information about most functions can
2465  * be found in the files where the functions are located.
2466  */
2467 
2468 
2469 /* Various modes of operation, that are visible to applications because
2470  * they are used for unknown chunk location.
2471  */
2472 #define PNG_HAVE_IHDR               0x01
2473 #define PNG_HAVE_PLTE               0x02
2474 #define PNG_HAVE_IDAT               0x04
2475 #define PNG_AFTER_IDAT              0x08 /* Have complete zlib datastream */
2476 #define PNG_HAVE_IEND               0x10
2477 
2478 #ifdef PNG_INTERNAL
2479 
2480 /* More modes of operation.  Note that after an init, mode is set to
2481  * zero automatically when the structure is created.
2482  */
2483 #define PNG_HAVE_gAMA               0x20
2484 #define PNG_HAVE_cHRM               0x40
2485 #define PNG_HAVE_sRGB               0x80
2486 #define PNG_HAVE_CHUNK_HEADER      0x100
2487 #define PNG_WROTE_tIME             0x200
2488 #define PNG_WROTE_INFO_BEFORE_PLTE 0x400
2489 #define PNG_BACKGROUND_IS_GRAY     0x800
2490 #define PNG_HAVE_PNG_SIGNATURE    0x1000
2491 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
2492 
2493 /* Flags for the transformations the PNG library does on the image data */
2494 #define PNG_BGR                0x0001
2495 #define PNG_INTERLACE          0x0002
2496 #define PNG_PACK               0x0004
2497 #define PNG_SHIFT              0x0008
2498 #define PNG_SWAP_BYTES         0x0010
2499 #define PNG_INVERT_MONO        0x0020
2500 #define PNG_DITHER             0x0040
2501 #define PNG_BACKGROUND         0x0080
2502 #define PNG_BACKGROUND_EXPAND  0x0100
2503                           /*   0x0200 unused */
2504 #define PNG_16_TO_8            0x0400
2505 #define PNG_RGBA               0x0800
2506 #define PNG_EXPAND             0x1000
2507 #define PNG_GAMMA              0x2000
2508 #define PNG_GRAY_TO_RGB        0x4000
2509 #define PNG_FILLER             0x8000L
2510 #define PNG_PACKSWAP          0x10000L
2511 #define PNG_SWAP_ALPHA        0x20000L
2512 #define PNG_STRIP_ALPHA       0x40000L
2513 #define PNG_INVERT_ALPHA      0x80000L
2514 #define PNG_USER_TRANSFORM   0x100000L
2515 #define PNG_RGB_TO_GRAY_ERR  0x200000L
2516 #define PNG_RGB_TO_GRAY_WARN 0x400000L
2517 #define PNG_RGB_TO_GRAY      0x600000L  /* two bits, RGB_TO_GRAY_ERR|WARN */
2518                        /*    0x800000L     Unused */
2519 #define PNG_ADD_ALPHA       0x1000000L  /* Added to libpng-1.2.7 */
2520 #define PNG_EXPAND_tRNS     0x2000000L  /* Added to libpng-1.2.9 */
2521 #define PNG_PREMULTIPLY_ALPHA 0x4000000L  /* Added to libpng-1.2.41 */
2522                                           /* by volker */
2523                        /*   0x8000000L  unused */
2524                        /*  0x10000000L  unused */
2525                        /*  0x20000000L  unused */
2526                        /*  0x40000000L  unused */
2527 
2528 /* Flags for png_create_struct */
2529 #define PNG_STRUCT_PNG   0x0001
2530 #define PNG_STRUCT_INFO  0x0002
2531 
2532 /* Scaling factor for filter heuristic weighting calculations */
2533 #define PNG_WEIGHT_SHIFT 8
2534 #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
2535 #define PNG_COST_SHIFT 3
2536 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
2537 
2538 /* Flags for the png_ptr->flags rather than declaring a byte for each one */
2539 #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001
2540 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL        0x0002
2541 #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL    0x0004
2542 #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS  0x0008
2543 #define PNG_FLAG_ZLIB_CUSTOM_METHOD       0x0010
2544 #define PNG_FLAG_ZLIB_FINISHED            0x0020
2545 #define PNG_FLAG_ROW_INIT                 0x0040
2546 #define PNG_FLAG_FILLER_AFTER             0x0080
2547 #define PNG_FLAG_CRC_ANCILLARY_USE        0x0100
2548 #define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200
2549 #define PNG_FLAG_CRC_CRITICAL_USE         0x0400
2550 #define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800
2551 #define PNG_FLAG_FREE_PLTE                0x1000
2552 #define PNG_FLAG_FREE_TRNS                0x2000
2553 #define PNG_FLAG_FREE_HIST                0x4000
2554 #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000L
2555 #define PNG_FLAG_KEEP_UNSAFE_CHUNKS       0x10000L
2556 #define PNG_FLAG_LIBRARY_MISMATCH         0x20000L
2557 #define PNG_FLAG_STRIP_ERROR_NUMBERS      0x40000L
2558 #define PNG_FLAG_STRIP_ERROR_TEXT         0x80000L
2559 #define PNG_FLAG_MALLOC_NULL_MEM_OK       0x100000L
2560 #define PNG_FLAG_ADD_ALPHA                0x200000L  /* Added to libpng-1.2.8 */
2561 #define PNG_FLAG_STRIP_ALPHA              0x400000L  /* Added to libpng-1.2.8 */
2562                                   /*      0x800000L  unused */
2563                                   /*     0x1000000L  unused */
2564                                   /*     0x2000000L  unused */
2565                                   /*     0x4000000L  unused */
2566                                   /*     0x8000000L  unused */
2567                                   /*    0x10000000L  unused */
2568                                   /*    0x20000000L  unused */
2569                                   /*    0x40000000L  unused */
2570 
2571 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
2572                                      PNG_FLAG_CRC_ANCILLARY_NOWARN)
2573 
2574 #define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \
2575                                      PNG_FLAG_CRC_CRITICAL_IGNORE)
2576 
2577 #define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \
2578                                      PNG_FLAG_CRC_CRITICAL_MASK)
2579 
2580 /* Save typing and make code easier to understand */
2581 
2582 #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
2583    abs((int)((c1).green) - (int)((c2).green)) + \
2584    abs((int)((c1).blue) - (int)((c2).blue)))
2585 
2586 /* Added to libpng-1.2.6 JB */
2587 #define PNG_ROWBYTES(pixel_bits, width) \
2588     ((pixel_bits) >= 8 ? \
2589     ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \
2590     (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) )
2591 
2592 /* PNG_OUT_OF_RANGE returns true if value is outside the range
2593  * ideal-delta..ideal+delta.  Each argument is evaluated twice.
2594  * "ideal" and "delta" should be constants, normally simple
2595  * integers, "value" a variable. Added to libpng-1.2.6 JB
2596  */
2597 #define PNG_OUT_OF_RANGE(value, ideal, delta) \
2598         ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
2599 
2600 /* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */
2601 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
2602 /* Place to hold the signature string for a PNG file. */
2603 #ifdef PNG_USE_GLOBAL_ARRAYS
2604    PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8];
2605 #else
2606 #endif
2607 #endif /* PNG_NO_EXTERN */
2608 
2609 /* Constant strings for known chunk types.  If you need to add a chunk,
2610  * define the name here, and add an invocation of the macro in png.c and
2611  * wherever it's needed.
2612  */
2613 #define PNG_IHDR png_byte png_IHDR[5] = { 73,  72,  68,  82, '\0'}
2614 #define PNG_IDAT png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'}
2615 #define PNG_IEND png_byte png_IEND[5] = { 73,  69,  78,  68, '\0'}
2616 #define PNG_PLTE png_byte png_PLTE[5] = { 80,  76,  84,  69, '\0'}
2617 #define PNG_bKGD png_byte png_bKGD[5] = { 98,  75,  71,  68, '\0'}
2618 #define PNG_cHRM png_byte png_cHRM[5] = { 99,  72,  82,  77, '\0'}
2619 #define PNG_gAMA png_byte png_gAMA[5] = {103,  65,  77,  65, '\0'}
2620 #define PNG_hIST png_byte png_hIST[5] = {104,  73,  83,  84, '\0'}
2621 #define PNG_iCCP png_byte png_iCCP[5] = {105,  67,  67,  80, '\0'}
2622 #define PNG_iTXt png_byte png_iTXt[5] = {105,  84,  88, 116, '\0'}
2623 #define PNG_oFFs png_byte png_oFFs[5] = {111,  70,  70, 115, '\0'}
2624 #define PNG_pCAL png_byte png_pCAL[5] = {112,  67,  65,  76, '\0'}
2625 #define PNG_sCAL png_byte png_sCAL[5] = {115,  67,  65,  76, '\0'}
2626 #define PNG_pHYs png_byte png_pHYs[5] = {112,  72,  89, 115, '\0'}
2627 #define PNG_sBIT png_byte png_sBIT[5] = {115,  66,  73,  84, '\0'}
2628 #define PNG_sPLT png_byte png_sPLT[5] = {115,  80,  76,  84, '\0'}
2629 #define PNG_sRGB png_byte png_sRGB[5] = {115,  82,  71,  66, '\0'}
2630 #define PNG_tEXt png_byte png_tEXt[5] = {116,  69,  88, 116, '\0'}
2631 #define PNG_tIME png_byte png_tIME[5] = {116,  73,  77,  69, '\0'}
2632 #define PNG_tRNS png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'}
2633 #define PNG_zTXt png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'}
2634 
2635 #ifdef PNG_USE_GLOBAL_ARRAYS
2636 PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5];
2637 PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5];
2638 PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5];
2639 PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5];
2640 PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5];
2641 PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5];
2642 PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5];
2643 PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5];
2644 PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5];
2645 PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5];
2646 PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5];
2647 PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5];
2648 PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5];
2649 PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5];
2650 PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5];
2651 PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5];
2652 PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5];
2653 PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5];
2654 PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5];
2655 PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5];
2656 PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5];
2657 #endif /* PNG_USE_GLOBAL_ARRAYS */
2658 
2659 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
2660 /* Initialize png_ptr struct for reading, and allocate any other memory.
2661  * (old interface - DEPRECATED - use png_create_read_struct instead).
2662  */
2663 extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr))
2664     PNG_DEPRECATED;
2665 #undef png_read_init
2666 #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
2667     PNG_LIBPNG_VER_STRING,  png_sizeof(png_struct));
2668 #endif
2669 
2670 extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
2671     png_const_charp user_png_ver, png_size_t png_struct_size));
2672 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
2673 extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
2674     png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
2675     png_info_size));
2676 #endif
2677 
2678 #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
2679 /* Initialize png_ptr struct for writing, and allocate any other memory.
2680  * (old interface - DEPRECATED - use png_create_write_struct instead).
2681  */
2682 extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr))
2683     PNG_DEPRECATED;
2684 #undef png_write_init
2685 #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
2686     PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
2687 #endif
2688 
2689 extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
2690     png_const_charp user_png_ver, png_size_t png_struct_size));
2691 extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr,
2692     png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
2693     png_info_size));
2694 
2695 /* Allocate memory for an internal libpng struct */
2696 PNG_EXTERN png_voidp png_create_struct PNGARG((int type)) PNG_PRIVATE;
2697 
2698 /* Free memory from internal libpng struct */
2699 PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)) PNG_PRIVATE;
2700 
2701 PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
2702   malloc_fn, png_voidp mem_ptr)) PNG_PRIVATE;
2703 PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
2704    png_free_ptr free_fn, png_voidp mem_ptr)) PNG_PRIVATE;
2705 
2706 /* Free any memory that info_ptr points to and reset struct. */
2707 PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
2708    png_infop info_ptr)) PNG_PRIVATE;
2709 
2710 #ifndef PNG_1_0_X
2711 /* Function to allocate memory for zlib. */
2712 PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items,
2713    uInt size)) PNG_PRIVATE;
2714 
2715 /* Function to free memory for zlib */
2716 PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)) PNG_PRIVATE;
2717 
2718 #ifdef PNG_SIZE_T
2719 /* Function to convert a sizeof an item to png_sizeof item */
2720    PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size))
2721       PNG_PRIVATE;
2722 #endif
2723 
2724 /* Next four functions are used internally as callbacks.  PNGAPI is required
2725  * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3.
2726  */
2727 
2728 PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
2729    png_bytep data, png_size_t length)) PNG_PRIVATE;
2730 
2731 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
2732 PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
2733    png_bytep buffer, png_size_t length)) PNG_PRIVATE;
2734 #endif
2735 
2736 PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
2737    png_bytep data, png_size_t length)) PNG_PRIVATE;
2738 
2739 #ifdef PNG_WRITE_FLUSH_SUPPORTED
2740 #ifdef PNG_STDIO_SUPPORTED
2741 PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr))
2742    PNG_PRIVATE;
2743 #endif
2744 #endif
2745 #else /* PNG_1_0_X */
2746 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
2747 PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
2748    png_bytep buffer, png_size_t length)) PNG_PRIVATE;
2749 #endif
2750 #endif /* PNG_1_0_X */
2751 
2752 /* Reset the CRC variable */
2753 PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2754 
2755 /* Write the "data" buffer to whatever output you are using. */
2756 PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
2757    png_size_t length)) PNG_PRIVATE;
2758 
2759 /* Read data from whatever input you are using into the "data" buffer */
2760 PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
2761    png_size_t length)) PNG_PRIVATE;
2762 
2763 /* Read bytes into buf, and update png_ptr->crc */
2764 PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
2765    png_size_t length)) PNG_PRIVATE;
2766 
2767 /* Decompress data in a chunk that uses compression */
2768 #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
2769     defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
2770 PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,
2771    int comp_type, png_size_t chunklength,
2772    png_size_t prefix_length, png_size_t *data_length)) PNG_PRIVATE;
2773 #endif
2774 
2775 /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
2776 PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)
2777    PNG_PRIVATE);
2778 
2779 /* Read the CRC from the file and compare it to the libpng calculated CRC */
2780 PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2781 
2782 /* Calculate the CRC over a section of data.  Note that we are only
2783  * passing a maximum of 64K on systems that have this as a memory limit,
2784  * since this is the maximum buffer size we can specify.
2785  */
2786 PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
2787    png_size_t length)) PNG_PRIVATE;
2788 
2789 #ifdef PNG_WRITE_FLUSH_SUPPORTED
2790 PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2791 #endif
2792 
2793 /* Simple function to write the signature */
2794 PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2795 
2796 /* Write various chunks */
2797 
2798 /* Write the IHDR chunk, and update the png_struct with the necessary
2799  * information.
2800  */
2801 PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
2802    png_uint_32 height,
2803    int bit_depth, int color_type, int compression_method, int filter_method,
2804    int interlace_method)) PNG_PRIVATE;
2805 
2806 PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
2807    png_uint_32 num_pal)) PNG_PRIVATE;
2808 
2809 PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
2810    png_size_t length)) PNG_PRIVATE;
2811 
2812 PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2813 
2814 #ifdef PNG_WRITE_gAMA_SUPPORTED
2815 #ifdef PNG_FLOATING_POINT_SUPPORTED
2816 PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma))
2817     PNG_PRIVATE;
2818 #endif
2819 #ifdef PNG_FIXED_POINT_SUPPORTED
2820 PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr,
2821     png_fixed_point file_gamma)) PNG_PRIVATE;
2822 #endif
2823 #endif
2824 
2825 #ifdef PNG_WRITE_sBIT_SUPPORTED
2826 PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
2827    int color_type)) PNG_PRIVATE;
2828 #endif
2829 
2830 #ifdef PNG_WRITE_cHRM_SUPPORTED
2831 #ifdef PNG_FLOATING_POINT_SUPPORTED
2832 PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
2833    double white_x, double white_y,
2834    double red_x, double red_y, double green_x, double green_y,
2835    double blue_x, double blue_y)) PNG_PRIVATE;
2836 #endif
2837 #ifdef PNG_FIXED_POINT_SUPPORTED
2838 PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
2839    png_fixed_point int_white_x, png_fixed_point int_white_y,
2840    png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
2841    int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
2842    png_fixed_point int_blue_y)) PNG_PRIVATE;
2843 #endif
2844 #endif
2845 
2846 #ifdef PNG_WRITE_sRGB_SUPPORTED
2847 PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
2848    int intent)) PNG_PRIVATE;
2849 #endif
2850 
2851 #ifdef PNG_WRITE_iCCP_SUPPORTED
2852 PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
2853    png_charp name, int compression_type,
2854    png_charp profile, int proflen)) PNG_PRIVATE;
2855    /* Note to maintainer: profile should be png_bytep */
2856 #endif
2857 
2858 #ifdef PNG_WRITE_sPLT_SUPPORTED
2859 PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
2860    png_sPLT_tp palette)) PNG_PRIVATE;
2861 #endif
2862 
2863 #ifdef PNG_WRITE_tRNS_SUPPORTED
2864 PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
2865    png_color_16p values, int number, int color_type)) PNG_PRIVATE;
2866 #endif
2867 
2868 #ifdef PNG_WRITE_bKGD_SUPPORTED
2869 PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
2870    png_color_16p values, int color_type)) PNG_PRIVATE;
2871 #endif
2872 
2873 #ifdef PNG_WRITE_hIST_SUPPORTED
2874 PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
2875    int num_hist)) PNG_PRIVATE;
2876 #endif
2877 
2878 #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
2879     defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
2880 PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
2881    png_charp key, png_charpp new_key)) PNG_PRIVATE;
2882 #endif
2883 
2884 #ifdef PNG_WRITE_tEXt_SUPPORTED
2885 PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
2886    png_charp text, png_size_t text_len)) PNG_PRIVATE;
2887 #endif
2888 
2889 #ifdef PNG_WRITE_zTXt_SUPPORTED
2890 PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
2891    png_charp text, png_size_t text_len, int compression)) PNG_PRIVATE;
2892 #endif
2893 
2894 #ifdef PNG_WRITE_iTXt_SUPPORTED
2895 PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
2896    int compression, png_charp key, png_charp lang, png_charp lang_key,
2897    png_charp text)) PNG_PRIVATE;
2898 #endif
2899 
2900 #ifdef PNG_TEXT_SUPPORTED  /* Added at version 1.0.14 and 1.2.4 */
2901 PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
2902    png_infop info_ptr, png_textp text_ptr, int num_text)) PNG_PRIVATE;
2903 #endif
2904 
2905 #ifdef PNG_WRITE_oFFs_SUPPORTED
2906 PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
2907    png_int_32 x_offset, png_int_32 y_offset, int unit_type)) PNG_PRIVATE;
2908 #endif
2909 
2910 #ifdef PNG_WRITE_pCAL_SUPPORTED
2911 PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
2912    png_int_32 X0, png_int_32 X1, int type, int nparams,
2913    png_charp units, png_charpp params)) PNG_PRIVATE;
2914 #endif
2915 
2916 #ifdef PNG_WRITE_pHYs_SUPPORTED
2917 PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
2918    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
2919    int unit_type)) PNG_PRIVATE;
2920 #endif
2921 
2922 #ifdef PNG_WRITE_tIME_SUPPORTED
2923 PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
2924    png_timep mod_time)) PNG_PRIVATE;
2925 #endif
2926 
2927 #ifdef PNG_WRITE_sCAL_SUPPORTED
2928 #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
2929 PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
2930    int unit, double width, double height)) PNG_PRIVATE;
2931 #else
2932 #ifdef PNG_FIXED_POINT_SUPPORTED
2933 PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
2934    int unit, png_charp width, png_charp height)) PNG_PRIVATE;
2935 #endif
2936 #endif
2937 #endif
2938 
2939 /* Called when finished processing a row of data */
2940 PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2941 
2942 /* Internal use only.   Called before first row of data */
2943 PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2944 
2945 #ifdef PNG_READ_GAMMA_SUPPORTED
2946 PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2947 #endif
2948 
2949 /* Combine a row of data, dealing with alpha, etc. if requested */
2950 PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
2951    int mask)) PNG_PRIVATE;
2952 
2953 #ifdef PNG_READ_INTERLACING_SUPPORTED
2954 /* Expand an interlaced row */
2955 /* OLD pre-1.0.9 interface:
2956 PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
2957    png_bytep row, int pass, png_uint_32 transformations)) PNG_PRIVATE;
2958  */
2959 PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2960 #endif
2961 
2962 /* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */
2963 
2964 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
2965 /* Grab pixels out of a row for an interlaced pass */
2966 PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
2967    png_bytep row, int pass)) PNG_PRIVATE;
2968 #endif
2969 
2970 /* Unfilter a row */
2971 PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
2972    png_row_infop row_info, png_bytep row, png_bytep prev_row,
2973    int filter)) PNG_PRIVATE;
2974 
2975 /* Choose the best filter to use and filter the row data */
2976 PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
2977    png_row_infop row_info)) PNG_PRIVATE;
2978 
2979 /* Write out the filtered row. */
2980 PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
2981    png_bytep filtered_row)) PNG_PRIVATE;
2982 /* Finish a row while reading, dealing with interlacing passes, etc. */
2983 PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
2984 
2985 /* Initialize the row buffers, etc. */
2986 PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)) PNG_PRIVATE;
2987 /* Optional call to update the users info structure */
2988 PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
2989    png_infop info_ptr)) PNG_PRIVATE;
2990 
2991 /* These are the functions that do the transformations */
2992 #ifdef PNG_READ_FILLER_SUPPORTED
2993 PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
2994    png_bytep row, png_uint_32 filler, png_uint_32 flags)) PNG_PRIVATE;
2995 #endif
2996 
2997 #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
2998 PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
2999    png_bytep row)) PNG_PRIVATE;
3000 #endif
3001 
3002 #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
3003 PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
3004    png_bytep row)) PNG_PRIVATE;
3005 #endif
3006 
3007 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
3008 PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
3009    png_bytep row)) PNG_PRIVATE;
3010 #endif
3011 
3012 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
3013 PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
3014    png_bytep row)) PNG_PRIVATE;
3015 #endif
3016 
3017 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
3018     defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
3019 PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
3020    png_bytep row, png_uint_32 flags)) PNG_PRIVATE;
3021 #endif
3022 
3023 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
3024 PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info,
3025     png_bytep row)) PNG_PRIVATE;
3026 #endif
3027 
3028 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
3029 PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info,
3030     png_bytep row)) PNG_PRIVATE;
3031 #endif
3032 
3033 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
3034 PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
3035    row_info, png_bytep row)) PNG_PRIVATE;
3036 #endif
3037 
3038 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
3039 PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
3040    png_bytep row)) PNG_PRIVATE;
3041 #endif
3042 
3043 #ifdef PNG_READ_PACK_SUPPORTED
3044 PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info,
3045     png_bytep row)) PNG_PRIVATE;
3046 #endif
3047 
3048 #ifdef PNG_READ_SHIFT_SUPPORTED
3049 PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
3050    png_color_8p sig_bits)) PNG_PRIVATE;
3051 #endif
3052 
3053 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
3054 PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info,
3055     png_bytep row)) PNG_PRIVATE;
3056 #endif
3057 
3058 #ifdef PNG_READ_16_TO_8_SUPPORTED
3059 PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,
3060     png_bytep row)) PNG_PRIVATE;
3061 #endif
3062 
3063 #ifdef PNG_READ_DITHER_SUPPORTED
3064 PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
3065    png_bytep row, png_bytep palette_lookup,
3066     png_bytep dither_lookup)) PNG_PRIVATE;
3067 
3068 #  ifdef PNG_CORRECT_PALETTE_SUPPORTED
3069 PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
3070    png_colorp palette, int num_palette)) PNG_PRIVATE;
3071 #  endif
3072 #endif
3073 
3074 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
3075 PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info,
3076     png_bytep row)) PNG_PRIVATE;
3077 #endif
3078 
3079 #ifdef PNG_WRITE_PACK_SUPPORTED
3080 PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
3081    png_bytep row, png_uint_32 bit_depth)) PNG_PRIVATE;
3082 #endif
3083 
3084 #ifdef PNG_WRITE_SHIFT_SUPPORTED
3085 PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
3086    png_color_8p bit_depth)) PNG_PRIVATE;
3087 #endif
3088 
3089 #ifdef PNG_READ_BACKGROUND_SUPPORTED
3090 #ifdef PNG_READ_GAMMA_SUPPORTED
3091 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
3092    png_color_16p trans_values, png_color_16p background,
3093    png_color_16p background_1,
3094    png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
3095    png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
3096    png_uint_16pp gamma_16_to_1, int gamma_shift)) PNG_PRIVATE;
3097 #else
3098 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
3099    png_color_16p trans_values, png_color_16p background)) PNG_PRIVATE;
3100 #endif
3101 #endif
3102 
3103 #ifdef PNG_READ_GAMMA_SUPPORTED
3104 PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
3105    png_bytep gamma_table, png_uint_16pp gamma_16_table,
3106    int gamma_shift)) PNG_PRIVATE;
3107 #endif
3108 
3109 #ifdef PNG_READ_EXPAND_SUPPORTED
3110 PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
3111    png_bytep row, png_colorp palette, png_bytep trans,
3112    int num_trans)) PNG_PRIVATE;
3113 PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
3114    png_bytep row, png_color_16p trans_value)) PNG_PRIVATE;
3115 #endif
3116 
3117 /* The following decodes the appropriate chunks, and does error correction,
3118  * then calls the appropriate callback for the chunk if it is valid.
3119  */
3120 
3121 /* Decode the IHDR chunk */
3122 PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
3123    png_uint_32 length)) PNG_PRIVATE;
3124 PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
3125    png_uint_32 length));
3126 PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
3127    png_uint_32 length));
3128 
3129 #ifdef PNG_READ_bKGD_SUPPORTED
3130 PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
3131    png_uint_32 length)) PNG_PRIVATE;
3132 #endif
3133 
3134 #ifdef PNG_READ_cHRM_SUPPORTED
3135 PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
3136    png_uint_32 length)) PNG_PRIVATE;
3137 #endif
3138 
3139 #ifdef PNG_READ_gAMA_SUPPORTED
3140 PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
3141    png_uint_32 length)) PNG_PRIVATE;
3142 #endif
3143 
3144 #ifdef PNG_READ_hIST_SUPPORTED
3145 PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
3146    png_uint_32 length)) PNG_PRIVATE;
3147 #endif
3148 
3149 #ifdef PNG_READ_iCCP_SUPPORTED
3150 extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
3151    png_uint_32 length));
3152 #endif /* PNG_READ_iCCP_SUPPORTED */
3153 
3154 #ifdef PNG_READ_iTXt_SUPPORTED
3155 PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
3156    png_uint_32 length)) PNG_PRIVATE;
3157 #endif
3158 
3159 #ifdef PNG_READ_oFFs_SUPPORTED
3160 PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
3161    png_uint_32 length)) PNG_PRIVATE;
3162 #endif
3163 
3164 #ifdef PNG_READ_pCAL_SUPPORTED
3165 PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
3166    png_uint_32 length)) PNG_PRIVATE;
3167 #endif
3168 
3169 #ifdef PNG_READ_pHYs_SUPPORTED
3170 PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
3171    png_uint_32 length)) PNG_PRIVATE;
3172 #endif
3173 
3174 #ifdef PNG_READ_sBIT_SUPPORTED
3175 PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
3176    png_uint_32 length)) PNG_PRIVATE;
3177 #endif
3178 
3179 #ifdef PNG_READ_sCAL_SUPPORTED
3180 PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
3181    png_uint_32 length)) PNG_PRIVATE;
3182 #endif
3183 
3184 #ifdef PNG_READ_sPLT_SUPPORTED
3185 extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
3186    png_uint_32 length)) PNG_PRIVATE;
3187 #endif /* PNG_READ_sPLT_SUPPORTED */
3188 
3189 #ifdef PNG_READ_sRGB_SUPPORTED
3190 PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
3191    png_uint_32 length)) PNG_PRIVATE;
3192 #endif
3193 
3194 #ifdef PNG_READ_tEXt_SUPPORTED
3195 PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
3196    png_uint_32 length)) PNG_PRIVATE;
3197 #endif
3198 
3199 #ifdef PNG_READ_tIME_SUPPORTED
3200 PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
3201    png_uint_32 length)) PNG_PRIVATE;
3202 #endif
3203 
3204 #ifdef PNG_READ_tRNS_SUPPORTED
3205 PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
3206    png_uint_32 length)) PNG_PRIVATE;
3207 #endif
3208 
3209 #ifdef PNG_READ_zTXt_SUPPORTED
3210 PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
3211    png_uint_32 length)) PNG_PRIVATE;
3212 #endif
3213 
3214 PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
3215    png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3216 
3217 PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
3218    png_bytep chunk_name)) PNG_PRIVATE;
3219 
3220 /* Handle the transformations for reading and writing */
3221 PNG_EXTERN void png_do_read_transformations
3222    PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3223 PNG_EXTERN void png_do_write_transformations
3224    PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3225 
3226 PNG_EXTERN void png_init_read_transformations
3227    PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3228 
3229 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
3230 PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
3231    png_infop info_ptr)) PNG_PRIVATE;
3232 PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
3233    png_infop info_ptr)) PNG_PRIVATE;
3234 PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3235 PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
3236    png_uint_32 length)) PNG_PRIVATE;
3237 PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3238 PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3239 PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
3240    png_bytep buffer, png_size_t buffer_length)) PNG_PRIVATE;
3241 PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3242 PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
3243    png_bytep buffer, png_size_t buffer_length)) PNG_PRIVATE;
3244 PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3245 PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
3246    png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3247 PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
3248    png_infop info_ptr)) PNG_PRIVATE;
3249 PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
3250    png_infop info_ptr)) PNG_PRIVATE;
3251 PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr,
3252    png_bytep row)) PNG_PRIVATE;
3253 PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
3254    png_infop info_ptr)) PNG_PRIVATE;
3255 PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
3256    png_infop info_ptr)) PNG_PRIVATE;
3257 PNG_EXTERN void png_read_push_finish_row
3258    PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3259 #ifdef PNG_READ_tEXt_SUPPORTED
3260 PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
3261    png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3262 PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
3263    png_infop info_ptr)) PNG_PRIVATE;
3264 #endif
3265 #ifdef PNG_READ_zTXt_SUPPORTED
3266 PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
3267    png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3268 PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
3269    png_infop info_ptr)) PNG_PRIVATE;
3270 #endif
3271 #ifdef PNG_READ_iTXt_SUPPORTED
3272 PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
3273    png_infop info_ptr, png_uint_32 length)) PNG_PRIVATE;
3274 PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
3275    png_infop info_ptr)) PNG_PRIVATE;
3276 #endif
3277 
3278 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
3279 
3280 #ifdef PNG_MNG_FEATURES_SUPPORTED
3281 PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
3282    png_bytep row)) PNG_PRIVATE;
3283 PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
3284    png_bytep row)) PNG_PRIVATE;
3285 #endif
3286 
3287 
3288 /* The following six functions will be exported in libpng-1.4.0. */
3289 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
3290 PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr,
3291 png_infop info_ptr));
3292 
3293 PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr,
3294 png_infop info_ptr));
3295 
3296 PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr,
3297 png_infop info_ptr));
3298 
3299 PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr,
3300 png_infop info_ptr));
3301 
3302 PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr,
3303 png_infop info_ptr));
3304 
3305 #ifdef PNG_pHYs_SUPPORTED
3306 PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr,
3307 png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
3308 #endif /* PNG_pHYs_SUPPORTED */
3309 #endif  /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
3310 
3311 /* Read the chunk header (length + type name) */
3312 PNG_EXTERN png_uint_32 png_read_chunk_header
3313    PNGARG((png_structp png_ptr)) PNG_PRIVATE;
3314 
3315 /* Added at libpng version 1.2.34 */
3316 #ifdef PNG_cHRM_SUPPORTED
3317 PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
3318    png_fixed_point int_white_x, png_fixed_point int_white_y,
3319    png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
3320    int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
3321    png_fixed_point int_blue_y)) PNG_PRIVATE;
3322 #endif
3323 
3324 #ifdef PNG_cHRM_SUPPORTED
3325 #ifdef PNG_CHECK_cHRM_SUPPORTED
3326 /* Added at libpng version 1.2.34 */
3327 PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
3328    unsigned long *hi_product, unsigned long *lo_product)) PNG_PRIVATE;
3329 #endif
3330 #endif
3331 
3332 /* Added at libpng version 1.2.41 */
3333 PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
3334    png_uint_32 width, png_uint_32 height, int bit_depth,
3335    int color_type, int interlace_type, int compression_type,
3336    int filter_type)) PNG_PRIVATE;
3337 
3338 /* Added at libpng version 1.2.41 */
3339 PNG_EXTERN png_voidp png_calloc PNGARG((png_structp png_ptr,
3340    png_uint_32 size));
3341 
3342 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
3343 
3344 #endif /* PNG_INTERNAL */
3345 
3346 #ifdef __cplusplus
3347 }
3348 #endif
3349 
3350 #endif /* PNG_VERSION_INFO_ONLY */
3351 /* Do not put anything past this line */
3352 #endif /* PNG_H */
3353