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