blob: e3eaeba4dc7b960308fef8adfd3524d0711a4890 [file] [log] [blame]
Guy Schalnat0d580581995-07-20 02:43:20 -05001
Andreas Dilger47a0c421997-05-16 02:46:07 -05002/* png.h - header file for PNG reference library
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06003 *
Glenn Randers-Pehrson2687fcc1998-01-07 20:54:20 -06004 * libpng 0.97 beta
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06005 * For conditions of distribution and use, see copyright notice in png.h
6 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
7 * Copyright (c) 1996, 1997 Andreas Dilger
Glenn Randers-Pehrson2687fcc1998-01-07 20:54:20 -06008 * Copyright (c) 1998 Glenn Randers-Pehrson
9 * January 7, 1998
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -060010 *
11 * BETA NOTICE:
12 * This is a beta version. It reads and writes valid files on the
13 * platforms I have, and has had a wide testing program. You may
14 * have to modify the includes below to get it to work on your
15 * system, and you may have to supply the correct compiler flags in
16 * the makefile if you can't find a makefile suitable for your
17 * operating system/compiler combination. Read libpng.txt for more
18 * information, including how to contact the authors if you have any
19 * problems, or if you want your compiler/platform to be supported in
20 * the next official libpng release.
21 *
22 * See libpng.txt for more information. The PNG specification is available
23 * as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
24 * and as a W3C Recommendation <http://www.w3.org/pub/WWW/TR/REC.png.html>
25 *
26 * Contributing Authors:
27 * John Bowler
28 * Sam Bushell
29 * Kevin Bracey
30 * Andreas Dilger
31 * Magnus Holmgren
32 * Tom Lane
33 * Dave Martindale
34 * Glenn Randers-Pehrson
35 * Greg Roelofs
36 * Guy Eric Schalnat
37 * Paul Schmidt
38 * Tom Tanner
39 * Tim Wegner
40 *
41 * The contributing authors would like to thank all those who helped
42 * with testing, bug fixes, and patience. This wouldn't have been
43 * possible without all of you.
44 *
45 * Thanks to Frank J. T. Wojcik for helping with the documentation.
46 *
47 * The PNG Reference Library is supplied "AS IS". The Contributing Authors
48 * and Group 42, Inc. disclaim all warranties, expressed or implied,
49 * including, without limitation, the warranties of merchantability and of
50 * fitness for any purpose. The Contributing Authors and Group 42, Inc.
51 * assume no liability for direct, indirect, incidental, special, exemplary,
52 * or consequential damages, which may result from the use of the PNG
53 * Reference Library, even if advised of the possibility of such damage.
54 *
55 * Permission is hereby granted to use, copy, modify, and distribute this
56 * source code, or portions hereof, for any purpose, without fee, subject
57 * to the following restrictions:
58 * 1. The origin of this source code must not be misrepresented.
59 * 2. Altered versions must be plainly marked as such and must not be
60 * misrepresented as being the original source.
61 * 3. This Copyright notice may not be removed or altered from any source or
62 * altered source distribution.
63 *
64 * The Contributing Authors and Group 42, Inc. specifically permit, without
65 * fee, and encourage the use of this source code as a component to
66 * supporting the PNG file format in commercial products. If you use this
67 * source code in a product, acknowledgment is not required but would be
68 * appreciated.
69 */
Guy Schalnat0d580581995-07-20 02:43:20 -050070
71#ifndef _PNG_H
72#define _PNG_H
73
Andreas Dilger02ad0ef1997-01-17 01:34:35 -060074#ifdef __cplusplus
75extern "C" {
Andreas Dilger47a0c421997-05-16 02:46:07 -050076#endif /* __cplusplus */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -060077
Guy Schalnat0d580581995-07-20 02:43:20 -050078/* This is not the place to learn how to use libpng. The file libpng.txt
Andreas Dilger47a0c421997-05-16 02:46:07 -050079 * describes how to use libpng, and the file example.c summarizes it
80 * with some code on which to build. This file is useful for looking
81 * at the actual function definitions and structure components.
82 */
Guy Schalnat0d580581995-07-20 02:43:20 -050083
Guy Schalnat0d580581995-07-20 02:43:20 -050084/* include the compression library's header */
85#include "zlib.h"
86
Guy Schalnat51f0eb41995-09-26 05:22:39 -050087/* include all user configurable info */
88#include "pngconf.h"
Guy Schalnat0d580581995-07-20 02:43:20 -050089
Andreas Dilger47a0c421997-05-16 02:46:07 -050090/* This file is arranged in several sections. The first section contains
91 * structure and type definitions. The second section contains the external
92 * library functions, while the third has the internal library functions,
93 * which applications aren't expected to use directly.
94 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -050095
Andreas Dilger47a0c421997-05-16 02:46:07 -050096/* Version information for png.h - this should match the version in png.c */
Glenn Randers-Pehrson2687fcc1998-01-07 20:54:20 -060097#define PNG_LIBPNG_VER_STRING "0.97"
Guy Schalnat51f0eb41995-09-26 05:22:39 -050098
Andreas Dilger47a0c421997-05-16 02:46:07 -050099/* careful here. At one time, I wanted to use 082, but that would be octal.
100 * Version 1.0 will be 100 here, etc.
101 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600102#define PNG_LIBPNG_VER 97
Andreas Dilger47a0c421997-05-16 02:46:07 -0500103
104/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500105#ifndef PNG_NO_EXTERN
Andreas Dilger47a0c421997-05-16 02:46:07 -0500106/* Version information for C files, stored in png.c. This had better match
107 * the version above.
108 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500109extern char png_libpng_ver[];
Guy Schalnat0d580581995-07-20 02:43:20 -0500110
Glenn Randers-Pehrson2687fcc1998-01-07 20:54:20 -0600111/*
112 * Note about libpng version numbers:
113 *
114 * Due to various miscommunications, unforeseen code incompatibilities
115 * and occasional factors outside the authors' control, version numbering
116 * on the library has not always been consistent and straightforward.
117 * The following table summarizes matters since version 0.89c, which was
118 * the first widely used release:
119 *
120 * source png.h shared-lib
121 * version string version
122 * ------- ------ ----------
123 * 0.89c ("1.0 beta 3") 0.89 1.0.89
124 * 0.90 ("1.0 beta 4") 0.90 0.90 [should have been 2.0.90]
125 * 0.95 ("1.0 beta 5") 0.95 0.95 [should have been 2.0.95]
126 * 0.96 ("1.0 beta 6") 0.96 0.96 [should have been 2.0.96]
127 * 0.97b ("1.00.97 beta 7") 1.00.97 1.0.0 [should have been 2.0.97]
128 * 0.97c 0.97 2.0.97
129 * 0.98 0.98 2.0.98
130 * 0.99 0.99 2.0.99
131 * 1.0 1.00 2.1.0
132 *
133 * Henceforth the source version will match the shared-library minor
134 * and patch numbers; the shared-library major version number will be
135 * used for changes in backward compatibility, as it is intended.
136 */
137
Andreas Dilger47a0c421997-05-16 02:46:07 -0500138/* Structures to facilitate easy interlacing. See png.c for more details */
139extern int FARDATA png_pass_start[];
140extern int FARDATA png_pass_inc[];
141extern int FARDATA png_pass_ystart[];
142extern int FARDATA png_pass_yinc[];
143extern int FARDATA png_pass_mask[];
144extern int FARDATA png_pass_dsp_mask[];
145/* These aren't currently used. If you need them, see png.c for more details
146extern int FARDATA png_pass_width[];
147extern int FARDATA png_pass_height[];
148*/
149#endif /* PNG_NO_EXTERN */
150
151/* Three color definitions. The order of the red, green, and blue, (and the
152 * exact size) is not important, although the size of the fields need to
153 * be png_byte or png_uint_16 (as defined below).
154 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500155typedef struct png_color_struct
156{
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600157 png_byte red;
Guy Schalnat0d580581995-07-20 02:43:20 -0500158 png_byte green;
159 png_byte blue;
160} png_color;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500161typedef png_color FAR * png_colorp;
162typedef png_color FAR * FAR * png_colorpp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500163
164typedef struct png_color_16_struct
165{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500166 png_byte index; /* used for palette files */
167 png_uint_16 red; /* for use in red green blue files */
Guy Schalnat0d580581995-07-20 02:43:20 -0500168 png_uint_16 green;
169 png_uint_16 blue;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500170 png_uint_16 gray; /* for use in grayscale files */
Guy Schalnat0d580581995-07-20 02:43:20 -0500171} png_color_16;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500172typedef png_color_16 FAR * png_color_16p;
173typedef png_color_16 FAR * FAR * png_color_16pp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500174
175typedef struct png_color_8_struct
176{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500177 png_byte red; /* for use in red green blue files */
Guy Schalnat0d580581995-07-20 02:43:20 -0500178 png_byte green;
179 png_byte blue;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500180 png_byte gray; /* for use in grayscale files */
Guy Schalnat0d580581995-07-20 02:43:20 -0500181 png_byte alpha; /* for alpha channel files */
182} png_color_8;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500183typedef png_color_8 FAR * png_color_8p;
184typedef png_color_8 FAR * FAR * png_color_8pp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500185
Andreas Dilger47a0c421997-05-16 02:46:07 -0500186/* png_text holds the text in a PNG file, and whether they are compressed
187 in the PNG file or not. The "text" field points to a regular C string. */
Guy Schalnat0d580581995-07-20 02:43:20 -0500188typedef struct png_text_struct
189{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500190 int compression; /* compression value, see PNG_TEXT_COMPRESSION_ */
191 png_charp key; /* keyword, 1-79 character description of "text" */
192 png_charp text; /* comment, may be an empty string (ie "") */
193 png_size_t text_length; /* length of "text" field */
Guy Schalnat0d580581995-07-20 02:43:20 -0500194} png_text;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500195typedef png_text FAR * png_textp;
196typedef png_text FAR * FAR * png_textpp;
197
198/* Supported compression types for text in PNG files (tEXt, and zTXt).
199 * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
200#define PNG_TEXT_COMPRESSION_NONE_WR -3
201#define PNG_TEXT_COMPRESSION_zTXt_WR -2
202#define PNG_TEXT_COMPRESSION_NONE -1
203#define PNG_TEXT_COMPRESSION_zTXt 0
204#define PNG_TEXT_COMPRESSION_LAST 1 /* Not a valid value */
Guy Schalnat0d580581995-07-20 02:43:20 -0500205
206/* png_time is a way to hold the time in an machine independent way.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600207 * Two conversions are provided, both from time_t and struct tm. There
208 * is no portable way to convert to either of these structures, as far
209 * as I know. If you know of a portable way, send it to me. As a side
210 * note - PNG is Year 2000 compliant!
211 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500212typedef struct png_time_struct
213{
214 png_uint_16 year; /* full year, as in, 1995 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500215 png_byte month; /* month of year, 1 - 12 */
216 png_byte day; /* day of month, 1 - 31 */
217 png_byte hour; /* hour of day, 0 - 23 */
218 png_byte minute; /* minute of hour, 0 - 59 */
219 png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
Guy Schalnat0d580581995-07-20 02:43:20 -0500220} png_time;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500221typedef png_time FAR * png_timep;
222typedef png_time FAR * FAR * png_timepp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500223
Andreas Dilger47a0c421997-05-16 02:46:07 -0500224/* png_info is a structure that holds the information in a PNG file so
225 * that the application can find out the characteristics of the image.
226 * If you are reading the file, this structure will tell you what is
227 * in the PNG file. If you are writing the file, fill in the information
228 * you want to put into the PNG file, then call png_write_info().
229 * The names chosen should be very close to the PNG specification, so
230 * consult that document for information about the meaning of each field.
231 *
232 * With libpng < 0.95, it was only possible to directly set and read the
233 * the values in the png_info_struct, which meant that the contents and
234 * order of the values had to remain fixed. With libpng 0.95 and later,
235 * however, * there are now functions which abstract the contents of
236 * png_info_struct from the application, so this makes it easier to use
237 * libpng with dynamic libraries, and even makes it possible to use
238 * libraries that don't have all of the libpng ancillary chunk-handing
239 * functionality.
240 *
241 * In any case, the order of the parameters in png_info_struct should NOT
242 * be changed for as long as possible to keep compatibility with applications
243 * that use the old direct-access method with png_info_struct.
244 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500245typedef struct png_info_struct
246{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500247 /* the following are necessary for every PNG file */
248 png_uint_32 width; /* width of image in pixels (from IHDR) */
249 png_uint_32 height; /* height of image in pixels (from IHDR) */
250 png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
251 png_size_t rowbytes; /* bytes needed to hold an untransformed row */
252 png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
253 png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
254 png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
255 png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
256 png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
257 png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
258 png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
259 png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500260
Andreas Dilger47a0c421997-05-16 02:46:07 -0500261 /* The following is informational only on read, and not used on writes. */
262 png_byte channels; /* number of data channels per pixel (1, 3, 4)*/
263 png_byte pixel_depth; /* number of bits per pixel */
264 png_byte spare_byte; /* to align the data, and for future use */
265 png_byte signature[8]; /* magic bytes read by libpng from start of file */
266
267 /* The rest of the data is optional. If you are reading, check the
268 * valid field to see if the information in these are valid. If you
269 * are writing, set the valid field to those chunks you want written,
270 * and initialize the appropriate fields below.
271 */
272
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500273#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500274 /* 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 */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600280
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
Guy Schalnate5a37791996-06-05 15:50:50 -0500287#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
288 defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500289 /* 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 */
Guy Schalnate5a37791996-06-05 15:50:50 -0500300#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500301 /* 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 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500306#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500307 /* 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 */
Guy Schalnate5a37791996-06-05 15:50:50 -0500315#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500316 /* 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 */
Guy Schalnate5a37791996-06-05 15:50:50 -0500328#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500329 /* The bKGD chunk gives the suggested image background color if the
330 * display program does not have its own background color and the image
331 * is needs to composited onto a background before display. The colors
332 * in "background" are normally in the same color space/depth as the
333 * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
334 */
335 png_color_16 background;
336#endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500337#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500338 /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
339 * and downwards from the top-left corner of the display, page, or other
340 * application-specific co-ordinate space. See the PNG_OFFSET_ defines
341 * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
342 */
Guy Schalnate5a37791996-06-05 15:50:50 -0500343 png_uint_32 x_offset; /* x offset on page */
344 png_uint_32 y_offset; /* y offset on page */
345 png_byte offset_unit_type; /* offset units type */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500346#endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500347#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500348 /* The pHYs chunk gives the physical pixel density of the image for
349 * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
350 * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
351 */
352 png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
353 png_uint_32 y_pixels_per_unit; /* vertical pixel density */
354 png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
355#endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500356#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500357 /* The hIST chunk contains the relative frequency or importance of the
358 * various palette entries, so that a viewer can intelligently select a
359 * reduced-color palette, if required. Data is an array of "num_palette"
360 * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
361 * is non-zero.
362 */
363 png_uint_16p hist;
364#endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500365#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500366 /* The cHRM chunk describes the CIE color characteristics of the monitor
367 * on which the PNG was created. This data allows the viewer to do gamut
368 * mapping of the input image to ensure that the viewer sees the same
369 * colors in the image as the creator. Values are in the range
370 * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
371 */
372 float x_white;
Guy Schalnat0d580581995-07-20 02:43:20 -0500373 float y_white;
374 float x_red;
375 float y_red;
376 float x_green;
377 float y_green;
378 float x_blue;
379 float y_blue;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500380#endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
381#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
382 /* The pCAL chunk describes a transformation between the stored pixel
383 * values and original physcical data values used to create the image.
384 * The integer range [0, 2^bit_depth - 1] maps to the floating-point
385 * range given by [pcal_X0, pcal_X1], and are further transformed by a
386 * (possibly non-linear) transformation function given by "pcal_type"
387 * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
388 * defines below, and the PNG-Group's Scientific Visualization extension
389 * chunks document png-scivis-19970203 for a complete description of the
390 * transformations and how they should be implemented, as well as the
391 * png-extensions document for a description of the ASCII parameter
392 * strings. Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
393 */
394 png_charp pcal_purpose; /* pCAL chunk description string */
395 png_int_32 pcal_X0; /* minimum value */
396 png_int_32 pcal_X1; /* maximum value */
397 png_charp pcal_units; /* Latin-1 string giving physical units */
398 png_charpp pcal_params; /* ASCII strings containing parameter values */
399 png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
400 png_byte pcal_nparams; /* number of parameters given in pcal_params */
401#endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500402} png_info;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500403typedef png_info FAR * png_infop;
404typedef png_info FAR * FAR * png_infopp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500405
Andreas Dilger47a0c421997-05-16 02:46:07 -0500406/* These describe the color_type field in png_info. */
Guy Schalnat0d580581995-07-20 02:43:20 -0500407/* color type masks */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500408#define PNG_COLOR_MASK_PALETTE 1
409#define PNG_COLOR_MASK_COLOR 2
410#define PNG_COLOR_MASK_ALPHA 4
Guy Schalnat0d580581995-07-20 02:43:20 -0500411
412/* color types. Note that not all combinations are legal */
Guy Schalnate5a37791996-06-05 15:50:50 -0500413#define PNG_COLOR_TYPE_GRAY 0
Andreas Dilger47a0c421997-05-16 02:46:07 -0500414#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
415#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
416#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
Guy Schalnat0d580581995-07-20 02:43:20 -0500417#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
418
Andreas Dilger47a0c421997-05-16 02:46:07 -0500419/* This is for compression type. PNG 1.0 only defines the single type. */
420#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
421#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
422
423/* This is for filter type. PNG 1.0 only defines the single type. */
424#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
425#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
426
427/* These are for the interlacing type. These values should NOT be changed. */
428#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */
429#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */
430#define PNG_INTERLACE_LAST 2 /* Not a valid value */
431
432/* These are for the oFFs chunk. These values should NOT be changed. */
433#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */
434#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */
435#define PNG_OFFSET_LAST 2 /* Not a valid value */
436
437/* These are for the pCAL chunk. These values should NOT be changed. */
438#define PNG_EQUATION_LINEAR 0 /* Linear transformation */
439#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */
440#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */
441#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */
442#define PNG_EQUATION_LAST 4 /* Not a valid value */
443
444/* These are for the pHYs chunk. These values should NOT be changed. */
445#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */
446#define PNG_RESOLUTION_METER 1 /* pixels/meter */
447#define PNG_RESOLUTION_LAST 2 /* Not a valid value */
448
449/* These determine if an ancillary chunk's data has been successfully read
450 * from the PNG header, or if the application has filled in the corresponding
451 * data in the info_struct to be written into the output file. The values
452 * of the PNG_INFO_<chunk> defines should NOT be changed.
453 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500454#define PNG_INFO_gAMA 0x0001
455#define PNG_INFO_sBIT 0x0002
456#define PNG_INFO_cHRM 0x0004
457#define PNG_INFO_PLTE 0x0008
458#define PNG_INFO_tRNS 0x0010
459#define PNG_INFO_bKGD 0x0020
460#define PNG_INFO_hIST 0x0040
461#define PNG_INFO_pHYs 0x0080
462#define PNG_INFO_oFFs 0x0100
463#define PNG_INFO_tIME 0x0200
Andreas Dilger47a0c421997-05-16 02:46:07 -0500464#define PNG_INFO_pCAL 0x0400
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600465#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
Guy Schalnat0d580581995-07-20 02:43:20 -0500466
Andreas Dilger47a0c421997-05-16 02:46:07 -0500467/* This is used for the transformation routines, as some of them
468 * change these values for the row. It also should enable using
469 * the routines for other purposes.
470 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500471typedef struct png_row_info_struct
472{
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600473 png_uint_32 width; /* width of row */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500474 png_size_t rowbytes; /* number of bytes in row */
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600475 png_byte color_type; /* color type of row */
476 png_byte bit_depth; /* bit depth of row */
477 png_byte channels; /* number of channels (1, 2, 3, or 4) */
478 png_byte pixel_depth; /* bits per pixel (depth * channels) */
Guy Schalnat0d580581995-07-20 02:43:20 -0500479} png_row_info;
480
Andreas Dilger47a0c421997-05-16 02:46:07 -0500481typedef png_row_info FAR * png_row_infop;
482typedef png_row_info FAR * FAR * png_row_infopp;
Guy Schalnat0f716451995-11-28 11:22:13 -0600483
484/* These are the function types for the I/O functions, and the functions which
Guy Schalnate5a37791996-06-05 15:50:50 -0500485 * modify the default I/O functions to user I/O functions. The png_error_ptr
Guy Schalnat0f716451995-11-28 11:22:13 -0600486 * type should match that of user supplied warning and error functions, while
487 * the png_rw_ptr type should match that of the user read/write data functions.
488 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600489typedef struct png_struct_def png_struct;
490typedef png_struct FAR * png_structp;
Guy Schalnat0f716451995-11-28 11:22:13 -0600491
Guy Schalnate5a37791996-06-05 15:50:50 -0500492typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp));
Andreas Dilger47a0c421997-05-16 02:46:07 -0500493typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
Guy Schalnat6d764711995-12-19 03:22:19 -0600494typedef void (*png_flush_ptr) PNGARG((png_structp));
Guy Schalnat69b14481996-01-10 02:56:49 -0600495#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
Guy Schalnat6d764711995-12-19 03:22:19 -0600496typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
497typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop));
498typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600499 png_uint_32, int));
Andreas Dilger47a0c421997-05-16 02:46:07 -0500500#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
Guy Schalnat6d764711995-12-19 03:22:19 -0600501
Andreas Dilger47a0c421997-05-16 02:46:07 -0500502/* The structure that holds the information to read and write PNG files.
503 * The only people who need to care about what is inside of this are the
504 * people who will be modifying the library for their own special needs.
505 * It should NOT be accessed directly by an application, except to store
506 * the jmp_buf.
507 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600508
Guy Schalnat69b14481996-01-10 02:56:49 -0600509struct png_struct_def
Guy Schalnat0d580581995-07-20 02:43:20 -0500510{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500511 jmp_buf jmpbuf; /* used in png_error */
Guy Schalnate5a37791996-06-05 15:50:50 -0500512
Andreas Dilger47a0c421997-05-16 02:46:07 -0500513 png_error_ptr error_fn; /* function for printing errors and aborting */
514 png_error_ptr warning_fn; /* function for printing warnings */
Guy Schalnate5a37791996-06-05 15:50:50 -0500515 png_voidp error_ptr; /* user supplied struct for error functions */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500516 png_rw_ptr write_data_fn; /* function for writing output data */
517 png_rw_ptr read_data_fn; /* function for reading input data */
518 png_voidp io_ptr; /* ptr to application struct for I/O functions*/
Guy Schalnate5a37791996-06-05 15:50:50 -0500519
Andreas Dilger47a0c421997-05-16 02:46:07 -0500520 png_uint_32 mode; /* tells us whre we are in the PNG file */
521 png_uint_32 flags; /* flags indicating various things to libpng */
Guy Schalnate5a37791996-06-05 15:50:50 -0500522 png_uint_32 transformations; /* which transformations to perform */
523
Andreas Dilger47a0c421997-05-16 02:46:07 -0500524 z_stream zstream; /* pointer to decompression structure (below) */
525 png_bytep zbuf; /* buffer for zlib */
526 png_size_t zbuf_size; /* size of zbuf */
527 int zlib_level; /* holds zlib compression level */
528 int zlib_method; /* holds zlib compression method */
529 int zlib_window_bits; /* holds zlib compression window bits */
530 int zlib_mem_level; /* holds zlib compression memory level */
531 int zlib_strategy; /* holds zlib compression strategy */
Guy Schalnate5a37791996-06-05 15:50:50 -0500532
Andreas Dilger47a0c421997-05-16 02:46:07 -0500533 png_uint_32 width; /* width of image in pixels */
534 png_uint_32 height; /* height of image in pixels */
535 png_uint_32 num_rows; /* number of rows in current pass */
536 png_uint_32 usr_width; /* width of row at start of write */
537 png_size_t rowbytes; /* size of row in bytes */
538 png_size_t irowbytes; /* size of current interlaced row in bytes */
539 png_uint_32 iwidth; /* width of current interlaced row in pixels */
540 png_uint_32 row_number; /* current row in interlace pass */
541 png_bytep prev_row; /* buffer to save previous (unfiltered) row */
542 png_bytep row_buf; /* buffer to save current (unfiltered) row */
543 png_bytep sub_row; /* buffer to save "sub" row when filtering */
544 png_bytep up_row; /* buffer to save "up" row when filtering */
545 png_bytep avg_row; /* buffer to save "avg" row when filtering */
546 png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
547 png_row_info row_info; /* used for transformation routines */
Guy Schalnate5a37791996-06-05 15:50:50 -0500548
Andreas Dilger47a0c421997-05-16 02:46:07 -0500549 png_uint_32 idat_size; /* current IDAT size for read */
550 png_uint_32 crc; /* current chunk CRC value */
551 png_colorp palette; /* palette from the input file */
552 png_uint_16 num_palette; /* number of color entries in palette */
553 png_uint_16 num_trans; /* number of transparency values */
554 png_byte chunk_name[5]; /* null-terminated name of current chunk */
555 png_byte compression; /* file compression type (always 0) */
556 png_byte filter; /* file filter type (always 0) */
557 png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
558 png_byte pass; /* current interlace pass (0 - 6) */
559 png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
560 png_byte color_type; /* color type of file */
561 png_byte bit_depth; /* bit depth of file */
562 png_byte usr_bit_depth; /* bit depth of users row */
563 png_byte pixel_depth; /* number of bits per pixel */
564 png_byte channels; /* number of channels in file */
565 png_byte usr_channels; /* channels at start of write */
566 png_byte sig_bytes; /* magic bytes read/written from start of file */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600567
Guy Schalnate5a37791996-06-05 15:50:50 -0500568#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500569 png_byte filler; /* filler byte for 24->32-bit pixel expansion */
570#endif /* PNG_READ_FILLER_SUPPORTED */
571#if defined(PNG_READ_bKGD_SUPPORTED)
Guy Schalnate5a37791996-06-05 15:50:50 -0500572 png_byte background_gamma_type;
573 float background_gamma;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500574 png_color_16 background; /* background color in screen gamma space */
Guy Schalnate5a37791996-06-05 15:50:50 -0500575#if defined(PNG_READ_GAMMA_SUPPORTED)
576 png_color_16 background_1; /* background normalized to gamma 1.0 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500577#endif /* PNG_READ_GAMMA && PNG_READ_bKGD_SUPPORTED */
578#endif /* PNG_READ_bKGD_SUPPORTED */
Guy Schalnat6d764711995-12-19 03:22:19 -0600579#if defined(PNG_WRITE_FLUSH_SUPPORTED)
Guy Schalnate5a37791996-06-05 15:50:50 -0500580 png_flush_ptr output_flush_fn;/* Function for flushing output */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500581 png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
582 png_uint_32 flush_rows; /* number of rows written since last flush */
Guy Schalnat6d764711995-12-19 03:22:19 -0600583#endif /* PNG_WRITE_FLUSH_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500584#if defined(PNG_READ_GAMMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500585 int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
586 float gamma; /* file gamma value */
587 float display_gamma; /* display gamma value */
588#endif /* PNG_READ_GAMMA_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500589#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500590 png_bytep gamma_table; /* gamma table for 8 bit depth files */
591 png_bytep gamma_from_1; /* converts from 1.0 to screen */
592 png_bytep gamma_to_1; /* converts from file to 1.0 */
Guy Schalnate5a37791996-06-05 15:50:50 -0500593 png_uint_16pp gamma_16_table; /* gamma table for 16 bit depth files */
594 png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
595 png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500596#endif /* PNG_READ_GAMMA_SUPPORTED || PNG_WRITE_GAMMA_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500597#if defined(PNG_READ_GAMMA_SUPPORTED) || defined (PNG_READ_sBIT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500598 png_color_8 sig_bit; /* significant bits in each available channel */
599#endif /* PNG_READ_GAMMA_SUPPORTED || PNG_READ_sBIT_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500600#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500601 png_color_8 shift; /* shift for significant bit tranformation */
602#endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
603#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
604 png_bytep trans; /* transparency values for paletted files */
605 png_color_16 trans_values; /* transparency values for non-paletted files */
606#endif /* PNG_READ_tRNS_SUPPORTED || PNG_READ_BACKGROUND_SUPPORTED */
Guy Schalnat6d764711995-12-19 03:22:19 -0600607#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500608 png_progressive_info_ptr info_fn; /* called after header data fully read */
609 png_progressive_row_ptr row_fn; /* called after each row is decoded */
610 png_progressive_end_ptr end_fn; /* called after image is complete */
611 png_bytep save_buffer_ptr; /* current location in save_buffer */
612 png_bytep save_buffer; /* buffer for previously read data */
613 png_bytep current_buffer_ptr; /* current location in current_buffer */
614 png_bytep current_buffer; /* buffer for recently used data */
615 png_uint_32 push_length; /* size of current input chunk */
616 png_uint_32 skip_length; /* bytes to skip in input data */
617 png_size_t save_buffer_size; /* amount of data now in save_buffer */
618 png_size_t save_buffer_max; /* total size of save_buffer */
619 png_size_t buffer_size; /* total amount of available input data */
620 png_size_t current_buffer_size; /* amount of data now in current_buffer */
621 int process_mode; /* what push library is currently doing */
622 int cur_palette; /* current push library palette index */
Guy Schalnat6d764711995-12-19 03:22:19 -0600623#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500624 png_size_t current_text_size; /* current size of text input data */
625 png_size_t current_text_left; /* how much text left to read in input */
626 png_charp current_text; /* current text chunk buffer */
627 png_charp current_text_ptr; /* current location in current_text */
628#endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_tEXt/zTXt_SUPPORTED */
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600629#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
630/* for the Borland special 64K segment handler */
631 png_bytepp offset_table_ptr;
632 png_bytep offset_table;
633 png_uint_16 offset_table_number;
634 png_uint_16 offset_table_count;
635 png_uint_16 offset_table_count_free;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500636#endif /* PNG_PROGRESSIVE_READ_SUPPORTED&&__TURBOC__&&!_Windows&&!__FLAT__ */
Guy Schalnate5a37791996-06-05 15:50:50 -0500637#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500638#if defined(PNG_READ_DITHER_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500639 png_bytep palette_lookup; /* lookup table for dithering */
640 png_bytep dither_index; /* index translation for palette files */
641 png_uint_16p hist; /* histogram */
642#endif /* PNG_READ_DITHER_SUPPORTED */
643#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
644 png_byte heuristic_method; /* heuristic for row filter selection */
645 png_byte num_prev_filters; /* number of weights for previous rows */
646 png_bytep prev_filters; /* filter type(s) of previous row(s) */
647 png_uint_16p filter_weights; /* weight(s) for previous line(s) */
648 png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
649 png_uint_16p filter_costs; /* relative filter calculation cost */
650 png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
651#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600652#if defined(PNG_TIME_RFC1152_SUPPORTED)
653 png_charp time_buffer; /* String to hold RFC 1152 time text */
654#endif /* PNG_TIME_RFC1152_SUPPORTED */
Guy Schalnat0f716451995-11-28 11:22:13 -0600655};
Guy Schalnat0d580581995-07-20 02:43:20 -0500656
Andreas Dilger47a0c421997-05-16 02:46:07 -0500657typedef png_struct FAR * FAR * png_structpp;
Guy Schalnat6d764711995-12-19 03:22:19 -0600658
Guy Schalnat0d580581995-07-20 02:43:20 -0500659/* Here are the function definitions most commonly used. This is not
Andreas Dilger47a0c421997-05-16 02:46:07 -0500660 * the place to find out how to use libpng. See libpng.txt for the
661 * full explanation, see example.c for the summary. This just provides
662 * a simple one line of the use of each function.
663 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500664
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600665/* Tell lib we have already handled the first <num_bytes> magic bytes.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500666 * Handling more than 8 bytes from the beginning of the file is an error.
667 */
668extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
669 int num_bytes));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600670
Andreas Dilger47a0c421997-05-16 02:46:07 -0500671/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
672 * PNG file. Returns zero if the supplied bytes match the 8-byte PNG
673 * signature, and non-zero otherwise. Having num_to_check == 0 or
674 * start > 7 will always fail (ie return non-zero).
675 */
676extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
677 png_size_t num_to_check));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600678
Andreas Dilger47a0c421997-05-16 02:46:07 -0500679/* Simple signature checking function. This is the same as calling
680 * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
681 */
682extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
Guy Schalnat0d580581995-07-20 02:43:20 -0500683
Andreas Dilger47a0c421997-05-16 02:46:07 -0500684/* Allocate and initialize png_ptr struct for reading, and any other memory. */
685extern PNG_EXPORT(png_structp,png_create_read_struct)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600686 PNGARG((png_const_charp user_png_ver, voidp error_ptr,
687 png_error_ptr error_fn, png_error_ptr warn_fn));
Guy Schalnat0d580581995-07-20 02:43:20 -0500688
Andreas Dilger47a0c421997-05-16 02:46:07 -0500689/* Allocate and initialize png_ptr struct for reading, and any other memory */
690extern PNG_EXPORT(png_structp,png_create_write_struct)
Guy Schalnate5a37791996-06-05 15:50:50 -0500691 PNGARG((png_const_charp user_png_ver, voidp error_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600692 png_error_ptr error_fn, png_error_ptr warn_fn));
Guy Schalnate5a37791996-06-05 15:50:50 -0500693
Andreas Dilger47a0c421997-05-16 02:46:07 -0500694/* Allocate and initialize the info structure */
695extern PNG_EXPORT(png_infop,png_create_info_struct)
696 PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500697
Andreas Dilger47a0c421997-05-16 02:46:07 -0500698/* Initialize the info structure (old interface - NOT DLL EXPORTED) */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600699extern void png_info_init PNGARG((png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500700
Andreas Dilger47a0c421997-05-16 02:46:07 -0500701/* Writes all the PNG information before the image. */
702extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
703 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500704
705/* read the information before the actual image data. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500706extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
707 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500708
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600709#if defined(PNG_TIME_RFC1152_SUPPORTED)
710extern PNG_EXPORT(png_charp,png_convert_to_rfc1152)
711 PNGARG((png_structp png_ptr, png_timep ptime));
712#endif /* PNG_TIME_RFC1152_SUPPORTED */
713
Guy Schalnat0f716451995-11-28 11:22:13 -0600714#if defined(PNG_WRITE_tIME_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500715/* convert from a struct tm to png_time */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500716extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
Guy Schalnate5a37791996-06-05 15:50:50 -0500717 struct tm FAR * ttime));
Guy Schalnat0d580581995-07-20 02:43:20 -0500718
719/* convert from time_t to png_time. Uses gmtime() */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500720extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
721 time_t ttime));
722#endif /* PNG_WRITE_tIME_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500723
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500724#if defined(PNG_READ_EXPAND_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500725/* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha if available. */
726extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
727#endif /* PNG_READ_EXPAND_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500728
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500729#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500730/* Use blue, green, red order for pixels. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500731extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
732#endif /* PNG_READ_BGR_SUPPORTED || PNG_WRITE_BGR_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500733
Guy Schalnat69b14481996-01-10 02:56:49 -0600734#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
735/* Expand the grayscale to 24 bit RGB if necessary. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500736extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
737#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
Guy Schalnat69b14481996-01-10 02:56:49 -0600738
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600739#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
740/* Reduce RGB to grayscale. (Not yet implemented) */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500741extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr));
742#endif /* PNG_READ_RGB_TO_GRAY_SUPPORTED */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600743
Andreas Dilger47a0c421997-05-16 02:46:07 -0500744extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600745 png_colorp palette));
746
Andreas Dilger47a0c421997-05-16 02:46:07 -0500747#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
748extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
749#endif /* PNG_READ_STRIP_ALPHA_SUPPORTED */
750
751#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
752 defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
753extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
754#endif /* PNG_READ_SWAP_ALPHA_SUPPORTED || PNG_WRITE_SWAP_ALPHA_SUPPORTED */
755
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500756#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500757/* Add a filler byte to 24-bit RGB images. */
758extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
759 png_uint_32 filler, int flags));
760
761/* The values of the PNG_FILLER_ defines should NOT be changed */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500762#define PNG_FILLER_BEFORE 0
763#define PNG_FILLER_AFTER 1
Andreas Dilger47a0c421997-05-16 02:46:07 -0500764#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500765
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500766#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500767/* Swap bytes in 16 bit depth files. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500768extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
769#endif /* PNG_READ_SWAP_SUPPORTED || PNG_WRITE_SWAP_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500770
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500771#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500772/* Use 1 byte per pixel in 1, 2, or 4 bit depth files. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500773extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
774#endif /* PNG_READ_PACK_SUPPORTED || PNG_WRITE_PACK_SUPPORTED */
775
776#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPOR)
777/* Swap packing order of pixels in bytes. */
778extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
779#endif /* PNG_READ_PACKSWAP_SUPPORTED || PNG_WRITE_PACKSWAP_SUPPOR */
Guy Schalnat0d580581995-07-20 02:43:20 -0500780
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500781#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500782/* Converts files to legal bit depths. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500783extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
Guy Schalnat6d764711995-12-19 03:22:19 -0600784 png_color_8p true_bits));
Andreas Dilger47a0c421997-05-16 02:46:07 -0500785#endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500786
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500787#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
788 defined(PNG_WRITE_INTERLACING_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500789/* Have the code handle the interlacing. Returns the number of passes. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500790extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
791#endif /* PNG_READ_INTERLACING_SUPPORTED || PNG_WRITE_INTERLACING_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500792
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500793#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500794/* Invert monocrome files */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500795extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
796#endif /* PNG_READ_INVERT_SUPPORTED || PNG_WRITE_INVERT_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500797
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500798#if defined(PNG_READ_BACKGROUND_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500799/* Handle alpha and tRNS by replacing with a background color. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500800extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
801 png_color_16p background_color, int background_gamma_code,
802 int need_expand, double background_gamma));
Guy Schalnate5a37791996-06-05 15:50:50 -0500803#define PNG_BACKGROUND_GAMMA_UNKNOWN 0
804#define PNG_BACKGROUND_GAMMA_SCREEN 1
805#define PNG_BACKGROUND_GAMMA_FILE 2
806#define PNG_BACKGROUND_GAMMA_UNIQUE 3
Andreas Dilger47a0c421997-05-16 02:46:07 -0500807#endif /* PNG_READ_BACKGROUND_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500808
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500809#if defined(PNG_READ_16_TO_8_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500810/* strip the second byte of information from a 16 bit depth file. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500811extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
812#endif /* PNG_READ_16_TO_8_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500813
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500814#if defined(PNG_READ_DITHER_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500815/* Turn on dithering, and reduce the palette to the number of colors available. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500816extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
817 png_colorp palette, int num_palette, int maximum_colors,
818 png_uint_16p histogram, int full_dither));
819#endif /* PNG_READ_DITHER_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500820
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500821#if defined(PNG_READ_GAMMA_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500822/* Handle gamma correction. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500823extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
824 double screen_gamma, double default_file_gamma));
825#endif /* PNG_READ_GAMMA_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500826
Guy Schalnat0f716451995-11-28 11:22:13 -0600827#if defined(PNG_WRITE_FLUSH_SUPPORTED)
828/* Set how many lines between output flushes - 0 for no flushing */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500829extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
Guy Schalnat0f716451995-11-28 11:22:13 -0600830
831/* Flush the current PNG output buffer */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500832extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
Guy Schalnat0f716451995-11-28 11:22:13 -0600833#endif /* PNG_WRITE_FLUSH_SUPPORTED */
834
Guy Schalnat0d580581995-07-20 02:43:20 -0500835/* optional update palette with requested transformations */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500836extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500837
838/* optional call to update the users info structure */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500839extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600840 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500841
842/* read a one or more rows of image data.*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500843extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
844 png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
Guy Schalnat0d580581995-07-20 02:43:20 -0500845
846/* read a row of data.*/
Andreas Dilger47a0c421997-05-16 02:46:07 -0500847extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600848 png_bytep row,
849 png_bytep display_row));
Guy Schalnat0d580581995-07-20 02:43:20 -0500850
851/* read the whole image into memory at once. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500852extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600853 png_bytepp image));
Guy Schalnat0d580581995-07-20 02:43:20 -0500854
855/* write a row of image data */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500856extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600857 png_bytep row));
Guy Schalnat0d580581995-07-20 02:43:20 -0500858
859/* write a few rows of image data */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500860extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
861 png_bytepp row, png_uint_32 num_rows));
Guy Schalnat0d580581995-07-20 02:43:20 -0500862
863/* write the image data */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500864extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
865 png_bytepp image));
Guy Schalnat0d580581995-07-20 02:43:20 -0500866
Andreas Dilger47a0c421997-05-16 02:46:07 -0500867/* writes the end of the PNG file. */
868extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
869 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500870
Andreas Dilger47a0c421997-05-16 02:46:07 -0500871/* read the end of the PNG file. */
872extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
873 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500874
Andreas Dilger47a0c421997-05-16 02:46:07 -0500875/* free any memory associated with the png_info_struct */
876extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600877 png_infopp info_ptr_ptr));
Guy Schalnate5a37791996-06-05 15:50:50 -0500878
Andreas Dilger47a0c421997-05-16 02:46:07 -0500879/* free any memory associated with the png_struct and the png_info_structs */
880extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
881 png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
Guy Schalnate5a37791996-06-05 15:50:50 -0500882
Andreas Dilger47a0c421997-05-16 02:46:07 -0500883/* free all memory used by the read (old method - NOT DLL EXPORTED) */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600884extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
885 png_infop end_info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500886
Andreas Dilger47a0c421997-05-16 02:46:07 -0500887/* free any memory associated with the png_struct and the png_info_structs */
888extern PNG_EXPORT(void,png_destroy_write_struct)
889 PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
Guy Schalnate5a37791996-06-05 15:50:50 -0500890
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600891/* free any memory used in info_ptr struct (old method - NOT DLL EXPORTED) */
892extern void png_write_destroy_info PNGARG((png_infop info_ptr));
893
Andreas Dilger47a0c421997-05-16 02:46:07 -0500894/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
Guy Schalnat6d764711995-12-19 03:22:19 -0600895extern void png_write_destroy PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500896
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600897/* set the libpng method of handling chunk CRC errors */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500898extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
899 int crit_action, int ancil_action));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600900
901/* Values for png_set_crc_action() to say how to handle CRC errors in
Andreas Dilger47a0c421997-05-16 02:46:07 -0500902 * ancillary and critical chunks, and whether to use the data contained
903 * therein. Note that it is impossible to "discard" data in a critical
904 * chunk. For versions prior to 0.90, the action was always error/quit,
905 * whereas in version 0.90 and later, the action for CRC errors in ancillary
906 * chunks is warn/discard. These values should NOT be changed.
907 *
908 * value action:critical action:ancillary
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600909 */
910#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */
911#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */
912#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */
913#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */
914#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
915#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
916
Andreas Dilger47a0c421997-05-16 02:46:07 -0500917/* These functions give the user control over the scan-line filtering in
918 * libpng and the compression methods used by zlib. These functions are
919 * mainly useful for testing, as the defaults should work with most users.
920 * Those users who are tight on memory or want faster performance at the
921 * expense of compression can modify them. See the compression library
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600922 * header file (zlib.h) for an explination of the compression functions.
923 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600924
Andreas Dilger47a0c421997-05-16 02:46:07 -0500925/* set the filtering method(s) used by libpng. Currently, the only valid
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600926 * value for "method" is 0.
927 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500928extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
Guy Schalnate5a37791996-06-05 15:50:50 -0500929 int filters));
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500930
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600931/* Flags for png_set_filter() to say which filters to use. The flags
Andreas Dilger47a0c421997-05-16 02:46:07 -0500932 * are chosen so that they don't conflict with real filter types
933 * below, in case they are supplied instead of the #defined constants.
934 * These values should NOT be changed.
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600935 */
936#define PNG_NO_FILTERS 0x00
937#define PNG_FILTER_NONE 0x08
938#define PNG_FILTER_SUB 0x10
939#define PNG_FILTER_UP 0x20
940#define PNG_FILTER_AVG 0x40
941#define PNG_FILTER_PAETH 0x80
942#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
943 PNG_FILTER_AVG | PNG_FILTER_PAETH)
944
Andreas Dilger47a0c421997-05-16 02:46:07 -0500945/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
946 * These defines should NOT be changed.
947 */
948#define PNG_FILTER_VALUE_NONE 0
949#define PNG_FILTER_VALUE_SUB 1
950#define PNG_FILTER_VALUE_UP 2
951#define PNG_FILTER_VALUE_AVG 3
952#define PNG_FILTER_VALUE_PAETH 4
953#define PNG_FILTER_VALUE_LAST 5
954
955#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
956/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
957 * defines, either the default (minimum-sum-of-absolute-differences), or
958 * the experimental method (weighted-minimum-sum-of-absolute-differences).
959 *
960 * Weights are factors >= 1.0, indicating how important it is to keep the
961 * filter type consistent between rows. Larger numbers mean the current
962 * filter is that many times as likely to be the same as the "num_weights"
963 * previous filters. This is cumulative for each previous row with a weight.
964 * There needs to be "num_weights" values in "filter_weights", or it can be
965 * NULL if the weights aren't being specified. Weights have no influence on
966 * the selection of the first row filter. Well chosen weights can (in theory)
967 * improve the compression for a given image.
968 *
969 * Costs are factors >= 1.0 indicating the relative decoding costs of a
970 * filter type. Higher costs indicate more decoding expense, and are
971 * therefore less likely to be selected over a filter with lower computational
972 * costs. There needs to be a value in "filter_costs" for each valid filter
973 * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
974 * setting the costs. Costs try to improve the speed of decompression without
975 * unduly increasing the compressed image size.
976 *
977 * A negative weight or cost indicates the default value is to be used, and
978 * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
979 * The default values for both weights and costs are currently 1.0, but may
980 * change if good general weighting/cost heuristics can be found. If both
981 * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
982 * to the UNWEIGHTED method, but with added encoding time/computation.
983 */
984extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
985 int heuristic_method, int num_weights, png_doublep filter_weights,
986 png_doublep filter_costs));
987#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
988
989/* Heuristic used for row filter selection. These defines should NOT be
990 * changed.
991 */
992#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
993#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
994#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
995#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
996
997/* Set the library compression level. Currently, valid values range from
998 * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
999 * (0 - no compression, 9 - "maximal" compression). Note that tests have
1000 * shown that zlib compression levels 3-6 usually perform as well as level 9
1001 * for PNG images, and do considerably fewer caclulations. In the future,
1002 * these values may not correspond directly to the zlib compression levels.
1003 */
1004extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001005 int level));
1006
Andreas Dilger47a0c421997-05-16 02:46:07 -05001007extern PNG_EXPORT(void,png_set_compression_mem_level)
1008 PNGARG((png_structp png_ptr, int mem_level));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001009
Andreas Dilger47a0c421997-05-16 02:46:07 -05001010extern PNG_EXPORT(void,png_set_compression_strategy)
1011 PNGARG((png_structp png_ptr, int strategy));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001012
Andreas Dilger47a0c421997-05-16 02:46:07 -05001013extern PNG_EXPORT(void,png_set_compression_window_bits)
1014 PNGARG((png_structp png_ptr, int window_bits));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001015
Andreas Dilger47a0c421997-05-16 02:46:07 -05001016extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001017 int method));
Guy Schalnat0d580581995-07-20 02:43:20 -05001018
Guy Schalnate5a37791996-06-05 15:50:50 -05001019/* These next functions are called for input/output, memory, and error
Andreas Dilger47a0c421997-05-16 02:46:07 -05001020 * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
1021 * and call standard C I/O routines such as fread(), fwrite(), and
1022 * fprintf(). These functions can be made to use other I/O routines
1023 * at run time for those applications that need to handle I/O in a
1024 * different manner by calling png_set_???_fn(). See libpng.txt for
1025 * more information.
1026 */
Guy Schalnat0d580581995-07-20 02:43:20 -05001027
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -06001028#if !defined(PNG_NO_STDIO)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001029/* Initialize the input/output for the PNG file to the default functions. */
1030extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, FILE *fp));
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -06001031#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001032
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001033/* Replace the (error and abort), and warning functions with user
Andreas Dilger47a0c421997-05-16 02:46:07 -05001034 * supplied functions. If no messages are to be printed you must still
1035 * write and use replacement functions. The replacement error_fn should
1036 * still do a longjmp to the last setjmp location if you are using this
1037 * method of error handling. If error_fn or warning_fn is NULL, the
1038 * default function will be used.
1039 */
1040extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
1041 png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
Guy Schalnat6d764711995-12-19 03:22:19 -06001042
Guy Schalnate5a37791996-06-05 15:50:50 -05001043/* Return the user pointer associated with the error functions */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001044extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06001045
1046/* Replace the default data output functions with a user supplied one(s).
Andreas Dilger47a0c421997-05-16 02:46:07 -05001047 * If buffered output is not used, then output_flush_fn can be set to NULL.
1048 * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
1049 * output_flush_fn will be ignored (and thus can be NULL).
1050 */
1051extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
1052 png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
Guy Schalnat6d764711995-12-19 03:22:19 -06001053
1054/* Replace the default data input function with a user supplied one. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001055extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
1056 png_voidp io_ptr, png_rw_ptr read_data_fn));
Guy Schalnat6d764711995-12-19 03:22:19 -06001057
1058/* Return the user pointer associated with the I/O functions */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001059extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06001060
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001061#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001062/* Sets the function callbacks for the push reader, and a pointer to a
1063 * user-defined structure available to the callback functions.
1064 */
1065extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
1066 png_voidp progressive_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001067 png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
1068 png_progressive_end_ptr end_fn));
Guy Schalnat6d764711995-12-19 03:22:19 -06001069
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001070/* returns the user pointer associated with the push read functions */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001071extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
1072 PNGARG((png_structp png_ptr));
1073
1074/* function to be called when data becomes available */
1075extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
1076 png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
1077
1078/* function which combines rows. Not very much different than the
1079 * png_combine_row() call. Is this even used?????
1080 */
1081extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
1082 png_bytep old_row, png_bytep new_row));
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001083#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
Guy Schalnat6d764711995-12-19 03:22:19 -06001084
Andreas Dilger47a0c421997-05-16 02:46:07 -05001085extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001086 png_uint_32 size));
Guy Schalnat0d580581995-07-20 02:43:20 -05001087
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001088/* frees a pointer allocated by png_malloc() */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001089extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
Guy Schalnate5a37791996-06-05 15:50:50 -05001090
Andreas Dilger47a0c421997-05-16 02:46:07 -05001091#if defined(USE_FAR_KEYWORD) /* memory model conversion function */
1092extern void *far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,int check));
1093#endif /* USE_FAR_KEYWORD */
1094
1095/* Fatal error in PNG image of libpng - can't continue */
1096extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
1097 png_const_charp error));
Guy Schalnat0d580581995-07-20 02:43:20 -05001098
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -06001099/* The same, but the chunk name is prepended to the error string. */
1100extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
1101 png_const_charp error));
1102
Guy Schalnat6d764711995-12-19 03:22:19 -06001103/* Non-fatal error in libpng. Can continue, but may have a problem. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001104extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
1105 png_const_charp message));
Guy Schalnat0d580581995-07-20 02:43:20 -05001106
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -06001107/* Non-fatal error in libpng, chunk name is prepended to message. */
1108extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
1109 png_const_charp message));
1110
Andreas Dilger47a0c421997-05-16 02:46:07 -05001111/* The png_set_<chunk> functions are for storing values in the png_info_struct.
1112 * Similarly, the png_get_<chunk> calls are used to read values from the
1113 * png_info_struct, either storing the parameters in the passed variables, or
1114 * setting pointers into the png_info_struct where the data is stored. The
1115 * png_get_<chunk> functions return a non-zero value if the data was available
1116 * in info_ptr, or return zero and do not change any of the parameters if the
1117 * data was not available.
1118 *
1119 * These functions should be used instead of directly accessing png_info
1120 * to avoid problems with future changes in the size and internal layout of
1121 * png_info_struct.
1122 */
1123/* Returns "flag" if chunk data is valid in info_ptr */
1124extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
1125png_infop info_ptr, png_uint_32 flag));
1126
1127/* Returns number of bytes needed to hold a transformed row */
1128extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
1129png_infop info_ptr));
1130
1131/* Returns number of color channels in image */
1132extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
1133png_infop info_ptr));
1134
1135/* Returns pointer to signature string read from PNG header */
1136extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
1137png_infop info_ptr));
1138
1139#if defined(PNG_READ_bKGD_SUPPORTED)
1140extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
1141 png_infop info_ptr, png_color_16p *background));
1142#endif /* PNG_READ_bKGD_SUPPORTED */
1143
1144#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
1145extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
1146 png_infop info_ptr, png_color_16p background));
1147#endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
1148
1149#if defined(PNG_READ_cHRM_SUPPORTED)
1150extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
1151 png_infop info_ptr, double *white_x, double *white_y, double *red_x,
1152 double *red_y, double *green_x, double *green_y, double *blue_x,
1153 double *blue_y));
1154#endif /* PNG_READ_cHRM_SUPPORTED */
1155
1156#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
1157extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
1158 png_infop info_ptr, double white_x, double white_y, double red_x,
1159 double red_y, double green_x, double green_y, double blue_x, double blue_y));
1160#endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
1161
1162#if defined(PNG_READ_gAMA_SUPPORTED)
1163extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
1164 png_infop info_ptr, double *file_gamma));
1165#endif /* PNG_READ_gAMA_SUPPORTED */
1166
1167#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
1168extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
1169 png_infop info_ptr, double file_gamma));
1170#endif /* PNG_READ_gAMA_SUPPORTED || PNG_WRITE_gAMA_SUPPORTED */
1171
1172#if defined(PNG_READ_hIST_SUPPORTED)
1173extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
1174 png_infop info_ptr, png_uint_16p *hist));
1175#endif /* PNG_READ_hIST_SUPPORTED */
1176
1177#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
1178extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
1179 png_infop info_ptr, png_uint_16p hist));
1180#endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
1181
1182extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
1183 png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
1184 int *bit_depth, int *color_type, int *interlace_type,
1185 int *compression_type, int *filter_type));
1186
1187extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
1188 png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
1189 int color_type, int interlace_type, int compression_type, int filter_type));
1190
1191#if defined(PNG_READ_oFFs_SUPPORTED)
1192extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
1193 png_infop info_ptr, png_uint_32 *offset_x, png_uint_32 *offset_y,
1194 int *unit_type));
1195#endif /* PNG_READ_oFFs_SUPPORTED */
1196
1197#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
1198extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
1199 png_infop info_ptr, png_uint_32 offset_x, png_uint_32 offset_y,
1200 int unit_type));
1201#endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
1202
1203#if defined(PNG_READ_pCAL_SUPPORTED)
1204extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
1205 png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
1206 int *type, int *nparams, png_charp *units, png_charpp *params));
1207#endif /* PNG_READ_pCAL_SUPPORTED */
1208
1209#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
1210extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
1211 png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
1212 int type, int nparams, png_charp units, png_charpp params));
1213#endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
1214
1215#if defined(PNG_READ_pHYs_SUPPORTED)
1216extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
1217 png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
1218#endif /* PNG_READ_pHYs_SUPPORTED */
1219
1220#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
1221extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
1222 png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
1223#endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
1224
1225extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
1226 png_infop info_ptr, png_colorp *palette, int *num_palette));
1227
1228extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
1229 png_infop info_ptr, png_colorp palette, int num_palette));
1230
1231#if defined(PNG_READ_sBIT_SUPPORTED)
1232extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
1233 png_infop info_ptr, png_color_8p *sig_bit));
1234#endif /* PNG_READ_sBIT_SUPPORTED */
1235
1236#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
1237extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
1238 png_infop info_ptr, png_color_8p sig_bit));
1239#endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
1240
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001241#if defined(PNG_READ_sRGB_SUPPORTED)
1242extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -06001243 png_infop info_ptr, png_bytep srgb_intent));
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001244#endif /* PNG_READ_sRGB_SUPPORTED */
1245
1246#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
1247extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
1248 png_infop info_ptr, png_byte srgb_intent));
1249extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
1250 png_infop info_ptr, png_byte srgb_intent));
1251#endif /* PNG_READ_sRGB_SUPPORTED || PNG_WRITE_sRGB_SUPPORTED */
1252
Andreas Dilger47a0c421997-05-16 02:46:07 -05001253#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
1254/* png_get_text also returns the number of text chunks in text_ptr */
1255extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
1256 png_infop info_ptr, png_textp *text_ptr, int *num_text));
1257#endif /* PNG_READ_tEXt_SUPPORTED || PNG_READ_zTXt_SUPPORTED */
1258
1259#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
1260 defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
1261extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
1262 png_infop info_ptr, png_textp text_ptr, int num_text));
1263#endif /* PNG_READ_tEXt_SUPPORTED || PNG_WRITE_tEXt_SUPPORTED ||
1264 PNG_READ_zTXt_SUPPORTED || PNG_WRITE_zTXt_SUPPORTED */
1265
1266#if defined(PNG_READ_tIME_SUPPORTED)
1267extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
1268 png_infop info_ptr, png_timep *mod_time));
1269#endif /* PNG_READ_tIME_SUPPORTED */
1270
1271#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
1272extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
1273 png_infop info_ptr, png_timep mod_time));
1274#endif /* PNG_READ_tIME_SUPPORTED || PNG_WRITE_tIME_SUPPORTED */
1275
1276#if defined(PNG_READ_tRNS_SUPPORTED)
1277extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
1278 png_infop info_ptr, png_bytep *trans, int *num_trans,
1279 png_color_16p *trans_values));
1280#endif /* PNG_READ_tRNS_SUPPORTED */
1281
1282#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
1283extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
1284 png_infop info_ptr, png_bytep trans, int num_trans,
1285 png_color_16p trans_values));
1286#endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
1287
1288/* Define PNG_DEBUG at compile time for debugging information. Higher
1289 * numbers for PNG_DEBUG mean more debugging information. This has
1290 * only been added since version 0.95 so it is not implemented throughout
1291 * libpng yet, but more support will be added as needed.
1292 */
1293#if (PNG_DEBUG > 0)
1294#ifndef PNG_DEBUG_FILE
1295#define PNG_DEBUG_FILE stderr
1296#endif /* PNG_DEBUG_FILE */
1297
1298#define png_debug(l,m) if (PNG_DEBUG > l) \
1299 fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
1300 (l==2 ? "\t\t":(l==3 ? "\t\t\t":""))))
1301#define png_debug1(l,m,p1) if (PNG_DEBUG > l) \
1302 fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
1303 (l==2 ? "\t\t":(l==3 ? "\t\t\t":""))),p1)
1304#define png_debug2(l,m,p1,p2) if (PNG_DEBUG > l) \
1305 fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
1306 (l==2 ? "\t\t":(l==3 ? "\t\t\t":""))),p1,p2)
1307#else
1308#define png_debug(l, m)
1309#define png_debug1(l, m, p1)
1310#define png_debug2(l, m, p1, p2)
1311#endif /* (PNG_DEBUG > 0) */
1312
1313/* These next functions are used internally in the code. They generally
1314 * shouldn't be used unless you are writing code to add or replace some
1315 * functionality in libpng. More information about most functions can
1316 * be found in the files where the functions are located.
1317 */
Guy Schalnat0d580581995-07-20 02:43:20 -05001318
Guy Schalnate5a37791996-06-05 15:50:50 -05001319#if defined(PNG_INTERNAL)
Guy Schalnat0d580581995-07-20 02:43:20 -05001320
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001321/* Various modes of operation. Note that after an init, mode is set to
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001322 * zero automatically when the structure is created.
1323 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001324#define PNG_BEFORE_IHDR 0x00
1325#define PNG_HAVE_IHDR 0x01
1326#define PNG_HAVE_PLTE 0x02
1327#define PNG_HAVE_IDAT 0x04
1328#define PNG_AFTER_IDAT 0x08
1329#define PNG_HAVE_IEND 0x10
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001330#define PNG_HAVE_gAMA 0x20
1331#define PNG_HAVE_cHRM 0x40
1332#define PNG_HAVE_sRGB 0x80
Guy Schalnat0d580581995-07-20 02:43:20 -05001333
Guy Schalnat6d764711995-12-19 03:22:19 -06001334/* push model modes */
Guy Schalnate5a37791996-06-05 15:50:50 -05001335#define PNG_READ_SIG_MODE 0
Guy Schalnat6d764711995-12-19 03:22:19 -06001336#define PNG_READ_CHUNK_MODE 1
Guy Schalnate5a37791996-06-05 15:50:50 -05001337#define PNG_READ_IDAT_MODE 2
Andreas Dilger47a0c421997-05-16 02:46:07 -05001338#define PNG_SKIP_MODE 3
1339#define PNG_READ_tEXt_MODE 4
1340#define PNG_READ_zTXt_MODE 5
1341#define PNG_READ_DONE_MODE 6
1342#define PNG_ERROR_MODE 7
Guy Schalnat6d764711995-12-19 03:22:19 -06001343
Andreas Dilger47a0c421997-05-16 02:46:07 -05001344/* flags for the transformations the PNG library does on the image data */
Guy Schalnate5a37791996-06-05 15:50:50 -05001345#define PNG_BGR 0x0001
1346#define PNG_INTERLACE 0x0002
1347#define PNG_PACK 0x0004
1348#define PNG_SHIFT 0x0008
1349#define PNG_SWAP_BYTES 0x0010
1350#define PNG_INVERT_MONO 0x0020
1351#define PNG_DITHER 0x0040
1352#define PNG_BACKGROUND 0x0080
1353#define PNG_BACKGROUND_EXPAND 0x0100
Andreas Dilger47a0c421997-05-16 02:46:07 -05001354#define PNG_RGB_TO_GRAY 0x0200 /* Not currently implemented */
Guy Schalnate5a37791996-06-05 15:50:50 -05001355#define PNG_16_TO_8 0x0400
1356#define PNG_RGBA 0x0800
1357#define PNG_EXPAND 0x1000
1358#define PNG_GAMMA 0x2000
1359#define PNG_GRAY_TO_RGB 0x4000
1360#define PNG_FILLER 0x8000
Andreas Dilger47a0c421997-05-16 02:46:07 -05001361#define PNG_PACKSWAP 0x10000
1362#define PNG_SWAP_ALPHA 0x20000
1363#define PNG_STRIP_ALPHA 0x40000
Guy Schalnate5a37791996-06-05 15:50:50 -05001364
Guy Schalnate5a37791996-06-05 15:50:50 -05001365/* flags for png_create_struct */
1366#define PNG_STRUCT_PNG 0x0001
1367#define PNG_STRUCT_INFO 0x0002
1368
Andreas Dilger47a0c421997-05-16 02:46:07 -05001369/* Scaling factor for filter heuristic weighting calculations */
1370#define PNG_WEIGHT_SHIFT 8
1371#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
1372#define PNG_COST_SHIFT 3
1373#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
1374
1375/* flags for the png_ptr->flags rather than declaring a byte for each one */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001376#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
1377#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002
1378#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004
1379#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008
1380#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010
1381#define PNG_FLAG_ZLIB_FINISHED 0x0020
1382#define PNG_FLAG_ROW_INIT 0x0040
1383#define PNG_FLAG_FILLER_AFTER 0x0080
1384#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
1385#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
1386#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
1387#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
1388#define PNG_FLAG_FREE_PALETTE 0x1000
1389#define PNG_FLAG_FREE_TRANS 0x2000
1390#define PNG_FLAG_FREE_HIST 0x4000
1391#define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000
1392#define PNG_FLAG_WROTE_tIME 0x10000
1393
1394#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
1395 PNG_FLAG_CRC_ANCILLARY_NOWARN)
1396
1397#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
1398 PNG_FLAG_CRC_CRITICAL_IGNORE)
1399
1400#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
1401 PNG_FLAG_CRC_CRITICAL_MASK)
Guy Schalnat0d580581995-07-20 02:43:20 -05001402
1403/* save typing and make code easier to understand */
1404#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
1405 abs((int)((c1).green) - (int)((c2).green)) + \
1406 abs((int)((c1).blue) - (int)((c2).blue)))
1407
Andreas Dilger47a0c421997-05-16 02:46:07 -05001408/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
Guy Schalnat0d580581995-07-20 02:43:20 -05001409#ifndef PNG_NO_EXTERN
Andreas Dilger47a0c421997-05-16 02:46:07 -05001410/* place to hold the signiture string for a PNG file. */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001411extern png_byte FARDATA png_sig[];
Guy Schalnat0d580581995-07-20 02:43:20 -05001412
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001413/* Constant strings for known chunk types. If you need to add a chunk,
1414 * add a string holding the name here. See png.c for more details. We
1415 * can't selectively include these, since we still check for chunk in the
1416 * wrong locations with these labels.
1417 */
Guy Schalnat6d764711995-12-19 03:22:19 -06001418extern png_byte FARDATA png_IHDR[];
1419extern png_byte FARDATA png_IDAT[];
1420extern png_byte FARDATA png_IEND[];
1421extern png_byte FARDATA png_PLTE[];
Guy Schalnat6d764711995-12-19 03:22:19 -06001422extern png_byte FARDATA png_bKGD[];
Andreas Dilger47a0c421997-05-16 02:46:07 -05001423extern png_byte FARDATA png_cHRM[];
1424extern png_byte FARDATA png_gAMA[];
Guy Schalnat6d764711995-12-19 03:22:19 -06001425extern png_byte FARDATA png_hIST[];
Guy Schalnat6d764711995-12-19 03:22:19 -06001426extern png_byte FARDATA png_oFFs[];
Andreas Dilger47a0c421997-05-16 02:46:07 -05001427extern png_byte FARDATA png_pCAL[];
1428extern png_byte FARDATA png_pHYs[];
1429extern png_byte FARDATA png_sBIT[];
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001430extern png_byte FARDATA png_sRGB[];
Andreas Dilger47a0c421997-05-16 02:46:07 -05001431extern png_byte FARDATA png_tEXt[];
Guy Schalnat6d764711995-12-19 03:22:19 -06001432extern png_byte FARDATA png_tIME[];
Andreas Dilger47a0c421997-05-16 02:46:07 -05001433extern png_byte FARDATA png_tRNS[];
1434extern png_byte FARDATA png_zTXt[];
Guy Schalnat0d580581995-07-20 02:43:20 -05001435
1436#endif /* PNG_NO_EXTERN */
1437
Andreas Dilger47a0c421997-05-16 02:46:07 -05001438/* Inline macros to do direct reads of bytes from the input buffer. These
1439 * require that you are using an architecture that uses PNG byte ordering
1440 * (MSB first) and supports unaligned data storage. I think that PowerPC
1441 * in big-endian mode and 680x0 are the only ones that will support this.
1442 * The x86 line of processors definitely do not. The png_get_int_32()
1443 * routine also assumes we are using two's complement format for negative
1444 * values, which is almost certainly true.
1445 */
1446#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
1447#if defined(PNG_READ_pCAL_SUPPORTED)
1448#define png_get_int_32(buf) ( *((png_int_32p) (buf)))
1449#endif /* PNG_READ_pCAL_SUPPORTED */
1450#define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
1451#define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
1452#else
1453#if defined(PNG_READ_pCAL_SUPPORTED)
1454PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
1455#endif /* PNG_READ_pCAL_SUPPORTED */
1456PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
1457PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
1458#endif /* PNG_BIG_ENDIAN_GET_SUPPORTED */
1459
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001460/* Initialize png_ptr struct for reading, and allocate any other memory.
1461 * (old interface - NOT DLL EXPORTED).
1462 */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001463extern void png_read_init PNGARG((png_structp png_ptr));
1464
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001465/* Initialize png_ptr struct for writing, and allocate any other memory.
1466 * (old interface - NOT DLL EXPORTED).
1467 */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001468extern void png_write_init PNGARG((png_structp png_ptr));
1469
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001470/* allocate memory for an internal libpng struct */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001471PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001472
1473/* free memory from internal libpng struct */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001474PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001475
1476/* free any memory that info_ptr points to and reset struct. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001477PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001478 png_infop info_ptr));
1479
Guy Schalnat0d580581995-07-20 02:43:20 -05001480/* Function to allocate memory for zlib. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001481PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
Guy Schalnat0d580581995-07-20 02:43:20 -05001482
1483/* function to free memory for zlib */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001484PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001485
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001486/* reset the CRC variable */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001487PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
1488
1489/* Write the "data" buffer to whatever output you are using. */
1490PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
1491 png_size_t length));
1492
1493/* Read data from whatever input you are using into the "data" buffer */
1494PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
1495 png_size_t length));
Guy Schalnat0d580581995-07-20 02:43:20 -05001496
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001497/* read bytes into buf, and update png_ptr->crc */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001498PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
1499 png_size_t length));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001500
1501/* read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001502PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001503
1504/* read the CRC from the file and compare it to the libpng calculated CRC */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001505PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001506
Andreas Dilger47a0c421997-05-16 02:46:07 -05001507/* Calculate the CRC over a section of data. Note that we are only
1508 * passing a maximum of 64K on systems that have this as a memory limit,
1509 * since this is the maximum buffer size we can specify.
1510 */
1511PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
1512 png_size_t length));
Guy Schalnat6d764711995-12-19 03:22:19 -06001513
Guy Schalnat6d764711995-12-19 03:22:19 -06001514#if defined(PNG_WRITE_FLUSH_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001515PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06001516#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001517
Andreas Dilger47a0c421997-05-16 02:46:07 -05001518/* Place a 32-bit number into a buffer in PNG byte order (big-endian).
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001519 * The only currently known PNG chunk that uses signed numbers is
Andreas Dilger47a0c421997-05-16 02:46:07 -05001520 * the ancillary extension chunk, pCAL.
1521 */
1522PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
Guy Schalnat0d580581995-07-20 02:43:20 -05001523
Andreas Dilger47a0c421997-05-16 02:46:07 -05001524#if defined(PNG_WRITE_pCAL_SUPPORTED)
1525PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
1526#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001527
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001528/* Place a 16 bit number into a buffer in PNG byte order.
1529 * The parameter is declared unsigned int, not png_uint_16,
1530 * just to avoid potential problems on pre-ANSI C compilers.
1531 */
1532PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
Guy Schalnat0d580581995-07-20 02:43:20 -05001533
Andreas Dilger47a0c421997-05-16 02:46:07 -05001534/* Write a PNG chunk - size, type, (optional) data, CRC. */
1535PNG_EXTERN void png_write_chunk PNGARG((png_structp png_ptr,
1536 png_bytep chunk_name, png_bytep data, png_size_t length));
Guy Schalnat0d580581995-07-20 02:43:20 -05001537
Andreas Dilger47a0c421997-05-16 02:46:07 -05001538/* Write the start of a PNG chunk - length and chunk name. */
1539PNG_EXTERN void png_write_chunk_start PNGARG((png_structp png_ptr,
1540 png_bytep chunk_name, png_uint_32 length));
Guy Schalnat0d580581995-07-20 02:43:20 -05001541
Andreas Dilger47a0c421997-05-16 02:46:07 -05001542/* Write the data of a PNG chunk started with png_write_chunk_start(). */
1543PNG_EXTERN void png_write_chunk_data PNGARG((png_structp png_ptr,
1544 png_bytep data, png_size_t length));
Guy Schalnat0d580581995-07-20 02:43:20 -05001545
Andreas Dilger47a0c421997-05-16 02:46:07 -05001546/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
1547PNG_EXTERN void png_write_chunk_end PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001548
1549/* simple function to write the signiture */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001550PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001551
1552/* write various chunks */
1553
1554/* Write the IHDR chunk, and update the png_struct with the necessary
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001555 * information.
1556 */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001557PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001558 png_uint_32 height,
1559 int bit_depth, int color_type, int compression_type, int filter_type,
1560 int interlace_type));
Guy Schalnat0d580581995-07-20 02:43:20 -05001561
Andreas Dilger47a0c421997-05-16 02:46:07 -05001562PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
1563 png_uint_32 num_pal));
Guy Schalnat0d580581995-07-20 02:43:20 -05001564
Andreas Dilger47a0c421997-05-16 02:46:07 -05001565PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
1566 png_size_t length));
Guy Schalnat0d580581995-07-20 02:43:20 -05001567
Andreas Dilger47a0c421997-05-16 02:46:07 -05001568PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001569
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001570#if defined(PNG_WRITE_gAMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001571PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001572#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001573
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001574#if defined(PNG_WRITE_sBIT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001575PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001576 int color_type));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001577#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001578
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001579#if defined(PNG_WRITE_cHRM_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001580PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001581 double white_x, double white_y,
1582 double red_x, double red_y, double green_x, double green_y,
1583 double blue_x, double blue_y));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001584#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001585
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001586#if defined(PNG_WRITE_sRGB_SUPPORTED)
1587PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
1588 png_byte srgb_intent));
1589#endif
1590
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001591#if defined(PNG_WRITE_tRNS_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001592PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001593 png_color_16p values, int number, int color_type));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001594#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001595
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001596#if defined(PNG_WRITE_bKGD_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001597PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
1598 png_color_16p values, int color_type));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001599#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001600
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001601#if defined(PNG_WRITE_hIST_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001602PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
1603 png_uint_32 num_hist));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001604#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001605
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001606#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001607PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001608 png_charp key, png_charpp new_key));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001609#endif
1610
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001611#if defined(PNG_WRITE_tEXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001612PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
1613 png_charp text, png_size_t text_len));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001614#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001615
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001616#if defined(PNG_WRITE_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001617PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
1618 png_charp text, png_size_t text_len, int compression));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001619#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001620
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001621#if defined(PNG_WRITE_oFFs_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001622PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
1623 png_uint_32 x_offset, png_uint_32 y_offset, int unit_type));
1624#endif
1625
1626#if defined(PNG_WRITE_pCAL_SUPPORTED)
1627PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
1628 png_int_32 X0, png_int_32 X1, int type, int nparams,
1629 png_charp units, png_charpp params));
1630#endif
1631
1632#if defined(PNG_WRITE_pHYs_SUPPORTED)
1633PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
1634 png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
Guy Schalnat0d580581995-07-20 02:43:20 -05001635 int unit_type));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001636#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001637
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001638#if defined(PNG_WRITE_tIME_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001639PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001640 png_timep mod_time));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001641#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001642
Andreas Dilger47a0c421997-05-16 02:46:07 -05001643/* Called when finished processing a row of data */
1644PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001645
Andreas Dilger47a0c421997-05-16 02:46:07 -05001646/* Internal use only. Called before first row of data */
1647PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001648
1649#if defined(PNG_READ_GAMMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001650PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001651#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001652
1653/* combine a row of data, dealing with alpha, etc. if requested */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001654PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
Guy Schalnat0d580581995-07-20 02:43:20 -05001655 int mask));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001656
1657#if defined(PNG_READ_INTERLACING_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -05001658/* expand an interlaced row */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001659PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
1660 png_bytep row, int pass, png_uint_32 transformations));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001661#endif
1662
1663#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -05001664/* grab pixels out of a row for an interlaced pass */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001665PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001666 png_bytep row, int pass));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001667#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001668
1669/* unfilter a row */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001670PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
Guy Schalnate5a37791996-06-05 15:50:50 -05001671 png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001672
1673/* Choose the best filter to use and filter the row data */
1674PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
Guy Schalnate5a37791996-06-05 15:50:50 -05001675 png_row_infop row_info));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001676
1677/* Write out the filtered row. */
1678PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
Guy Schalnate5a37791996-06-05 15:50:50 -05001679 png_bytep filtered_row));
Guy Schalnat0d580581995-07-20 02:43:20 -05001680/* finish a row while reading, dealing with interlacing passes, etc. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001681PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
1682
Guy Schalnat0d580581995-07-20 02:43:20 -05001683/* initialize the row buffers, etc. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001684PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001685/* optional call to update the users info structure */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001686PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001687 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001688
1689/* these are the functions that do the transformations */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001690#if defined(PNG_READ_FILLER_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001691PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
1692 png_bytep row, png_uint_32 filler, png_uint_32 flags));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001693#endif
1694
Andreas Dilger47a0c421997-05-16 02:46:07 -05001695#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
1696PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
1697 png_bytep row));
1698#endif
1699
1700#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
1701PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
1702 png_bytep row));
1703#endif
1704
1705#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
1706 defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
1707PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
1708 png_bytep row, png_uint_32 flags));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001709#endif
1710
1711#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001712PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
1713#endif
1714
1715#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPOR)
1716PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001717#endif
1718
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001719#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001720PNG_EXTERN void png_do_rgb_to_gray PNGARG((png_row_infop row_info,
1721 png_bytep row));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001722#endif
1723
1724#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001725PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
1726 png_bytep row));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001727#endif
1728
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001729#if defined(PNG_READ_PACK_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001730PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001731#endif
1732
1733#if defined(PNG_READ_SHIFT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001734PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
Guy Schalnat6d764711995-12-19 03:22:19 -06001735 png_color_8p sig_bits));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001736#endif
1737
1738#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001739PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001740#endif
1741
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001742#if defined(PNG_READ_16_TO_8_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001743PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001744#endif
1745
1746#if defined(PNG_READ_DITHER_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001747PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001748 png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001749
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001750# if defined(PNG_CORRECT_PALETTE_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001751PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
Guy Schalnate5a37791996-06-05 15:50:50 -05001752 png_colorp palette, int num_palette));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001753# endif
Guy Schalnate5a37791996-06-05 15:50:50 -05001754#endif
1755
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001756#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001757PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001758#endif
1759
1760#if defined(PNG_WRITE_PACK_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001761PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
1762 png_bytep row, png_uint_32 bit_depth));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001763#endif
1764
1765#if defined(PNG_WRITE_SHIFT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001766PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
Guy Schalnat6d764711995-12-19 03:22:19 -06001767 png_color_8p bit_depth));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001768#endif
1769
1770#if defined(PNG_READ_BACKGROUND_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001771PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
Guy Schalnat6d764711995-12-19 03:22:19 -06001772 png_color_16p trans_values, png_color_16p background,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001773 png_color_16p background_1,
1774 png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
1775 png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
1776 png_uint_16pp gamma_16_to_1, int gamma_shift));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001777#endif
1778
1779#if defined(PNG_READ_GAMMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001780PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001781 png_bytep gamma_table, png_uint_16pp gamma_16_table,
Guy Schalnat0d580581995-07-20 02:43:20 -05001782 int gamma_shift));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001783#endif
1784
1785#if defined(PNG_READ_EXPAND_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001786PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001787 png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001788PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001789 png_bytep row, png_color_16p trans_value));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001790#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001791
Andreas Dilger47a0c421997-05-16 02:46:07 -05001792/* The following decodes the appropriate chunks, and does error correction,
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001793 * then calls the appropriate callback for the chunk if it is valid.
1794 */
Guy Schalnat0d580581995-07-20 02:43:20 -05001795
1796/* decode the IHDR chunk */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001797PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001798 png_uint_32 length));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001799PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001800 png_uint_32 length));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001801PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001802 png_uint_32 length));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001803
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001804#if defined(PNG_READ_gAMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001805PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001806 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001807#endif
1808
1809#if defined(PNG_READ_sBIT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001810PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001811 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001812#endif
1813
1814#if defined(PNG_READ_cHRM_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001815PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001816 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001817#endif
1818
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001819#if defined(PNG_READ_sRGB_SUPPORTED)
1820PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
1821 png_uint_32 length));
1822#endif
1823
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001824#if defined(PNG_READ_tRNS_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001825PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001826 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001827#endif
1828
1829#if defined(PNG_READ_bKGD_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001830PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001831 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001832#endif
1833
1834#if defined(PNG_READ_hIST_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001835PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001836 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001837#endif
1838
1839#if defined(PNG_READ_oFFs_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001840PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
1841 png_uint_32 length));
1842#endif
1843
1844#if defined(PNG_READ_pCAL_SUPPORTED)
1845PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
1846 png_uint_32 length));
1847#endif
1848
1849#if defined(PNG_READ_pHYs_SUPPORTED)
1850PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001851 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001852#endif
1853
1854#if defined(PNG_READ_tIME_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001855PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001856 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001857#endif
1858
1859#if defined(PNG_READ_tEXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001860PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001861 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001862#endif
1863
1864#if defined(PNG_READ_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001865PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05001866 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001867#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001868
Andreas Dilger47a0c421997-05-16 02:46:07 -05001869PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
1870 png_infop info_ptr, png_uint_32 length));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001871
Andreas Dilger47a0c421997-05-16 02:46:07 -05001872PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001873 png_bytep chunk_name));
1874
Guy Schalnat0d580581995-07-20 02:43:20 -05001875/* handle the transformations for reading and writing */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001876PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
1877PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001878
Andreas Dilger47a0c421997-05-16 02:46:07 -05001879PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001880
Guy Schalnat6d764711995-12-19 03:22:19 -06001881#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001882PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001883 png_infop info_ptr));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001884PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
1885 png_infop info_ptr));
1886PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
1887PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001888 png_uint_32 length));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001889PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
1890PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
1891 png_bytep buffer, png_size_t length));
1892PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
1893PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
1894 png_bytep buffer, png_size_t buffer_length));
1895PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
1896PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
1897 png_bytep buffer, png_size_t buffer_length));
1898PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
1899PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
1900 png_infop info_ptr, png_uint_32 length));
1901PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
1902 png_infop info_ptr));
1903PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
1904 png_infop info_ptr));
1905PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
1906PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
1907 png_infop info_ptr));
1908PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
1909 png_infop info_ptr));
1910PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
1911#if defined(PNG_READ_tEXt_SUPPORTED)
1912PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
1913 png_infop info_ptr, png_uint_32 length));
1914PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
1915 png_infop info_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06001916#endif
1917#if defined(PNG_READ_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001918PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
1919 png_infop info_ptr, png_uint_32 length));
1920PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
1921 png_infop info_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06001922#endif
1923
1924#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -05001925
1926#endif /* PNG_INTERNAL */
1927
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001928#ifdef __cplusplus
1929}
1930#endif
1931
Guy Schalnat0d580581995-07-20 02:43:20 -05001932/* do not put anything past this line */
1933#endif /* _PNG_H */