blob: c966dda61998da9ef035a49fc59fe600cd5ead2f [file] [log] [blame]
Glenn Randers-Pehrsond60b8fa2006-04-20 21:31:14 -05001
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05002/* pngpriv.h - private declarations for use inside libpng
Glenn Randers-Pehrsond60b8fa2006-04-20 21:31:14 -05003 *
Glenn Randers-Pehrsonaa4e3592010-07-06 07:40:47 -05004 * libpng version 1.5.0beta33 - July 6, 2010
Glenn Randers-Pehrsond60b8fa2006-04-20 21:31:14 -05005 * For conditions of distribution and use, see copyright notice in png.h
Glenn Randers-Pehrsone69b55d2010-01-01 10:29:06 -06006 * Copyright (c) 1998-2010 Glenn Randers-Pehrson
Glenn Randers-Pehrsond60b8fa2006-04-20 21:31:14 -05007 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -05009 *
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -050010 * This code is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -050011 * For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -050012 * and license in png.h
Glenn Randers-Pehrsond60b8fa2006-04-20 21:31:14 -050013 */
14
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -050015/* The symbols declared in this file (including the functions declared
16 * as PNG_EXTERN) are PRIVATE. They are not part of the libpng public
17 * interface, and are not recommended for use by regular applications.
18 * Some of them may become public in the future; others may stay private,
19 * change in an incompatible way, or even disappear.
20 * Although the libpng users are not forbidden to include this header,
21 * they should be well aware of the issues that may arise from doing so.
22 */
23
24#ifndef PNGPRIV_H
25#define PNGPRIV_H
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050026
Glenn Randers-Pehrsoneae8e362010-03-12 17:36:53 -060027#define PNGLIB_BUILD
Glenn Randers-Pehrsonaecef092010-04-17 18:03:02 -050028#ifdef PNG_USER_CONFIG
29# include "pngusr.h"
30#endif
Glenn Randers-Pehrsonc3cd22b2010-03-08 21:10:25 -060031#include "png.h"
32#include "pnginfo.h"
33#include "pngstruct.h"
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050034
35#include <stdlib.h>
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050036#ifdef BSD
37# include <strings.h>
38#else
39# include <string.h>
40#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050041
Glenn Randers-Pehrsondc6182a2010-03-09 16:45:06 -060042/* Added at libpng-1.2.9 */
43/* Moved to pngpriv.h at libpng-1.5.0 */
44
45/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure"
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050046 * script. We may need it here to get the correct configuration on things
47 * like limits.
Glenn Randers-Pehrsondc6182a2010-03-09 16:45:06 -060048 */
49#ifdef PNG_CONFIGURE_LIBPNG
50# ifdef HAVE_CONFIG_H
51# include "config.h"
52# endif
53#endif
54
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050055/* Moved to pngpriv.h at libpng-1.5.0 */
56/* If you are running on a machine where you cannot allocate more
57 * than 64K of memory at once, uncomment this. While libpng will not
58 * normally need that much memory in a chunk (unless you load up a very
59 * large file), zlib needs to know how big of a chunk it can use, and
60 * libpng thus makes sure to check any memory allocation to verify it
61 * will fit into memory.
62 *
63 * zlib provides 'MAXSEG_64K' which, if defined, indicates the
64 * same limit and pngconf.h (already included) sets the limit
65 * if certain operating systems are detected.
66 */
67#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
68# define PNG_MAX_MALLOC_64K
69#endif
70
71/* Moved to pngpriv.h at libpng-1.5.0 */
72/* Feature support: in 1.4 this was in pngconf.h, but these
73 * features have no affect on the libpng API. Add library
74 * only features to the end of this list. Add features that
75 * affect the API to scipts/config.dfn using png_on or png_off
76 * as determined by the default and update scripts/config.std
77 */
78/* Added at libpng version 1.4.0 */
79#if !defined(PNG_NO_WARNINGS) && !defined(PNG_WARNINGS_SUPPORTED)
80# define PNG_WARNINGS_SUPPORTED
81#endif
82
Glenn Randers-Pehrsonaecef092010-04-17 18:03:02 -050083/* If warnings or errors are turned off the code is disabled
84 * or redirected here.
85 */
86#ifndef PNG_WARNINGS_SUPPORTED
87# define png_warning(s1,s2) ((void)0)
88# define png_chunk_warning(s1,s2) ((void)0)
89#endif
90#ifndef PNG_ERROR_TEXT_SUPPORTED
91# define png_error(s1,s2) png_err(s1)
92# define png_chunk_error(s1,s2) png_err(s1)
93#endif
94
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -050095/* Added at libpng version 1.4.0 */
96#if !defined(PNG_NO_CHECK_cHRM) && !defined(PNG_CHECK_cHRM_SUPPORTED)
97# define PNG_CHECK_cHRM_SUPPORTED
98#endif
99
100/* Added at libpng version 1.4.0 */
101#if !defined(PNG_NO_ALIGNED_MEMORY) && !defined(PNG_ALIGNED_MEMORY_SUPPORTED)
102# define PNG_ALIGNED_MEMORY_SUPPORTED
103#endif
104
105/* Buggy compilers (e.g., gcc 2.7.2.2) need PNG_NO_POINTER_INDEXING
106 * See png[wr]util.c
107 */
108#if !defined(PNG_NO_POINTER_INDEXING) && \
109 !defined(PNG_POINTER_INDEXING_SUPPORTED)
110# define PNG_POINTER_INDEXING_SUPPORTED
111#endif
112
113/* Other defines for things like memory and the like can go here. */
114
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500115/* This controls how fine the quantizing gets. As this allocates
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500116 * a largish chunk of memory (32K), those who are not as concerned
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500117 * with quantizing quality can decrease some or all of these.
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500118 */
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500119#ifndef PNG_QUANTIZE_RED_BITS
120# define PNG_QUANTIZE_RED_BITS 5
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500121#endif
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500122#ifndef PNG_QUANTIZE_GREEN_BITS
123# define PNG_QUANTIZE_GREEN_BITS 5
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500124#endif
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500125#ifndef PNG_QUANTIZE_BLUE_BITS
126# define PNG_QUANTIZE_BLUE_BITS 5
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500127#endif
128
129/* This controls how fine the gamma correction becomes when you
130 * are only interested in 8 bits anyway. Increasing this value
131 * results in more memory being used, and more pow() functions
132 * being called to fill in the gamma tables. Don't set this value
133 * less then 8, and even that may not work (I haven't tested it).
134 */
135#ifndef PNG_MAX_GAMMA_8
136# define PNG_MAX_GAMMA_8 11
137#endif
138
139/* This controls how much a difference in gamma we can tolerate before
140 * we actually start doing gamma conversion.
141 */
142#ifndef PNG_GAMMA_THRESHOLD
143# define PNG_GAMMA_THRESHOLD 0.05
144#endif
145
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500146/* The functions exported by PNG_EXTERN are internal functions, which
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500147 * aren't usually used outside the library (as far as I know), so it is
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500148 * debatable if they should be exported at all. In the future, when it
149 * is possible to have run-time registry of chunk-handling functions,
150 * some of these will be made available again.
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500151#define PNG_EXTERN extern
152 */
153#define PNG_EXTERN
154
155/* Other defines specific to compilers can go here. Try to keep
156 * them inside an appropriate ifdef/endif pair for portability.
157 */
158
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500159#ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrsond00bbb22010-03-14 09:15:49 -0500160# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
161 defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500162 /* We need to check that <math.h> hasn't already been included earlier
163 * as it seems it doesn't agree with <fp.h>, yet we should really use
164 * <fp.h> if possible.
165 */
166# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
167# include <fp.h>
168# endif
169# else
170# include <math.h>
171# endif
172# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
173 /* Amiga SAS/C: We must include builtin FPU functions when compiling using
174 * MATH=68881
175 */
176# include <m68881.h>
177# endif
178#endif
179
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500180/* This provides the non-ANSI (far) memory allocation routines. */
181#if defined(__TURBOC__) && defined(__MSDOS__)
182# include <mem.h>
183# include <alloc.h>
184#endif
185
186#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
Glenn Randers-Pehrsonf74c5ac2009-09-20 07:27:34 -0500187 defined(_WIN32) || defined(__WIN32__)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500188# include <windows.h> /* defines _WINDOWS_ macro */
189/* I have no idea why is this necessary... */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500190# ifdef _MSC_VER
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500191# include <malloc.h>
192# endif
193#endif
194
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -0500195/* This is the size of the compression buffer, and thus the size of
196 * an IDAT chunk. Make this whatever size you feel is best for your
197 * machine. One of these will be allocated per png_struct. When this
198 * is full, it writes the data to the disk, and does some other
199 * calculations. Making this an extremely small size will slow
200 * the library down, but you may want to experiment to determine
201 * where it becomes significant, if you are concerned with memory
202 * usage. Note that zlib allocates at least 32Kb also. For readers,
203 * this describes the size of the buffer available to read the data in.
204 * Unless this gets smaller than the size of a row (compressed),
205 * it should not make much difference how big this is.
206 */
207
208#ifndef PNG_ZBUF_SIZE
209# define PNG_ZBUF_SIZE 8192
210#endif
211
212/* Just a little check that someone hasn't tried to define something
213 * contradictory.
214 */
215#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
216# undef PNG_ZBUF_SIZE
217# define PNG_ZBUF_SIZE 65536L
218#endif
219
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500220/* Various modes of operation. Note that after an init, mode is set to
221 * zero automatically when the structure is created.
222 */
223#define PNG_HAVE_IHDR 0x01
224#define PNG_HAVE_PLTE 0x02
225#define PNG_HAVE_IDAT 0x04
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500226#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500227#define PNG_HAVE_IEND 0x10
228#define PNG_HAVE_gAMA 0x20
229#define PNG_HAVE_cHRM 0x40
230#define PNG_HAVE_sRGB 0x80
231#define PNG_HAVE_CHUNK_HEADER 0x100
232#define PNG_WROTE_tIME 0x200
233#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
234#define PNG_BACKGROUND_IS_GRAY 0x800
235#define PNG_HAVE_PNG_SIGNATURE 0x1000
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500236#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500237
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500238/* Flags for the transformations the PNG library does on the image data */
Glenn Randers-Pehrson1916f6a2008-08-14 13:44:49 -0500239#define PNG_BGR 0x0001
240#define PNG_INTERLACE 0x0002
241#define PNG_PACK 0x0004
242#define PNG_SHIFT 0x0008
243#define PNG_SWAP_BYTES 0x0010
244#define PNG_INVERT_MONO 0x0020
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -0500245#define PNG_QUANTIZE 0x0040
Glenn Randers-Pehrson1916f6a2008-08-14 13:44:49 -0500246#define PNG_BACKGROUND 0x0080
247#define PNG_BACKGROUND_EXPAND 0x0100
248 /* 0x0200 unused */
249#define PNG_16_TO_8 0x0400
250#define PNG_RGBA 0x0800
251#define PNG_EXPAND 0x1000
252#define PNG_GAMMA 0x2000
253#define PNG_GRAY_TO_RGB 0x4000
254#define PNG_FILLER 0x8000L
255#define PNG_PACKSWAP 0x10000L
256#define PNG_SWAP_ALPHA 0x20000L
257#define PNG_STRIP_ALPHA 0x40000L
258#define PNG_INVERT_ALPHA 0x80000L
259#define PNG_USER_TRANSFORM 0x100000L
260#define PNG_RGB_TO_GRAY_ERR 0x200000L
261#define PNG_RGB_TO_GRAY_WARN 0x400000L
262#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
263 /* 0x800000L Unused */
264#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */
265#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */
Glenn Randers-Pehrson5876b852009-11-27 00:24:42 -0600266 /* 0x4000000L unused */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500267 /* 0x8000000L unused */
268 /* 0x10000000L unused */
269 /* 0x20000000L unused */
270 /* 0x40000000L unused */
271
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500272/* Flags for png_create_struct */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500273#define PNG_STRUCT_PNG 0x0001
274#define PNG_STRUCT_INFO 0x0002
275
276/* Scaling factor for filter heuristic weighting calculations */
277#define PNG_WEIGHT_SHIFT 8
278#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
279#define PNG_COST_SHIFT 3
280#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
281
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500282/* Flags for the png_ptr->flags rather than declaring a byte for each one */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500283#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
284#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002
285#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004
286#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008
287#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010
288#define PNG_FLAG_ZLIB_FINISHED 0x0020
289#define PNG_FLAG_ROW_INIT 0x0040
290#define PNG_FLAG_FILLER_AFTER 0x0080
291#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
292#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
293#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
294#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
Glenn Randers-Pehrsonf74c5ac2009-09-20 07:27:34 -0500295 /* 0x1000 unused */
296 /* 0x2000 unused */
297 /* 0x4000 unused */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500298#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
299#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
300#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L
301#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L
302#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L
303#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L
304#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */
305#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500306#define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500307 /* 0x1000000L unused */
308 /* 0x2000000L unused */
309 /* 0x4000000L unused */
310 /* 0x8000000L unused */
311 /* 0x10000000L unused */
312 /* 0x20000000L unused */
313 /* 0x40000000L unused */
314
315#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
316 PNG_FLAG_CRC_ANCILLARY_NOWARN)
317
318#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
319 PNG_FLAG_CRC_CRITICAL_IGNORE)
320
321#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
322 PNG_FLAG_CRC_CRITICAL_MASK)
323
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500324/* Save typing and make code easier to understand */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500325
326#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
327 abs((int)((c1).green) - (int)((c2).green)) + \
328 abs((int)((c1).blue) - (int)((c2).blue)))
329
330/* Added to libpng-1.2.6 JB */
331#define PNG_ROWBYTES(pixel_bits, width) \
332 ((pixel_bits) >= 8 ? \
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500333 ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
334 (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500335
336/* PNG_OUT_OF_RANGE returns true if value is outside the range
Glenn Randers-Pehrson9bf60832009-09-20 13:37:50 -0500337 * ideal-delta..ideal+delta. Each argument is evaluated twice.
338 * "ideal" and "delta" should be constants, normally simple
339 * integers, "value" a variable. Added to libpng-1.2.6 JB
340 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500341#define PNG_OUT_OF_RANGE(value, ideal, delta) \
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600342 ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500343
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500344/* Constant strings for known chunk types. If you need to add a chunk,
Glenn Randers-Pehrson9bf60832009-09-20 13:37:50 -0500345 * define the name here, and add an invocation of the macro wherever it's
346 * needed.
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500347 */
Glenn Randers-Pehrson9bf60832009-09-20 13:37:50 -0500348#define PNG_IHDR PNG_CONST png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
349#define PNG_IDAT PNG_CONST png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
350#define PNG_IEND PNG_CONST png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
351#define PNG_PLTE PNG_CONST png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'}
352#define PNG_bKGD PNG_CONST png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'}
353#define PNG_cHRM PNG_CONST png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
354#define PNG_gAMA PNG_CONST png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
355#define PNG_hIST PNG_CONST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
356#define PNG_iCCP PNG_CONST png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
357#define PNG_iTXt PNG_CONST png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
358#define PNG_oFFs PNG_CONST png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
359#define PNG_pCAL PNG_CONST png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
360#define PNG_sCAL PNG_CONST png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
361#define PNG_pHYs PNG_CONST png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
362#define PNG_sBIT PNG_CONST png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
363#define PNG_sPLT PNG_CONST png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
364#define PNG_sRGB PNG_CONST png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
365#define PNG_sTER PNG_CONST png_byte png_sTER[5] = {115, 84, 69, 82, '\0'}
366#define PNG_tEXt PNG_CONST png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
367#define PNG_tIME PNG_CONST png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
368#define PNG_tRNS PNG_CONST png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
369#define PNG_zTXt PNG_CONST png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500370
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500371
372/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
373#ifdef __cplusplus
374extern "C" {
375#endif /* __cplusplus */
376
377/* These functions are used internally in the code. They generally
378 * shouldn't be used unless you are writing code to add or replace some
379 * functionality in libpng. More information about most functions can
380 * be found in the files where the functions are located.
381 */
382
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500383/* Allocate memory for an internal libpng struct */
384PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
385
386/* Free memory from internal libpng struct */
387PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
388
389PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600390 malloc_fn, png_voidp mem_ptr));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500391PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600392 png_free_ptr free_fn, png_voidp mem_ptr));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500393
394/* Free any memory that info_ptr points to and reset struct. */
395PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600396 png_infop info_ptr));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500397
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500398/* Function to allocate memory for zlib. PNGAPI is disallowed. */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500399PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
400
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500401/* Function to free memory for zlib. PNGAPI is disallowed. */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500402PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
403
Glenn Randers-Pehrsoneae8e362010-03-12 17:36:53 -0600404/* Next four functions are used internally as callbacks. PNGCBAPI is required
405 * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to PNGCBAPI
406 * at 1.5.0
407 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500408
Glenn Randers-Pehrsoneae8e362010-03-12 17:36:53 -0600409PNG_EXTERN void PNGCBAPI png_default_read_data PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600410 png_bytep data, png_size_t length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500411
412#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
Glenn Randers-Pehrsoneae8e362010-03-12 17:36:53 -0600413PNG_EXTERN void PNGCBAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600414 png_bytep buffer, png_size_t length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500415#endif
416
Glenn Randers-Pehrsoneae8e362010-03-12 17:36:53 -0600417PNG_EXTERN void PNGCBAPI png_default_write_data PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600418 png_bytep data, png_size_t length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500419
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500420#ifdef PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600421# ifdef PNG_STDIO_SUPPORTED
Glenn Randers-Pehrsoneae8e362010-03-12 17:36:53 -0600422PNG_EXTERN void PNGCBAPI png_default_flush PNGARG((png_structp png_ptr));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600423# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500424#endif
425
426/* Reset the CRC variable */
427PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
428
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500429/* Write the "data" buffer to whatever output you are using */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500430PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600431 png_size_t length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500432
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500433/* Read the chunk header (length + type name) */
434PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
435
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500436/* Read data from whatever input you are using into the "data" buffer */
437PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600438 png_size_t length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500439
440/* Read bytes into buf, and update png_ptr->crc */
441PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600442 png_size_t length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500443
444/* Decompress data in a chunk that uses compression */
445#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
446 defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
Glenn Randers-Pehrson895a9c92008-07-25 08:51:18 -0500447PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600448 int comp_type, png_size_t chunklength, png_size_t prefix_length,
449 png_size_t *data_length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500450#endif
451
452/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
453PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
454
455/* Read the CRC from the file and compare it to the libpng calculated CRC */
456PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
457
458/* Calculate the CRC over a section of data. Note that we are only
459 * passing a maximum of 64K on systems that have this as a memory limit,
460 * since this is the maximum buffer size we can specify.
461 */
462PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600463 png_size_t length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500464
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500465#ifdef PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500466PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
467#endif
468
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500469/* Write various chunks */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500470
471/* Write the IHDR chunk, and update the png_struct with the necessary
472 * information.
473 */
474PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600475 png_uint_32 height,
476 int bit_depth, int color_type, int compression_method, int filter_method,
477 int interlace_method));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500478
479PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600480 png_uint_32 num_pal));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500481
482PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600483 png_size_t length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500484
485PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
486
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500487#ifdef PNG_WRITE_gAMA_SUPPORTED
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600488# ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500489PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600490# endif
491# ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600492PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr,
493 png_fixed_point file_gamma));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600494# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500495#endif
496
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500497#ifdef PNG_WRITE_sBIT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500498PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600499 int color_type));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500500#endif
501
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500502#ifdef PNG_WRITE_cHRM_SUPPORTED
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600503# ifdef PNG_FLOATING_POINT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500504PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600505 double white_x, double white_y,
506 double red_x, double red_y, double green_x, double green_y,
507 double blue_x, double blue_y));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600508# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500509PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600510 png_fixed_point int_white_x, png_fixed_point int_white_y,
511 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
512 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
513 png_fixed_point int_blue_y));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500514#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500515
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500516#ifdef PNG_WRITE_sRGB_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500517PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600518 int intent));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500519#endif
520
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500521#ifdef PNG_WRITE_iCCP_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500522PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600523 png_charp name, int compression_type,
524 png_charp profile, int proflen));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500525 /* Note to maintainer: profile should be png_bytep */
526#endif
527
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500528#ifdef PNG_WRITE_sPLT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500529PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600530 png_sPLT_tp palette));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500531#endif
532
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500533#ifdef PNG_WRITE_tRNS_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500534PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600535 png_color_16p values, int number, int color_type));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500536#endif
537
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500538#ifdef PNG_WRITE_bKGD_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500539PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600540 png_color_16p values, int color_type));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500541#endif
542
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500543#ifdef PNG_WRITE_hIST_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500544PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600545 int num_hist));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500546#endif
547
548#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
549 defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
550PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600551 png_charp key, png_charpp new_key));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500552#endif
553
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500554#ifdef PNG_WRITE_tEXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500555PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600556 png_charp text, png_size_t text_len));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500557#endif
558
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500559#ifdef PNG_WRITE_zTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500560PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600561 png_charp text, png_size_t text_len, int compression));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500562#endif
563
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500564#ifdef PNG_WRITE_iTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500565PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600566 int compression, png_charp key, png_charp lang, png_charp lang_key,
567 png_charp text));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500568#endif
569
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500570#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500571PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600572 png_infop info_ptr, png_textp text_ptr, int num_text));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500573#endif
574
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500575#ifdef PNG_WRITE_oFFs_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500576PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600577 png_int_32 x_offset, png_int_32 y_offset, int unit_type));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500578#endif
579
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500580#ifdef PNG_WRITE_pCAL_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500581PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600582 png_int_32 X0, png_int_32 X1, int type, int nparams,
583 png_charp units, png_charpp params));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500584#endif
585
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500586#ifdef PNG_WRITE_pHYs_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500587PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600588 png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
589 int unit_type));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500590#endif
591
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500592#ifdef PNG_WRITE_tIME_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500593PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600594 png_timep mod_time));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500595#endif
596
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500597#ifdef PNG_WRITE_sCAL_SUPPORTED
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600598# if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500599PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600600 int unit, double width, double height));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600601# else
602# ifdef PNG_FIXED_POINT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500603PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600604 int unit, png_charp width, png_charp height));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600605# endif
606# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500607#endif
608
609/* Called when finished processing a row of data */
610PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
611
612/* Internal use only. Called before first row of data */
613PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
614
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500615#ifdef PNG_READ_GAMMA_SUPPORTED
Glenn Randers-Pehrsonffa89242009-12-13 08:14:40 -0600616PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600617 png_byte bit_depth));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500618#endif
619
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500620/* Combine a row of data, dealing with alpha, etc. if requested */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500621PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600622 int mask));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500623
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500624#ifdef PNG_READ_INTERLACING_SUPPORTED
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500625/* Expand an interlaced row */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500626/* OLD pre-1.0.9 interface:
627PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600628 png_bytep row, int pass, png_uint_32 transformations));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500629 */
630PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr));
631#endif
632
633/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */
634
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500635#ifdef PNG_WRITE_INTERLACING_SUPPORTED
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500636/* Grab pixels out of a row for an interlaced pass */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500637PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600638 png_bytep row, int pass));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500639#endif
640
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500641/* Unfilter a row */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500642PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600643 png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500644
645/* Choose the best filter to use and filter the row data */
646PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600647 png_row_infop row_info));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500648
649/* Write out the filtered row. */
650PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600651 png_bytep filtered_row));
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500652/* Finish a row while reading, dealing with interlacing passes, etc. */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500653PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
654
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500655/* Initialize the row buffers, etc. */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500656PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500657/* Optional call to update the users info structure */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500658PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600659 png_infop info_ptr));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500660
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500661/* These are the functions that do the transformations */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500662#ifdef PNG_READ_FILLER_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500663PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600664 png_bytep row, png_uint_32 filler, png_uint_32 flags));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500665#endif
666
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500667#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500668PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600669 png_bytep row));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500670#endif
671
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500672#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500673PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600674 png_bytep row));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500675#endif
676
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500677#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500678PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600679 png_bytep row));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500680#endif
681
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500682#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500683PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600684 png_bytep row));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500685#endif
686
687#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
688 defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
689PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600690 png_bytep row, png_uint_32 flags));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500691#endif
692
693#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
694PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
695#endif
696
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600697#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
698 defined(PNG_WRITE_PACKSWAP_SUPPORTED)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500699PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
700#endif
701
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500702#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500703PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600704 row_info, png_bytep row));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500705#endif
706
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500707#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500708PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600709 png_bytep row));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500710#endif
711
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500712#ifdef PNG_READ_PACK_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500713PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
714#endif
715
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500716#ifdef PNG_READ_SHIFT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500717PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600718 png_color_8p sig_bits));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500719#endif
720
721#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
722PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
723#endif
724
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500725#ifdef PNG_READ_16_TO_8_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500726PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
727#endif
728
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -0500729#ifdef PNG_READ_QUANTIZE_SUPPORTED
730PNG_EXTERN void png_do_quantize PNGARG((png_row_infop row_info,
731 png_bytep row, png_bytep palette_lookup, png_bytep quantize_lookup));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500732
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500733# ifdef PNG_CORRECT_PALETTE_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500734PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600735 png_colorp palette, int num_palette));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500736# endif
737#endif
738
739#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
740PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
741#endif
742
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500743#ifdef PNG_WRITE_PACK_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500744PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
745 png_bytep row, png_uint_32 bit_depth));
746#endif
747
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500748#ifdef PNG_WRITE_SHIFT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500749PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600750 png_color_8p bit_depth));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500751#endif
752
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500753#ifdef PNG_READ_BACKGROUND_SUPPORTED
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600754# ifdef PNG_READ_GAMMA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500755PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600756 png_color_16p trans_color, png_color_16p background,
757 png_color_16p background_1,
758 png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
759 png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
760 png_uint_16pp gamma_16_to_1, int gamma_shift));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600761# else
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500762PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600763 png_color_16p trans_color, png_color_16p background));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600764# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500765#endif
766
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500767#ifdef PNG_READ_GAMMA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500768PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600769 png_bytep gamma_table, png_uint_16pp gamma_16_table,
770 int gamma_shift));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500771#endif
772
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500773#ifdef PNG_READ_EXPAND_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500774PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600775 png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500776PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600777 png_bytep row, png_color_16p trans_value));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500778#endif
779
780/* The following decodes the appropriate chunks, and does error correction,
781 * then calls the appropriate callback for the chunk if it is valid.
782 */
783
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500784/* Decode the IHDR chunk */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500785PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600786 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500787PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600788 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500789PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600790 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500791
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500792#ifdef PNG_READ_bKGD_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500793PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600794 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500795#endif
796
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500797#ifdef PNG_READ_cHRM_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500798PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600799 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500800#endif
801
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500802#ifdef PNG_READ_gAMA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500803PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600804 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500805#endif
806
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500807#ifdef PNG_READ_hIST_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500808PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600809 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500810#endif
811
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500812#ifdef PNG_READ_iCCP_SUPPORTED
Glenn Randers-Pehrsonaa4e3592010-07-06 07:40:47 -0500813PNG_EXTERN void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600814 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500815#endif /* PNG_READ_iCCP_SUPPORTED */
816
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500817#ifdef PNG_READ_iTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500818PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600819 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500820#endif
821
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500822#ifdef PNG_READ_oFFs_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500823PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600824 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500825#endif
826
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500827#ifdef PNG_READ_pCAL_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500828PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600829 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500830#endif
831
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500832#ifdef PNG_READ_pHYs_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500833PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600834 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500835#endif
836
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500837#ifdef PNG_READ_sBIT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500838PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600839 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500840#endif
841
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500842#ifdef PNG_READ_sCAL_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500843PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600844 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500845#endif
846
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500847#ifdef PNG_READ_sPLT_SUPPORTED
Glenn Randers-Pehrsonaa4e3592010-07-06 07:40:47 -0500848PNG_EXTERN void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600849 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500850#endif /* PNG_READ_sPLT_SUPPORTED */
851
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500852#ifdef PNG_READ_sRGB_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500853PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600854 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500855#endif
856
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500857#ifdef PNG_READ_tEXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500858PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600859 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500860#endif
861
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500862#ifdef PNG_READ_tIME_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500863PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600864 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500865#endif
866
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500867#ifdef PNG_READ_tRNS_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500868PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600869 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500870#endif
871
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500872#ifdef PNG_READ_zTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500873PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600874 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500875#endif
876
877PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600878 png_infop info_ptr, png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500879
880PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600881 png_bytep chunk_name));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500882
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500883/* Handle the transformations for reading and writing */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500884PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
885PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
886
887PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
888
889#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
890PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600891 png_infop info_ptr));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500892PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600893 png_infop info_ptr));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500894PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
895PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600896 png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500897PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
898PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
899PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600900 png_bytep buffer, png_size_t buffer_length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500901PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
902PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600903 png_bytep buffer, png_size_t buffer_length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500904PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
905PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
906 png_infop info_ptr, png_uint_32 length));
907PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
908 png_infop info_ptr));
909PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
910 png_infop info_ptr));
911PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
912PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600913 png_infop info_ptr));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500914PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600915 png_infop info_ptr));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500916PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600917# ifdef PNG_READ_tEXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500918PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600919 png_infop info_ptr, png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500920PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600921 png_infop info_ptr));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600922# endif
923# ifdef PNG_READ_zTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500924PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600925 png_infop info_ptr, png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500926PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600927 png_infop info_ptr));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600928# endif
929# ifdef PNG_READ_iTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500930PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600931 png_infop info_ptr, png_uint_32 length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500932PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600933 png_infop info_ptr));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600934# endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500935
936#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
937
938#ifdef PNG_MNG_FEATURES_SUPPORTED
939PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600940 png_bytep row));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500941PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600942 png_bytep row));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500943#endif
944
Glenn Randers-Pehrsonf7831012008-11-13 06:05:13 -0600945/* Added at libpng version 1.4.0 */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500946#ifdef PNG_cHRM_SUPPORTED
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500947PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600948 png_fixed_point int_white_x, png_fixed_point int_white_y,
949 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
950 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
951 png_fixed_point int_blue_y));
Glenn Randers-Pehrsonf7831012008-11-13 06:05:13 -0600952#endif
Glenn Randers-Pehrsonf7831012008-11-13 06:05:13 -0600953
Glenn Randers-Pehrson7ec330d2009-09-25 11:45:42 -0500954#ifdef PNG_cHRM_SUPPORTED
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600955# ifdef PNG_CHECK_cHRM_SUPPORTED
Glenn Randers-Pehrson7ec330d2009-09-25 11:45:42 -0500956/* Added at libpng version 1.2.34 and 1.4.0 */
957PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600958 unsigned long *hi_product, unsigned long *lo_product));
Glenn Randers-Pehrsond4df36c2010-03-06 10:45:55 -0600959# endif
Glenn Randers-Pehrson7ec330d2009-09-25 11:45:42 -0500960#endif
961
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500962/* Added at libpng version 1.4.0 */
963PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600964 png_uint_32 width, png_uint_32 height, int bit_depth,
965 int color_type, int interlace_type, int compression_type,
966 int filter_type));
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500967
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -0600968/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
Glenn Randers-Pehrsonaa4e3592010-07-06 07:40:47 -0500969PNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600970 png_infop end_info_ptr));
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -0600971
972/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
Glenn Randers-Pehrsonaa4e3592010-07-06 07:40:47 -0500973PNG_EXTERN void png_write_destroy PNGARG((png_structp png_ptr));
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -0600974
975#ifdef USE_FAR_KEYWORD /* memory model conversion function */
Glenn Randers-Pehrsonaa4e3592010-07-06 07:40:47 -0500976PNG_EXTERN void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
Glenn Randers-Pehrsone8b1aa02010-03-06 11:39:29 -0600977 int check));
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -0600978#endif /* USE_FAR_KEYWORD */
979
Glenn Randers-Pehrsonc3cd22b2010-03-08 21:10:25 -0600980#include "pngdebug.h"
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -0600981
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500982/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
983
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500984#ifdef __cplusplus
985}
986#endif
987
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500988#endif /* PNGPRIV_H */