blob: d35a313fc8564ddd23afa772456b90e537c5dd2c [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-Pehrson5876b852009-11-27 00:24:42 -06004 * libpng version 1.4.0beta106 - November 27, 2009
Glenn Randers-Pehrsond60b8fa2006-04-20 21:31:14 -05005 * For conditions of distribution and use, see copyright notice in png.h
Glenn Randers-Pehrson79134c62009-02-14 10:32:18 -06006 * Copyright (c) 1998-2009 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
27#ifndef PNG_VERSION_INFO_ONLY
28
29#include <stdlib.h>
30
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -050031/* The functions exported by PNG_EXTERN are internal functions, which
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050032 * aren't usually used outside the library (as far as I know), so it is
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -050033 * debatable if they should be exported at all. In the future, when it
34 * is possible to have run-time registry of chunk-handling functions,
35 * some of these will be made available again.
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050036#define PNG_EXTERN extern
37 */
38#define PNG_EXTERN
39
40/* Other defines specific to compilers can go here. Try to keep
41 * them inside an appropriate ifdef/endif pair for portability.
42 */
43
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -050044#ifdef PNG_FLOATING_POINT_SUPPORTED
45# ifdef MACOS
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050046 /* We need to check that <math.h> hasn't already been included earlier
47 * as it seems it doesn't agree with <fp.h>, yet we should really use
48 * <fp.h> if possible.
49 */
50# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
51# include <fp.h>
52# endif
53# else
54# include <math.h>
55# endif
56# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
57 /* Amiga SAS/C: We must include builtin FPU functions when compiling using
58 * MATH=68881
59 */
60# include <m68881.h>
61# endif
62#endif
63
64/* Codewarrior on NT has linking problems without this. */
65#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__)
66# define PNG_ALWAYS_EXTERN
67#endif
68
69/* This provides the non-ANSI (far) memory allocation routines. */
70#if defined(__TURBOC__) && defined(__MSDOS__)
71# include <mem.h>
72# include <alloc.h>
73#endif
74
75#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
Glenn Randers-Pehrsonf74c5ac2009-09-20 07:27:34 -050076 defined(_WIN32) || defined(__WIN32__)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050077# include <windows.h> /* defines _WINDOWS_ macro */
78/* I have no idea why is this necessary... */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -050079# ifdef _MSC_VER
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050080# include <malloc.h>
81# endif
82#endif
83
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050084/* Various modes of operation. Note that after an init, mode is set to
85 * zero automatically when the structure is created.
86 */
87#define PNG_HAVE_IHDR 0x01
88#define PNG_HAVE_PLTE 0x02
89#define PNG_HAVE_IDAT 0x04
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050090#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050091#define PNG_HAVE_IEND 0x10
92#define PNG_HAVE_gAMA 0x20
93#define PNG_HAVE_cHRM 0x40
94#define PNG_HAVE_sRGB 0x80
95#define PNG_HAVE_CHUNK_HEADER 0x100
96#define PNG_WROTE_tIME 0x200
97#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
98#define PNG_BACKGROUND_IS_GRAY 0x800
99#define PNG_HAVE_PNG_SIGNATURE 0x1000
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500100#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500101
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500102/* Flags for the transformations the PNG library does on the image data */
Glenn Randers-Pehrson1916f6a2008-08-14 13:44:49 -0500103#define PNG_BGR 0x0001
104#define PNG_INTERLACE 0x0002
105#define PNG_PACK 0x0004
106#define PNG_SHIFT 0x0008
107#define PNG_SWAP_BYTES 0x0010
108#define PNG_INVERT_MONO 0x0020
109#define PNG_DITHER 0x0040
110#define PNG_BACKGROUND 0x0080
111#define PNG_BACKGROUND_EXPAND 0x0100
112 /* 0x0200 unused */
113#define PNG_16_TO_8 0x0400
114#define PNG_RGBA 0x0800
115#define PNG_EXPAND 0x1000
116#define PNG_GAMMA 0x2000
117#define PNG_GRAY_TO_RGB 0x4000
118#define PNG_FILLER 0x8000L
119#define PNG_PACKSWAP 0x10000L
120#define PNG_SWAP_ALPHA 0x20000L
121#define PNG_STRIP_ALPHA 0x40000L
122#define PNG_INVERT_ALPHA 0x80000L
123#define PNG_USER_TRANSFORM 0x100000L
124#define PNG_RGB_TO_GRAY_ERR 0x200000L
125#define PNG_RGB_TO_GRAY_WARN 0x400000L
126#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
127 /* 0x800000L Unused */
128#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */
129#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */
Glenn Randers-Pehrson5876b852009-11-27 00:24:42 -0600130 /* 0x4000000L unused */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500131 /* 0x8000000L unused */
132 /* 0x10000000L unused */
133 /* 0x20000000L unused */
134 /* 0x40000000L unused */
135
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500136/* Flags for png_create_struct */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500137#define PNG_STRUCT_PNG 0x0001
138#define PNG_STRUCT_INFO 0x0002
139
140/* Scaling factor for filter heuristic weighting calculations */
141#define PNG_WEIGHT_SHIFT 8
142#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
143#define PNG_COST_SHIFT 3
144#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
145
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500146/* Flags for the png_ptr->flags rather than declaring a byte for each one */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500147#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
148#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002
149#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004
150#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008
151#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010
152#define PNG_FLAG_ZLIB_FINISHED 0x0020
153#define PNG_FLAG_ROW_INIT 0x0040
154#define PNG_FLAG_FILLER_AFTER 0x0080
155#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
156#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
157#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
158#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
Glenn Randers-Pehrsonf74c5ac2009-09-20 07:27:34 -0500159 /* 0x1000 unused */
160 /* 0x2000 unused */
161 /* 0x4000 unused */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500162#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
163#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
164#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L
165#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L
166#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L
167#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L
168#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */
169#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500170#define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500171 /* 0x1000000L unused */
172 /* 0x2000000L unused */
173 /* 0x4000000L unused */
174 /* 0x8000000L unused */
175 /* 0x10000000L unused */
176 /* 0x20000000L unused */
177 /* 0x40000000L unused */
178
179#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
180 PNG_FLAG_CRC_ANCILLARY_NOWARN)
181
182#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
183 PNG_FLAG_CRC_CRITICAL_IGNORE)
184
185#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
186 PNG_FLAG_CRC_CRITICAL_MASK)
187
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500188/* Save typing and make code easier to understand */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500189
190#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
191 abs((int)((c1).green) - (int)((c2).green)) + \
192 abs((int)((c1).blue) - (int)((c2).blue)))
193
194/* Added to libpng-1.2.6 JB */
195#define PNG_ROWBYTES(pixel_bits, width) \
196 ((pixel_bits) >= 8 ? \
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500197 ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
198 (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500199
200/* PNG_OUT_OF_RANGE returns true if value is outside the range
Glenn Randers-Pehrson9bf60832009-09-20 13:37:50 -0500201 * ideal-delta..ideal+delta. Each argument is evaluated twice.
202 * "ideal" and "delta" should be constants, normally simple
203 * integers, "value" a variable. Added to libpng-1.2.6 JB
204 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500205#define PNG_OUT_OF_RANGE(value, ideal, delta) \
206 ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
207
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500208/* Constant strings for known chunk types. If you need to add a chunk,
Glenn Randers-Pehrson9bf60832009-09-20 13:37:50 -0500209 * define the name here, and add an invocation of the macro wherever it's
210 * needed.
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500211 */
Glenn Randers-Pehrson9bf60832009-09-20 13:37:50 -0500212#define PNG_IHDR PNG_CONST png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
213#define PNG_IDAT PNG_CONST png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
214#define PNG_IEND PNG_CONST png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
215#define PNG_PLTE PNG_CONST png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'}
216#define PNG_bKGD PNG_CONST png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'}
217#define PNG_cHRM PNG_CONST png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
218#define PNG_gAMA PNG_CONST png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
219#define PNG_hIST PNG_CONST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
220#define PNG_iCCP PNG_CONST png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
221#define PNG_iTXt PNG_CONST png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
222#define PNG_oFFs PNG_CONST png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
223#define PNG_pCAL PNG_CONST png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
224#define PNG_sCAL PNG_CONST png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
225#define PNG_pHYs PNG_CONST png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
226#define PNG_sBIT PNG_CONST png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
227#define PNG_sPLT PNG_CONST png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
228#define PNG_sRGB PNG_CONST png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
229#define PNG_sTER PNG_CONST png_byte png_sTER[5] = {115, 84, 69, 82, '\0'}
230#define PNG_tEXt PNG_CONST png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
231#define PNG_tIME PNG_CONST png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
232#define PNG_tRNS PNG_CONST png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
233#define PNG_zTXt PNG_CONST png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500234
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500235
236/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
237#ifdef __cplusplus
238extern "C" {
239#endif /* __cplusplus */
240
241/* These functions are used internally in the code. They generally
242 * shouldn't be used unless you are writing code to add or replace some
243 * functionality in libpng. More information about most functions can
244 * be found in the files where the functions are located.
245 */
246
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500247/* Allocate memory for an internal libpng struct */
248PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
249
250/* Free memory from internal libpng struct */
251PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
252
253PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
254 malloc_fn, png_voidp mem_ptr));
255PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
256 png_free_ptr free_fn, png_voidp mem_ptr));
257
258/* Free any memory that info_ptr points to and reset struct. */
259PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
260 png_infop info_ptr));
261
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500262/* Function to allocate memory for zlib. PNGAPI is disallowed. */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500263PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
264
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500265/* Function to free memory for zlib. PNGAPI is disallowed. */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500266PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
267
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500268/* Next four functions are used internally as callbacks. PNGAPI is required
269 * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */
270
271PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
272 png_bytep data, png_size_t length));
273
274#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
275PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
276 png_bytep buffer, png_size_t length));
277#endif
278
279PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
280 png_bytep data, png_size_t length));
281
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500282#ifdef PNG_WRITE_FLUSH_SUPPORTED
283#ifdef PNG_STDIO_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500284PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr));
285#endif
286#endif
287
288/* Reset the CRC variable */
289PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
290
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500291/* Write the "data" buffer to whatever output you are using */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500292PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
293 png_size_t length));
294
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500295/* Read the chunk header (length + type name) */
296PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
297
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500298/* Read data from whatever input you are using into the "data" buffer */
299PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
300 png_size_t length));
301
302/* Read bytes into buf, and update png_ptr->crc */
303PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
304 png_size_t length));
305
306/* Decompress data in a chunk that uses compression */
307#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
308 defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
Glenn Randers-Pehrson895a9c92008-07-25 08:51:18 -0500309PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,
310 int comp_type, png_size_t chunklength, png_size_t prefix_length,
311 png_size_t *data_length));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500312#endif
313
314/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
315PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
316
317/* Read the CRC from the file and compare it to the libpng calculated CRC */
318PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
319
320/* Calculate the CRC over a section of data. Note that we are only
321 * passing a maximum of 64K on systems that have this as a memory limit,
322 * since this is the maximum buffer size we can specify.
323 */
324PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
325 png_size_t length));
326
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500327#ifdef PNG_WRITE_FLUSH_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500328PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
329#endif
330
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500331/* Write various chunks */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500332
333/* Write the IHDR chunk, and update the png_struct with the necessary
334 * information.
335 */
336PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
337 png_uint_32 height,
338 int bit_depth, int color_type, int compression_method, int filter_method,
339 int interlace_method));
340
341PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
342 png_uint_32 num_pal));
343
344PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
345 png_size_t length));
346
347PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
348
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500349#ifdef PNG_WRITE_gAMA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500350#ifdef PNG_FLOATING_POINT_SUPPORTED
351PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
352#endif
353#ifdef PNG_FIXED_POINT_SUPPORTED
354PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point
355 file_gamma));
356#endif
357#endif
358
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500359#ifdef PNG_WRITE_sBIT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500360PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
361 int color_type));
362#endif
363
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500364#ifdef PNG_WRITE_cHRM_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500365#ifdef PNG_FLOATING_POINT_SUPPORTED
366PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
367 double white_x, double white_y,
368 double red_x, double red_y, double green_x, double green_y,
369 double blue_x, double blue_y));
370#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500371PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
372 png_fixed_point int_white_x, png_fixed_point int_white_y,
373 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
374 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
375 png_fixed_point int_blue_y));
376#endif
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500377
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500378#ifdef PNG_WRITE_sRGB_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500379PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
380 int intent));
381#endif
382
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500383#ifdef PNG_WRITE_iCCP_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500384PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
385 png_charp name, int compression_type,
386 png_charp profile, int proflen));
387 /* Note to maintainer: profile should be png_bytep */
388#endif
389
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500390#ifdef PNG_WRITE_sPLT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500391PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
392 png_sPLT_tp palette));
393#endif
394
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500395#ifdef PNG_WRITE_tRNS_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500396PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
397 png_color_16p values, int number, int color_type));
398#endif
399
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500400#ifdef PNG_WRITE_bKGD_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500401PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
402 png_color_16p values, int color_type));
403#endif
404
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500405#ifdef PNG_WRITE_hIST_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500406PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
407 int num_hist));
408#endif
409
410#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
411 defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
412PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
413 png_charp key, png_charpp new_key));
414#endif
415
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500416#ifdef PNG_WRITE_tEXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500417PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
418 png_charp text, png_size_t text_len));
419#endif
420
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500421#ifdef PNG_WRITE_zTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500422PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
423 png_charp text, png_size_t text_len, int compression));
424#endif
425
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500426#ifdef PNG_WRITE_iTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500427PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
428 int compression, png_charp key, png_charp lang, png_charp lang_key,
429 png_charp text));
430#endif
431
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500432#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500433PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
434 png_infop info_ptr, png_textp text_ptr, int num_text));
435#endif
436
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500437#ifdef PNG_WRITE_oFFs_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500438PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
439 png_int_32 x_offset, png_int_32 y_offset, int unit_type));
440#endif
441
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500442#ifdef PNG_WRITE_pCAL_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500443PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
444 png_int_32 X0, png_int_32 X1, int type, int nparams,
445 png_charp units, png_charpp params));
446#endif
447
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500448#ifdef PNG_WRITE_pHYs_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500449PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
450 png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
451 int unit_type));
452#endif
453
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500454#ifdef PNG_WRITE_tIME_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500455PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
456 png_timep mod_time));
457#endif
458
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500459#ifdef PNG_WRITE_sCAL_SUPPORTED
Glenn Randers-Pehrsondbd40142009-08-31 08:42:02 -0500460#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500461PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
462 int unit, double width, double height));
463#else
464#ifdef PNG_FIXED_POINT_SUPPORTED
465PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
466 int unit, png_charp width, png_charp height));
467#endif
468#endif
469#endif
470
471/* Called when finished processing a row of data */
472PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
473
474/* Internal use only. Called before first row of data */
475PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
476
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500477#ifdef PNG_READ_GAMMA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500478PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
479#endif
480
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500481/* Combine a row of data, dealing with alpha, etc. if requested */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500482PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
483 int mask));
484
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500485#ifdef PNG_READ_INTERLACING_SUPPORTED
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500486/* Expand an interlaced row */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500487/* OLD pre-1.0.9 interface:
488PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
489 png_bytep row, int pass, png_uint_32 transformations));
490 */
491PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr));
492#endif
493
494/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */
495
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500496#ifdef PNG_WRITE_INTERLACING_SUPPORTED
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500497/* Grab pixels out of a row for an interlaced pass */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500498PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
499 png_bytep row, int pass));
500#endif
501
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500502/* Unfilter a row */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500503PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
504 png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
505
506/* Choose the best filter to use and filter the row data */
507PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
508 png_row_infop row_info));
509
510/* Write out the filtered row. */
511PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
512 png_bytep filtered_row));
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500513/* Finish a row while reading, dealing with interlacing passes, etc. */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500514PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
515
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500516/* Initialize the row buffers, etc. */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500517PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500518/* Optional call to update the users info structure */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500519PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
520 png_infop info_ptr));
521
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500522/* These are the functions that do the transformations */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500523#ifdef PNG_READ_FILLER_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500524PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
525 png_bytep row, png_uint_32 filler, png_uint_32 flags));
526#endif
527
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500528#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500529PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
530 png_bytep row));
531#endif
532
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500533#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500534PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
535 png_bytep row));
536#endif
537
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500538#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500539PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
540 png_bytep row));
541#endif
542
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500543#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500544PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
545 png_bytep row));
546#endif
547
548#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
549 defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
550PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
551 png_bytep row, png_uint_32 flags));
552#endif
553
554#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
555PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
556#endif
557
558#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
559PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
560#endif
561
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500562#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500563PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
564 row_info, png_bytep row));
565#endif
566
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500567#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500568PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
569 png_bytep row));
570#endif
571
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500572#ifdef PNG_READ_PACK_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500573PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
574#endif
575
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500576#ifdef PNG_READ_SHIFT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500577PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
578 png_color_8p sig_bits));
579#endif
580
581#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
582PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
583#endif
584
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500585#ifdef PNG_READ_16_TO_8_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500586PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
587#endif
588
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500589#ifdef PNG_READ_DITHER_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500590PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
591 png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
592
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500593# ifdef PNG_CORRECT_PALETTE_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500594PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
595 png_colorp palette, int num_palette));
596# endif
597#endif
598
599#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
600PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
601#endif
602
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500603#ifdef PNG_WRITE_PACK_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500604PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
605 png_bytep row, png_uint_32 bit_depth));
606#endif
607
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500608#ifdef PNG_WRITE_SHIFT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500609PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
610 png_color_8p bit_depth));
611#endif
612
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500613#ifdef PNG_READ_BACKGROUND_SUPPORTED
614#ifdef PNG_READ_GAMMA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500615PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -0500616 png_color_16p trans_color, png_color_16p background,
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500617 png_color_16p background_1,
618 png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
619 png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
620 png_uint_16pp gamma_16_to_1, int gamma_shift));
621#else
622PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -0500623 png_color_16p trans_color, png_color_16p background));
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500624#endif
625#endif
626
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500627#ifdef PNG_READ_GAMMA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500628PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
629 png_bytep gamma_table, png_uint_16pp gamma_16_table,
630 int gamma_shift));
631#endif
632
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500633#ifdef PNG_READ_EXPAND_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500634PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
635 png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
636PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
637 png_bytep row, png_color_16p trans_value));
638#endif
639
640/* The following decodes the appropriate chunks, and does error correction,
641 * then calls the appropriate callback for the chunk if it is valid.
642 */
643
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500644/* Decode the IHDR chunk */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500645PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
646 png_uint_32 length));
647PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
648 png_uint_32 length));
649PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
650 png_uint_32 length));
651
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500652#ifdef PNG_READ_bKGD_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500653PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
654 png_uint_32 length));
655#endif
656
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500657#ifdef PNG_READ_cHRM_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500658PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
659 png_uint_32 length));
660#endif
661
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500662#ifdef PNG_READ_gAMA_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500663PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
664 png_uint_32 length));
665#endif
666
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500667#ifdef PNG_READ_hIST_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500668PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
669 png_uint_32 length));
670#endif
671
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500672#ifdef PNG_READ_iCCP_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500673extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
674 png_uint_32 length));
675#endif /* PNG_READ_iCCP_SUPPORTED */
676
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500677#ifdef PNG_READ_iTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500678PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
679 png_uint_32 length));
680#endif
681
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500682#ifdef PNG_READ_oFFs_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500683PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
684 png_uint_32 length));
685#endif
686
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500687#ifdef PNG_READ_pCAL_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500688PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
689 png_uint_32 length));
690#endif
691
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500692#ifdef PNG_READ_pHYs_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500693PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
694 png_uint_32 length));
695#endif
696
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500697#ifdef PNG_READ_sBIT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500698PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
699 png_uint_32 length));
700#endif
701
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500702#ifdef PNG_READ_sCAL_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500703PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
704 png_uint_32 length));
705#endif
706
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500707#ifdef PNG_READ_sPLT_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500708extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
709 png_uint_32 length));
710#endif /* PNG_READ_sPLT_SUPPORTED */
711
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500712#ifdef PNG_READ_sRGB_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500713PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
714 png_uint_32 length));
715#endif
716
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500717#ifdef PNG_READ_tEXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500718PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
719 png_uint_32 length));
720#endif
721
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500722#ifdef PNG_READ_tIME_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500723PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
724 png_uint_32 length));
725#endif
726
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500727#ifdef PNG_READ_tRNS_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500728PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
729 png_uint_32 length));
730#endif
731
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500732#ifdef PNG_READ_zTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500733PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
734 png_uint_32 length));
735#endif
736
737PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
738 png_infop info_ptr, png_uint_32 length));
739
740PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
741 png_bytep chunk_name));
742
Glenn Randers-Pehrson6c7a09a2009-06-15 21:57:39 -0500743/* Handle the transformations for reading and writing */
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500744PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
745PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
746
747PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
748
749#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
750PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
751 png_infop info_ptr));
752PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
753 png_infop info_ptr));
754PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
755PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
756 png_uint_32 length));
757PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
758PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
759PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
760 png_bytep buffer, png_size_t buffer_length));
761PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
762PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
763 png_bytep buffer, png_size_t buffer_length));
764PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
765PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
766 png_infop info_ptr, png_uint_32 length));
767PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
768 png_infop info_ptr));
769PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
770 png_infop info_ptr));
771PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
772PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
773 png_infop info_ptr));
774PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
775 png_infop info_ptr));
776PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500777#ifdef PNG_READ_tEXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500778PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
779 png_infop info_ptr, png_uint_32 length));
780PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
781 png_infop info_ptr));
782#endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500783#ifdef PNG_READ_zTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500784PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
785 png_infop info_ptr, png_uint_32 length));
786PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
787 png_infop info_ptr));
788#endif
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500789#ifdef PNG_READ_iTXt_SUPPORTED
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500790PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
791 png_infop info_ptr, png_uint_32 length));
792PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
793 png_infop info_ptr));
794#endif
795
796#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
797
798#ifdef PNG_MNG_FEATURES_SUPPORTED
799PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
800 png_bytep row));
801PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
802 png_bytep row));
803#endif
804
Glenn Randers-Pehrsonf7831012008-11-13 06:05:13 -0600805/* Added at libpng version 1.4.0 */
Glenn Randers-Pehrson4e6b5e92009-09-23 10:24:53 -0500806#ifdef PNG_cHRM_SUPPORTED
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500807PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
Glenn Randers-Pehrsonf7831012008-11-13 06:05:13 -0600808 png_fixed_point int_white_x, png_fixed_point int_white_y,
809 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
810 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
811 png_fixed_point int_blue_y));
812#endif
Glenn Randers-Pehrsonf7831012008-11-13 06:05:13 -0600813
Glenn Randers-Pehrson7ec330d2009-09-25 11:45:42 -0500814#ifdef PNG_cHRM_SUPPORTED
815#ifdef PNG_CHECK_cHRM_SUPPORTED
816/* Added at libpng version 1.2.34 and 1.4.0 */
817PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
818 unsigned long *hi_product, unsigned long *lo_product));
819#endif
820#endif
821
Glenn Randers-Pehrson134bbe42009-09-24 18:10:49 -0500822/* Added at libpng version 1.4.0 */
823PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
824 png_uint_32 width, png_uint_32 height, int bit_depth,
825 int color_type, int interlace_type, int compression_type,
826 int filter_type));
827
Glenn Randers-Pehrsond29033f2009-11-07 10:46:42 -0600828/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
829extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
830 png_infop end_info_ptr));
831
832/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
833extern void png_write_destroy PNGARG((png_structp png_ptr));
834
835#ifdef USE_FAR_KEYWORD /* memory model conversion function */
836extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
837 int check));
838#endif /* USE_FAR_KEYWORD */
839
840/* Define PNG_DEBUG at compile time for debugging information. Higher
841 * numbers for PNG_DEBUG mean more debugging information. This has
842 * only been added since version 0.95 so it is not implemented throughout
843 * libpng yet, but more support will be added as needed.
844 */
845#ifdef PNG_DEBUG
846#if (PNG_DEBUG > 0)
847#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
848#include <crtdbg.h>
849#if (PNG_DEBUG > 1)
850#ifndef _DEBUG
851# define _DEBUG
852#endif
853#ifndef png_debug
854#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
855#endif
856#ifndef png_debug1
857#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
858#endif
859#ifndef png_debug2
860#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
861#endif
862#endif
863#else /* PNG_DEBUG_FILE || !_MSC_VER */
864#ifndef PNG_DEBUG_FILE
865#define PNG_DEBUG_FILE stderr
866#endif /* PNG_DEBUG_FILE */
867
868#if (PNG_DEBUG > 1)
869/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
870 * non-ISO compilers
871 */
872# ifdef __STDC__
873# ifndef png_debug
874# define png_debug(l,m) \
875 { \
876 int num_tabs=l; \
877 fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
878 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
879 }
880# endif
881# ifndef png_debug1
882# define png_debug1(l,m,p1) \
883 { \
884 int num_tabs=l; \
885 fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
886 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
887 }
888# endif
889# ifndef png_debug2
890# define png_debug2(l,m,p1,p2) \
891 { \
892 int num_tabs=l; \
893 fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
894 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
895 }
896# endif
897# else /* __STDC __ */
898# ifndef png_debug
899# define png_debug(l,m) \
900 { \
901 int num_tabs=l; \
902 char format[256]; \
903 snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
904 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
905 m,PNG_STRING_NEWLINE); \
906 fprintf(PNG_DEBUG_FILE,format); \
907 }
908# endif
909# ifndef png_debug1
910# define png_debug1(l,m,p1) \
911 { \
912 int num_tabs=l; \
913 char format[256]; \
914 snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
915 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
916 m,PNG_STRING_NEWLINE); \
917 fprintf(PNG_DEBUG_FILE,format,p1); \
918 }
919# endif
920# ifndef png_debug2
921# define png_debug2(l,m,p1,p2) \
922 { \
923 int num_tabs=l; \
924 char format[256]; \
925 snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
926 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
927 m,PNG_STRING_NEWLINE); \
928 fprintf(PNG_DEBUG_FILE,format,p1,p2); \
929 }
930# endif
931# endif /* __STDC __ */
932#endif /* (PNG_DEBUG > 1) */
933
934#endif /* _MSC_VER */
935#endif /* (PNG_DEBUG > 0) */
936#endif /* PNG_DEBUG */
937#ifndef png_debug
938#define png_debug(l, m)
939#endif
940#ifndef png_debug1
941#define png_debug1(l, m, p1)
942#endif
943#ifndef png_debug2
944#define png_debug2(l, m, p1, p2)
945#endif
946
947#if 0
948extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
949#endif
950
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500951/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
952
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500953#ifdef __cplusplus
954}
955#endif
956
957#endif /* PNG_VERSION_INFO_ONLY */
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500958#endif /* PNGPRIV_H */