]> git.saurik.com Git - wxWidgets.git/blob - src/png/png.h
forgot to commit - no changes
[wxWidgets.git] / src / png / png.h
1
2 /* png.h - header file for PNG reference library
3 *
4 * libpng version 1.0.3 - January 14, 1999
5 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
6 * Copyright (c) 1996, 1997 Andreas Dilger
7 * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
8 *
9 * Y2K compliance in libpng:
10 * =========================
11 *
12 * January 13, 1999
13 *
14 * Since the PNG Development group is an ad-hoc body, we can't make
15 * an official declaration.
16 *
17 * This is your unofficial assurance that libpng from version 0.81 and
18 * upward are Y2K compliant. It is my belief that earlier versions were
19 * also Y2K compliant.
20 *
21 * Libpng only has three year fields. One is a 2-byte unsigned integer
22 * that will hold years up to 65535. The other two hold the date in text
23 * format, and will hold years up to 9999.
24 *
25 * The integer is
26 * "png_uint_16 year" in png_time_struct.
27 *
28 * The strings are
29 * "png_charp time_buffer" in png_struct and
30 * "near_time_buffer", which is a local character string in png.c.
31 *
32 * There are seven time-related functions:
33 * png.c: png_convert_to_rfc_1123() in png.c
34 * (formerly png_convert_to_rfc_1152() in error)
35 * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
36 * png_convert_from_time_t() in pngwrite.c
37 * png_get_tIME() in pngget.c
38 * png_handle_tIME() in pngrutil.c, called in pngread.c
39 * png_set_tIME() in pngset.c
40 * png_write_tIME() in pngwutil.c, called in pngwrite.c
41 *
42 * All handle dates properly in a Y2K environment. The
43 * png_convert_from_time_t() function calls gmtime() to convert from system
44 * clock time, which returns (year - 1900), which we properly convert to
45 * the full 4-digit year. There is a possibility that applications using
46 * libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
47 * function, or incorrectly passing only a 2-digit year instead of
48 * "year - 1900" into the png_convert_from_struct_tm() function, but this
49 * is not under our control. The libpng documentation has always stated
50 * that it works with 4-digit years, and the APIs have been documented as
51 * such.
52 *
53 * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
54 * integer to hold the year, and can hold years as large as 65535.
55 *
56 *
57 * Glenn Randers-Pehrson
58 * libpng maintainer
59 * PNG Development Group
60 *
61 * Note about libpng version numbers:
62 *
63 * Due to various miscommunications, unforeseen code incompatibilities
64 * and occasional factors outside the authors' control, version numbering
65 * on the library has not always been consistent and straightforward.
66 * The following table summarizes matters since version 0.89c, which was
67 * the first widely used release:
68 *
69 * source png.h png.h shared-lib
70 * version string int version
71 * ------- ------ ----- ----------
72 * 0.89c ("1.0 beta 3") 0.89 89 1.0.89
73 * 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
74 * 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
75 * 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
76 * 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
77 * 0.97c 0.97 97 2.0.97
78 * 0.98 0.98 98 2.0.98
79 * 0.99 0.99 98 2.0.99
80 * 0.99a-m 0.99 99 2.0.99
81 * 1.00 1.00 100 2.1.0 [int should be 10000]
82 * 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
83 * 1.0.1 1.0.1 10001 2.1.0
84 * 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e
85 * 1.0.2 1.0.2 10002 2.1.0.2
86 * 1.0.2a-c 1.0.2a 10003 2.1.0.2a-c
87 * 1.0.3 1.0.3 10003 2.1.0.3
88 *
89 * Henceforth the source version will match the shared-library minor
90 * and patch numbers; the shared-library major version number will be
91 * used for changes in backward compatibility, as it is intended. The
92 * PNG_PNGLIB_VER macro, which is not used within libpng but is available
93 * for applications, is an unsigned integer of the form xyyzz corresponding
94 * to the source version x.y.z (leading zeros in y and z).
95 *
96 * See libpng.txt or libpng.3 for more information. The PNG specification
97 * is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
98 * and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
99 *
100 * Contributing Authors:
101 * John Bowler
102 * Kevin Bracey
103 * Sam Bushell
104 * Andreas Dilger
105 * Magnus Holmgren
106 * Tom Lane
107 * Dave Martindale
108 * Glenn Randers-Pehrson
109 * Greg Roelofs
110 * Guy Eric Schalnat
111 * Paul Schmidt
112 * Tom Tanner
113 * Willem van Schaik
114 * Tim Wegner
115 *
116 * The contributing authors would like to thank all those who helped
117 * with testing, bug fixes, and patience. This wouldn't have been
118 * possible without all of you.
119 *
120 * Thanks to Frank J. T. Wojcik for helping with the documentation.
121 *
122 * COPYRIGHT NOTICE:
123 *
124 * The PNG Reference Library is supplied "AS IS". The Contributing Authors
125 * and Group 42, Inc. disclaim all warranties, expressed or implied,
126 * including, without limitation, the warranties of merchantability and of
127 * fitness for any purpose. The Contributing Authors and Group 42, Inc.
128 * assume no liability for direct, indirect, incidental, special, exemplary,
129 * or consequential damages, which may result from the use of the PNG
130 * Reference Library, even if advised of the possibility of such damage.
131 *
132 * Permission is hereby granted to use, copy, modify, and distribute this
133 * source code, or portions hereof, for any purpose, without fee, subject
134 * to the following restrictions:
135 * 1. The origin of this source code must not be misrepresented.
136 * 2. Altered versions must be plainly marked as such and must not be
137 * misrepresented as being the original source.
138 * 3. This Copyright notice may not be removed or altered from any source or
139 * altered source distribution.
140 *
141 * The Contributing Authors and Group 42, Inc. specifically permit, without
142 * fee, and encourage the use of this source code as a component to
143 * supporting the PNG file format in commercial products. If you use this
144 * source code in a product, acknowledgment is not required but would be
145 * appreciated.
146 */
147
148
149 #ifndef _PNG_H
150 #define _PNG_H
151
152 #ifdef __cplusplus
153 extern "C" {
154 #endif /* __cplusplus */
155
156 /* This is not the place to learn how to use libpng. The file libpng.txt
157 * describes how to use libpng, and the file example.c summarizes it
158 * with some code on which to build. This file is useful for looking
159 * at the actual function definitions and structure components.
160 */
161
162 /* include the compression library's header */
163 #include "zlib.h"
164
165 /* include all user configurable info */
166 #include "pngconf.h"
167
168 /* This file is arranged in several sections. The first section contains
169 * structure and type definitions. The second section contains the external
170 * library functions, while the third has the internal library functions,
171 * which applications aren't expected to use directly.
172 */
173
174 /* Version information for png.h - this should match the version in png.c */
175 #define PNG_LIBPNG_VER_STRING "1.0.3"
176
177 /* Careful here. At one time, Guy wanted to use 082, but that would be octal.
178 * We must not include leading zeros.
179 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
180 * version 1.0.0 was mis-numbered 100 instead of 10000). From
181 * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
182 #define PNG_LIBPNG_VER 10003 /* 1.0.3 */
183
184 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
185 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
186 /* Version information for C files, stored in png.c. This had better match
187 * the version above.
188 */
189 extern char png_libpng_ver[12]; /* need room for 99.99.99aa */
190
191 /* Structures to facilitate easy interlacing. See png.c for more details */
192 extern int FARDATA png_pass_start[7];
193 extern int FARDATA png_pass_inc[7];
194 extern int FARDATA png_pass_ystart[7];
195 extern int FARDATA png_pass_yinc[7];
196 extern int FARDATA png_pass_mask[7];
197 extern int FARDATA png_pass_dsp_mask[7];
198 /* These aren't currently used. If you need them, see png.c for more details
199 extern int FARDATA png_pass_width[7];
200 extern int FARDATA png_pass_height[7];
201 */
202
203 #endif /* PNG_NO_EXTERN */
204
205 /* Three color definitions. The order of the red, green, and blue, (and the
206 * exact size) is not important, although the size of the fields need to
207 * be png_byte or png_uint_16 (as defined below).
208 */
209 typedef struct png_color_struct
210 {
211 png_byte red;
212 png_byte green;
213 png_byte blue;
214 } png_color;
215 typedef png_color FAR * png_colorp;
216 typedef png_color FAR * FAR * png_colorpp;
217
218 typedef struct png_color_16_struct
219 {
220 png_byte index; /* used for palette files */
221 png_uint_16 red; /* for use in red green blue files */
222 png_uint_16 green;
223 png_uint_16 blue;
224 png_uint_16 gray; /* for use in grayscale files */
225 } png_color_16;
226 typedef png_color_16 FAR * png_color_16p;
227 typedef png_color_16 FAR * FAR * png_color_16pp;
228
229 typedef struct png_color_8_struct
230 {
231 png_byte red; /* for use in red green blue files */
232 png_byte green;
233 png_byte blue;
234 png_byte gray; /* for use in grayscale files */
235 png_byte alpha; /* for alpha channel files */
236 } png_color_8;
237 typedef png_color_8 FAR * png_color_8p;
238 typedef png_color_8 FAR * FAR * png_color_8pp;
239
240 /* png_text holds the text in a PNG file, and whether they are compressed
241 in the PNG file or not. The "text" field points to a regular C string. */
242 typedef struct png_text_struct
243 {
244 int compression; /* compression value, see PNG_TEXT_COMPRESSION_ */
245 png_charp key; /* keyword, 1-79 character description of "text" */
246 png_charp text; /* comment, may be an empty string (ie "") */
247 png_size_t text_length; /* length of "text" field */
248 } png_text;
249 typedef png_text FAR * png_textp;
250 typedef png_text FAR * FAR * png_textpp;
251
252 /* Supported compression types for text in PNG files (tEXt, and zTXt).
253 * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
254 #define PNG_TEXT_COMPRESSION_NONE_WR -3
255 #define PNG_TEXT_COMPRESSION_zTXt_WR -2
256 #define PNG_TEXT_COMPRESSION_NONE -1
257 #define PNG_TEXT_COMPRESSION_zTXt 0
258 #define PNG_TEXT_COMPRESSION_LAST 1 /* Not a valid value */
259
260 /* png_time is a way to hold the time in an machine independent way.
261 * Two conversions are provided, both from time_t and struct tm. There
262 * is no portable way to convert to either of these structures, as far
263 * as I know. If you know of a portable way, send it to me. As a side
264 * note - PNG is Year 2000 compliant!
265 */
266 typedef struct png_time_struct
267 {
268 png_uint_16 year; /* full year, as in, 1995 */
269 png_byte month; /* month of year, 1 - 12 */
270 png_byte day; /* day of month, 1 - 31 */
271 png_byte hour; /* hour of day, 0 - 23 */
272 png_byte minute; /* minute of hour, 0 - 59 */
273 png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
274 } png_time;
275 typedef png_time FAR * png_timep;
276 typedef png_time FAR * FAR * png_timepp;
277
278 /* png_info is a structure that holds the information in a PNG file so
279 * that the application can find out the characteristics of the image.
280 * If you are reading the file, this structure will tell you what is
281 * in the PNG file. If you are writing the file, fill in the information
282 * you want to put into the PNG file, then call png_write_info().
283 * The names chosen should be very close to the PNG specification, so
284 * consult that document for information about the meaning of each field.
285 *
286 * With libpng < 0.95, it was only possible to directly set and read the
287 * the values in the png_info_struct, which meant that the contents and
288 * order of the values had to remain fixed. With libpng 0.95 and later,
289 * however, there are now functions that abstract the contents of
290 * png_info_struct from the application, so this makes it easier to use
291 * libpng with dynamic libraries, and even makes it possible to use
292 * libraries that don't have all of the libpng ancillary chunk-handing
293 * functionality.
294 *
295 * In any case, the order of the parameters in png_info_struct should NOT
296 * be changed for as long as possible to keep compatibility with applications
297 * that use the old direct-access method with png_info_struct.
298 */
299 typedef struct png_info_struct
300 {
301 /* the following are necessary for every PNG file */
302 png_uint_32 width; /* width of image in pixels (from IHDR) */
303 png_uint_32 height; /* height of image in pixels (from IHDR) */
304 png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
305 png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */
306 png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
307 png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
308 png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
309 png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
310 png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
311 png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
312 png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
313 png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
314
315 /* The following is informational only on read, and not used on writes. */
316 png_byte channels; /* number of data channels per pixel (1, 3, 4)*/
317 png_byte pixel_depth; /* number of bits per pixel */
318 png_byte spare_byte; /* to align the data, and for future use */
319 png_byte signature[8]; /* magic bytes read by libpng from start of file */
320
321 /* The rest of the data is optional. If you are reading, check the
322 * valid field to see if the information in these are valid. If you
323 * are writing, set the valid field to those chunks you want written,
324 * and initialize the appropriate fields below.
325 */
326
327 #if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED) || \
328 defined(PNG_READ_GAMMA_SUPPORTED)
329 /* The gAMA chunk describes the gamma characteristics of the system
330 * on which the image was created, normally in the range [1.0, 2.5].
331 * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
332 */
333 float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
334 #endif /* PNG_READ_gAMA_SUPPORTED || PNG_WRITE_gAMA_SUPPORTED */
335
336 #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
337 /* GR-P, 0.96a */
338 /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
339 png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
340 #endif /* PNG_READ_sRGB_SUPPORTED || PNG_WRITE_sRGB_SUPPORTED */
341
342 #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
343 defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
344 /* The tEXt and zTXt chunks contain human-readable textual data in
345 * uncompressed and compressed forms, respectively. The data in "text"
346 * is an array of pointers to uncompressed, null-terminated C strings.
347 * Each chunk has a keyword that describes the textual data contained
348 * in that chunk. Keywords are not required to be unique, and the text
349 * string may be empty. Any number of text chunks may be in an image.
350 */
351 int num_text; /* number of comments read/to write */
352 int max_text; /* current size of text array */
353 png_textp text; /* array of comments read/to write */
354 #endif /* PNG_READ_OR_WRITE_tEXt_OR_zTXt_SUPPORTED */
355 #if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
356 /* The tIME chunk holds the last time the displayed image data was
357 * modified. See the png_time struct for the contents of this struct.
358 */
359 png_time mod_time;
360 #endif /* PNG_READ_tIME_SUPPORTED || PNG_WRITE_tIME_SUPPORTED */
361 #if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
362 /* The sBIT chunk specifies the number of significant high-order bits
363 * in the pixel data. Values are in the range [1, bit_depth], and are
364 * only specified for the channels in the pixel data. The contents of
365 * the low-order bits is not specified. Data is valid if
366 * (valid & PNG_INFO_sBIT) is non-zero.
367 */
368 png_color_8 sig_bit; /* significant bits in color channels */
369 #endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
370 #if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED) || \
371 defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
372 /* The tRNS chunk supplies transparency data for paletted images and
373 * other image types that don't need a full alpha channel. There are
374 * "num_trans" transparency values for a paletted image, stored in the
375 * same order as the palette colors, starting from index 0. Values
376 * for the data are in the range [0, 255], ranging from fully transparent
377 * to fully opaque, respectively. For non-paletted images, there is a
378 * single color specified that should be treated as fully transparent.
379 * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
380 */
381 png_bytep trans; /* transparent values for paletted image */
382 png_color_16 trans_values; /* transparent color for non-palette image */
383 #endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
384 #if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED) || \
385 defined(PNG_READ_BACKGROUND_SUPPORTED)
386 /* The bKGD chunk gives the suggested image background color if the
387 * display program does not have its own background color and the image
388 * is needs to composited onto a background before display. The colors
389 * in "background" are normally in the same color space/depth as the
390 * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
391 */
392 png_color_16 background;
393 #endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
394 #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
395 /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
396 * and downwards from the top-left corner of the display, page, or other
397 * application-specific co-ordinate space. See the PNG_OFFSET_ defines
398 * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
399 */
400 png_uint_32 x_offset; /* x offset on page */
401 png_uint_32 y_offset; /* y offset on page */
402 png_byte offset_unit_type; /* offset units type */
403 #endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
404 #if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
405 /* The pHYs chunk gives the physical pixel density of the image for
406 * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
407 * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
408 */
409 png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
410 png_uint_32 y_pixels_per_unit; /* vertical pixel density */
411 png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
412 #endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
413 #if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
414 /* The hIST chunk contains the relative frequency or importance of the
415 * various palette entries, so that a viewer can intelligently select a
416 * reduced-color palette, if required. Data is an array of "num_palette"
417 * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
418 * is non-zero.
419 */
420 png_uint_16p hist;
421 #endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
422 #if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
423 /* The cHRM chunk describes the CIE color characteristics of the monitor
424 * on which the PNG was created. This data allows the viewer to do gamut
425 * mapping of the input image to ensure that the viewer sees the same
426 * colors in the image as the creator. Values are in the range
427 * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
428 */
429 float x_white;
430 float y_white;
431 float x_red;
432 float y_red;
433 float x_green;
434 float y_green;
435 float x_blue;
436 float y_blue;
437 #endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
438 #if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
439 /* The pCAL chunk describes a transformation between the stored pixel
440 * values and original physcical data values used to create the image.
441 * The integer range [0, 2^bit_depth - 1] maps to the floating-point
442 * range given by [pcal_X0, pcal_X1], and are further transformed by a
443 * (possibly non-linear) transformation function given by "pcal_type"
444 * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
445 * defines below, and the PNG-Group's Scientific Visualization extension
446 * chunks document png-scivis-19970203 for a complete description of the
447 * transformations and how they should be implemented, as well as the
448 * png-extensions document for a description of the ASCII parameter
449 * strings. Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
450 */
451 png_charp pcal_purpose; /* pCAL chunk description string */
452 png_int_32 pcal_X0; /* minimum value */
453 png_int_32 pcal_X1; /* maximum value */
454 png_charp pcal_units; /* Latin-1 string giving physical units */
455 png_charpp pcal_params; /* ASCII strings containing parameter values */
456 png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
457 png_byte pcal_nparams; /* number of parameters given in pcal_params */
458 #endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
459 } png_info;
460 typedef png_info FAR * png_infop;
461 typedef png_info FAR * FAR * png_infopp;
462
463 /* These describe the color_type field in png_info. */
464 /* color type masks */
465 #define PNG_COLOR_MASK_PALETTE 1
466 #define PNG_COLOR_MASK_COLOR 2
467 #define PNG_COLOR_MASK_ALPHA 4
468
469 /* color types. Note that not all combinations are legal */
470 #define PNG_COLOR_TYPE_GRAY 0
471 #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
472 #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
473 #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
474 #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
475
476 /* This is for compression type. PNG 1.0 only defines the single type. */
477 #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
478 #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
479
480 /* This is for filter type. PNG 1.0 only defines the single type. */
481 #define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
482 #define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
483
484 /* These are for the interlacing type. These values should NOT be changed. */
485 #define PNG_INTERLACE_NONE 0 /* Non-interlaced image */
486 #define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */
487 #define PNG_INTERLACE_LAST 2 /* Not a valid value */
488
489 /* These are for the oFFs chunk. These values should NOT be changed. */
490 #define PNG_OFFSET_PIXEL 0 /* Offset in pixels */
491 #define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */
492 #define PNG_OFFSET_LAST 2 /* Not a valid value */
493
494 /* These are for the pCAL chunk. These values should NOT be changed. */
495 #define PNG_EQUATION_LINEAR 0 /* Linear transformation */
496 #define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */
497 #define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */
498 #define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */
499 #define PNG_EQUATION_LAST 4 /* Not a valid value */
500
501 /* These are for the pHYs chunk. These values should NOT be changed. */
502 #define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */
503 #define PNG_RESOLUTION_METER 1 /* pixels/meter */
504 #define PNG_RESOLUTION_LAST 2 /* Not a valid value */
505
506 /* These are for the sRGB chunk. These values should NOT be changed. */
507 #define PNG_sRGB_INTENT_SATURATION 0
508 #define PNG_sRGB_INTENT_PERCEPTUAL 1
509 #define PNG_sRGB_INTENT_ABSOLUTE 2
510 #define PNG_sRGB_INTENT_RELATIVE 3
511 #define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
512
513
514
515 /* These determine if an ancillary chunk's data has been successfully read
516 * from the PNG header, or if the application has filled in the corresponding
517 * data in the info_struct to be written into the output file. The values
518 * of the PNG_INFO_<chunk> defines should NOT be changed.
519 */
520 #define PNG_INFO_gAMA 0x0001
521 #define PNG_INFO_sBIT 0x0002
522 #define PNG_INFO_cHRM 0x0004
523 #define PNG_INFO_PLTE 0x0008
524 #define PNG_INFO_tRNS 0x0010
525 #define PNG_INFO_bKGD 0x0020
526 #define PNG_INFO_hIST 0x0040
527 #define PNG_INFO_pHYs 0x0080
528 #define PNG_INFO_oFFs 0x0100
529 #define PNG_INFO_tIME 0x0200
530 #define PNG_INFO_pCAL 0x0400
531 #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
532
533 /* This is used for the transformation routines, as some of them
534 * change these values for the row. It also should enable using
535 * the routines for other purposes.
536 */
537 typedef struct png_row_info_struct
538 {
539 png_uint_32 width; /* width of row */
540 png_uint_32 rowbytes; /* number of bytes in row */
541 png_byte color_type; /* color type of row */
542 png_byte bit_depth; /* bit depth of row */
543 png_byte channels; /* number of channels (1, 2, 3, or 4) */
544 png_byte pixel_depth; /* bits per pixel (depth * channels) */
545 } png_row_info;
546
547 typedef png_row_info FAR * png_row_infop;
548 typedef png_row_info FAR * FAR * png_row_infopp;
549
550 /* These are the function types for the I/O functions and for the functions
551 * that allow the user to override the default I/O functions with his or her
552 * own. The png_error_ptr type should match that of user-supplied warning
553 * and error functions, while the png_rw_ptr type should match that of the
554 * user read/write data functions.
555 */
556 typedef struct png_struct_def png_struct;
557 typedef png_struct FAR * png_structp;
558
559 typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp));
560 typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
561 typedef void (*png_flush_ptr) PNGARG((png_structp));
562 typedef void (*png_read_status_ptr) PNGARG((png_structp, png_uint_32, int));
563 typedef void (*png_write_status_ptr) PNGARG((png_structp, png_uint_32, int));
564 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
565 typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
566 typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop));
567 typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
568 png_uint_32, int));
569 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
570
571 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
572 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
573 typedef void (*png_user_transform_ptr) PNGARG((png_structp,
574 png_row_infop, png_bytep));
575 #endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */
576
577 typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
578 typedef void (*png_free_ptr) PNGARG((png_structp, png_structp));
579
580 /* The structure that holds the information to read and write PNG files.
581 * The only people who need to care about what is inside of this are the
582 * people who will be modifying the library for their own special needs.
583 * It should NOT be accessed directly by an application, except to store
584 * the jmp_buf.
585 */
586
587 struct png_struct_def
588 {
589 jmp_buf jmpbuf; /* used in png_error */
590
591 png_error_ptr error_fn; /* function for printing errors and aborting */
592 png_error_ptr warning_fn; /* function for printing warnings */
593 png_voidp error_ptr; /* user supplied struct for error functions */
594 png_rw_ptr write_data_fn; /* function for writing output data */
595 png_rw_ptr read_data_fn; /* function for reading input data */
596 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
597 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
598 png_user_transform_ptr read_user_transform_fn; /* user read transform */
599 png_user_transform_ptr write_user_transform_fn; /* user write transform */
600 #endif
601 png_voidp io_ptr; /* ptr to application struct for I/O functions*/
602
603 png_uint_32 mode; /* tells us where we are in the PNG file */
604 png_uint_32 flags; /* flags indicating various things to libpng */
605 png_uint_32 transformations; /* which transformations to perform */
606
607 z_stream zstream; /* pointer to decompression structure (below) */
608 png_bytep zbuf; /* buffer for zlib */
609 png_size_t zbuf_size; /* size of zbuf */
610 int zlib_level; /* holds zlib compression level */
611 int zlib_method; /* holds zlib compression method */
612 int zlib_window_bits; /* holds zlib compression window bits */
613 int zlib_mem_level; /* holds zlib compression memory level */
614 int zlib_strategy; /* holds zlib compression strategy */
615
616 png_uint_32 width; /* width of image in pixels */
617 png_uint_32 height; /* height of image in pixels */
618 png_uint_32 num_rows; /* number of rows in current pass */
619 png_uint_32 usr_width; /* width of row at start of write */
620 png_uint_32 rowbytes; /* size of row in bytes */
621 png_uint_32 irowbytes; /* size of current interlaced row in bytes */
622 png_uint_32 iwidth; /* width of current interlaced row in pixels */
623 png_uint_32 row_number; /* current row in interlace pass */
624 png_bytep prev_row; /* buffer to save previous (unfiltered) row */
625 png_bytep row_buf; /* buffer to save current (unfiltered) row */
626 png_bytep sub_row; /* buffer to save "sub" row when filtering */
627 png_bytep up_row; /* buffer to save "up" row when filtering */
628 png_bytep avg_row; /* buffer to save "avg" row when filtering */
629 png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
630 png_row_info row_info; /* used for transformation routines */
631
632 png_uint_32 idat_size; /* current IDAT size for read */
633 png_uint_32 crc; /* current chunk CRC value */
634 png_colorp palette; /* palette from the input file */
635 png_uint_16 num_palette; /* number of color entries in palette */
636 png_uint_16 num_trans; /* number of transparency values */
637 png_byte chunk_name[5]; /* null-terminated name of current chunk */
638 png_byte compression; /* file compression type (always 0) */
639 png_byte filter; /* file filter type (always 0) */
640 png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
641 png_byte pass; /* current interlace pass (0 - 6) */
642 png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
643 png_byte color_type; /* color type of file */
644 png_byte bit_depth; /* bit depth of file */
645 png_byte usr_bit_depth; /* bit depth of users row */
646 png_byte pixel_depth; /* number of bits per pixel */
647 png_byte channels; /* number of channels in file */
648 png_byte usr_channels; /* channels at start of write */
649 png_byte sig_bytes; /* magic bytes read/written from start of file */
650
651 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
652 png_uint_16 filler; /* filler bytes for pixel expansion */
653 #endif /* PNG_READ_FILLER_SUPPORTED */
654 #if defined(PNG_READ_bKGD_SUPPORTED)
655 png_byte background_gamma_type;
656 float background_gamma;
657 png_color_16 background; /* background color in screen gamma space */
658 #if defined(PNG_READ_GAMMA_SUPPORTED)
659 png_color_16 background_1; /* background normalized to gamma 1.0 */
660 #endif /* PNG_READ_GAMMA && PNG_READ_bKGD_SUPPORTED */
661 #endif /* PNG_READ_bKGD_SUPPORTED */
662 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
663 png_flush_ptr output_flush_fn;/* Function for flushing output */
664 png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
665 png_uint_32 flush_rows; /* number of rows written since last flush */
666 #endif /* PNG_WRITE_FLUSH_SUPPORTED */
667 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
668 int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
669 float gamma; /* file gamma value */
670 float screen_gamma; /* screen gamma value (display_gamma/viewing_gamma */
671 #endif /* PNG_READ_GAMMA_SUPPORTED */
672 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
673 png_bytep gamma_table; /* gamma table for 8 bit depth files */
674 png_bytep gamma_from_1; /* converts from 1.0 to screen */
675 png_bytep gamma_to_1; /* converts from file to 1.0 */
676 png_uint_16pp gamma_16_table; /* gamma table for 16 bit depth files */
677 png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
678 png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
679 #endif /* PNG_READ_GAMMA_SUPPORTED || PNG_WRITE_GAMMA_SUPPORTED */
680 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined (PNG_READ_sBIT_SUPPORTED)
681 png_color_8 sig_bit; /* significant bits in each available channel */
682 #endif /* PNG_READ_GAMMA_SUPPORTED || PNG_READ_sBIT_SUPPORTED */
683 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
684 png_color_8 shift; /* shift for significant bit tranformation */
685 #endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
686 #if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
687 || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
688 png_bytep trans; /* transparency values for paletted files */
689 png_color_16 trans_values; /* transparency values for non-paletted files */
690 #endif /* PNG_READ|WRITE_tRNS_SUPPORTED||PNG_READ_EXPAND|BACKGROUND_SUPPORTED */
691 png_read_status_ptr read_row_fn; /* called after each row is decoded */
692 png_write_status_ptr write_row_fn; /* called after each row is encoded */
693 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
694 png_progressive_info_ptr info_fn; /* called after header data fully read */
695 png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */
696 png_progressive_end_ptr end_fn; /* called after image is complete */
697 png_bytep save_buffer_ptr; /* current location in save_buffer */
698 png_bytep save_buffer; /* buffer for previously read data */
699 png_bytep current_buffer_ptr; /* current location in current_buffer */
700 png_bytep current_buffer; /* buffer for recently used data */
701 png_uint_32 push_length; /* size of current input chunk */
702 png_uint_32 skip_length; /* bytes to skip in input data */
703 png_size_t save_buffer_size; /* amount of data now in save_buffer */
704 png_size_t save_buffer_max; /* total size of save_buffer */
705 png_size_t buffer_size; /* total amount of available input data */
706 png_size_t current_buffer_size; /* amount of data now in current_buffer */
707 int process_mode; /* what push library is currently doing */
708 int cur_palette; /* current push library palette index */
709 #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
710 png_size_t current_text_size; /* current size of text input data */
711 png_size_t current_text_left; /* how much text left to read in input */
712 png_charp current_text; /* current text chunk buffer */
713 png_charp current_text_ptr; /* current location in current_text */
714 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_tEXt/zTXt_SUPPORTED */
715 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
716 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
717 /* for the Borland special 64K segment handler */
718 png_bytepp offset_table_ptr;
719 png_bytep offset_table;
720 png_uint_16 offset_table_number;
721 png_uint_16 offset_table_count;
722 png_uint_16 offset_table_count_free;
723 #endif /* __TURBOC__&&!_Windows&&!__FLAT__ */
724 #if defined(PNG_READ_DITHER_SUPPORTED)
725 png_bytep palette_lookup; /* lookup table for dithering */
726 png_bytep dither_index; /* index translation for palette files */
727 #endif /* PNG_READ_DITHER_SUPPORTED */
728 #if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_READ_hIST_SUPPORTED)
729 png_uint_16p hist; /* histogram */
730 #endif
731 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
732 png_byte heuristic_method; /* heuristic for row filter selection */
733 png_byte num_prev_filters; /* number of weights for previous rows */
734 png_bytep prev_filters; /* filter type(s) of previous row(s) */
735 png_uint_16p filter_weights; /* weight(s) for previous line(s) */
736 png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
737 png_uint_16p filter_costs; /* relative filter calculation cost */
738 png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
739 #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
740 #if defined(PNG_TIME_RFC1123_SUPPORTED)
741 png_charp time_buffer; /* String to hold RFC 1123 time text */
742 #endif /* PNG_TIME_RFC1123_SUPPORTED */
743 #ifdef PNG_USER_MEM_SUPPORTED
744 png_voidp mem_ptr; /* user supplied struct for mem functions */
745 png_malloc_ptr malloc_fn; /* function for allocating memory */
746 png_free_ptr free_fn; /* function for freeing memory */
747 #endif /* PNG_USER_MEM_SUPPORTED */
748 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
749 png_byte rgb_to_gray_status;
750 png_byte rgb_to_gray_red_coeff;
751 png_byte rgb_to_gray_green_coeff;
752 png_byte rgb_to_gray_blue_coeff;
753 #endif
754 };
755
756 typedef png_struct FAR * FAR * png_structpp;
757
758 /* Here are the function definitions most commonly used. This is not
759 * the place to find out how to use libpng. See libpng.txt for the
760 * full explanation, see example.c for the summary. This just provides
761 * a simple one line of the use of each function.
762 */
763
764 /* Tell lib we have already handled the first <num_bytes> magic bytes.
765 * Handling more than 8 bytes from the beginning of the file is an error.
766 */
767 extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
768 int num_bytes));
769
770 /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
771 * PNG file. Returns zero if the supplied bytes match the 8-byte PNG
772 * signature, and non-zero otherwise. Having num_to_check == 0 or
773 * start > 7 will always fail (ie return non-zero).
774 */
775 extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
776 png_size_t num_to_check));
777
778 /* Simple signature checking function. This is the same as calling
779 * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
780 */
781 extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
782
783 /* Allocate and initialize png_ptr struct for reading, and any other memory. */
784 extern PNG_EXPORT(png_structp,png_create_read_struct)
785 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
786 png_error_ptr error_fn, png_error_ptr warn_fn));
787
788 /* Allocate and initialize png_ptr struct for writing, and any other memory */
789 extern PNG_EXPORT(png_structp,png_create_write_struct)
790 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
791 png_error_ptr error_fn, png_error_ptr warn_fn));
792
793 #ifdef PNG_USER_MEM_SUPPORTED
794 extern PNG_EXPORT(png_structp,png_create_read_struct_2)
795 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
796 png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
797 png_malloc_ptr malloc_fn, png_free_ptr free_fn));
798 extern PNG_EXPORT(png_structp,png_create_write_struct_2)
799 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
800 png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
801 png_malloc_ptr malloc_fn, png_free_ptr free_fn));
802 #endif
803
804 /* Write a PNG chunk - size, type, (optional) data, CRC. */
805 extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
806 png_bytep chunk_name, png_bytep data, png_size_t length));
807
808 /* Write the start of a PNG chunk - length and chunk name. */
809 extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
810 png_bytep chunk_name, png_uint_32 length));
811
812 /* Write the data of a PNG chunk started with png_write_chunk_start(). */
813 extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
814 png_bytep data, png_size_t length));
815
816 /* Finish a chunk started with png_write_chunk_start() (includes CRC). */
817 extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
818
819 /* Allocate and initialize the info structure */
820 extern PNG_EXPORT(png_infop,png_create_info_struct)
821 PNGARG((png_structp png_ptr));
822
823 /* Initialize the info structure (old interface - NOT DLL EXPORTED) */
824 extern void png_info_init PNGARG((png_infop info_ptr));
825
826 /* Writes all the PNG information before the image. */
827 extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
828 png_infop info_ptr));
829
830 /* read the information before the actual image data. */
831 extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
832 png_infop info_ptr));
833
834 #if defined(PNG_TIME_RFC1123_SUPPORTED)
835 extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
836 PNGARG((png_structp png_ptr, png_timep ptime));
837 #endif /* PNG_TIME_RFC1123_SUPPORTED */
838
839 #if defined(PNG_WRITE_tIME_SUPPORTED)
840 /* convert from a struct tm to png_time */
841 extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
842 struct tm FAR * ttime));
843
844 /* convert from time_t to png_time. Uses gmtime() */
845 extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
846 time_t ttime));
847 #endif /* PNG_WRITE_tIME_SUPPORTED */
848
849 #if defined(PNG_READ_EXPAND_SUPPORTED)
850 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha if available. */
851 extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
852 #endif /* PNG_READ_EXPAND_SUPPORTED */
853
854 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
855 /* Use blue, green, red order for pixels. */
856 extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
857 #endif /* PNG_READ_BGR_SUPPORTED || PNG_WRITE_BGR_SUPPORTED */
858
859 #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
860 /* Expand the grayscale to 24 bit RGB if necessary. */
861 extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
862 #endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
863
864 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
865 /* Reduce RGB to grayscale. */
866 extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
867 int error_action, float red, float green ));
868 extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
869 png_ptr));
870 #endif /* PNG_READ_RGB_TO_GRAY_SUPPORTED */
871
872 extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
873 png_colorp palette));
874
875 #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
876 extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
877 #endif /* PNG_READ_STRIP_ALPHA_SUPPORTED */
878
879 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
880 defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
881 extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
882 #endif /* PNG_READ_SWAP_ALPHA_SUPPORTED || PNG_WRITE_SWAP_ALPHA_SUPPORTED */
883
884 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
885 defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
886 extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
887 #endif /* PNG_READ_INVERT_ALPHA_SUPPORTED || PNG_WRITE_INVERT_ALPHA_SUPPORTED */
888
889 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
890 /* Add a filler byte to 24-bit RGB images. */
891 extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
892 png_uint_32 filler, int flags));
893
894 /* The values of the PNG_FILLER_ defines should NOT be changed */
895 #define PNG_FILLER_BEFORE 0
896 #define PNG_FILLER_AFTER 1
897 #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
898
899 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
900 /* Swap bytes in 16 bit depth files. */
901 extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
902 #endif /* PNG_READ_SWAP_SUPPORTED || PNG_WRITE_SWAP_SUPPORTED */
903
904 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
905 /* Use 1 byte per pixel in 1, 2, or 4 bit depth files. */
906 extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
907 #endif /* PNG_READ_PACK_SUPPORTED || PNG_WRITE_PACK_SUPPORTED */
908
909 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
910 /* Swap packing order of pixels in bytes. */
911 extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
912 #endif /* PNG_READ_PACKSWAP_SUPPORTED || PNG_WRITE_PACKSWAP_SUPPOR */
913
914 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
915 /* Converts files to legal bit depths. */
916 extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
917 png_color_8p true_bits));
918 #endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
919
920 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
921 defined(PNG_WRITE_INTERLACING_SUPPORTED)
922 /* Have the code handle the interlacing. Returns the number of passes. */
923 extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
924 #endif /* PNG_READ_INTERLACING_SUPPORTED || PNG_WRITE_INTERLACING_SUPPORTED */
925
926 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
927 /* Invert monocrome files */
928 extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
929 #endif /* PNG_READ_INVERT_SUPPORTED || PNG_WRITE_INVERT_SUPPORTED */
930
931 #if defined(PNG_READ_BACKGROUND_SUPPORTED)
932 /* Handle alpha and tRNS by replacing with a background color. */
933 extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
934 png_color_16p background_color, int background_gamma_code,
935 int need_expand, double background_gamma));
936 #define PNG_BACKGROUND_GAMMA_UNKNOWN 0
937 #define PNG_BACKGROUND_GAMMA_SCREEN 1
938 #define PNG_BACKGROUND_GAMMA_FILE 2
939 #define PNG_BACKGROUND_GAMMA_UNIQUE 3
940 #endif /* PNG_READ_BACKGROUND_SUPPORTED */
941
942 #if defined(PNG_READ_16_TO_8_SUPPORTED)
943 /* strip the second byte of information from a 16 bit depth file. */
944 extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
945 #endif /* PNG_READ_16_TO_8_SUPPORTED */
946
947 #if defined(PNG_READ_DITHER_SUPPORTED)
948 /* Turn on dithering, and reduce the palette to the number of colors available. */
949 extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
950 png_colorp palette, int num_palette, int maximum_colors,
951 png_uint_16p histogram, int full_dither));
952 #endif /* PNG_READ_DITHER_SUPPORTED */
953
954 #if defined(PNG_READ_GAMMA_SUPPORTED)
955 /* Handle gamma correction. Screen_gamma=(display_gamma/viewing_gamma) */
956 extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
957 double screen_gamma, double default_file_gamma));
958 #endif /* PNG_READ_GAMMA_SUPPORTED */
959
960 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
961 /* Set how many lines between output flushes - 0 for no flushing */
962 extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
963
964 /* Flush the current PNG output buffer */
965 extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
966 #endif /* PNG_WRITE_FLUSH_SUPPORTED */
967
968 /* optional update palette with requested transformations */
969 extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
970
971 /* optional call to update the users info structure */
972 extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
973 png_infop info_ptr));
974
975 /* read a one or more rows of image data.*/
976 extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
977 png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
978
979 /* read a row of data.*/
980 extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
981 png_bytep row,
982 png_bytep display_row));
983
984 /* read the whole image into memory at once. */
985 extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
986 png_bytepp image));
987
988 /* write a row of image data */
989 extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
990 png_bytep row));
991
992 /* write a few rows of image data */
993 extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
994 png_bytepp row, png_uint_32 num_rows));
995
996 /* write the image data */
997 extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
998 png_bytepp image));
999
1000 /* writes the end of the PNG file. */
1001 extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
1002 png_infop info_ptr));
1003
1004 /* read the end of the PNG file. */
1005 extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
1006 png_infop info_ptr));
1007
1008 /* free any memory associated with the png_info_struct */
1009 extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
1010 png_infopp info_ptr_ptr));
1011
1012 /* free any memory associated with the png_struct and the png_info_structs */
1013 extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
1014 png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
1015
1016 /* free all memory used by the read (old method - NOT DLL EXPORTED) */
1017 extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
1018 png_infop end_info_ptr));
1019
1020 /* free any memory associated with the png_struct and the png_info_structs */
1021 extern PNG_EXPORT(void,png_destroy_write_struct)
1022 PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
1023
1024 /* free any memory used in info_ptr struct (old method - NOT DLL EXPORTED) */
1025 extern void png_write_destroy_info PNGARG((png_infop info_ptr));
1026
1027 /* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
1028 extern void png_write_destroy PNGARG((png_structp png_ptr));
1029
1030 /* set the libpng method of handling chunk CRC errors */
1031 extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
1032 int crit_action, int ancil_action));
1033
1034 /* Values for png_set_crc_action() to say how to handle CRC errors in
1035 * ancillary and critical chunks, and whether to use the data contained
1036 * therein. Note that it is impossible to "discard" data in a critical
1037 * chunk. For versions prior to 0.90, the action was always error/quit,
1038 * whereas in version 0.90 and later, the action for CRC errors in ancillary
1039 * chunks is warn/discard. These values should NOT be changed.
1040 *
1041 * value action:critical action:ancillary
1042 */
1043 #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */
1044 #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */
1045 #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */
1046 #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */
1047 #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
1048 #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
1049
1050 /* These functions give the user control over the scan-line filtering in
1051 * libpng and the compression methods used by zlib. These functions are
1052 * mainly useful for testing, as the defaults should work with most users.
1053 * Those users who are tight on memory or want faster performance at the
1054 * expense of compression can modify them. See the compression library
1055 * header file (zlib.h) for an explination of the compression functions.
1056 */
1057
1058 /* set the filtering method(s) used by libpng. Currently, the only valid
1059 * value for "method" is 0.
1060 */
1061 extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
1062 int filters));
1063
1064 /* Flags for png_set_filter() to say which filters to use. The flags
1065 * are chosen so that they don't conflict with real filter types
1066 * below, in case they are supplied instead of the #defined constants.
1067 * These values should NOT be changed.
1068 */
1069 #define PNG_NO_FILTERS 0x00
1070 #define PNG_FILTER_NONE 0x08
1071 #define PNG_FILTER_SUB 0x10
1072 #define PNG_FILTER_UP 0x20
1073 #define PNG_FILTER_AVG 0x40
1074 #define PNG_FILTER_PAETH 0x80
1075 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
1076 PNG_FILTER_AVG | PNG_FILTER_PAETH)
1077
1078 /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
1079 * These defines should NOT be changed.
1080 */
1081 #define PNG_FILTER_VALUE_NONE 0
1082 #define PNG_FILTER_VALUE_SUB 1
1083 #define PNG_FILTER_VALUE_UP 2
1084 #define PNG_FILTER_VALUE_AVG 3
1085 #define PNG_FILTER_VALUE_PAETH 4
1086 #define PNG_FILTER_VALUE_LAST 5
1087
1088 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
1089 /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
1090 * defines, either the default (minimum-sum-of-absolute-differences), or
1091 * the experimental method (weighted-minimum-sum-of-absolute-differences).
1092 *
1093 * Weights are factors >= 1.0, indicating how important it is to keep the
1094 * filter type consistent between rows. Larger numbers mean the current
1095 * filter is that many times as likely to be the same as the "num_weights"
1096 * previous filters. This is cumulative for each previous row with a weight.
1097 * There needs to be "num_weights" values in "filter_weights", or it can be
1098 * NULL if the weights aren't being specified. Weights have no influence on
1099 * the selection of the first row filter. Well chosen weights can (in theory)
1100 * improve the compression for a given image.
1101 *
1102 * Costs are factors >= 1.0 indicating the relative decoding costs of a
1103 * filter type. Higher costs indicate more decoding expense, and are
1104 * therefore less likely to be selected over a filter with lower computational
1105 * costs. There needs to be a value in "filter_costs" for each valid filter
1106 * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
1107 * setting the costs. Costs try to improve the speed of decompression without
1108 * unduly increasing the compressed image size.
1109 *
1110 * A negative weight or cost indicates the default value is to be used, and
1111 * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
1112 * The default values for both weights and costs are currently 1.0, but may
1113 * change if good general weighting/cost heuristics can be found. If both
1114 * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
1115 * to the UNWEIGHTED method, but with added encoding time/computation.
1116 */
1117 extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
1118 int heuristic_method, int num_weights, png_doublep filter_weights,
1119 png_doublep filter_costs));
1120 #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
1121
1122 /* Heuristic used for row filter selection. These defines should NOT be
1123 * changed.
1124 */
1125 #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
1126 #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
1127 #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
1128 #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
1129
1130 /* Set the library compression level. Currently, valid values range from
1131 * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
1132 * (0 - no compression, 9 - "maximal" compression). Note that tests have
1133 * shown that zlib compression levels 3-6 usually perform as well as level 9
1134 * for PNG images, and do considerably fewer caclulations. In the future,
1135 * these values may not correspond directly to the zlib compression levels.
1136 */
1137 extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
1138 int level));
1139
1140 extern PNG_EXPORT(void,png_set_compression_mem_level)
1141 PNGARG((png_structp png_ptr, int mem_level));
1142
1143 extern PNG_EXPORT(void,png_set_compression_strategy)
1144 PNGARG((png_structp png_ptr, int strategy));
1145
1146 extern PNG_EXPORT(void,png_set_compression_window_bits)
1147 PNGARG((png_structp png_ptr, int window_bits));
1148
1149 extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
1150 int method));
1151
1152 /* These next functions are called for input/output, memory, and error
1153 * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
1154 * and call standard C I/O routines such as fread(), fwrite(), and
1155 * fprintf(). These functions can be made to use other I/O routines
1156 * at run time for those applications that need to handle I/O in a
1157 * different manner by calling png_set_???_fn(). See libpng.txt for
1158 * more information.
1159 */
1160
1161 #if !defined(PNG_NO_STDIO)
1162 /* Initialize the input/output for the PNG file to the default functions. */
1163 extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, FILE *fp));
1164 #endif
1165
1166 /* Replace the (error and abort), and warning functions with user
1167 * supplied functions. If no messages are to be printed you must still
1168 * write and use replacement functions. The replacement error_fn should
1169 * still do a longjmp to the last setjmp location if you are using this
1170 * method of error handling. If error_fn or warning_fn is NULL, the
1171 * default function will be used.
1172 */
1173
1174 extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
1175 png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
1176
1177 /* Return the user pointer associated with the error functions */
1178 extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
1179
1180 /* Replace the default data output functions with a user supplied one(s).
1181 * If buffered output is not used, then output_flush_fn can be set to NULL.
1182 * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
1183 * output_flush_fn will be ignored (and thus can be NULL).
1184 */
1185 extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
1186 png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
1187
1188 /* Replace the default data input function with a user supplied one. */
1189 extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
1190 png_voidp io_ptr, png_rw_ptr read_data_fn));
1191
1192 /* Return the user pointer associated with the I/O functions */
1193 extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
1194
1195 extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
1196 png_read_status_ptr read_row_fn));
1197
1198 extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
1199 png_write_status_ptr write_row_fn));
1200
1201 #ifdef PNG_USER_MEM_SUPPORTED
1202 /* Replace the default memory allocation functions with user supplied one(s). */
1203 extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
1204 png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
1205
1206 /* Return the user pointer associated with the memory functions */
1207 extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
1208 #endif /* PNG_USER_MEM_SUPPORTED */
1209
1210 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
1211 extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
1212 png_ptr, png_user_transform_ptr read_user_transform_fn));
1213 #endif
1214
1215 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
1216 extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
1217 png_ptr, png_user_transform_ptr write_user_transform_fn));
1218 #endif
1219
1220 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
1221 /* Sets the function callbacks for the push reader, and a pointer to a
1222 * user-defined structure available to the callback functions.
1223 */
1224 extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
1225 png_voidp progressive_ptr,
1226 png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
1227 png_progressive_end_ptr end_fn));
1228
1229 /* returns the user pointer associated with the push read functions */
1230 extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
1231 PNGARG((png_structp png_ptr));
1232
1233 /* function to be called when data becomes available */
1234 extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
1235 png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
1236
1237 /* function that combines rows. Not very much different than the
1238 * png_combine_row() call. Is this even used?????
1239 */
1240 extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
1241 png_bytep old_row, png_bytep new_row));
1242 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
1243
1244 extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
1245 png_uint_32 size));
1246
1247 /* frees a pointer allocated by png_malloc() */
1248 extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
1249
1250 #ifdef PNG_USER_MEM_SUPPORTED
1251 extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
1252 png_uint_32 size));
1253 extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
1254 png_voidp ptr));
1255 #endif /* PNG_USER_MEM_SUPPORTED */
1256
1257 extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
1258 png_voidp s1, png_voidp s2, png_uint_32 size));
1259
1260 extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr,
1261 png_voidp s1, int value, png_uint_32 size));
1262
1263 #if defined(USE_FAR_KEYWORD) /* memory model conversion function */
1264 extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
1265 int check));
1266 #endif /* USE_FAR_KEYWORD */
1267
1268 /* Fatal error in PNG image of libpng - can't continue */
1269 extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
1270 png_const_charp error));
1271
1272 /* The same, but the chunk name is prepended to the error string. */
1273 extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
1274 png_const_charp error));
1275
1276 /* Non-fatal error in libpng. Can continue, but may have a problem. */
1277 extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
1278 png_const_charp message));
1279
1280 /* Non-fatal error in libpng, chunk name is prepended to message. */
1281 extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
1282 png_const_charp message));
1283
1284 /* The png_set_<chunk> functions are for storing values in the png_info_struct.
1285 * Similarly, the png_get_<chunk> calls are used to read values from the
1286 * png_info_struct, either storing the parameters in the passed variables, or
1287 * setting pointers into the png_info_struct where the data is stored. The
1288 * png_get_<chunk> functions return a non-zero value if the data was available
1289 * in info_ptr, or return zero and do not change any of the parameters if the
1290 * data was not available.
1291 *
1292 * These functions should be used instead of directly accessing png_info
1293 * to avoid problems with future changes in the size and internal layout of
1294 * png_info_struct.
1295 */
1296 /* Returns "flag" if chunk data is valid in info_ptr. */
1297 extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
1298 png_infop info_ptr, png_uint_32 flag));
1299
1300 /* Returns number of bytes needed to hold a transformed row. */
1301 extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
1302 png_infop info_ptr));
1303
1304 /* Returns number of color channels in image. */
1305 extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
1306 png_infop info_ptr));
1307
1308 #ifdef PNG_EASY_ACCESS_SUPPORTED
1309 /* Returns image width in pixels. */
1310 extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
1311 png_ptr, png_infop info_ptr));
1312
1313 /* Returns image height in pixels. */
1314 extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
1315 png_ptr, png_infop info_ptr));
1316
1317 /* Returns image bit_depth. */
1318 extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
1319 png_ptr, png_infop info_ptr));
1320
1321 /* Returns image color_type. */
1322 extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
1323 png_ptr, png_infop info_ptr));
1324
1325 /* Returns image filter_type. */
1326 extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
1327 png_ptr, png_infop info_ptr));
1328
1329 /* Returns image interlace_type. */
1330 extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
1331 png_ptr, png_infop info_ptr));
1332
1333 /* Returns image compression_type. */
1334 extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
1335 png_ptr, png_infop info_ptr));
1336
1337 /* Returns image resolution in pixels per meter, from pHYs chunk data. */
1338 extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
1339 png_ptr, png_infop info_ptr));
1340 extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
1341 png_ptr, png_infop info_ptr));
1342 extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
1343 png_ptr, png_infop info_ptr));
1344
1345 /* Returns pixel aspect ratio, computed from pHYs chunk data. */
1346 extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
1347 png_ptr, png_infop info_ptr));
1348
1349 /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
1350 extern PNG_EXPORT(png_uint_32, png_get_x_offset_pixels) PNGARG((png_structp
1351 png_ptr, png_infop info_ptr));
1352 extern PNG_EXPORT(png_uint_32, png_get_y_offset_pixels) PNGARG((png_structp
1353 png_ptr, png_infop info_ptr));
1354 extern PNG_EXPORT(png_uint_32, png_get_x_offset_microns) PNGARG((png_structp
1355 png_ptr, png_infop info_ptr));
1356 extern PNG_EXPORT(png_uint_32, png_get_y_offset_microns) PNGARG((png_structp
1357 png_ptr, png_infop info_ptr));
1358
1359 #endif /* PNG_EASY_ACCESS_SUPPORTED */
1360
1361 /* Returns pointer to signature string read from PNG header */
1362 extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
1363 png_infop info_ptr));
1364
1365 #if defined(PNG_READ_bKGD_SUPPORTED)
1366 extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
1367 png_infop info_ptr, png_color_16p *background));
1368 #endif /* PNG_READ_bKGD_SUPPORTED */
1369
1370 #if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
1371 extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
1372 png_infop info_ptr, png_color_16p background));
1373 #endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
1374
1375 #if defined(PNG_READ_cHRM_SUPPORTED)
1376 extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
1377 png_infop info_ptr, double *white_x, double *white_y, double *red_x,
1378 double *red_y, double *green_x, double *green_y, double *blue_x,
1379 double *blue_y));
1380 #endif /* PNG_READ_cHRM_SUPPORTED */
1381
1382 #if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
1383 extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
1384 png_infop info_ptr, double white_x, double white_y, double red_x,
1385 double red_y, double green_x, double green_y, double blue_x, double blue_y));
1386 #endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
1387
1388 #if defined(PNG_READ_gAMA_SUPPORTED)
1389 extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
1390 png_infop info_ptr, double *file_gamma));
1391 #endif /* PNG_READ_gAMA_SUPPORTED */
1392
1393 #if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
1394 extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
1395 png_infop info_ptr, double file_gamma));
1396 #endif /* PNG_READ_gAMA_SUPPORTED || PNG_WRITE_gAMA_SUPPORTED */
1397
1398 #if defined(PNG_READ_hIST_SUPPORTED)
1399 extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
1400 png_infop info_ptr, png_uint_16p *hist));
1401 #endif /* PNG_READ_hIST_SUPPORTED */
1402
1403 #if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
1404 extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
1405 png_infop info_ptr, png_uint_16p hist));
1406 #endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
1407
1408 extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
1409 png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
1410 int *bit_depth, int *color_type, int *interlace_type,
1411 int *compression_type, int *filter_type));
1412
1413 extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
1414 png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
1415 int color_type, int interlace_type, int compression_type, int filter_type));
1416
1417 #if defined(PNG_READ_oFFs_SUPPORTED)
1418 extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
1419 png_infop info_ptr, png_uint_32 *offset_x, png_uint_32 *offset_y,
1420 int *unit_type));
1421 #endif /* PNG_READ_oFFs_SUPPORTED */
1422
1423 #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
1424 extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
1425 png_infop info_ptr, png_uint_32 offset_x, png_uint_32 offset_y,
1426 int unit_type));
1427 #endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
1428
1429 #if defined(PNG_READ_pCAL_SUPPORTED)
1430 extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
1431 png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
1432 int *type, int *nparams, png_charp *units, png_charpp *params));
1433 #endif /* PNG_READ_pCAL_SUPPORTED */
1434
1435 #if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
1436 extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
1437 png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
1438 int type, int nparams, png_charp units, png_charpp params));
1439 #endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
1440
1441 #if defined(PNG_READ_pHYs_SUPPORTED)
1442 extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
1443 png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
1444 #endif /* PNG_READ_pHYs_SUPPORTED */
1445
1446 #if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
1447 extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
1448 png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
1449 #endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
1450
1451 extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
1452 png_infop info_ptr, png_colorp *palette, int *num_palette));
1453
1454 extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
1455 png_infop info_ptr, png_colorp palette, int num_palette));
1456
1457 #if defined(PNG_READ_sBIT_SUPPORTED)
1458 extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
1459 png_infop info_ptr, png_color_8p *sig_bit));
1460 #endif /* PNG_READ_sBIT_SUPPORTED */
1461
1462 #if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
1463 extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
1464 png_infop info_ptr, png_color_8p sig_bit));
1465 #endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
1466
1467 #if defined(PNG_READ_sRGB_SUPPORTED)
1468 extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
1469 png_infop info_ptr, int *intent));
1470 #endif /* PNG_READ_sRGB_SUPPORTED */
1471
1472 #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
1473 extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
1474 png_infop info_ptr, int intent));
1475 extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
1476 png_infop info_ptr, int intent));
1477 #endif /* PNG_READ_sRGB_SUPPORTED || PNG_WRITE_sRGB_SUPPORTED */
1478
1479 #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
1480 /* png_get_text also returns the number of text chunks in text_ptr */
1481 extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
1482 png_infop info_ptr, png_textp *text_ptr, int *num_text));
1483 #endif /* PNG_READ_tEXt_SUPPORTED || PNG_READ_zTXt_SUPPORTED */
1484
1485 #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
1486 defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
1487 extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
1488 png_infop info_ptr, png_textp text_ptr, int num_text));
1489 #endif /* PNG_READ_OR_WRITE_tEXt_OR_zTXt_SUPPORTED */
1490
1491 #if defined(PNG_READ_tIME_SUPPORTED)
1492 extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
1493 png_infop info_ptr, png_timep *mod_time));
1494 #endif /* PNG_READ_tIME_SUPPORTED */
1495
1496 #if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
1497 extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
1498 png_infop info_ptr, png_timep mod_time));
1499 #endif /* PNG_READ_tIME_SUPPORTED || PNG_WRITE_tIME_SUPPORTED */
1500
1501 #if defined(PNG_READ_tRNS_SUPPORTED)
1502 extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
1503 png_infop info_ptr, png_bytep *trans, int *num_trans,
1504 png_color_16p *trans_values));
1505 #endif /* PNG_READ_tRNS_SUPPORTED */
1506
1507 #if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
1508 extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
1509 png_infop info_ptr, png_bytep trans, int num_trans,
1510 png_color_16p trans_values));
1511 #endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
1512
1513 /* Define PNG_DEBUG at compile time for debugging information. Higher
1514 * numbers for PNG_DEBUG mean more debugging information. This has
1515 * only been added since version 0.95 so it is not implemented throughout
1516 * libpng yet, but more support will be added as needed.
1517 */
1518 #ifdef PNG_DEBUG
1519 #if (PNG_DEBUG > 0)
1520 #ifndef PNG_DEBUG_FILE
1521 #define PNG_DEBUG_FILE stderr
1522 #endif /* PNG_DEBUG_FILE */
1523
1524 #define png_debug(l,m) if (PNG_DEBUG > l) \
1525 fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
1526 (l==2 ? "\t\t":(l>2 ? "\t\t\t":""))))
1527 #define png_debug1(l,m,p1) if (PNG_DEBUG > l) \
1528 fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
1529 (l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1)
1530 #define png_debug2(l,m,p1,p2) if (PNG_DEBUG > l) \
1531 fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
1532 (l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1,p2)
1533 #endif /* (PNG_DEBUG > 0) */
1534 #endif /* PNG_DEBUG */
1535 #ifndef png_debug
1536 #define png_debug(l, m)
1537 #endif
1538 #ifndef png_debug1
1539 #define png_debug1(l, m, p1)
1540 #endif
1541 #ifndef png_debug2
1542 #define png_debug2(l, m, p1, p2)
1543 #endif
1544
1545 extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
1546 extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
1547
1548 #ifdef PNG_NO_EXTERN
1549 /* this only gets included in png.c */
1550 png_charp
1551 png_get_header_version(png_structp png_ptr)
1552 {
1553 if(png_ptr == NULL)
1554 /* silence compiler warning about unused png_ptr */ ;
1555 return("\n libpng version 1.0.3 - January 14, 1999 (header)\n");
1556 }
1557 #endif
1558
1559 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
1560 /* With these routines we avoid an integer divide, which will be slower on
1561 * most machines. However, it does take more operations than the corresponding
1562 * divide method, so it may be slower on a few RISC systems. There are two
1563 * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
1564 *
1565 * Note that the rounding factors are NOT supposed to be the same! 128 and
1566 * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
1567 * standard method.
1568 *
1569 * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
1570 */
1571
1572 /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
1573
1574 # define png_composite(composite, fg, alpha, bg) \
1575 { png_uint_16 temp = ((png_uint_16)(fg) * (png_uint_16)(alpha) + \
1576 (png_uint_16)(bg)*(png_uint_16)(255 - \
1577 (png_uint_16)(alpha)) + (png_uint_16)128); \
1578 (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
1579
1580 # define png_composite_16(composite, fg, alpha, bg) \
1581 { png_uint_32 temp = ((png_uint_32)(fg) * (png_uint_32)(alpha) + \
1582 (png_uint_32)(bg)*(png_uint_32)(65535L - \
1583 (png_uint_32)(alpha)) + (png_uint_32)32768L); \
1584 (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
1585
1586 #else /* standard method using integer division */
1587
1588 # define png_composite(composite, fg, alpha, bg) \
1589 (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
1590 (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
1591 (png_uint_16)127) / 255)
1592
1593 # define png_composite_16(composite, fg, alpha, bg) \
1594 (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
1595 (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \
1596 (png_uint_32)32767) / (png_uint_32)65535L)
1597
1598 #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
1599
1600 /* These next functions are used internally in the code. They generally
1601 * shouldn't be used unless you are writing code to add or replace some
1602 * functionality in libpng. More information about most functions can
1603 * be found in the files where the functions are located.
1604 */
1605
1606 #if defined(PNG_INTERNAL)
1607
1608 /* Various modes of operation. Note that after an init, mode is set to
1609 * zero automatically when the structure is created.
1610 */
1611 #define PNG_BEFORE_IHDR 0x00
1612 #define PNG_HAVE_IHDR 0x01
1613 #define PNG_HAVE_PLTE 0x02
1614 #define PNG_HAVE_IDAT 0x04
1615 #define PNG_AFTER_IDAT 0x08
1616 #define PNG_HAVE_IEND 0x10
1617 #define PNG_HAVE_gAMA 0x20
1618 #define PNG_HAVE_cHRM 0x40
1619 #define PNG_HAVE_sRGB 0x80
1620
1621 /* push model modes */
1622 #define PNG_READ_SIG_MODE 0
1623 #define PNG_READ_CHUNK_MODE 1
1624 #define PNG_READ_IDAT_MODE 2
1625 #define PNG_SKIP_MODE 3
1626 #define PNG_READ_tEXt_MODE 4
1627 #define PNG_READ_zTXt_MODE 5
1628 #define PNG_READ_DONE_MODE 6
1629 #define PNG_ERROR_MODE 7
1630
1631 /* flags for the transformations the PNG library does on the image data */
1632 #define PNG_BGR 0x0001
1633 #define PNG_INTERLACE 0x0002
1634 #define PNG_PACK 0x0004
1635 #define PNG_SHIFT 0x0008
1636 #define PNG_SWAP_BYTES 0x0010
1637 #define PNG_INVERT_MONO 0x0020
1638 #define PNG_DITHER 0x0040
1639 #define PNG_BACKGROUND 0x0080
1640 #define PNG_BACKGROUND_EXPAND 0x0100
1641 /* 0x0200 unused */
1642 #define PNG_16_TO_8 0x0400
1643 #define PNG_RGBA 0x0800
1644 #define PNG_EXPAND 0x1000
1645 #define PNG_GAMMA 0x2000
1646 #define PNG_GRAY_TO_RGB 0x4000
1647 #define PNG_FILLER 0x8000
1648 #define PNG_PACKSWAP 0x10000L
1649 #define PNG_SWAP_ALPHA 0x20000L
1650 #define PNG_STRIP_ALPHA 0x40000L
1651 #define PNG_INVERT_ALPHA 0x80000L
1652 #define PNG_USER_TRANSFORM 0x100000L
1653 #define PNG_RGB_TO_GRAY_ERR 0x200000L
1654 #define PNG_RGB_TO_GRAY_WARN 0x400000L
1655 #define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
1656
1657 /* flags for png_create_struct */
1658 #define PNG_STRUCT_PNG 0x0001
1659 #define PNG_STRUCT_INFO 0x0002
1660
1661 /* Scaling factor for filter heuristic weighting calculations */
1662 #define PNG_WEIGHT_SHIFT 8
1663 #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
1664 #define PNG_COST_SHIFT 3
1665 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
1666
1667 /* flags for the png_ptr->flags rather than declaring a byte for each one */
1668 #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
1669 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002
1670 #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004
1671 #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008
1672 #define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010
1673 #define PNG_FLAG_ZLIB_FINISHED 0x0020
1674 #define PNG_FLAG_ROW_INIT 0x0040
1675 #define PNG_FLAG_FILLER_AFTER 0x0080
1676 #define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
1677 #define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
1678 #define PNG_FLAG_CRC_CRITICAL_USE 0x0400
1679 #define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
1680 #define PNG_FLAG_FREE_PALETTE 0x1000
1681 #define PNG_FLAG_FREE_TRANS 0x2000
1682 #define PNG_FLAG_FREE_HIST 0x4000
1683 #define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000L
1684 #define PNG_FLAG_WROTE_tIME 0x10000L
1685 #define PNG_FLAG_BACKGROUND_IS_GRAY 0x20000L
1686
1687 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
1688 PNG_FLAG_CRC_ANCILLARY_NOWARN)
1689
1690 #define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
1691 PNG_FLAG_CRC_CRITICAL_IGNORE)
1692
1693 #define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
1694 PNG_FLAG_CRC_CRITICAL_MASK)
1695
1696 /* save typing and make code easier to understand */
1697 #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
1698 abs((int)((c1).green) - (int)((c2).green)) + \
1699 abs((int)((c1).blue) - (int)((c2).blue)))
1700
1701 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
1702 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
1703 /* place to hold the signature string for a PNG file. */
1704 extern png_byte FARDATA png_sig[8];
1705
1706 /* Constant strings for known chunk types. If you need to add a chunk,
1707 * add a string holding the name here. See png.c for more details. We
1708 * can't selectively include these, since we still check for chunk in the
1709 * wrong locations with these labels.
1710 */
1711 extern png_byte FARDATA png_IHDR[5];
1712 extern png_byte FARDATA png_IDAT[5];
1713 extern png_byte FARDATA png_IEND[5];
1714 extern png_byte FARDATA png_PLTE[5];
1715 extern png_byte FARDATA png_bKGD[5];
1716 extern png_byte FARDATA png_cHRM[5];
1717 extern png_byte FARDATA png_gAMA[5];
1718 extern png_byte FARDATA png_hIST[5];
1719 extern png_byte FARDATA png_oFFs[5];
1720 extern png_byte FARDATA png_pCAL[5];
1721 extern png_byte FARDATA png_pHYs[5];
1722 extern png_byte FARDATA png_sBIT[5];
1723 extern png_byte FARDATA png_sRGB[5];
1724 extern png_byte FARDATA png_tEXt[5];
1725 extern png_byte FARDATA png_tIME[5];
1726 extern png_byte FARDATA png_tRNS[5];
1727 extern png_byte FARDATA png_zTXt[5];
1728
1729 #endif /* PNG_NO_EXTERN */
1730
1731 /* Inline macros to do direct reads of bytes from the input buffer. These
1732 * require that you are using an architecture that uses PNG byte ordering
1733 * (MSB first) and supports unaligned data storage. I think that PowerPC
1734 * in big-endian mode and 680x0 are the only ones that will support this.
1735 * The x86 line of processors definitely do not. The png_get_int_32()
1736 * routine also assumes we are using two's complement format for negative
1737 * values, which is almost certainly true.
1738 */
1739 #if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
1740 #if defined(PNG_READ_pCAL_SUPPORTED)
1741 #define png_get_int_32(buf) ( *((png_int_32p) (buf)))
1742 #endif /* PNG_READ_pCAL_SUPPORTED */
1743 #define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
1744 #define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
1745 #else
1746 #if defined(PNG_READ_pCAL_SUPPORTED)
1747 PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
1748 #endif /* PNG_READ_pCAL_SUPPORTED */
1749 PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
1750 PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
1751 #endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */
1752
1753 /* Initialize png_ptr struct for reading, and allocate any other memory.
1754 * (old interface - NOT DLL EXPORTED).
1755 */
1756 extern void png_read_init PNGARG((png_structp png_ptr));
1757
1758 /* Initialize png_ptr struct for writing, and allocate any other memory.
1759 * (old interface - NOT DLL EXPORTED).
1760 */
1761 extern void png_write_init PNGARG((png_structp png_ptr));
1762
1763 /* allocate memory for an internal libpng struct */
1764 PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
1765
1766 /* free memory from internal libpng struct */
1767 PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
1768
1769 PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
1770 malloc_fn));
1771 PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
1772 png_free_ptr free_fn));
1773
1774 /* free any memory that info_ptr points to and reset struct. */
1775 PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
1776 png_infop info_ptr));
1777
1778 /* Function to allocate memory for zlib. */
1779 PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
1780
1781 /* function to free memory for zlib */
1782 PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
1783
1784 /* reset the CRC variable */
1785 PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
1786
1787 /* Write the "data" buffer to whatever output you are using. */
1788 PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
1789 png_size_t length));
1790
1791 /* Read data from whatever input you are using into the "data" buffer */
1792 PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
1793 png_size_t length));
1794
1795 /* read bytes into buf, and update png_ptr->crc */
1796 PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
1797 png_size_t length));
1798
1799 /* read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
1800 PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
1801
1802 /* read the CRC from the file and compare it to the libpng calculated CRC */
1803 PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
1804
1805 /* Calculate the CRC over a section of data. Note that we are only
1806 * passing a maximum of 64K on systems that have this as a memory limit,
1807 * since this is the maximum buffer size we can specify.
1808 */
1809 PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
1810 png_size_t length));
1811
1812 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
1813 PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
1814 #endif
1815
1816 /* Place a 32-bit number into a buffer in PNG byte order (big-endian).
1817 * The only currently known PNG chunks that use signed numbers are
1818 * the ancillary extension chunks, oFFs and pCAL.
1819 */
1820 PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
1821
1822 #if defined(PNG_WRITE_pCAL_SUPPORTED)
1823 PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
1824 #endif
1825
1826 /* Place a 16 bit number into a buffer in PNG byte order.
1827 * The parameter is declared unsigned int, not png_uint_16,
1828 * just to avoid potential problems on pre-ANSI C compilers.
1829 */
1830 PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
1831
1832 /* simple function to write the signature */
1833 PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
1834
1835 /* write various chunks */
1836
1837 /* Write the IHDR chunk, and update the png_struct with the necessary
1838 * information.
1839 */
1840 PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
1841 png_uint_32 height,
1842 int bit_depth, int color_type, int compression_type, int filter_type,
1843 int interlace_type));
1844
1845 PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
1846 png_uint_32 num_pal));
1847
1848 PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
1849 png_size_t length));
1850
1851 PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
1852
1853 #if defined(PNG_WRITE_gAMA_SUPPORTED)
1854 PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
1855 #endif
1856
1857 #if defined(PNG_WRITE_sBIT_SUPPORTED)
1858 PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
1859 int color_type));
1860 #endif
1861
1862 #if defined(PNG_WRITE_cHRM_SUPPORTED)
1863 PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
1864 double white_x, double white_y,
1865 double red_x, double red_y, double green_x, double green_y,
1866 double blue_x, double blue_y));
1867 #endif
1868
1869 #if defined(PNG_WRITE_sRGB_SUPPORTED)
1870 PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
1871 int intent));
1872 #endif
1873
1874 #if defined(PNG_WRITE_tRNS_SUPPORTED)
1875 PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
1876 png_color_16p values, int number, int color_type));
1877 #endif
1878
1879 #if defined(PNG_WRITE_bKGD_SUPPORTED)
1880 PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
1881 png_color_16p values, int color_type));
1882 #endif
1883
1884 #if defined(PNG_WRITE_hIST_SUPPORTED)
1885 PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
1886 int num_hist));
1887 #endif
1888
1889 #if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED) || \
1890 defined(PNG_WRITE_pCAL_SUPPORTED)
1891 PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
1892 png_charp key, png_charpp new_key));
1893 #endif
1894
1895 #if defined(PNG_WRITE_tEXt_SUPPORTED)
1896 PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
1897 png_charp text, png_size_t text_len));
1898 #endif
1899
1900 #if defined(PNG_WRITE_zTXt_SUPPORTED)
1901 PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
1902 png_charp text, png_size_t text_len, int compression));
1903 #endif
1904
1905 #if defined(PNG_WRITE_oFFs_SUPPORTED)
1906 PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
1907 png_uint_32 x_offset, png_uint_32 y_offset, int unit_type));
1908 #endif
1909
1910 #if defined(PNG_WRITE_pCAL_SUPPORTED)
1911 PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
1912 png_int_32 X0, png_int_32 X1, int type, int nparams,
1913 png_charp units, png_charpp params));
1914 #endif
1915
1916 #if defined(PNG_WRITE_pHYs_SUPPORTED)
1917 PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
1918 png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
1919 int unit_type));
1920 #endif
1921
1922 #if defined(PNG_WRITE_tIME_SUPPORTED)
1923 PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
1924 png_timep mod_time));
1925 #endif
1926
1927 /* Called when finished processing a row of data */
1928 PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
1929
1930 /* Internal use only. Called before first row of data */
1931 PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
1932
1933 #if defined(PNG_READ_GAMMA_SUPPORTED)
1934 PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
1935 #endif
1936
1937 /* combine a row of data, dealing with alpha, etc. if requested */
1938 PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
1939 int mask));
1940
1941 #if defined(PNG_READ_INTERLACING_SUPPORTED)
1942 /* expand an interlaced row */
1943 PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
1944 png_bytep row, int pass, png_uint_32 transformations));
1945 #endif
1946
1947 #if defined(PNG_WRITE_INTERLACING_SUPPORTED)
1948 /* grab pixels out of a row for an interlaced pass */
1949 PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
1950 png_bytep row, int pass));
1951 #endif
1952
1953 /* unfilter a row */
1954 PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
1955 png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
1956
1957 /* Choose the best filter to use and filter the row data */
1958 PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
1959 png_row_infop row_info));
1960
1961 /* Write out the filtered row. */
1962 PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
1963 png_bytep filtered_row));
1964 /* finish a row while reading, dealing with interlacing passes, etc. */
1965 PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
1966
1967 /* initialize the row buffers, etc. */
1968 PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
1969 /* optional call to update the users info structure */
1970 PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
1971 png_infop info_ptr));
1972
1973 /* these are the functions that do the transformations */
1974 #if defined(PNG_READ_FILLER_SUPPORTED)
1975 PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
1976 png_bytep row, png_uint_32 filler, png_uint_32 flags));
1977 #endif
1978
1979 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
1980 PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
1981 png_bytep row));
1982 #endif
1983
1984 #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
1985 PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
1986 png_bytep row));
1987 #endif
1988
1989 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
1990 PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
1991 png_bytep row));
1992 #endif
1993
1994 #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
1995 PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
1996 png_bytep row));
1997 #endif
1998
1999 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
2000 defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
2001 PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
2002 png_bytep row, png_uint_32 flags));
2003 #endif
2004
2005 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
2006 PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
2007 #endif
2008
2009 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
2010 PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
2011 #endif
2012
2013 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
2014 PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
2015 row_info, png_bytep row));
2016 #endif
2017
2018 #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
2019 PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
2020 png_bytep row));
2021 #endif
2022
2023 #if defined(PNG_READ_PACK_SUPPORTED)
2024 PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
2025 #endif
2026
2027 #if defined(PNG_READ_SHIFT_SUPPORTED)
2028 PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
2029 png_color_8p sig_bits));
2030 #endif
2031
2032 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
2033 PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
2034 #endif
2035
2036 #if defined(PNG_READ_16_TO_8_SUPPORTED)
2037 PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
2038 #endif
2039
2040 #if defined(PNG_READ_DITHER_SUPPORTED)
2041 PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
2042 png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
2043
2044 # if defined(PNG_CORRECT_PALETTE_SUPPORTED)
2045 PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
2046 png_colorp palette, int num_palette));
2047 # endif
2048 #endif
2049
2050 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
2051 PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
2052 #endif
2053
2054 #if defined(PNG_WRITE_PACK_SUPPORTED)
2055 PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
2056 png_bytep row, png_uint_32 bit_depth));
2057 #endif
2058
2059 #if defined(PNG_WRITE_SHIFT_SUPPORTED)
2060 PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
2061 png_color_8p bit_depth));
2062 #endif
2063
2064 #if defined(PNG_READ_BACKGROUND_SUPPORTED)
2065 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
2066 png_color_16p trans_values, png_color_16p background,
2067 png_color_16p background_1,
2068 png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
2069 png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
2070 png_uint_16pp gamma_16_to_1, int gamma_shift));
2071 #endif
2072
2073 #if defined(PNG_READ_GAMMA_SUPPORTED)
2074 PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
2075 png_bytep gamma_table, png_uint_16pp gamma_16_table,
2076 int gamma_shift));
2077 #endif
2078
2079 #if defined(PNG_READ_EXPAND_SUPPORTED)
2080 PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
2081 png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
2082 PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
2083 png_bytep row, png_color_16p trans_value));
2084 #endif
2085
2086 /* The following decodes the appropriate chunks, and does error correction,
2087 * then calls the appropriate callback for the chunk if it is valid.
2088 */
2089
2090 /* decode the IHDR chunk */
2091 PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
2092 png_uint_32 length));
2093 PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
2094 png_uint_32 length));
2095 PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
2096 png_uint_32 length));
2097
2098 #if defined(PNG_READ_gAMA_SUPPORTED)
2099 PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
2100 png_uint_32 length));
2101 #endif
2102
2103 #if defined(PNG_READ_sBIT_SUPPORTED)
2104 PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
2105 png_uint_32 length));
2106 #endif
2107
2108 #if defined(PNG_READ_cHRM_SUPPORTED)
2109 PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
2110 png_uint_32 length));
2111 #endif
2112
2113 #if defined(PNG_READ_sRGB_SUPPORTED)
2114 PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
2115 png_uint_32 length));
2116 #endif
2117
2118 #if defined(PNG_READ_tRNS_SUPPORTED)
2119 PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
2120 png_uint_32 length));
2121 #endif
2122
2123 #if defined(PNG_READ_bKGD_SUPPORTED)
2124 PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
2125 png_uint_32 length));
2126 #endif
2127
2128 #if defined(PNG_READ_hIST_SUPPORTED)
2129 PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
2130 png_uint_32 length));
2131 #endif
2132
2133 #if defined(PNG_READ_oFFs_SUPPORTED)
2134 PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
2135 png_uint_32 length));
2136 #endif
2137
2138 #if defined(PNG_READ_pCAL_SUPPORTED)
2139 PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
2140 png_uint_32 length));
2141 #endif
2142
2143 #if defined(PNG_READ_pHYs_SUPPORTED)
2144 PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
2145 png_uint_32 length));
2146 #endif
2147
2148 #if defined(PNG_READ_tIME_SUPPORTED)
2149 PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
2150 png_uint_32 length));
2151 #endif
2152
2153 #if defined(PNG_READ_tEXt_SUPPORTED)
2154 PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
2155 png_uint_32 length));
2156 #endif
2157
2158 #if defined(PNG_READ_zTXt_SUPPORTED)
2159 PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
2160 png_uint_32 length));
2161 #endif
2162
2163 PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
2164 png_infop info_ptr, png_uint_32 length));
2165
2166 PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
2167 png_bytep chunk_name));
2168
2169 /* handle the transformations for reading and writing */
2170 PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
2171 PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
2172
2173 PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
2174
2175 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
2176 PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
2177 png_infop info_ptr));
2178 PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
2179 png_infop info_ptr));
2180 PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
2181 PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
2182 png_uint_32 length));
2183 PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
2184 PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
2185 png_bytep buffer, png_size_t length));
2186 PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
2187 PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
2188 png_bytep buffer, png_size_t buffer_length));
2189 PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
2190 PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
2191 png_bytep buffer, png_size_t buffer_length));
2192 PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
2193 PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
2194 png_infop info_ptr, png_uint_32 length));
2195 PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
2196 png_infop info_ptr));
2197 PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
2198 png_infop info_ptr));
2199 PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
2200 PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
2201 png_infop info_ptr));
2202 PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
2203 png_infop info_ptr));
2204 PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
2205 #if defined(PNG_READ_tEXt_SUPPORTED)
2206 PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
2207 png_infop info_ptr, png_uint_32 length));
2208 PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
2209 png_infop info_ptr));
2210 #endif
2211 #if defined(PNG_READ_zTXt_SUPPORTED)
2212 PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
2213 png_infop info_ptr, png_uint_32 length));
2214 PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
2215 png_infop info_ptr));
2216 #endif
2217
2218 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
2219
2220 #endif /* PNG_INTERNAL */
2221
2222 #ifdef __cplusplus
2223 }
2224 #endif
2225
2226 /* do not put anything past this line */
2227 #endif /* _PNG_H */