blob: 571ddfaa00c0dbaf852fce8519e123d4ba91cd3e [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-Pehrsonf8b008c1999-09-18 10:54:36 -05004 * libpng version 1.0.4 - September 18, 1999
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06005 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
6 * Copyright (c) 1996, 1997 Andreas Dilger
Glenn Randers-Pehrsonc9442291999-01-06 21:50:16 -06007 * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -06008 *
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05009 * Authors and maintainers:
10 * libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
11 * libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -050012 * libpng versions 0.97, January 1998, through 1.0.4 - September 18, 1999: Glenn R-P
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050013 * See also "Contributing Authors", below.
14 *
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -060015 * Y2K compliance in libpng:
16 * =========================
17 *
18 * January 13, 1999
19 *
20 * Since the PNG Development group is an ad-hoc body, we can't make
21 * an official declaration.
22 *
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050023 * This is your unofficial assurance that libpng from version 0.71 and
24 * upward through 1.0.4 are Y2K compliant. It is my belief that earlier
25 * versions were also Y2K compliant.
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -060026 *
27 * Libpng only has three year fields. One is a 2-byte unsigned integer
28 * that will hold years up to 65535. The other two hold the date in text
29 * format, and will hold years up to 9999.
30 *
31 * The integer is
32 * "png_uint_16 year" in png_time_struct.
33 *
34 * The strings are
35 * "png_charp time_buffer" in png_struct and
36 * "near_time_buffer", which is a local character string in png.c.
37 *
38 * There are seven time-related functions:
39 * png.c: png_convert_to_rfc_1123() in png.c
40 * (formerly png_convert_to_rfc_1152() in error)
41 * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
42 * png_convert_from_time_t() in pngwrite.c
43 * png_get_tIME() in pngget.c
44 * png_handle_tIME() in pngrutil.c, called in pngread.c
45 * png_set_tIME() in pngset.c
46 * png_write_tIME() in pngwutil.c, called in pngwrite.c
47 *
48 * All handle dates properly in a Y2K environment. The
49 * png_convert_from_time_t() function calls gmtime() to convert from system
50 * clock time, which returns (year - 1900), which we properly convert to
51 * the full 4-digit year. There is a possibility that applications using
52 * libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050053 * function, or that they are incorrectly passing only a 2-digit year
54 * instead of "year - 1900" into the png_convert_from_struct_tm() function,
55 * but this is not under our control. The libpng documentation has always
56 * stated that it works with 4-digit years, and the APIs have been
57 * documented as such.
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -060058 *
59 * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
60 * integer to hold the year, and can hold years as large as 65535.
61 *
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050062 * zlib, upon which libpng depends, is also Y2K compliant. It contains
63 * no date-related code.
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -060064 *
65 * Glenn Randers-Pehrson
66 * libpng maintainer
67 * PNG Development Group
68 *
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -060069 * Note about libpng version numbers:
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -060070 *
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -060071 * Due to various miscommunications, unforeseen code incompatibilities
72 * and occasional factors outside the authors' control, version numbering
73 * on the library has not always been consistent and straightforward.
74 * The following table summarizes matters since version 0.89c, which was
75 * the first widely used release:
76 *
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050077 * source png.h png.h shared-lib
78 * version string int version
79 * ------- ------ ----- ----------
80 * 0.89c ("1.0 beta 3") 0.89 89 1.0.89
81 * 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
82 * 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
83 * 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
84 * 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
85 * 0.97c 0.97 97 2.0.97
86 * 0.98 0.98 98 2.0.98
87 * 0.99 0.99 98 2.0.99
88 * 0.99a-m 0.99 99 2.0.99
89 * 1.00 1.00 100 2.1.0 [int should be 10000]
90 * 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
91 * 1.0.1 1.0.1 10001 2.1.0
92 * 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e
93 * 1.0.2 1.0.2 10002 2.1.0.2
94 * 1.0.2a-b 1.0.2a-b 10003 2.1.0.2a-b
95 * 1.0.3 1.0.3 10003 2.1.0.3
96 * 1.0.3a-d 1.0.3a-d 10004 2.1.0.3a-d
97 * 1.0.4 1.0.4 10004 2.1.0.4
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -060098 *
99 * Henceforth the source version will match the shared-library minor
100 * and patch numbers; the shared-library major version number will be
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -0500101 * used for changes in backward compatibility, as it is intended. The
102 * PNG_PNGLIB_VER macro, which is not used within libpng but is available
103 * for applications, is an unsigned integer of the form xyyzz corresponding
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500104 * to the source version x.y.z (leading zeros in y and z). Internal
105 * png-group versions (x.y.z[a-z]) will be given the next higher number.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600106 *
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -0500107 * See libpng.txt or libpng.3 for more information. The PNG specification
108 * is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600109 * and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600110 *
111 * Contributing Authors:
112 * John Bowler
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600113 * Kevin Bracey
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600114 * Sam Bushell
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600115 * Andreas Dilger
116 * Magnus Holmgren
117 * Tom Lane
118 * Dave Martindale
119 * Glenn Randers-Pehrson
120 * Greg Roelofs
121 * Guy Eric Schalnat
122 * Paul Schmidt
123 * Tom Tanner
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600124 * Willem van Schaik
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600125 * Tim Wegner
126 *
127 * The contributing authors would like to thank all those who helped
128 * with testing, bug fixes, and patience. This wouldn't have been
129 * possible without all of you.
130 *
131 * Thanks to Frank J. T. Wojcik for helping with the documentation.
132 *
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600133 * COPYRIGHT NOTICE:
134 *
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500135 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
136 * (libpng versions 0.5, May 1995, through 0.89c, May 1996)
137 * Copyright (c) 1996, 1997 Andreas Dilger
138 * (libpng versions 0.90, December 1996, through 0.96, May 1997)
139 * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -0500140 * (libpng versions 0.97, January 1998, through 1.0.4 - September 18, 1999)
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500141 *
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600142 * The PNG Reference Library is supplied "AS IS". The Contributing Authors
143 * and Group 42, Inc. disclaim all warranties, expressed or implied,
144 * including, without limitation, the warranties of merchantability and of
145 * fitness for any purpose. The Contributing Authors and Group 42, Inc.
146 * assume no liability for direct, indirect, incidental, special, exemplary,
147 * or consequential damages, which may result from the use of the PNG
148 * Reference Library, even if advised of the possibility of such damage.
149 *
150 * Permission is hereby granted to use, copy, modify, and distribute this
151 * source code, or portions hereof, for any purpose, without fee, subject
152 * to the following restrictions:
153 * 1. The origin of this source code must not be misrepresented.
154 * 2. Altered versions must be plainly marked as such and must not be
155 * misrepresented as being the original source.
156 * 3. This Copyright notice may not be removed or altered from any source or
157 * altered source distribution.
158 *
159 * The Contributing Authors and Group 42, Inc. specifically permit, without
160 * fee, and encourage the use of this source code as a component to
161 * supporting the PNG file format in commercial products. If you use this
162 * source code in a product, acknowledgment is not required but would be
163 * appreciated.
164 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500165
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -0600166
Guy Schalnat0d580581995-07-20 02:43:20 -0500167#ifndef _PNG_H
168#define _PNG_H
169
170/* This is not the place to learn how to use libpng. The file libpng.txt
Andreas Dilger47a0c421997-05-16 02:46:07 -0500171 * describes how to use libpng, and the file example.c summarizes it
172 * with some code on which to build. This file is useful for looking
173 * at the actual function definitions and structure components.
174 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500175
Guy Schalnat0d580581995-07-20 02:43:20 -0500176/* include the compression library's header */
177#include "zlib.h"
178
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500179/* include all user configurable info */
180#include "pngconf.h"
Guy Schalnat0d580581995-07-20 02:43:20 -0500181
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500182/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
183#ifdef __cplusplus
184extern "C" {
185#endif /* __cplusplus */
186
Andreas Dilger47a0c421997-05-16 02:46:07 -0500187/* This file is arranged in several sections. The first section contains
188 * structure and type definitions. The second section contains the external
189 * library functions, while the third has the internal library functions,
190 * which applications aren't expected to use directly.
191 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500192
Andreas Dilger47a0c421997-05-16 02:46:07 -0500193/* Version information for png.h - this should match the version in png.c */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500194#define PNG_LIBPNG_VER_STRING "1.0.4"
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500195
Glenn Randers-Pehrsonf9f2fe01998-03-15 18:20:23 -0600196/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
197 * We must not include leading zeros.
Glenn Randers-Pehrson8f8fb6a1998-03-09 23:02:06 -0600198 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
199 * version 1.0.0 was mis-numbered 100 instead of 10000). From
Glenn Randers-Pehrsonf9f2fe01998-03-15 18:20:23 -0600200 * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500201#define PNG_LIBPNG_VER 10004 /* 1.0.4 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500202
203/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600204#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500205/* Version information for C files, stored in png.c. This had better match
206 * the version above.
207 */
Glenn Randers-Pehrson8f8fb6a1998-03-09 23:02:06 -0600208extern char png_libpng_ver[12]; /* need room for 99.99.99aa */
Guy Schalnat0d580581995-07-20 02:43:20 -0500209
Andreas Dilger47a0c421997-05-16 02:46:07 -0500210/* Structures to facilitate easy interlacing. See png.c for more details */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600211extern int FARDATA png_pass_start[7];
212extern int FARDATA png_pass_inc[7];
213extern int FARDATA png_pass_ystart[7];
214extern int FARDATA png_pass_yinc[7];
215extern int FARDATA png_pass_mask[7];
216extern int FARDATA png_pass_dsp_mask[7];
Andreas Dilger47a0c421997-05-16 02:46:07 -0500217/* These aren't currently used. If you need them, see png.c for more details
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600218extern int FARDATA png_pass_width[7];
219extern int FARDATA png_pass_height[7];
Andreas Dilger47a0c421997-05-16 02:46:07 -0500220*/
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600221
Andreas Dilger47a0c421997-05-16 02:46:07 -0500222#endif /* PNG_NO_EXTERN */
223
224/* Three color definitions. The order of the red, green, and blue, (and the
225 * exact size) is not important, although the size of the fields need to
226 * be png_byte or png_uint_16 (as defined below).
227 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500228typedef struct png_color_struct
229{
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600230 png_byte red;
Guy Schalnat0d580581995-07-20 02:43:20 -0500231 png_byte green;
232 png_byte blue;
233} png_color;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500234typedef png_color FAR * png_colorp;
235typedef png_color FAR * FAR * png_colorpp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500236
237typedef struct png_color_16_struct
238{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500239 png_byte index; /* used for palette files */
240 png_uint_16 red; /* for use in red green blue files */
Guy Schalnat0d580581995-07-20 02:43:20 -0500241 png_uint_16 green;
242 png_uint_16 blue;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500243 png_uint_16 gray; /* for use in grayscale files */
Guy Schalnat0d580581995-07-20 02:43:20 -0500244} png_color_16;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500245typedef png_color_16 FAR * png_color_16p;
246typedef png_color_16 FAR * FAR * png_color_16pp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500247
248typedef struct png_color_8_struct
249{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500250 png_byte red; /* for use in red green blue files */
Guy Schalnat0d580581995-07-20 02:43:20 -0500251 png_byte green;
252 png_byte blue;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500253 png_byte gray; /* for use in grayscale files */
Guy Schalnat0d580581995-07-20 02:43:20 -0500254 png_byte alpha; /* for alpha channel files */
255} png_color_8;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500256typedef png_color_8 FAR * png_color_8p;
257typedef png_color_8 FAR * FAR * png_color_8pp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500258
Andreas Dilger47a0c421997-05-16 02:46:07 -0500259/* png_text holds the text in a PNG file, and whether they are compressed
260 in the PNG file or not. The "text" field points to a regular C string. */
Guy Schalnat0d580581995-07-20 02:43:20 -0500261typedef struct png_text_struct
262{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500263 int compression; /* compression value, see PNG_TEXT_COMPRESSION_ */
264 png_charp key; /* keyword, 1-79 character description of "text" */
265 png_charp text; /* comment, may be an empty string (ie "") */
266 png_size_t text_length; /* length of "text" field */
Guy Schalnat0d580581995-07-20 02:43:20 -0500267} png_text;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500268typedef png_text FAR * png_textp;
269typedef png_text FAR * FAR * png_textpp;
270
271/* Supported compression types for text in PNG files (tEXt, and zTXt).
272 * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
273#define PNG_TEXT_COMPRESSION_NONE_WR -3
274#define PNG_TEXT_COMPRESSION_zTXt_WR -2
275#define PNG_TEXT_COMPRESSION_NONE -1
276#define PNG_TEXT_COMPRESSION_zTXt 0
277#define PNG_TEXT_COMPRESSION_LAST 1 /* Not a valid value */
Guy Schalnat0d580581995-07-20 02:43:20 -0500278
279/* png_time is a way to hold the time in an machine independent way.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600280 * Two conversions are provided, both from time_t and struct tm. There
281 * is no portable way to convert to either of these structures, as far
282 * as I know. If you know of a portable way, send it to me. As a side
283 * note - PNG is Year 2000 compliant!
284 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500285typedef struct png_time_struct
286{
287 png_uint_16 year; /* full year, as in, 1995 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500288 png_byte month; /* month of year, 1 - 12 */
289 png_byte day; /* day of month, 1 - 31 */
290 png_byte hour; /* hour of day, 0 - 23 */
291 png_byte minute; /* minute of hour, 0 - 59 */
292 png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
Guy Schalnat0d580581995-07-20 02:43:20 -0500293} png_time;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500294typedef png_time FAR * png_timep;
295typedef png_time FAR * FAR * png_timepp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500296
Andreas Dilger47a0c421997-05-16 02:46:07 -0500297/* png_info is a structure that holds the information in a PNG file so
298 * that the application can find out the characteristics of the image.
299 * If you are reading the file, this structure will tell you what is
300 * in the PNG file. If you are writing the file, fill in the information
301 * you want to put into the PNG file, then call png_write_info().
302 * The names chosen should be very close to the PNG specification, so
303 * consult that document for information about the meaning of each field.
304 *
305 * With libpng < 0.95, it was only possible to directly set and read the
306 * the values in the png_info_struct, which meant that the contents and
307 * order of the values had to remain fixed. With libpng 0.95 and later,
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500308 * however, there are now functions that abstract the contents of
Andreas Dilger47a0c421997-05-16 02:46:07 -0500309 * png_info_struct from the application, so this makes it easier to use
310 * libpng with dynamic libraries, and even makes it possible to use
311 * libraries that don't have all of the libpng ancillary chunk-handing
312 * functionality.
313 *
314 * In any case, the order of the parameters in png_info_struct should NOT
315 * be changed for as long as possible to keep compatibility with applications
316 * that use the old direct-access method with png_info_struct.
317 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500318typedef struct png_info_struct
319{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500320 /* the following are necessary for every PNG file */
321 png_uint_32 width; /* width of image in pixels (from IHDR) */
322 png_uint_32 height; /* height of image in pixels (from IHDR) */
323 png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600324 png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500325 png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
326 png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
327 png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
328 png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
329 png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
330 png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
331 png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
332 png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500333
Andreas Dilger47a0c421997-05-16 02:46:07 -0500334 /* The following is informational only on read, and not used on writes. */
335 png_byte channels; /* number of data channels per pixel (1, 3, 4)*/
336 png_byte pixel_depth; /* number of bits per pixel */
337 png_byte spare_byte; /* to align the data, and for future use */
338 png_byte signature[8]; /* magic bytes read by libpng from start of file */
339
340 /* The rest of the data is optional. If you are reading, check the
341 * valid field to see if the information in these are valid. If you
342 * are writing, set the valid field to those chunks you want written,
343 * and initialize the appropriate fields below.
344 */
345
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600346#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED) || \
347 defined(PNG_READ_GAMMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500348 /* The gAMA chunk describes the gamma characteristics of the system
349 * on which the image was created, normally in the range [1.0, 2.5].
350 * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
351 */
352 float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
353#endif /* PNG_READ_gAMA_SUPPORTED || PNG_WRITE_gAMA_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600354
355#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
356 /* GR-P, 0.96a */
357 /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
358 png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
359#endif /* PNG_READ_sRGB_SUPPORTED || PNG_WRITE_sRGB_SUPPORTED */
360
Guy Schalnate5a37791996-06-05 15:50:50 -0500361#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
362 defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500363 /* The tEXt and zTXt chunks contain human-readable textual data in
364 * uncompressed and compressed forms, respectively. The data in "text"
365 * is an array of pointers to uncompressed, null-terminated C strings.
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500366 * Each chunk has a keyword that describes the textual data contained
Andreas Dilger47a0c421997-05-16 02:46:07 -0500367 * in that chunk. Keywords are not required to be unique, and the text
368 * string may be empty. Any number of text chunks may be in an image.
369 */
370 int num_text; /* number of comments read/to write */
371 int max_text; /* current size of text array */
372 png_textp text; /* array of comments read/to write */
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500373#endif /* PNG_READ_OR_WRITE_tEXt_OR_zTXt_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500374#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500375 /* The tIME chunk holds the last time the displayed image data was
376 * modified. See the png_time struct for the contents of this struct.
377 */
378 png_time mod_time;
379#endif /* PNG_READ_tIME_SUPPORTED || PNG_WRITE_tIME_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500380#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500381 /* The sBIT chunk specifies the number of significant high-order bits
382 * in the pixel data. Values are in the range [1, bit_depth], and are
383 * only specified for the channels in the pixel data. The contents of
384 * the low-order bits is not specified. Data is valid if
385 * (valid & PNG_INFO_sBIT) is non-zero.
386 */
387 png_color_8 sig_bit; /* significant bits in color channels */
388#endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500389#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED) || \
390 defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500391 /* The tRNS chunk supplies transparency data for paletted images and
392 * other image types that don't need a full alpha channel. There are
393 * "num_trans" transparency values for a paletted image, stored in the
394 * same order as the palette colors, starting from index 0. Values
395 * for the data are in the range [0, 255], ranging from fully transparent
396 * to fully opaque, respectively. For non-paletted images, there is a
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500397 * single color specified that should be treated as fully transparent.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500398 * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
399 */
400 png_bytep trans; /* transparent values for paletted image */
401 png_color_16 trans_values; /* transparent color for non-palette image */
402#endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600403#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED) || \
404 defined(PNG_READ_BACKGROUND_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500405 /* The bKGD chunk gives the suggested image background color if the
406 * display program does not have its own background color and the image
407 * is needs to composited onto a background before display. The colors
408 * in "background" are normally in the same color space/depth as the
409 * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
410 */
411 png_color_16 background;
412#endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500413#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500414 /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
415 * and downwards from the top-left corner of the display, page, or other
416 * application-specific co-ordinate space. See the PNG_OFFSET_ defines
417 * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
418 */
Guy Schalnate5a37791996-06-05 15:50:50 -0500419 png_uint_32 x_offset; /* x offset on page */
420 png_uint_32 y_offset; /* y offset on page */
421 png_byte offset_unit_type; /* offset units type */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500422#endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500423#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500424 /* The pHYs chunk gives the physical pixel density of the image for
425 * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
426 * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
427 */
428 png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
429 png_uint_32 y_pixels_per_unit; /* vertical pixel density */
430 png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
431#endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500432#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500433 /* The hIST chunk contains the relative frequency or importance of the
434 * various palette entries, so that a viewer can intelligently select a
435 * reduced-color palette, if required. Data is an array of "num_palette"
436 * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
437 * is non-zero.
438 */
439 png_uint_16p hist;
440#endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500441#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500442 /* The cHRM chunk describes the CIE color characteristics of the monitor
443 * on which the PNG was created. This data allows the viewer to do gamut
444 * mapping of the input image to ensure that the viewer sees the same
445 * colors in the image as the creator. Values are in the range
446 * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
447 */
448 float x_white;
Guy Schalnat0d580581995-07-20 02:43:20 -0500449 float y_white;
450 float x_red;
451 float y_red;
452 float x_green;
453 float y_green;
454 float x_blue;
455 float y_blue;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500456#endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
457#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
458 /* The pCAL chunk describes a transformation between the stored pixel
459 * values and original physcical data values used to create the image.
460 * The integer range [0, 2^bit_depth - 1] maps to the floating-point
461 * range given by [pcal_X0, pcal_X1], and are further transformed by a
462 * (possibly non-linear) transformation function given by "pcal_type"
463 * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
464 * defines below, and the PNG-Group's Scientific Visualization extension
465 * chunks document png-scivis-19970203 for a complete description of the
466 * transformations and how they should be implemented, as well as the
467 * png-extensions document for a description of the ASCII parameter
468 * strings. Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
469 */
470 png_charp pcal_purpose; /* pCAL chunk description string */
471 png_int_32 pcal_X0; /* minimum value */
472 png_int_32 pcal_X1; /* maximum value */
473 png_charp pcal_units; /* Latin-1 string giving physical units */
474 png_charpp pcal_params; /* ASCII strings containing parameter values */
475 png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
476 png_byte pcal_nparams; /* number of parameters given in pcal_params */
477#endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500478} png_info;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500479typedef png_info FAR * png_infop;
480typedef png_info FAR * FAR * png_infopp;
Guy Schalnat0d580581995-07-20 02:43:20 -0500481
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500482/* Maximum positive integer used in PNG is (2^31)-1 */
483#define PNG_MAX_UINT ((png_uint_32)0x7fffffffL)
484
Andreas Dilger47a0c421997-05-16 02:46:07 -0500485/* These describe the color_type field in png_info. */
Guy Schalnat0d580581995-07-20 02:43:20 -0500486/* color type masks */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500487#define PNG_COLOR_MASK_PALETTE 1
488#define PNG_COLOR_MASK_COLOR 2
489#define PNG_COLOR_MASK_ALPHA 4
Guy Schalnat0d580581995-07-20 02:43:20 -0500490
491/* color types. Note that not all combinations are legal */
Guy Schalnate5a37791996-06-05 15:50:50 -0500492#define PNG_COLOR_TYPE_GRAY 0
Andreas Dilger47a0c421997-05-16 02:46:07 -0500493#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
494#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
495#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
Guy Schalnat0d580581995-07-20 02:43:20 -0500496#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
497
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500498/* This is for compression type. PNG 1.0-1.2 only define the single type. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500499#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
500#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
501
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500502/* This is for filter type. PNG 1.0-1.2 only define the single type. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500503#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
504#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
505
506/* These are for the interlacing type. These values should NOT be changed. */
507#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */
508#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */
509#define PNG_INTERLACE_LAST 2 /* Not a valid value */
510
511/* These are for the oFFs chunk. These values should NOT be changed. */
512#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */
513#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */
514#define PNG_OFFSET_LAST 2 /* Not a valid value */
515
516/* These are for the pCAL chunk. These values should NOT be changed. */
517#define PNG_EQUATION_LINEAR 0 /* Linear transformation */
518#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */
519#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */
520#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */
521#define PNG_EQUATION_LAST 4 /* Not a valid value */
522
523/* These are for the pHYs chunk. These values should NOT be changed. */
524#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */
525#define PNG_RESOLUTION_METER 1 /* pixels/meter */
526#define PNG_RESOLUTION_LAST 2 /* Not a valid value */
527
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600528/* These are for the sRGB chunk. These values should NOT be changed. */
529#define PNG_sRGB_INTENT_SATURATION 0
530#define PNG_sRGB_INTENT_PERCEPTUAL 1
531#define PNG_sRGB_INTENT_ABSOLUTE 2
532#define PNG_sRGB_INTENT_RELATIVE 3
533#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600534
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600535
536
Andreas Dilger47a0c421997-05-16 02:46:07 -0500537/* These determine if an ancillary chunk's data has been successfully read
538 * from the PNG header, or if the application has filled in the corresponding
539 * data in the info_struct to be written into the output file. The values
540 * of the PNG_INFO_<chunk> defines should NOT be changed.
541 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500542#define PNG_INFO_gAMA 0x0001
543#define PNG_INFO_sBIT 0x0002
544#define PNG_INFO_cHRM 0x0004
545#define PNG_INFO_PLTE 0x0008
546#define PNG_INFO_tRNS 0x0010
547#define PNG_INFO_bKGD 0x0020
548#define PNG_INFO_hIST 0x0040
549#define PNG_INFO_pHYs 0x0080
550#define PNG_INFO_oFFs 0x0100
551#define PNG_INFO_tIME 0x0200
Andreas Dilger47a0c421997-05-16 02:46:07 -0500552#define PNG_INFO_pCAL 0x0400
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600553#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
Guy Schalnat0d580581995-07-20 02:43:20 -0500554
Andreas Dilger47a0c421997-05-16 02:46:07 -0500555/* This is used for the transformation routines, as some of them
556 * change these values for the row. It also should enable using
557 * the routines for other purposes.
558 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500559typedef struct png_row_info_struct
560{
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600561 png_uint_32 width; /* width of row */
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600562 png_uint_32 rowbytes; /* number of bytes in row */
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600563 png_byte color_type; /* color type of row */
564 png_byte bit_depth; /* bit depth of row */
565 png_byte channels; /* number of channels (1, 2, 3, or 4) */
566 png_byte pixel_depth; /* bits per pixel (depth * channels) */
Guy Schalnat0d580581995-07-20 02:43:20 -0500567} png_row_info;
568
Andreas Dilger47a0c421997-05-16 02:46:07 -0500569typedef png_row_info FAR * png_row_infop;
570typedef png_row_info FAR * FAR * png_row_infopp;
Guy Schalnat0f716451995-11-28 11:22:13 -0600571
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -0500572/* These are the function types for the I/O functions and for the functions
573 * that allow the user to override the default I/O functions with his or her
574 * own. The png_error_ptr type should match that of user-supplied warning
575 * and error functions, while the png_rw_ptr type should match that of the
576 * user read/write data functions.
Guy Schalnat0f716451995-11-28 11:22:13 -0600577 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600578typedef struct png_struct_def png_struct;
579typedef png_struct FAR * png_structp;
Guy Schalnat0f716451995-11-28 11:22:13 -0600580
Guy Schalnate5a37791996-06-05 15:50:50 -0500581typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp));
Andreas Dilger47a0c421997-05-16 02:46:07 -0500582typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
Guy Schalnat6d764711995-12-19 03:22:19 -0600583typedef void (*png_flush_ptr) PNGARG((png_structp));
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600584typedef void (*png_read_status_ptr) PNGARG((png_structp, png_uint_32, int));
585typedef void (*png_write_status_ptr) PNGARG((png_structp, png_uint_32, int));
Guy Schalnat69b14481996-01-10 02:56:49 -0600586#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
Guy Schalnat6d764711995-12-19 03:22:19 -0600587typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
588typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop));
589typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600590 png_uint_32, int));
Andreas Dilger47a0c421997-05-16 02:46:07 -0500591#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
Guy Schalnat6d764711995-12-19 03:22:19 -0600592
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600593#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
594 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
595typedef void (*png_user_transform_ptr) PNGARG((png_structp,
596 png_row_infop, png_bytep));
597#endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */
598
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500599typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500600typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500601
Andreas Dilger47a0c421997-05-16 02:46:07 -0500602/* The structure that holds the information to read and write PNG files.
603 * The only people who need to care about what is inside of this are the
604 * people who will be modifying the library for their own special needs.
605 * It should NOT be accessed directly by an application, except to store
606 * the jmp_buf.
607 */
Guy Schalnat6d764711995-12-19 03:22:19 -0600608
Guy Schalnat69b14481996-01-10 02:56:49 -0600609struct png_struct_def
Guy Schalnat0d580581995-07-20 02:43:20 -0500610{
Andreas Dilger47a0c421997-05-16 02:46:07 -0500611 jmp_buf jmpbuf; /* used in png_error */
Guy Schalnate5a37791996-06-05 15:50:50 -0500612
Andreas Dilger47a0c421997-05-16 02:46:07 -0500613 png_error_ptr error_fn; /* function for printing errors and aborting */
614 png_error_ptr warning_fn; /* function for printing warnings */
Guy Schalnate5a37791996-06-05 15:50:50 -0500615 png_voidp error_ptr; /* user supplied struct for error functions */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500616 png_rw_ptr write_data_fn; /* function for writing output data */
617 png_rw_ptr read_data_fn; /* function for reading input data */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500618 png_voidp io_ptr; /* ptr to application struct for I/O functions*/
619#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600620 png_user_transform_ptr read_user_transform_fn; /* user read transform */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500621#endif
622#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600623 png_user_transform_ptr write_user_transform_fn; /* user write transform */
624#endif
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500625#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
626 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
627 png_voidp user_transform_ptr; /* user supplied struct for user transform */
628 int user_transform_depth; /* bit depth of user transformed pixels */
629 int user_transform_channels; /* channels in user transformed pixels */
630#endif
Guy Schalnate5a37791996-06-05 15:50:50 -0500631
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600632 png_uint_32 mode; /* tells us where we are in the PNG file */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500633 png_uint_32 flags; /* flags indicating various things to libpng */
Guy Schalnate5a37791996-06-05 15:50:50 -0500634 png_uint_32 transformations; /* which transformations to perform */
635
Andreas Dilger47a0c421997-05-16 02:46:07 -0500636 z_stream zstream; /* pointer to decompression structure (below) */
637 png_bytep zbuf; /* buffer for zlib */
638 png_size_t zbuf_size; /* size of zbuf */
639 int zlib_level; /* holds zlib compression level */
640 int zlib_method; /* holds zlib compression method */
641 int zlib_window_bits; /* holds zlib compression window bits */
642 int zlib_mem_level; /* holds zlib compression memory level */
643 int zlib_strategy; /* holds zlib compression strategy */
Guy Schalnate5a37791996-06-05 15:50:50 -0500644
Andreas Dilger47a0c421997-05-16 02:46:07 -0500645 png_uint_32 width; /* width of image in pixels */
646 png_uint_32 height; /* height of image in pixels */
647 png_uint_32 num_rows; /* number of rows in current pass */
648 png_uint_32 usr_width; /* width of row at start of write */
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600649 png_uint_32 rowbytes; /* size of row in bytes */
650 png_uint_32 irowbytes; /* size of current interlaced row in bytes */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500651 png_uint_32 iwidth; /* width of current interlaced row in pixels */
652 png_uint_32 row_number; /* current row in interlace pass */
653 png_bytep prev_row; /* buffer to save previous (unfiltered) row */
654 png_bytep row_buf; /* buffer to save current (unfiltered) row */
655 png_bytep sub_row; /* buffer to save "sub" row when filtering */
656 png_bytep up_row; /* buffer to save "up" row when filtering */
657 png_bytep avg_row; /* buffer to save "avg" row when filtering */
658 png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
659 png_row_info row_info; /* used for transformation routines */
Guy Schalnate5a37791996-06-05 15:50:50 -0500660
Andreas Dilger47a0c421997-05-16 02:46:07 -0500661 png_uint_32 idat_size; /* current IDAT size for read */
662 png_uint_32 crc; /* current chunk CRC value */
663 png_colorp palette; /* palette from the input file */
664 png_uint_16 num_palette; /* number of color entries in palette */
665 png_uint_16 num_trans; /* number of transparency values */
666 png_byte chunk_name[5]; /* null-terminated name of current chunk */
667 png_byte compression; /* file compression type (always 0) */
668 png_byte filter; /* file filter type (always 0) */
669 png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
670 png_byte pass; /* current interlace pass (0 - 6) */
671 png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
672 png_byte color_type; /* color type of file */
673 png_byte bit_depth; /* bit depth of file */
674 png_byte usr_bit_depth; /* bit depth of users row */
675 png_byte pixel_depth; /* number of bits per pixel */
676 png_byte channels; /* number of channels in file */
677 png_byte usr_channels; /* channels at start of write */
678 png_byte sig_bytes; /* magic bytes read/written from start of file */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600679
Guy Schalnate5a37791996-06-05 15:50:50 -0500680#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -0500681 png_uint_16 filler; /* filler bytes for pixel expansion */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500682#endif /* PNG_READ_FILLER_SUPPORTED */
683#if defined(PNG_READ_bKGD_SUPPORTED)
Guy Schalnate5a37791996-06-05 15:50:50 -0500684 png_byte background_gamma_type;
685 float background_gamma;
Andreas Dilger47a0c421997-05-16 02:46:07 -0500686 png_color_16 background; /* background color in screen gamma space */
Guy Schalnate5a37791996-06-05 15:50:50 -0500687#if defined(PNG_READ_GAMMA_SUPPORTED)
688 png_color_16 background_1; /* background normalized to gamma 1.0 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500689#endif /* PNG_READ_GAMMA && PNG_READ_bKGD_SUPPORTED */
690#endif /* PNG_READ_bKGD_SUPPORTED */
Guy Schalnat6d764711995-12-19 03:22:19 -0600691#if defined(PNG_WRITE_FLUSH_SUPPORTED)
Guy Schalnate5a37791996-06-05 15:50:50 -0500692 png_flush_ptr output_flush_fn;/* Function for flushing output */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500693 png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
694 png_uint_32 flush_rows; /* number of rows written since last flush */
Guy Schalnat6d764711995-12-19 03:22:19 -0600695#endif /* PNG_WRITE_FLUSH_SUPPORTED */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500696#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600697 int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
698 float gamma; /* file gamma value */
699 float screen_gamma; /* screen gamma value (display_gamma/viewing_gamma */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500700#endif /* PNG_READ_GAMMA_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500701#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500702 png_bytep gamma_table; /* gamma table for 8-bit depth files */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500703 png_bytep gamma_from_1; /* converts from 1.0 to screen */
704 png_bytep gamma_to_1; /* converts from file to 1.0 */
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500705 png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
Guy Schalnate5a37791996-06-05 15:50:50 -0500706 png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
707 png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500708#endif /* PNG_READ_GAMMA_SUPPORTED || PNG_WRITE_GAMMA_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500709#if defined(PNG_READ_GAMMA_SUPPORTED) || defined (PNG_READ_sBIT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500710 png_color_8 sig_bit; /* significant bits in each available channel */
711#endif /* PNG_READ_GAMMA_SUPPORTED || PNG_READ_sBIT_SUPPORTED */
Guy Schalnate5a37791996-06-05 15:50:50 -0500712#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500713 png_color_8 shift; /* shift for significant bit tranformation */
714#endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500715#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
716 || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500717 png_bytep trans; /* transparency values for paletted files */
718 png_color_16 trans_values; /* transparency values for non-paletted files */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500719#endif /* PNG_READ|WRITE_tRNS_SUPPORTED||PNG_READ_EXPAND|BACKGROUND_SUPPORTED */
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600720 png_read_status_ptr read_row_fn; /* called after each row is decoded */
721 png_write_status_ptr write_row_fn; /* called after each row is encoded */
Guy Schalnat6d764711995-12-19 03:22:19 -0600722#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -0500723 png_progressive_info_ptr info_fn; /* called after header data fully read */
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600724 png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500725 png_progressive_end_ptr end_fn; /* called after image is complete */
726 png_bytep save_buffer_ptr; /* current location in save_buffer */
727 png_bytep save_buffer; /* buffer for previously read data */
728 png_bytep current_buffer_ptr; /* current location in current_buffer */
729 png_bytep current_buffer; /* buffer for recently used data */
730 png_uint_32 push_length; /* size of current input chunk */
731 png_uint_32 skip_length; /* bytes to skip in input data */
732 png_size_t save_buffer_size; /* amount of data now in save_buffer */
733 png_size_t save_buffer_max; /* total size of save_buffer */
734 png_size_t buffer_size; /* total amount of available input data */
735 png_size_t current_buffer_size; /* amount of data now in current_buffer */
736 int process_mode; /* what push library is currently doing */
737 int cur_palette; /* current push library palette index */
Guy Schalnat6d764711995-12-19 03:22:19 -0600738#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500739 png_size_t current_text_size; /* current size of text input data */
740 png_size_t current_text_left; /* how much text left to read in input */
741 png_charp current_text; /* current text chunk buffer */
742 png_charp current_text_ptr; /* current location in current_text */
743#endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_tEXt/zTXt_SUPPORTED */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600744#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600745#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
746/* for the Borland special 64K segment handler */
747 png_bytepp offset_table_ptr;
748 png_bytep offset_table;
749 png_uint_16 offset_table_number;
750 png_uint_16 offset_table_count;
751 png_uint_16 offset_table_count_free;
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600752#endif /* __TURBOC__&&!_Windows&&!__FLAT__ */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500753#if defined(PNG_READ_DITHER_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500754 png_bytep palette_lookup; /* lookup table for dithering */
755 png_bytep dither_index; /* index translation for palette files */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500756#endif /* PNG_READ_DITHER_SUPPORTED */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -0600757#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_READ_hIST_SUPPORTED)
758 png_uint_16p hist; /* histogram */
759#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -0500760#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
761 png_byte heuristic_method; /* heuristic for row filter selection */
762 png_byte num_prev_filters; /* number of weights for previous rows */
763 png_bytep prev_filters; /* filter type(s) of previous row(s) */
764 png_uint_16p filter_weights; /* weight(s) for previous line(s) */
765 png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
766 png_uint_16p filter_costs; /* relative filter calculation cost */
767 png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
768#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600769#if defined(PNG_TIME_RFC1123_SUPPORTED)
770 png_charp time_buffer; /* String to hold RFC 1123 time text */
771#endif /* PNG_TIME_RFC1123_SUPPORTED */
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500772#ifdef PNG_USER_MEM_SUPPORTED
773 png_voidp mem_ptr; /* user supplied struct for mem functions */
774 png_malloc_ptr malloc_fn; /* function for allocating memory */
775 png_free_ptr free_fn; /* function for freeing memory */
776#endif /* PNG_USER_MEM_SUPPORTED */
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600777#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
778 png_byte rgb_to_gray_status;
779 png_byte rgb_to_gray_red_coeff;
780 png_byte rgb_to_gray_green_coeff;
781 png_byte rgb_to_gray_blue_coeff;
782#endif
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500783#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
784 defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
785 png_byte empty_plte_permitted;
786#endif
Guy Schalnat0f716451995-11-28 11:22:13 -0600787};
Guy Schalnat0d580581995-07-20 02:43:20 -0500788
Andreas Dilger47a0c421997-05-16 02:46:07 -0500789typedef png_struct FAR * FAR * png_structpp;
Guy Schalnat6d764711995-12-19 03:22:19 -0600790
Guy Schalnat0d580581995-07-20 02:43:20 -0500791/* Here are the function definitions most commonly used. This is not
Andreas Dilger47a0c421997-05-16 02:46:07 -0500792 * the place to find out how to use libpng. See libpng.txt for the
793 * full explanation, see example.c for the summary. This just provides
794 * a simple one line of the use of each function.
795 */
Guy Schalnat0d580581995-07-20 02:43:20 -0500796
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600797/* Tell lib we have already handled the first <num_bytes> magic bytes.
Andreas Dilger47a0c421997-05-16 02:46:07 -0500798 * Handling more than 8 bytes from the beginning of the file is an error.
799 */
800extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
801 int num_bytes));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600802
Andreas Dilger47a0c421997-05-16 02:46:07 -0500803/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
804 * PNG file. Returns zero if the supplied bytes match the 8-byte PNG
805 * signature, and non-zero otherwise. Having num_to_check == 0 or
806 * start > 7 will always fail (ie return non-zero).
807 */
808extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
809 png_size_t num_to_check));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600810
Andreas Dilger47a0c421997-05-16 02:46:07 -0500811/* Simple signature checking function. This is the same as calling
812 * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
813 */
814extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
Guy Schalnat0d580581995-07-20 02:43:20 -0500815
Andreas Dilger47a0c421997-05-16 02:46:07 -0500816/* Allocate and initialize png_ptr struct for reading, and any other memory. */
817extern PNG_EXPORT(png_structp,png_create_read_struct)
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500818 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600819 png_error_ptr error_fn, png_error_ptr warn_fn));
Guy Schalnat0d580581995-07-20 02:43:20 -0500820
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500821/* Allocate and initialize png_ptr struct for writing, and any other memory */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500822extern PNG_EXPORT(png_structp,png_create_write_struct)
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500823 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600824 png_error_ptr error_fn, png_error_ptr warn_fn));
Guy Schalnate5a37791996-06-05 15:50:50 -0500825
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500826#ifdef PNG_USER_MEM_SUPPORTED
827extern PNG_EXPORT(png_structp,png_create_read_struct_2)
828 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
829 png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
830 png_malloc_ptr malloc_fn, png_free_ptr free_fn));
831extern PNG_EXPORT(png_structp,png_create_write_struct_2)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600832 PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500833 png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
834 png_malloc_ptr malloc_fn, png_free_ptr free_fn));
835#endif
836
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600837/* Write a PNG chunk - size, type, (optional) data, CRC. */
838extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
839 png_bytep chunk_name, png_bytep data, png_size_t length));
840
841/* Write the start of a PNG chunk - length and chunk name. */
842extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
843 png_bytep chunk_name, png_uint_32 length));
844
845/* Write the data of a PNG chunk started with png_write_chunk_start(). */
846extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
847 png_bytep data, png_size_t length));
848
849/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
850extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
851
Andreas Dilger47a0c421997-05-16 02:46:07 -0500852/* Allocate and initialize the info structure */
853extern PNG_EXPORT(png_infop,png_create_info_struct)
854 PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500855
Andreas Dilger47a0c421997-05-16 02:46:07 -0500856/* Initialize the info structure (old interface - NOT DLL EXPORTED) */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600857extern void png_info_init PNGARG((png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500858
Andreas Dilger47a0c421997-05-16 02:46:07 -0500859/* Writes all the PNG information before the image. */
860extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
861 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500862
863/* read the information before the actual image data. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500864extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
865 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -0500866
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600867#if defined(PNG_TIME_RFC1123_SUPPORTED)
868extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600869 PNGARG((png_structp png_ptr, png_timep ptime));
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600870#endif /* PNG_TIME_RFC1123_SUPPORTED */
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -0600871
Guy Schalnat0f716451995-11-28 11:22:13 -0600872#if defined(PNG_WRITE_tIME_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500873/* convert from a struct tm to png_time */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500874extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
Guy Schalnate5a37791996-06-05 15:50:50 -0500875 struct tm FAR * ttime));
Guy Schalnat0d580581995-07-20 02:43:20 -0500876
877/* convert from time_t to png_time. Uses gmtime() */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500878extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
879 time_t ttime));
880#endif /* PNG_WRITE_tIME_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500881
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500882#if defined(PNG_READ_EXPAND_SUPPORTED)
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500883/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500884extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500885extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
886extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
887extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
Andreas Dilger47a0c421997-05-16 02:46:07 -0500888#endif /* PNG_READ_EXPAND_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500889
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500890#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500891/* Use blue, green, red order for pixels. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500892extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
893#endif /* PNG_READ_BGR_SUPPORTED || PNG_WRITE_BGR_SUPPORTED */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500894
Guy Schalnat69b14481996-01-10 02:56:49 -0600895#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500896/* Expand the grayscale to 24-bit RGB if necessary. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500897extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
898#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
Guy Schalnat69b14481996-01-10 02:56:49 -0600899
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600900#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600901/* Reduce RGB to grayscale. */
902extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500903 int error_action, double red, double green ));
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600904extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
905 png_ptr));
Andreas Dilger47a0c421997-05-16 02:46:07 -0500906#endif /* PNG_READ_RGB_TO_GRAY_SUPPORTED */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600907
Andreas Dilger47a0c421997-05-16 02:46:07 -0500908extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -0600909 png_colorp palette));
910
Andreas Dilger47a0c421997-05-16 02:46:07 -0500911#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
912extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
913#endif /* PNG_READ_STRIP_ALPHA_SUPPORTED */
914
915#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
916 defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
917extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
918#endif /* PNG_READ_SWAP_ALPHA_SUPPORTED || PNG_WRITE_SWAP_ALPHA_SUPPORTED */
919
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600920#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
921 defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
922extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
923#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED || PNG_WRITE_INVERT_ALPHA_SUPPORTED */
924
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500925#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500926/* Add a filler byte to 24-bit RGB images. */
927extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
928 png_uint_32 filler, int flags));
929
930/* The values of the PNG_FILLER_ defines should NOT be changed */
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500931#define PNG_FILLER_BEFORE 0
932#define PNG_FILLER_AFTER 1
Andreas Dilger47a0c421997-05-16 02:46:07 -0500933#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500934
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500935#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500936/* Swap bytes in 16-bit depth files. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500937extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
938#endif /* PNG_READ_SWAP_SUPPORTED || PNG_WRITE_SWAP_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500939
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500940#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500941/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500942extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
943#endif /* PNG_READ_PACK_SUPPORTED || PNG_WRITE_PACK_SUPPORTED */
944
Glenn Randers-Pehrson38d73af1998-03-07 21:30:44 -0600945#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -0500946/* Swap packing order of pixels in bytes. */
947extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500948#endif /* PNG_READ_PACKSWAP_SUPPORTED || PNG_WRITE_PACKSWAP_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500949
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500950#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500951/* Converts files to legal bit depths. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500952extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
Guy Schalnat6d764711995-12-19 03:22:19 -0600953 png_color_8p true_bits));
Andreas Dilger47a0c421997-05-16 02:46:07 -0500954#endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500955
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500956#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
957 defined(PNG_WRITE_INTERLACING_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500958/* Have the code handle the interlacing. Returns the number of passes. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500959extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
960#endif /* PNG_READ_INTERLACING_SUPPORTED || PNG_WRITE_INTERLACING_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500961
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500962#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500963/* Invert monocrome files */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500964extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
965#endif /* PNG_READ_INVERT_SUPPORTED || PNG_WRITE_INVERT_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500966
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500967#if defined(PNG_READ_BACKGROUND_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500968/* Handle alpha and tRNS by replacing with a background color. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500969extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
970 png_color_16p background_color, int background_gamma_code,
971 int need_expand, double background_gamma));
Guy Schalnate5a37791996-06-05 15:50:50 -0500972#define PNG_BACKGROUND_GAMMA_UNKNOWN 0
973#define PNG_BACKGROUND_GAMMA_SCREEN 1
974#define PNG_BACKGROUND_GAMMA_FILE 2
975#define PNG_BACKGROUND_GAMMA_UNIQUE 3
Andreas Dilger47a0c421997-05-16 02:46:07 -0500976#endif /* PNG_READ_BACKGROUND_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500977
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500978#if defined(PNG_READ_16_TO_8_SUPPORTED)
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500979/* strip the second byte of information from a 16-bit depth file. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500980extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
981#endif /* PNG_READ_16_TO_8_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500982
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500983#if defined(PNG_READ_DITHER_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -0500984/* Turn on dithering, and reduce the palette to the number of colors available. */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500985extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
986 png_colorp palette, int num_palette, int maximum_colors,
987 png_uint_16p histogram, int full_dither));
988#endif /* PNG_READ_DITHER_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500989
Guy Schalnat51f0eb41995-09-26 05:22:39 -0500990#if defined(PNG_READ_GAMMA_SUPPORTED)
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -0600991/* Handle gamma correction. Screen_gamma=(display_gamma/viewing_gamma) */
Andreas Dilger47a0c421997-05-16 02:46:07 -0500992extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
993 double screen_gamma, double default_file_gamma));
994#endif /* PNG_READ_GAMMA_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -0500995
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500996#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
997 defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
998/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
999extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
1000 int empty_plte_permitted));
1001#endif /* PNG_READ_EMPTY_PLTE_SUPPORTED */
1002
Guy Schalnat0f716451995-11-28 11:22:13 -06001003#if defined(PNG_WRITE_FLUSH_SUPPORTED)
1004/* Set how many lines between output flushes - 0 for no flushing */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001005extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
Guy Schalnat0f716451995-11-28 11:22:13 -06001006
1007/* Flush the current PNG output buffer */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001008extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
Guy Schalnat0f716451995-11-28 11:22:13 -06001009#endif /* PNG_WRITE_FLUSH_SUPPORTED */
1010
Guy Schalnat0d580581995-07-20 02:43:20 -05001011/* optional update palette with requested transformations */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001012extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001013
1014/* optional call to update the users info structure */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001015extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001016 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001017
1018/* read a one or more rows of image data.*/
Andreas Dilger47a0c421997-05-16 02:46:07 -05001019extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
1020 png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
Guy Schalnat0d580581995-07-20 02:43:20 -05001021
1022/* read a row of data.*/
Andreas Dilger47a0c421997-05-16 02:46:07 -05001023extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001024 png_bytep row,
1025 png_bytep display_row));
Guy Schalnat0d580581995-07-20 02:43:20 -05001026
1027/* read the whole image into memory at once. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001028extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001029 png_bytepp image));
Guy Schalnat0d580581995-07-20 02:43:20 -05001030
1031/* write a row of image data */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001032extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001033 png_bytep row));
Guy Schalnat0d580581995-07-20 02:43:20 -05001034
1035/* write a few rows of image data */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001036extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
1037 png_bytepp row, png_uint_32 num_rows));
Guy Schalnat0d580581995-07-20 02:43:20 -05001038
1039/* write the image data */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001040extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
1041 png_bytepp image));
Guy Schalnat0d580581995-07-20 02:43:20 -05001042
Andreas Dilger47a0c421997-05-16 02:46:07 -05001043/* writes the end of the PNG file. */
1044extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
1045 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001046
Andreas Dilger47a0c421997-05-16 02:46:07 -05001047/* read the end of the PNG file. */
1048extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
1049 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001050
Andreas Dilger47a0c421997-05-16 02:46:07 -05001051/* free any memory associated with the png_info_struct */
1052extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001053 png_infopp info_ptr_ptr));
Guy Schalnate5a37791996-06-05 15:50:50 -05001054
Andreas Dilger47a0c421997-05-16 02:46:07 -05001055/* free any memory associated with the png_struct and the png_info_structs */
1056extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
1057 png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
Guy Schalnate5a37791996-06-05 15:50:50 -05001058
Andreas Dilger47a0c421997-05-16 02:46:07 -05001059/* free all memory used by the read (old method - NOT DLL EXPORTED) */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001060extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
1061 png_infop end_info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001062
Andreas Dilger47a0c421997-05-16 02:46:07 -05001063/* free any memory associated with the png_struct and the png_info_structs */
1064extern PNG_EXPORT(void,png_destroy_write_struct)
1065 PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
Guy Schalnate5a37791996-06-05 15:50:50 -05001066
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001067/* free any memory used in info_ptr struct (old method - NOT DLL EXPORTED) */
1068extern void png_write_destroy_info PNGARG((png_infop info_ptr));
1069
Andreas Dilger47a0c421997-05-16 02:46:07 -05001070/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
Guy Schalnat6d764711995-12-19 03:22:19 -06001071extern void png_write_destroy PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001072
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001073/* set the libpng method of handling chunk CRC errors */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001074extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
1075 int crit_action, int ancil_action));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001076
1077/* Values for png_set_crc_action() to say how to handle CRC errors in
Andreas Dilger47a0c421997-05-16 02:46:07 -05001078 * ancillary and critical chunks, and whether to use the data contained
1079 * therein. Note that it is impossible to "discard" data in a critical
1080 * chunk. For versions prior to 0.90, the action was always error/quit,
1081 * whereas in version 0.90 and later, the action for CRC errors in ancillary
1082 * chunks is warn/discard. These values should NOT be changed.
1083 *
1084 * value action:critical action:ancillary
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001085 */
1086#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */
1087#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */
1088#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */
1089#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */
1090#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
1091#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
1092
Andreas Dilger47a0c421997-05-16 02:46:07 -05001093/* These functions give the user control over the scan-line filtering in
1094 * libpng and the compression methods used by zlib. These functions are
1095 * mainly useful for testing, as the defaults should work with most users.
1096 * Those users who are tight on memory or want faster performance at the
1097 * expense of compression can modify them. See the compression library
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001098 * header file (zlib.h) for an explination of the compression functions.
1099 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001100
Andreas Dilger47a0c421997-05-16 02:46:07 -05001101/* set the filtering method(s) used by libpng. Currently, the only valid
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001102 * value for "method" is 0.
1103 */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001104extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
Guy Schalnate5a37791996-06-05 15:50:50 -05001105 int filters));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001106
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001107/* Flags for png_set_filter() to say which filters to use. The flags
Andreas Dilger47a0c421997-05-16 02:46:07 -05001108 * are chosen so that they don't conflict with real filter types
1109 * below, in case they are supplied instead of the #defined constants.
1110 * These values should NOT be changed.
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001111 */
1112#define PNG_NO_FILTERS 0x00
1113#define PNG_FILTER_NONE 0x08
1114#define PNG_FILTER_SUB 0x10
1115#define PNG_FILTER_UP 0x20
1116#define PNG_FILTER_AVG 0x40
1117#define PNG_FILTER_PAETH 0x80
1118#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
1119 PNG_FILTER_AVG | PNG_FILTER_PAETH)
1120
Andreas Dilger47a0c421997-05-16 02:46:07 -05001121/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
1122 * These defines should NOT be changed.
1123 */
1124#define PNG_FILTER_VALUE_NONE 0
1125#define PNG_FILTER_VALUE_SUB 1
1126#define PNG_FILTER_VALUE_UP 2
1127#define PNG_FILTER_VALUE_AVG 3
1128#define PNG_FILTER_VALUE_PAETH 4
1129#define PNG_FILTER_VALUE_LAST 5
1130
1131#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
1132/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
1133 * defines, either the default (minimum-sum-of-absolute-differences), or
1134 * the experimental method (weighted-minimum-sum-of-absolute-differences).
1135 *
1136 * Weights are factors >= 1.0, indicating how important it is to keep the
1137 * filter type consistent between rows. Larger numbers mean the current
1138 * filter is that many times as likely to be the same as the "num_weights"
1139 * previous filters. This is cumulative for each previous row with a weight.
1140 * There needs to be "num_weights" values in "filter_weights", or it can be
1141 * NULL if the weights aren't being specified. Weights have no influence on
1142 * the selection of the first row filter. Well chosen weights can (in theory)
1143 * improve the compression for a given image.
1144 *
1145 * Costs are factors >= 1.0 indicating the relative decoding costs of a
1146 * filter type. Higher costs indicate more decoding expense, and are
1147 * therefore less likely to be selected over a filter with lower computational
1148 * costs. There needs to be a value in "filter_costs" for each valid filter
1149 * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
1150 * setting the costs. Costs try to improve the speed of decompression without
1151 * unduly increasing the compressed image size.
1152 *
1153 * A negative weight or cost indicates the default value is to be used, and
1154 * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
1155 * The default values for both weights and costs are currently 1.0, but may
1156 * change if good general weighting/cost heuristics can be found. If both
1157 * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
1158 * to the UNWEIGHTED method, but with added encoding time/computation.
1159 */
1160extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
1161 int heuristic_method, int num_weights, png_doublep filter_weights,
1162 png_doublep filter_costs));
1163#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
1164
1165/* Heuristic used for row filter selection. These defines should NOT be
1166 * changed.
1167 */
1168#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
1169#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
1170#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
1171#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
1172
1173/* Set the library compression level. Currently, valid values range from
1174 * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
1175 * (0 - no compression, 9 - "maximal" compression). Note that tests have
1176 * shown that zlib compression levels 3-6 usually perform as well as level 9
1177 * for PNG images, and do considerably fewer caclulations. In the future,
1178 * these values may not correspond directly to the zlib compression levels.
1179 */
1180extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001181 int level));
1182
Andreas Dilger47a0c421997-05-16 02:46:07 -05001183extern PNG_EXPORT(void,png_set_compression_mem_level)
1184 PNGARG((png_structp png_ptr, int mem_level));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001185
Andreas Dilger47a0c421997-05-16 02:46:07 -05001186extern PNG_EXPORT(void,png_set_compression_strategy)
1187 PNGARG((png_structp png_ptr, int strategy));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001188
Andreas Dilger47a0c421997-05-16 02:46:07 -05001189extern PNG_EXPORT(void,png_set_compression_window_bits)
1190 PNGARG((png_structp png_ptr, int window_bits));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001191
Andreas Dilger47a0c421997-05-16 02:46:07 -05001192extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001193 int method));
Guy Schalnat0d580581995-07-20 02:43:20 -05001194
Guy Schalnate5a37791996-06-05 15:50:50 -05001195/* These next functions are called for input/output, memory, and error
Andreas Dilger47a0c421997-05-16 02:46:07 -05001196 * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
1197 * and call standard C I/O routines such as fread(), fwrite(), and
1198 * fprintf(). These functions can be made to use other I/O routines
1199 * at run time for those applications that need to handle I/O in a
1200 * different manner by calling png_set_???_fn(). See libpng.txt for
1201 * more information.
1202 */
Guy Schalnat0d580581995-07-20 02:43:20 -05001203
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -06001204#if !defined(PNG_NO_STDIO)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001205/* Initialize the input/output for the PNG file to the default functions. */
1206extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, FILE *fp));
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -06001207#endif
Guy Schalnat6d764711995-12-19 03:22:19 -06001208
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001209/* Replace the (error and abort), and warning functions with user
Andreas Dilger47a0c421997-05-16 02:46:07 -05001210 * supplied functions. If no messages are to be printed you must still
1211 * write and use replacement functions. The replacement error_fn should
1212 * still do a longjmp to the last setjmp location if you are using this
1213 * method of error handling. If error_fn or warning_fn is NULL, the
1214 * default function will be used.
1215 */
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001216
Andreas Dilger47a0c421997-05-16 02:46:07 -05001217extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
1218 png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
Guy Schalnat6d764711995-12-19 03:22:19 -06001219
Guy Schalnate5a37791996-06-05 15:50:50 -05001220/* Return the user pointer associated with the error functions */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001221extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06001222
1223/* Replace the default data output functions with a user supplied one(s).
Andreas Dilger47a0c421997-05-16 02:46:07 -05001224 * If buffered output is not used, then output_flush_fn can be set to NULL.
1225 * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
1226 * output_flush_fn will be ignored (and thus can be NULL).
1227 */
1228extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
1229 png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
Guy Schalnat6d764711995-12-19 03:22:19 -06001230
1231/* Replace the default data input function with a user supplied one. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001232extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
1233 png_voidp io_ptr, png_rw_ptr read_data_fn));
Guy Schalnat6d764711995-12-19 03:22:19 -06001234
1235/* Return the user pointer associated with the I/O functions */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001236extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06001237
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001238extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
1239 png_read_status_ptr read_row_fn));
1240
1241extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
1242 png_write_status_ptr write_row_fn));
1243
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05001244#ifdef PNG_USER_MEM_SUPPORTED
1245/* Replace the default memory allocation functions with user supplied one(s). */
1246extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
1247 png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
1248
1249/* Return the user pointer associated with the memory functions */
1250extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
1251#endif /* PNG_USER_MEM_SUPPORTED */
1252
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001253#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
1254extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
1255 png_ptr, png_user_transform_ptr read_user_transform_fn));
1256#endif
1257
1258#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
1259extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
1260 png_ptr, png_user_transform_ptr write_user_transform_fn));
1261#endif
1262
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001263#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
1264 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
1265extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
1266 png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
1267 int user_transform_channels));
1268/* Return the user pointer associated with the user transform functions */
1269extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
1270 PNGARG((png_structp png_ptr));
1271#endif
1272
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001273#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05001274/* Sets the function callbacks for the push reader, and a pointer to a
1275 * user-defined structure available to the callback functions.
1276 */
1277extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
1278 png_voidp progressive_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001279 png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
1280 png_progressive_end_ptr end_fn));
Guy Schalnat6d764711995-12-19 03:22:19 -06001281
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001282/* returns the user pointer associated with the push read functions */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001283extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
1284 PNGARG((png_structp png_ptr));
1285
1286/* function to be called when data becomes available */
1287extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
1288 png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
1289
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -05001290/* function that combines rows. Not very much different than the
Andreas Dilger47a0c421997-05-16 02:46:07 -05001291 * png_combine_row() call. Is this even used?????
1292 */
1293extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
1294 png_bytep old_row, png_bytep new_row));
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001295#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
Guy Schalnat6d764711995-12-19 03:22:19 -06001296
Andreas Dilger47a0c421997-05-16 02:46:07 -05001297extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001298 png_uint_32 size));
Guy Schalnat0d580581995-07-20 02:43:20 -05001299
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001300/* frees a pointer allocated by png_malloc() */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001301extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
Guy Schalnate5a37791996-06-05 15:50:50 -05001302
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05001303#ifdef PNG_USER_MEM_SUPPORTED
1304extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
1305 png_uint_32 size));
1306extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
1307 png_voidp ptr));
1308#endif /* PNG_USER_MEM_SUPPORTED */
1309
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001310extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06001311 png_voidp s1, png_voidp s2, png_uint_32 size));
1312
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001313extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr,
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06001314 png_voidp s1, int value, png_uint_32 size));
1315
Andreas Dilger47a0c421997-05-16 02:46:07 -05001316#if defined(USE_FAR_KEYWORD) /* memory model conversion function */
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001317extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
1318 int check));
Andreas Dilger47a0c421997-05-16 02:46:07 -05001319#endif /* USE_FAR_KEYWORD */
1320
1321/* Fatal error in PNG image of libpng - can't continue */
1322extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
1323 png_const_charp error));
Guy Schalnat0d580581995-07-20 02:43:20 -05001324
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -06001325/* The same, but the chunk name is prepended to the error string. */
1326extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
1327 png_const_charp error));
1328
Guy Schalnat6d764711995-12-19 03:22:19 -06001329/* Non-fatal error in libpng. Can continue, but may have a problem. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001330extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
1331 png_const_charp message));
Guy Schalnat0d580581995-07-20 02:43:20 -05001332
Glenn Randers-Pehrson70e3f541998-01-03 22:40:55 -06001333/* Non-fatal error in libpng, chunk name is prepended to message. */
1334extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
1335 png_const_charp message));
1336
Andreas Dilger47a0c421997-05-16 02:46:07 -05001337/* The png_set_<chunk> functions are for storing values in the png_info_struct.
1338 * Similarly, the png_get_<chunk> calls are used to read values from the
1339 * png_info_struct, either storing the parameters in the passed variables, or
1340 * setting pointers into the png_info_struct where the data is stored. The
1341 * png_get_<chunk> functions return a non-zero value if the data was available
1342 * in info_ptr, or return zero and do not change any of the parameters if the
1343 * data was not available.
1344 *
1345 * These functions should be used instead of directly accessing png_info
1346 * to avoid problems with future changes in the size and internal layout of
1347 * png_info_struct.
1348 */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001349/* Returns "flag" if chunk data is valid in info_ptr. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001350extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
1351png_infop info_ptr, png_uint_32 flag));
1352
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001353/* Returns number of bytes needed to hold a transformed row. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001354extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
1355png_infop info_ptr));
1356
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001357/* Returns number of color channels in image. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001358extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
1359png_infop info_ptr));
1360
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001361#ifdef PNG_EASY_ACCESS_SUPPORTED
1362/* Returns image width in pixels. */
1363extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
1364png_ptr, png_infop info_ptr));
1365
1366/* Returns image height in pixels. */
1367extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
1368png_ptr, png_infop info_ptr));
1369
1370/* Returns image bit_depth. */
1371extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
1372png_ptr, png_infop info_ptr));
1373
1374/* Returns image color_type. */
1375extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
1376png_ptr, png_infop info_ptr));
1377
1378/* Returns image filter_type. */
1379extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
1380png_ptr, png_infop info_ptr));
1381
1382/* Returns image interlace_type. */
1383extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
1384png_ptr, png_infop info_ptr));
1385
1386/* Returns image compression_type. */
1387extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
1388png_ptr, png_infop info_ptr));
1389
1390/* Returns image resolution in pixels per meter, from pHYs chunk data. */
1391extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
1392png_ptr, png_infop info_ptr));
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001393extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
1394png_ptr, png_infop info_ptr));
1395extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
1396png_ptr, png_infop info_ptr));
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001397
1398/* Returns pixel aspect ratio, computed from pHYs chunk data. */
1399extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
1400png_ptr, png_infop info_ptr));
1401
1402/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
1403extern PNG_EXPORT(png_uint_32, png_get_x_offset_pixels) PNGARG((png_structp
1404png_ptr, png_infop info_ptr));
1405extern PNG_EXPORT(png_uint_32, png_get_y_offset_pixels) PNGARG((png_structp
1406png_ptr, png_infop info_ptr));
1407extern PNG_EXPORT(png_uint_32, png_get_x_offset_microns) PNGARG((png_structp
1408png_ptr, png_infop info_ptr));
1409extern PNG_EXPORT(png_uint_32, png_get_y_offset_microns) PNGARG((png_structp
1410png_ptr, png_infop info_ptr));
1411
1412#endif /* PNG_EASY_ACCESS_SUPPORTED */
1413
Andreas Dilger47a0c421997-05-16 02:46:07 -05001414/* Returns pointer to signature string read from PNG header */
1415extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
1416png_infop info_ptr));
1417
1418#if defined(PNG_READ_bKGD_SUPPORTED)
1419extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
1420 png_infop info_ptr, png_color_16p *background));
1421#endif /* PNG_READ_bKGD_SUPPORTED */
1422
1423#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
1424extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
1425 png_infop info_ptr, png_color_16p background));
1426#endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
1427
1428#if defined(PNG_READ_cHRM_SUPPORTED)
1429extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
1430 png_infop info_ptr, double *white_x, double *white_y, double *red_x,
1431 double *red_y, double *green_x, double *green_y, double *blue_x,
1432 double *blue_y));
1433#endif /* PNG_READ_cHRM_SUPPORTED */
1434
1435#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
1436extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
1437 png_infop info_ptr, double white_x, double white_y, double red_x,
1438 double red_y, double green_x, double green_y, double blue_x, double blue_y));
1439#endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
1440
1441#if defined(PNG_READ_gAMA_SUPPORTED)
1442extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
1443 png_infop info_ptr, double *file_gamma));
1444#endif /* PNG_READ_gAMA_SUPPORTED */
1445
1446#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
1447extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
1448 png_infop info_ptr, double file_gamma));
1449#endif /* PNG_READ_gAMA_SUPPORTED || PNG_WRITE_gAMA_SUPPORTED */
1450
1451#if defined(PNG_READ_hIST_SUPPORTED)
1452extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
1453 png_infop info_ptr, png_uint_16p *hist));
1454#endif /* PNG_READ_hIST_SUPPORTED */
1455
1456#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
1457extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
1458 png_infop info_ptr, png_uint_16p hist));
1459#endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
1460
1461extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
1462 png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
1463 int *bit_depth, int *color_type, int *interlace_type,
1464 int *compression_type, int *filter_type));
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001465
Andreas Dilger47a0c421997-05-16 02:46:07 -05001466extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
1467 png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
1468 int color_type, int interlace_type, int compression_type, int filter_type));
1469
1470#if defined(PNG_READ_oFFs_SUPPORTED)
1471extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
1472 png_infop info_ptr, png_uint_32 *offset_x, png_uint_32 *offset_y,
1473 int *unit_type));
1474#endif /* PNG_READ_oFFs_SUPPORTED */
1475
1476#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
1477extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
1478 png_infop info_ptr, png_uint_32 offset_x, png_uint_32 offset_y,
1479 int unit_type));
1480#endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
1481
1482#if defined(PNG_READ_pCAL_SUPPORTED)
1483extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
1484 png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
1485 int *type, int *nparams, png_charp *units, png_charpp *params));
1486#endif /* PNG_READ_pCAL_SUPPORTED */
1487
1488#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
1489extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
1490 png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
1491 int type, int nparams, png_charp units, png_charpp params));
1492#endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
1493
1494#if defined(PNG_READ_pHYs_SUPPORTED)
1495extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
1496 png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
1497#endif /* PNG_READ_pHYs_SUPPORTED */
1498
1499#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
1500extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
1501 png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
1502#endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
1503
1504extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
1505 png_infop info_ptr, png_colorp *palette, int *num_palette));
1506
1507extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
1508 png_infop info_ptr, png_colorp palette, int num_palette));
1509
1510#if defined(PNG_READ_sBIT_SUPPORTED)
1511extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
1512 png_infop info_ptr, png_color_8p *sig_bit));
1513#endif /* PNG_READ_sBIT_SUPPORTED */
1514
1515#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
1516extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
1517 png_infop info_ptr, png_color_8p sig_bit));
1518#endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
1519
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001520#if defined(PNG_READ_sRGB_SUPPORTED)
1521extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -06001522 png_infop info_ptr, int *intent));
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001523#endif /* PNG_READ_sRGB_SUPPORTED */
1524
1525#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
1526extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -06001527 png_infop info_ptr, int intent));
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001528extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -06001529 png_infop info_ptr, int intent));
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001530#endif /* PNG_READ_sRGB_SUPPORTED || PNG_WRITE_sRGB_SUPPORTED */
1531
Andreas Dilger47a0c421997-05-16 02:46:07 -05001532#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
1533/* png_get_text also returns the number of text chunks in text_ptr */
1534extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
1535 png_infop info_ptr, png_textp *text_ptr, int *num_text));
1536#endif /* PNG_READ_tEXt_SUPPORTED || PNG_READ_zTXt_SUPPORTED */
1537
1538#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
1539 defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
1540extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
1541 png_infop info_ptr, png_textp text_ptr, int num_text));
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -05001542#endif /* PNG_READ_OR_WRITE_tEXt_OR_zTXt_SUPPORTED */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001543
1544#if defined(PNG_READ_tIME_SUPPORTED)
1545extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
1546 png_infop info_ptr, png_timep *mod_time));
1547#endif /* PNG_READ_tIME_SUPPORTED */
1548
1549#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
1550extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
1551 png_infop info_ptr, png_timep mod_time));
1552#endif /* PNG_READ_tIME_SUPPORTED || PNG_WRITE_tIME_SUPPORTED */
1553
1554#if defined(PNG_READ_tRNS_SUPPORTED)
1555extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
1556 png_infop info_ptr, png_bytep *trans, int *num_trans,
1557 png_color_16p *trans_values));
1558#endif /* PNG_READ_tRNS_SUPPORTED */
1559
1560#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
1561extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
1562 png_infop info_ptr, png_bytep trans, int num_trans,
1563 png_color_16p trans_values));
1564#endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
1565
1566/* Define PNG_DEBUG at compile time for debugging information. Higher
1567 * numbers for PNG_DEBUG mean more debugging information. This has
1568 * only been added since version 0.95 so it is not implemented throughout
1569 * libpng yet, but more support will be added as needed.
1570 */
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001571#ifdef PNG_DEBUG
Andreas Dilger47a0c421997-05-16 02:46:07 -05001572#if (PNG_DEBUG > 0)
1573#ifndef PNG_DEBUG_FILE
1574#define PNG_DEBUG_FILE stderr
1575#endif /* PNG_DEBUG_FILE */
1576
1577#define png_debug(l,m) if (PNG_DEBUG > l) \
1578 fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001579 (l==2 ? "\t\t":(l>2 ? "\t\t\t":""))))
Andreas Dilger47a0c421997-05-16 02:46:07 -05001580#define png_debug1(l,m,p1) if (PNG_DEBUG > l) \
1581 fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001582 (l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001583#define png_debug2(l,m,p1,p2) if (PNG_DEBUG > l) \
1584 fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001585 (l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1,p2)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001586#endif /* (PNG_DEBUG > 0) */
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001587#endif /* PNG_DEBUG */
1588#ifndef png_debug
1589#define png_debug(l, m)
1590#endif
1591#ifndef png_debug1
1592#define png_debug1(l, m, p1)
1593#endif
1594#ifndef png_debug2
1595#define png_debug2(l, m, p1, p2)
1596#endif
1597
1598extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001599extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
Glenn Randers-Pehrsonc9442291999-01-06 21:50:16 -06001600
1601#ifdef PNG_NO_EXTERN
1602/* this only gets included in png.c */
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001603png_charp
1604png_get_header_version(png_structp png_ptr)
1605{
Glenn Randers-Pehrsonc9442291999-01-06 21:50:16 -06001606 if(png_ptr == NULL)
1607 /* silence compiler warning about unused png_ptr */ ;
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001608 return("\n libpng version 1.0.4 - September 18, 1999 (header)\n");
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001609}
1610#endif
Andreas Dilger47a0c421997-05-16 02:46:07 -05001611
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -05001612#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
Glenn Randers-Pehrson8686fff1998-05-21 09:27:50 -05001613/* With these routines we avoid an integer divide, which will be slower on
1614 * most machines. However, it does take more operations than the corresponding
1615 * divide method, so it may be slower on a few RISC systems. There are two
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -05001616 * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
1617 *
1618 * Note that the rounding factors are NOT supposed to be the same! 128 and
1619 * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
1620 * standard method.
1621 *
1622 * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
1623 */
1624
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001625 /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
1626
1627# define png_composite(composite, fg, alpha, bg) \
1628 { png_uint_16 temp = ((png_uint_16)(fg) * (png_uint_16)(alpha) + \
1629 (png_uint_16)(bg)*(png_uint_16)(255 - \
1630 (png_uint_16)(alpha)) + (png_uint_16)128); \
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -05001631 (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001632
1633# define png_composite_16(composite, fg, alpha, bg) \
1634 { png_uint_32 temp = ((png_uint_32)(fg) * (png_uint_32)(alpha) + \
1635 (png_uint_32)(bg)*(png_uint_32)(65535L - \
1636 (png_uint_32)(alpha)) + (png_uint_32)32768L); \
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -05001637 (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
1638
1639#else /* standard method using integer division */
1640
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001641# define png_composite(composite, fg, alpha, bg) \
1642 (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
1643 (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -05001644 (png_uint_16)127) / 255)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001645
1646# define png_composite_16(composite, fg, alpha, bg) \
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -05001647 (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001648 (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -05001649 (png_uint_32)32767) / (png_uint_32)65535L)
1650
1651#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
1652
Andreas Dilger47a0c421997-05-16 02:46:07 -05001653/* These next functions are used internally in the code. They generally
1654 * shouldn't be used unless you are writing code to add or replace some
1655 * functionality in libpng. More information about most functions can
1656 * be found in the files where the functions are located.
1657 */
Guy Schalnat0d580581995-07-20 02:43:20 -05001658
Guy Schalnate5a37791996-06-05 15:50:50 -05001659#if defined(PNG_INTERNAL)
Guy Schalnat0d580581995-07-20 02:43:20 -05001660
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001661/* Various modes of operation. Note that after an init, mode is set to
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001662 * zero automatically when the structure is created.
1663 */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001664#define PNG_BEFORE_IHDR 0x00
1665#define PNG_HAVE_IHDR 0x01
1666#define PNG_HAVE_PLTE 0x02
1667#define PNG_HAVE_IDAT 0x04
1668#define PNG_AFTER_IDAT 0x08
1669#define PNG_HAVE_IEND 0x10
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001670#define PNG_HAVE_gAMA 0x20
1671#define PNG_HAVE_cHRM 0x40
1672#define PNG_HAVE_sRGB 0x80
Guy Schalnat0d580581995-07-20 02:43:20 -05001673
Guy Schalnat6d764711995-12-19 03:22:19 -06001674/* push model modes */
Guy Schalnate5a37791996-06-05 15:50:50 -05001675#define PNG_READ_SIG_MODE 0
Guy Schalnat6d764711995-12-19 03:22:19 -06001676#define PNG_READ_CHUNK_MODE 1
Guy Schalnate5a37791996-06-05 15:50:50 -05001677#define PNG_READ_IDAT_MODE 2
Andreas Dilger47a0c421997-05-16 02:46:07 -05001678#define PNG_SKIP_MODE 3
1679#define PNG_READ_tEXt_MODE 4
1680#define PNG_READ_zTXt_MODE 5
1681#define PNG_READ_DONE_MODE 6
1682#define PNG_ERROR_MODE 7
Guy Schalnat6d764711995-12-19 03:22:19 -06001683
Andreas Dilger47a0c421997-05-16 02:46:07 -05001684/* flags for the transformations the PNG library does on the image data */
Guy Schalnate5a37791996-06-05 15:50:50 -05001685#define PNG_BGR 0x0001
1686#define PNG_INTERLACE 0x0002
1687#define PNG_PACK 0x0004
1688#define PNG_SHIFT 0x0008
1689#define PNG_SWAP_BYTES 0x0010
1690#define PNG_INVERT_MONO 0x0020
1691#define PNG_DITHER 0x0040
1692#define PNG_BACKGROUND 0x0080
1693#define PNG_BACKGROUND_EXPAND 0x0100
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001694 /* 0x0200 unused */
Guy Schalnate5a37791996-06-05 15:50:50 -05001695#define PNG_16_TO_8 0x0400
1696#define PNG_RGBA 0x0800
1697#define PNG_EXPAND 0x1000
1698#define PNG_GAMMA 0x2000
1699#define PNG_GRAY_TO_RGB 0x4000
1700#define PNG_FILLER 0x8000
Glenn Randers-Pehrson397100e1998-03-07 19:45:37 -06001701#define PNG_PACKSWAP 0x10000L
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06001702#define PNG_SWAP_ALPHA 0x20000L
1703#define PNG_STRIP_ALPHA 0x40000L
1704#define PNG_INVERT_ALPHA 0x80000L
Glenn Randers-Pehrson397100e1998-03-07 19:45:37 -06001705#define PNG_USER_TRANSFORM 0x100000L
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001706#define PNG_RGB_TO_GRAY_ERR 0x200000L
1707#define PNG_RGB_TO_GRAY_WARN 0x400000L
1708#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
Guy Schalnate5a37791996-06-05 15:50:50 -05001709
Guy Schalnate5a37791996-06-05 15:50:50 -05001710/* flags for png_create_struct */
1711#define PNG_STRUCT_PNG 0x0001
1712#define PNG_STRUCT_INFO 0x0002
1713
Andreas Dilger47a0c421997-05-16 02:46:07 -05001714/* Scaling factor for filter heuristic weighting calculations */
1715#define PNG_WEIGHT_SHIFT 8
1716#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
1717#define PNG_COST_SHIFT 3
1718#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
1719
1720/* flags for the png_ptr->flags rather than declaring a byte for each one */
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001721#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
1722#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002
1723#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004
1724#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008
1725#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010
1726#define PNG_FLAG_ZLIB_FINISHED 0x0020
1727#define PNG_FLAG_ROW_INIT 0x0040
1728#define PNG_FLAG_FILLER_AFTER 0x0080
1729#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
1730#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
1731#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
1732#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
1733#define PNG_FLAG_FREE_PALETTE 0x1000
1734#define PNG_FLAG_FREE_TRANS 0x2000
1735#define PNG_FLAG_FREE_HIST 0x4000
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001736#define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000L
Glenn Randers-Pehrson397100e1998-03-07 19:45:37 -06001737#define PNG_FLAG_WROTE_tIME 0x10000L
Glenn Randers-Pehrson1d963611998-05-02 12:52:25 -05001738#define PNG_FLAG_BACKGROUND_IS_GRAY 0x20000L
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001739
1740#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
1741 PNG_FLAG_CRC_ANCILLARY_NOWARN)
1742
1743#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
1744 PNG_FLAG_CRC_CRITICAL_IGNORE)
1745
1746#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
1747 PNG_FLAG_CRC_CRITICAL_MASK)
Guy Schalnat0d580581995-07-20 02:43:20 -05001748
1749/* save typing and make code easier to understand */
1750#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
1751 abs((int)((c1).green) - (int)((c2).green)) + \
1752 abs((int)((c1).blue) - (int)((c2).blue)))
1753
Andreas Dilger47a0c421997-05-16 02:46:07 -05001754/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06001755#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001756/* place to hold the signature string for a PNG file. */
1757extern png_byte FARDATA png_sig[8];
Guy Schalnat0d580581995-07-20 02:43:20 -05001758
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001759/* Constant strings for known chunk types. If you need to add a chunk,
1760 * add a string holding the name here. See png.c for more details. We
1761 * can't selectively include these, since we still check for chunk in the
1762 * wrong locations with these labels.
1763 */
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001764extern png_byte FARDATA png_IHDR[5];
1765extern png_byte FARDATA png_IDAT[5];
1766extern png_byte FARDATA png_IEND[5];
1767extern png_byte FARDATA png_PLTE[5];
1768extern png_byte FARDATA png_bKGD[5];
1769extern png_byte FARDATA png_cHRM[5];
1770extern png_byte FARDATA png_gAMA[5];
1771extern png_byte FARDATA png_hIST[5];
1772extern png_byte FARDATA png_oFFs[5];
1773extern png_byte FARDATA png_pCAL[5];
1774extern png_byte FARDATA png_pHYs[5];
1775extern png_byte FARDATA png_sBIT[5];
1776extern png_byte FARDATA png_sRGB[5];
1777extern png_byte FARDATA png_tEXt[5];
1778extern png_byte FARDATA png_tIME[5];
1779extern png_byte FARDATA png_tRNS[5];
1780extern png_byte FARDATA png_zTXt[5];
Guy Schalnat0d580581995-07-20 02:43:20 -05001781
1782#endif /* PNG_NO_EXTERN */
1783
Andreas Dilger47a0c421997-05-16 02:46:07 -05001784/* Inline macros to do direct reads of bytes from the input buffer. These
1785 * require that you are using an architecture that uses PNG byte ordering
1786 * (MSB first) and supports unaligned data storage. I think that PowerPC
1787 * in big-endian mode and 680x0 are the only ones that will support this.
1788 * The x86 line of processors definitely do not. The png_get_int_32()
1789 * routine also assumes we are using two's complement format for negative
1790 * values, which is almost certainly true.
1791 */
1792#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
1793#if defined(PNG_READ_pCAL_SUPPORTED)
1794#define png_get_int_32(buf) ( *((png_int_32p) (buf)))
1795#endif /* PNG_READ_pCAL_SUPPORTED */
1796#define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
1797#define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
1798#else
1799#if defined(PNG_READ_pCAL_SUPPORTED)
1800PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
1801#endif /* PNG_READ_pCAL_SUPPORTED */
1802PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
1803PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05001804#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001805
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001806/* Initialize png_ptr struct for reading, and allocate any other memory.
1807 * (old interface - NOT DLL EXPORTED).
1808 */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001809extern void png_read_init PNGARG((png_structp png_ptr));
1810
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001811/* Initialize png_ptr struct for writing, and allocate any other memory.
1812 * (old interface - NOT DLL EXPORTED).
1813 */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001814extern void png_write_init PNGARG((png_structp png_ptr));
1815
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001816/* allocate memory for an internal libpng struct */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001817PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001818
1819/* free memory from internal libpng struct */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001820PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001821
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05001822PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
1823 malloc_fn));
1824PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
1825 png_free_ptr free_fn));
1826
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001827/* free any memory that info_ptr points to and reset struct. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001828PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001829 png_infop info_ptr));
1830
Guy Schalnat0d580581995-07-20 02:43:20 -05001831/* Function to allocate memory for zlib. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001832PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
Guy Schalnat0d580581995-07-20 02:43:20 -05001833
1834/* function to free memory for zlib */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001835PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001836
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001837/* reset the CRC variable */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001838PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
1839
1840/* Write the "data" buffer to whatever output you are using. */
1841PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
1842 png_size_t length));
1843
1844/* Read data from whatever input you are using into the "data" buffer */
1845PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
1846 png_size_t length));
Guy Schalnat0d580581995-07-20 02:43:20 -05001847
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001848/* read bytes into buf, and update png_ptr->crc */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001849PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
1850 png_size_t length));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001851
1852/* read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001853PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001854
1855/* read the CRC from the file and compare it to the libpng calculated CRC */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001856PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001857
Andreas Dilger47a0c421997-05-16 02:46:07 -05001858/* Calculate the CRC over a section of data. Note that we are only
1859 * passing a maximum of 64K on systems that have this as a memory limit,
1860 * since this is the maximum buffer size we can specify.
1861 */
1862PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
1863 png_size_t length));
Guy Schalnat6d764711995-12-19 03:22:19 -06001864
Guy Schalnat6d764711995-12-19 03:22:19 -06001865#if defined(PNG_WRITE_FLUSH_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001866PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06001867#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001868
Andreas Dilger47a0c421997-05-16 02:46:07 -05001869/* Place a 32-bit number into a buffer in PNG byte order (big-endian).
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001870 * The only currently known PNG chunks that use signed numbers are
1871 * the ancillary extension chunks, oFFs and pCAL.
Andreas Dilger47a0c421997-05-16 02:46:07 -05001872 */
1873PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
Guy Schalnat0d580581995-07-20 02:43:20 -05001874
Andreas Dilger47a0c421997-05-16 02:46:07 -05001875#if defined(PNG_WRITE_pCAL_SUPPORTED)
1876PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
1877#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001878
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001879/* Place a 16-bit number into a buffer in PNG byte order.
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001880 * The parameter is declared unsigned int, not png_uint_16,
1881 * just to avoid potential problems on pre-ANSI C compilers.
1882 */
1883PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
Guy Schalnat0d580581995-07-20 02:43:20 -05001884
Glenn Randers-Pehrson46f61e21998-01-30 21:45:12 -06001885/* simple function to write the signature */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001886PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001887
1888/* write various chunks */
1889
1890/* Write the IHDR chunk, and update the png_struct with the necessary
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001891 * information.
1892 */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001893PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001894 png_uint_32 height,
1895 int bit_depth, int color_type, int compression_type, int filter_type,
1896 int interlace_type));
Guy Schalnat0d580581995-07-20 02:43:20 -05001897
Andreas Dilger47a0c421997-05-16 02:46:07 -05001898PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
1899 png_uint_32 num_pal));
Guy Schalnat0d580581995-07-20 02:43:20 -05001900
Andreas Dilger47a0c421997-05-16 02:46:07 -05001901PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
1902 png_size_t length));
Guy Schalnat0d580581995-07-20 02:43:20 -05001903
Andreas Dilger47a0c421997-05-16 02:46:07 -05001904PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05001905
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001906#if defined(PNG_WRITE_gAMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001907PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001908#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001909
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001910#if defined(PNG_WRITE_sBIT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001911PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001912 int color_type));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001913#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001914
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001915#if defined(PNG_WRITE_cHRM_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001916PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001917 double white_x, double white_y,
1918 double red_x, double red_y, double green_x, double green_y,
1919 double blue_x, double blue_y));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001920#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001921
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001922#if defined(PNG_WRITE_sRGB_SUPPORTED)
1923PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -06001924 int intent));
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001925#endif
1926
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001927#if defined(PNG_WRITE_tRNS_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001928PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001929 png_color_16p values, int number, int color_type));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001930#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001931
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001932#if defined(PNG_WRITE_bKGD_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001933PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
1934 png_color_16p values, int color_type));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001935#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001936
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001937#if defined(PNG_WRITE_hIST_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001938PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06001939 int num_hist));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001940#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001941
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05001942#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED) || \
1943 defined(PNG_WRITE_pCAL_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001944PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06001945 png_charp key, png_charpp new_key));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06001946#endif
1947
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001948#if defined(PNG_WRITE_tEXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001949PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
1950 png_charp text, png_size_t text_len));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001951#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001952
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001953#if defined(PNG_WRITE_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001954PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
1955 png_charp text, png_size_t text_len, int compression));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001956#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001957
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001958#if defined(PNG_WRITE_oFFs_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001959PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
1960 png_uint_32 x_offset, png_uint_32 y_offset, int unit_type));
1961#endif
1962
1963#if defined(PNG_WRITE_pCAL_SUPPORTED)
1964PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
1965 png_int_32 X0, png_int_32 X1, int type, int nparams,
1966 png_charp units, png_charpp params));
1967#endif
1968
1969#if defined(PNG_WRITE_pHYs_SUPPORTED)
1970PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
1971 png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
Guy Schalnat0d580581995-07-20 02:43:20 -05001972 int unit_type));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001973#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001974
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001975#if defined(PNG_WRITE_tIME_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001976PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06001977 png_timep mod_time));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001978#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001979
Andreas Dilger47a0c421997-05-16 02:46:07 -05001980/* Called when finished processing a row of data */
1981PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001982
Andreas Dilger47a0c421997-05-16 02:46:07 -05001983/* Internal use only. Called before first row of data */
1984PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001985
1986#if defined(PNG_READ_GAMMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05001987PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001988#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05001989
1990/* combine a row of data, dealing with alpha, etc. if requested */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001991PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
Guy Schalnat0d580581995-07-20 02:43:20 -05001992 int mask));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001993
1994#if defined(PNG_READ_INTERLACING_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -05001995/* expand an interlaced row */
Andreas Dilger47a0c421997-05-16 02:46:07 -05001996PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
1997 png_bytep row, int pass, png_uint_32 transformations));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05001998#endif
1999
2000#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
Guy Schalnat0d580581995-07-20 02:43:20 -05002001/* grab pixels out of a row for an interlaced pass */
Andreas Dilger47a0c421997-05-16 02:46:07 -05002002PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06002003 png_bytep row, int pass));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002004#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05002005
2006/* unfilter a row */
Andreas Dilger47a0c421997-05-16 02:46:07 -05002007PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
Guy Schalnate5a37791996-06-05 15:50:50 -05002008 png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
Andreas Dilger47a0c421997-05-16 02:46:07 -05002009
2010/* Choose the best filter to use and filter the row data */
2011PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
Guy Schalnate5a37791996-06-05 15:50:50 -05002012 png_row_infop row_info));
Andreas Dilger47a0c421997-05-16 02:46:07 -05002013
2014/* Write out the filtered row. */
2015PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
Guy Schalnate5a37791996-06-05 15:50:50 -05002016 png_bytep filtered_row));
Guy Schalnat0d580581995-07-20 02:43:20 -05002017/* finish a row while reading, dealing with interlacing passes, etc. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05002018PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
2019
Guy Schalnat0d580581995-07-20 02:43:20 -05002020/* initialize the row buffers, etc. */
Andreas Dilger47a0c421997-05-16 02:46:07 -05002021PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002022/* optional call to update the users info structure */
Andreas Dilger47a0c421997-05-16 02:46:07 -05002023PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06002024 png_infop info_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05002025
2026/* these are the functions that do the transformations */
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002027#if defined(PNG_READ_FILLER_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002028PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
2029 png_bytep row, png_uint_32 filler, png_uint_32 flags));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002030#endif
2031
Andreas Dilger47a0c421997-05-16 02:46:07 -05002032#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
2033PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
2034 png_bytep row));
2035#endif
2036
2037#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
2038PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
2039 png_bytep row));
2040#endif
2041
Glenn Randers-Pehrsonc4a2ae61998-01-16 22:06:18 -06002042#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
2043PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
2044 png_bytep row));
2045#endif
2046
2047#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
2048PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
2049 png_bytep row));
2050#endif
2051
Andreas Dilger47a0c421997-05-16 02:46:07 -05002052#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
2053 defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
2054PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
2055 png_bytep row, png_uint_32 flags));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002056#endif
2057
2058#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002059PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
2060#endif
2061
Glenn Randers-Pehrson8f8fb6a1998-03-09 23:02:06 -06002062#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002063PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002064#endif
2065
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002066#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002067PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
2068 row_info, png_bytep row));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002069#endif
2070
2071#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002072PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
2073 png_bytep row));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002074#endif
2075
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002076#if defined(PNG_READ_PACK_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002077PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002078#endif
2079
2080#if defined(PNG_READ_SHIFT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002081PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
Guy Schalnat6d764711995-12-19 03:22:19 -06002082 png_color_8p sig_bits));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002083#endif
2084
2085#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002086PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002087#endif
2088
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002089#if defined(PNG_READ_16_TO_8_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002090PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002091#endif
2092
2093#if defined(PNG_READ_DITHER_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002094PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06002095 png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
Andreas Dilger47a0c421997-05-16 02:46:07 -05002096
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002097# if defined(PNG_CORRECT_PALETTE_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002098PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
Guy Schalnate5a37791996-06-05 15:50:50 -05002099 png_colorp palette, int num_palette));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002100# endif
Guy Schalnate5a37791996-06-05 15:50:50 -05002101#endif
2102
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002103#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002104PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002105#endif
2106
2107#if defined(PNG_WRITE_PACK_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002108PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
2109 png_bytep row, png_uint_32 bit_depth));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002110#endif
2111
2112#if defined(PNG_WRITE_SHIFT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002113PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
Guy Schalnat6d764711995-12-19 03:22:19 -06002114 png_color_8p bit_depth));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002115#endif
2116
2117#if defined(PNG_READ_BACKGROUND_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002118PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
Guy Schalnat6d764711995-12-19 03:22:19 -06002119 png_color_16p trans_values, png_color_16p background,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06002120 png_color_16p background_1,
2121 png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
2122 png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
2123 png_uint_16pp gamma_16_to_1, int gamma_shift));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002124#endif
2125
2126#if defined(PNG_READ_GAMMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002127PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06002128 png_bytep gamma_table, png_uint_16pp gamma_16_table,
Guy Schalnat0d580581995-07-20 02:43:20 -05002129 int gamma_shift));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002130#endif
2131
2132#if defined(PNG_READ_EXPAND_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002133PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06002134 png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
Andreas Dilger47a0c421997-05-16 02:46:07 -05002135PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06002136 png_bytep row, png_color_16p trans_value));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002137#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05002138
Andreas Dilger47a0c421997-05-16 02:46:07 -05002139/* The following decodes the appropriate chunks, and does error correction,
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06002140 * then calls the appropriate callback for the chunk if it is valid.
2141 */
Guy Schalnat0d580581995-07-20 02:43:20 -05002142
2143/* decode the IHDR chunk */
Andreas Dilger47a0c421997-05-16 02:46:07 -05002144PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06002145 png_uint_32 length));
Andreas Dilger47a0c421997-05-16 02:46:07 -05002146PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002147 png_uint_32 length));
Andreas Dilger47a0c421997-05-16 02:46:07 -05002148PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002149 png_uint_32 length));
Andreas Dilger47a0c421997-05-16 02:46:07 -05002150
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002151#if defined(PNG_READ_gAMA_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002152PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002153 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002154#endif
2155
2156#if defined(PNG_READ_sBIT_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002157PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002158 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002159#endif
2160
2161#if defined(PNG_READ_cHRM_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002162PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002163 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002164#endif
2165
Glenn Randers-Pehrsonb6ce43d1998-01-01 07:13:13 -06002166#if defined(PNG_READ_sRGB_SUPPORTED)
2167PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
2168 png_uint_32 length));
2169#endif
2170
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002171#if defined(PNG_READ_tRNS_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002172PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002173 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002174#endif
2175
2176#if defined(PNG_READ_bKGD_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002177PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002178 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002179#endif
2180
2181#if defined(PNG_READ_hIST_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002182PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002183 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002184#endif
2185
2186#if defined(PNG_READ_oFFs_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002187PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
2188 png_uint_32 length));
2189#endif
2190
2191#if defined(PNG_READ_pCAL_SUPPORTED)
2192PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
2193 png_uint_32 length));
2194#endif
2195
2196#if defined(PNG_READ_pHYs_SUPPORTED)
2197PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002198 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002199#endif
2200
2201#if defined(PNG_READ_tIME_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002202PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002203 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002204#endif
2205
2206#if defined(PNG_READ_tEXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002207PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002208 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002209#endif
2210
2211#if defined(PNG_READ_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002212PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
Guy Schalnat0d580581995-07-20 02:43:20 -05002213 png_uint_32 length));
Guy Schalnat51f0eb41995-09-26 05:22:39 -05002214#endif
Guy Schalnat0d580581995-07-20 02:43:20 -05002215
Andreas Dilger47a0c421997-05-16 02:46:07 -05002216PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
2217 png_infop info_ptr, png_uint_32 length));
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002218
Andreas Dilger47a0c421997-05-16 02:46:07 -05002219PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002220 png_bytep chunk_name));
2221
Guy Schalnat0d580581995-07-20 02:43:20 -05002222/* handle the transformations for reading and writing */
Andreas Dilger47a0c421997-05-16 02:46:07 -05002223PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
2224PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05002225
Andreas Dilger47a0c421997-05-16 02:46:07 -05002226PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
Guy Schalnat0d580581995-07-20 02:43:20 -05002227
Guy Schalnat6d764711995-12-19 03:22:19 -06002228#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
Andreas Dilger47a0c421997-05-16 02:46:07 -05002229PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002230 png_infop info_ptr));
Andreas Dilger47a0c421997-05-16 02:46:07 -05002231PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
2232 png_infop info_ptr));
2233PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
2234PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
Guy Schalnat4ee97b01996-01-16 01:51:56 -06002235 png_uint_32 length));
Andreas Dilger47a0c421997-05-16 02:46:07 -05002236PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
2237PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
2238 png_bytep buffer, png_size_t length));
2239PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
2240PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
2241 png_bytep buffer, png_size_t buffer_length));
2242PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
2243PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
2244 png_bytep buffer, png_size_t buffer_length));
2245PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
2246PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
2247 png_infop info_ptr, png_uint_32 length));
2248PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
2249 png_infop info_ptr));
2250PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
2251 png_infop info_ptr));
2252PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
2253PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
2254 png_infop info_ptr));
2255PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
2256 png_infop info_ptr));
2257PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
2258#if defined(PNG_READ_tEXt_SUPPORTED)
2259PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
2260 png_infop info_ptr, png_uint_32 length));
2261PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
2262 png_infop info_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06002263#endif
2264#if defined(PNG_READ_zTXt_SUPPORTED)
Andreas Dilger47a0c421997-05-16 02:46:07 -05002265PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
2266 png_infop info_ptr, png_uint_32 length));
2267PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
2268 png_infop info_ptr));
Guy Schalnat6d764711995-12-19 03:22:19 -06002269#endif
2270
2271#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
Guy Schalnat0d580581995-07-20 02:43:20 -05002272
2273#endif /* PNG_INTERNAL */
2274
Andreas Dilger02ad0ef1997-01-17 01:34:35 -06002275#ifdef __cplusplus
2276}
2277#endif
2278
Guy Schalnat0d580581995-07-20 02:43:20 -05002279/* do not put anything past this line */
2280#endif /* _PNG_H */