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