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