Sync with trunk (r48042), except win32k/ntuser/cursoricon.c
[reactos.git] / include / reactos / libs / libpng / pngpriv.h
1
2 /* pngpriv.h - private declarations for use inside libpng
3 *
4 * libpng version 1.4.3 - June 26, 2010
5 * For conditions of distribution and use, see copyright notice in png.h
6 * Copyright (c) 1998-2010 Glenn Randers-Pehrson
7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9 *
10 * This code is released under the libpng license.
11 * For conditions of distribution and use, see the disclaimer
12 * and license in png.h
13 */
14
15 /* 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
26
27 #ifndef PNG_VERSION_INFO_ONLY
28
29 #include <stdlib.h>
30
31 /* The functions exported by PNG_EXTERN are internal functions, which
32 * aren't usually used outside the library (as far as I know), so it is
33 * 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.
36 #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
44 #ifdef PNG_FLOATING_POINT_SUPPORTED
45 # ifdef MACOS
46 /* 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) || \
76 defined(_WIN32) || defined(__WIN32__)
77 # include <windows.h> /* defines _WINDOWS_ macro */
78 /* I have no idea why is this necessary... */
79 # ifdef _MSC_VER
80 # include <malloc.h>
81 # endif
82 #endif
83
84 /* 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
90 #define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
91 #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
100 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
101
102 /* Flags for the transformations the PNG library does on the image data */
103 #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_QUANTIZE 0x0040 /* formerly PNG_DITHER */
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 */
130 /* 0x4000000L unused */
131 /* 0x8000000L unused */
132 /* 0x10000000L unused */
133 /* 0x20000000L unused */
134 /* 0x40000000L unused */
135
136 /* Flags for png_create_struct */
137 #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
146 /* Flags for the png_ptr->flags rather than declaring a byte for each one */
147 #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
159 /* 0x1000 unused */
160 /* 0x2000 unused */
161 /* 0x4000 unused */
162 #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 */
170 #define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */
171 /* 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
188 /* Save typing and make code easier to understand */
189
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 ? \
197 ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
198 (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )
199
200 /* PNG_OUT_OF_RANGE returns true if value is outside the range
201 * 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 */
205 #define PNG_OUT_OF_RANGE(value, ideal, delta) \
206 ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
207
208 /* Constant strings for known chunk types. If you need to add a chunk,
209 * define the name here, and add an invocation of the macro wherever it's
210 * needed.
211 */
212 #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'}
234
235
236 /* Inhibit C++ name-mangling for libpng functions but not for system calls. */
237 #ifdef __cplusplus
238 extern "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
247 /* Allocate memory for an internal libpng struct */
248 PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
249
250 /* Free memory from internal libpng struct */
251 PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
252
253 PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
254 malloc_fn, png_voidp mem_ptr));
255 PNG_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. */
259 PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
260 png_infop info_ptr));
261
262 /* Function to allocate memory for zlib. PNGAPI is disallowed. */
263 PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
264
265 /* Function to free memory for zlib. PNGAPI is disallowed. */
266 PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
267
268 /* 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
271 PNG_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
275 PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
276 png_bytep buffer, png_size_t length));
277 #endif
278
279 PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
280 png_bytep data, png_size_t length));
281
282 #ifdef PNG_WRITE_FLUSH_SUPPORTED
283 #ifdef PNG_STDIO_SUPPORTED
284 PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr));
285 #endif
286 #endif
287
288 /* Reset the CRC variable */
289 PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
290
291 /* Write the "data" buffer to whatever output you are using */
292 PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
293 png_size_t length));
294
295 /* Read the chunk header (length + type name) */
296 PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
297
298 /* Read data from whatever input you are using into the "data" buffer */
299 PNG_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 */
303 PNG_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)
309 PNG_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));
312 #endif
313
314 /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
315 PNG_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 */
318 PNG_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 */
324 PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
325 png_size_t length));
326
327 #ifdef PNG_WRITE_FLUSH_SUPPORTED
328 PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
329 #endif
330
331 /* Write various chunks */
332
333 /* Write the IHDR chunk, and update the png_struct with the necessary
334 * information.
335 */
336 PNG_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
341 PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
342 png_uint_32 num_pal));
343
344 PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
345 png_size_t length));
346
347 PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
348
349 #ifdef PNG_WRITE_gAMA_SUPPORTED
350 #ifdef PNG_FLOATING_POINT_SUPPORTED
351 PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
352 #endif
353 #ifdef PNG_FIXED_POINT_SUPPORTED
354 PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr,
355 png_fixed_point file_gamma));
356 #endif
357 #endif
358
359 #ifdef PNG_WRITE_sBIT_SUPPORTED
360 PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
361 int color_type));
362 #endif
363
364 #ifdef PNG_WRITE_cHRM_SUPPORTED
365 #ifdef PNG_FLOATING_POINT_SUPPORTED
366 PNG_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
371 PNG_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
377
378 #ifdef PNG_WRITE_sRGB_SUPPORTED
379 PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
380 int intent));
381 #endif
382
383 #ifdef PNG_WRITE_iCCP_SUPPORTED
384 PNG_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
390 #ifdef PNG_WRITE_sPLT_SUPPORTED
391 PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
392 png_sPLT_tp palette));
393 #endif
394
395 #ifdef PNG_WRITE_tRNS_SUPPORTED
396 PNG_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
400 #ifdef PNG_WRITE_bKGD_SUPPORTED
401 PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
402 png_color_16p values, int color_type));
403 #endif
404
405 #ifdef PNG_WRITE_hIST_SUPPORTED
406 PNG_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)
412 PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
413 png_charp key, png_charpp new_key));
414 #endif
415
416 #ifdef PNG_WRITE_tEXt_SUPPORTED
417 PNG_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
421 #ifdef PNG_WRITE_zTXt_SUPPORTED
422 PNG_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
426 #ifdef PNG_WRITE_iTXt_SUPPORTED
427 PNG_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
432 #ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
433 PNG_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
437 #ifdef PNG_WRITE_oFFs_SUPPORTED
438 PNG_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
442 #ifdef PNG_WRITE_pCAL_SUPPORTED
443 PNG_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
448 #ifdef PNG_WRITE_pHYs_SUPPORTED
449 PNG_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
454 #ifdef PNG_WRITE_tIME_SUPPORTED
455 PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
456 png_timep mod_time));
457 #endif
458
459 #ifdef PNG_WRITE_sCAL_SUPPORTED
460 #if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
461 PNG_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
465 PNG_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 */
472 PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
473
474 /* Internal use only. Called before first row of data */
475 PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
476
477 #ifdef PNG_READ_GAMMA_SUPPORTED
478 PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
479 png_byte bit_depth));
480 #endif
481
482 /* Combine a row of data, dealing with alpha, etc. if requested */
483 PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
484 int mask));
485
486 #ifdef PNG_READ_INTERLACING_SUPPORTED
487 /* Expand an interlaced row */
488 /* OLD pre-1.0.9 interface:
489 PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
490 png_bytep row, int pass, png_uint_32 transformations));
491 */
492 PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr));
493 #endif
494
495 /* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */
496
497 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
498 /* Grab pixels out of a row for an interlaced pass */
499 PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
500 png_bytep row, int pass));
501 #endif
502
503 /* Unfilter a row */
504 PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
505 png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
506
507 /* Choose the best filter to use and filter the row data */
508 PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
509 png_row_infop row_info));
510
511 /* Write out the filtered row. */
512 PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
513 png_bytep filtered_row));
514 /* Finish a row while reading, dealing with interlacing passes, etc. */
515 PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
516
517 /* Initialize the row buffers, etc. */
518 PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
519 /* Optional call to update the users info structure */
520 PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
521 png_infop info_ptr));
522
523 /* These are the functions that do the transformations */
524 #ifdef PNG_READ_FILLER_SUPPORTED
525 PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
526 png_bytep row, png_uint_32 filler, png_uint_32 flags));
527 #endif
528
529 #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
530 PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
531 png_bytep row));
532 #endif
533
534 #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
535 PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
536 png_bytep row));
537 #endif
538
539 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
540 PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
541 png_bytep row));
542 #endif
543
544 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
545 PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
546 png_bytep row));
547 #endif
548
549 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
550 defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
551 PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
552 png_bytep row, png_uint_32 flags));
553 #endif
554
555 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
556 PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
557 #endif
558
559 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
560 defined(PNG_WRITE_PACKSWAP_SUPPORTED)
561 PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
562 #endif
563
564 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
565 PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
566 row_info, png_bytep row));
567 #endif
568
569 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
570 PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
571 png_bytep row));
572 #endif
573
574 #ifdef PNG_READ_PACK_SUPPORTED
575 PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
576 #endif
577
578 #ifdef PNG_READ_SHIFT_SUPPORTED
579 PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
580 png_color_8p sig_bits));
581 #endif
582
583 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
584 PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
585 #endif
586
587 #ifdef PNG_READ_16_TO_8_SUPPORTED
588 PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
589 #endif
590
591 #ifdef PNG_READ_QUANTIZE_SUPPORTED
592 PNG_EXTERN void png_do_quantize PNGARG((png_row_infop row_info,
593 png_bytep row, png_bytep palette_lookup, png_bytep quantize_lookup));
594
595 # ifdef PNG_CORRECT_PALETTE_SUPPORTED
596 PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
597 png_colorp palette, int num_palette));
598 # endif
599 #endif
600
601 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
602 PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
603 #endif
604
605 #ifdef PNG_WRITE_PACK_SUPPORTED
606 PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
607 png_bytep row, png_uint_32 bit_depth));
608 #endif
609
610 #ifdef PNG_WRITE_SHIFT_SUPPORTED
611 PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
612 png_color_8p bit_depth));
613 #endif
614
615 #ifdef PNG_READ_BACKGROUND_SUPPORTED
616 #ifdef PNG_READ_GAMMA_SUPPORTED
617 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
618 png_color_16p trans_color, png_color_16p background,
619 png_color_16p background_1,
620 png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
621 png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
622 png_uint_16pp gamma_16_to_1, int gamma_shift));
623 #else
624 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
625 png_color_16p trans_color, png_color_16p background));
626 #endif
627 #endif
628
629 #ifdef PNG_READ_GAMMA_SUPPORTED
630 PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
631 png_bytep gamma_table, png_uint_16pp gamma_16_table,
632 int gamma_shift));
633 #endif
634
635 #ifdef PNG_READ_EXPAND_SUPPORTED
636 PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
637 png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
638 PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
639 png_bytep row, png_color_16p trans_value));
640 #endif
641
642 /* The following decodes the appropriate chunks, and does error correction,
643 * then calls the appropriate callback for the chunk if it is valid.
644 */
645
646 /* Decode the IHDR chunk */
647 PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
648 png_uint_32 length));
649 PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
650 png_uint_32 length));
651 PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
652 png_uint_32 length));
653
654 #ifdef PNG_READ_bKGD_SUPPORTED
655 PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
656 png_uint_32 length));
657 #endif
658
659 #ifdef PNG_READ_cHRM_SUPPORTED
660 PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
661 png_uint_32 length));
662 #endif
663
664 #ifdef PNG_READ_gAMA_SUPPORTED
665 PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
666 png_uint_32 length));
667 #endif
668
669 #ifdef PNG_READ_hIST_SUPPORTED
670 PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
671 png_uint_32 length));
672 #endif
673
674 #ifdef PNG_READ_iCCP_SUPPORTED
675 extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
676 png_uint_32 length));
677 #endif /* PNG_READ_iCCP_SUPPORTED */
678
679 #ifdef PNG_READ_iTXt_SUPPORTED
680 PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
681 png_uint_32 length));
682 #endif
683
684 #ifdef PNG_READ_oFFs_SUPPORTED
685 PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
686 png_uint_32 length));
687 #endif
688
689 #ifdef PNG_READ_pCAL_SUPPORTED
690 PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
691 png_uint_32 length));
692 #endif
693
694 #ifdef PNG_READ_pHYs_SUPPORTED
695 PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
696 png_uint_32 length));
697 #endif
698
699 #ifdef PNG_READ_sBIT_SUPPORTED
700 PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
701 png_uint_32 length));
702 #endif
703
704 #ifdef PNG_READ_sCAL_SUPPORTED
705 PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
706 png_uint_32 length));
707 #endif
708
709 #ifdef PNG_READ_sPLT_SUPPORTED
710 extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
711 png_uint_32 length));
712 #endif /* PNG_READ_sPLT_SUPPORTED */
713
714 #ifdef PNG_READ_sRGB_SUPPORTED
715 PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
716 png_uint_32 length));
717 #endif
718
719 #ifdef PNG_READ_tEXt_SUPPORTED
720 PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
721 png_uint_32 length));
722 #endif
723
724 #ifdef PNG_READ_tIME_SUPPORTED
725 PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
726 png_uint_32 length));
727 #endif
728
729 #ifdef PNG_READ_tRNS_SUPPORTED
730 PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
731 png_uint_32 length));
732 #endif
733
734 #ifdef PNG_READ_zTXt_SUPPORTED
735 PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
736 png_uint_32 length));
737 #endif
738
739 PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
740 png_infop info_ptr, png_uint_32 length));
741
742 PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
743 png_bytep chunk_name));
744
745 /* Handle the transformations for reading and writing */
746 PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
747 PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
748
749 PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
750
751 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
752 PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
753 png_infop info_ptr));
754 PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
755 png_infop info_ptr));
756 PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
757 PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
758 png_uint_32 length));
759 PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
760 PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
761 PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
762 png_bytep buffer, png_size_t buffer_length));
763 PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
764 PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
765 png_bytep buffer, png_size_t buffer_length));
766 PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
767 PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
768 png_infop info_ptr, png_uint_32 length));
769 PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
770 png_infop info_ptr));
771 PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
772 png_infop info_ptr));
773 PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
774 PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
775 png_infop info_ptr));
776 PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
777 png_infop info_ptr));
778 PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
779 #ifdef PNG_READ_tEXt_SUPPORTED
780 PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
781 png_infop info_ptr, png_uint_32 length));
782 PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
783 png_infop info_ptr));
784 #endif
785 #ifdef PNG_READ_zTXt_SUPPORTED
786 PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
787 png_infop info_ptr, png_uint_32 length));
788 PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
789 png_infop info_ptr));
790 #endif
791 #ifdef PNG_READ_iTXt_SUPPORTED
792 PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
793 png_infop info_ptr, png_uint_32 length));
794 PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
795 png_infop info_ptr));
796 #endif
797
798 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
799
800 #ifdef PNG_MNG_FEATURES_SUPPORTED
801 PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
802 png_bytep row));
803 PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
804 png_bytep row));
805 #endif
806
807 /* Added at libpng version 1.4.0 */
808 #ifdef PNG_cHRM_SUPPORTED
809 PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
810 png_fixed_point int_white_x, png_fixed_point int_white_y,
811 png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
812 int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
813 png_fixed_point int_blue_y));
814 #endif
815
816 #ifdef PNG_cHRM_SUPPORTED
817 #ifdef PNG_CHECK_cHRM_SUPPORTED
818 /* Added at libpng version 1.2.34 and 1.4.0 */
819 PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
820 unsigned long *hi_product, unsigned long *lo_product));
821 #endif
822 #endif
823
824 /* Added at libpng version 1.4.0 */
825 PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
826 png_uint_32 width, png_uint_32 height, int bit_depth,
827 int color_type, int interlace_type, int compression_type,
828 int filter_type));
829
830 /* Free all memory used by the read (old method - NOT DLL EXPORTED) */
831 extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
832 png_infop end_info_ptr));
833
834 /* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
835 extern void png_write_destroy PNGARG((png_structp png_ptr));
836
837 #ifdef USE_FAR_KEYWORD /* memory model conversion function */
838 extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
839 int check));
840 #endif /* USE_FAR_KEYWORD */
841
842 /* Define PNG_DEBUG at compile time for debugging information. Higher
843 * numbers for PNG_DEBUG mean more debugging information. This has
844 * only been added since version 0.95 so it is not implemented throughout
845 * libpng yet, but more support will be added as needed.
846 */
847 #ifdef PNG_DEBUG
848 #if (PNG_DEBUG > 0)
849 #if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
850 #include <crtdbg.h>
851 #if (PNG_DEBUG > 1)
852 #ifndef _DEBUG
853 # define _DEBUG
854 #endif
855 #ifndef png_debug
856 #define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
857 #endif
858 #ifndef png_debug1
859 #define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
860 #endif
861 #ifndef png_debug2
862 #define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
863 #endif
864 #endif
865 #else /* PNG_DEBUG_FILE || !_MSC_VER */
866 #ifndef PNG_DEBUG_FILE
867 #define PNG_DEBUG_FILE stderr
868 #endif /* PNG_DEBUG_FILE */
869
870 #if (PNG_DEBUG > 1)
871 /* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
872 * non-ISO compilers
873 */
874 # ifdef __STDC__
875 # ifndef png_debug
876 # define png_debug(l,m) \
877 { \
878 int num_tabs=l; \
879 fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
880 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
881 }
882 # endif
883 # ifndef png_debug1
884 # define png_debug1(l,m,p1) \
885 { \
886 int num_tabs=l; \
887 fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
888 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
889 }
890 # endif
891 # ifndef png_debug2
892 # define png_debug2(l,m,p1,p2) \
893 { \
894 int num_tabs=l; \
895 fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
896 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
897 }
898 # endif
899 # else /* __STDC __ */
900 # ifndef png_debug
901 # define png_debug(l,m) \
902 { \
903 int num_tabs=l; \
904 char format[256]; \
905 snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
906 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
907 m,PNG_STRING_NEWLINE); \
908 fprintf(PNG_DEBUG_FILE,format); \
909 }
910 # endif
911 # ifndef png_debug1
912 # define png_debug1(l,m,p1) \
913 { \
914 int num_tabs=l; \
915 char format[256]; \
916 snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
917 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
918 m,PNG_STRING_NEWLINE); \
919 fprintf(PNG_DEBUG_FILE,format,p1); \
920 }
921 # endif
922 # ifndef png_debug2
923 # define png_debug2(l,m,p1,p2) \
924 { \
925 int num_tabs=l; \
926 char format[256]; \
927 snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
928 (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
929 m,PNG_STRING_NEWLINE); \
930 fprintf(PNG_DEBUG_FILE,format,p1,p2); \
931 }
932 # endif
933 # endif /* __STDC __ */
934 #endif /* (PNG_DEBUG > 1) */
935
936 #endif /* _MSC_VER */
937 #endif /* (PNG_DEBUG > 0) */
938 #endif /* PNG_DEBUG */
939 #ifndef png_debug
940 #define png_debug(l, m)
941 #endif
942 #ifndef png_debug1
943 #define png_debug1(l, m, p1)
944 #endif
945 #ifndef png_debug2
946 #define png_debug2(l, m, p1, p2)
947 #endif
948
949 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
950
951 #ifdef __cplusplus
952 }
953 #endif
954
955 #endif /* PNG_VERSION_INFO_ONLY */
956 #endif /* PNGPRIV_H */