zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pngpriv.h
Go to the documentation of this file.
1 
2 /* pngpriv.h - private declarations for use inside libpng
3  *
4  * For conditions of distribution and use, see copyright notice in png.h
5  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
6  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
8  *
9  * Last changed in libpng 1.5.7 [December 15, 2011]
10  *
11  * This code is released under the libpng license.
12  * For conditions of distribution and use, see the disclaimer
13  * and license in png.h
14  */
15 
16 /* The symbols declared in this file (including the functions declared
17  * as PNG_EXTERN) are PRIVATE. They are not part of the libpng public
18  * interface, and are not recommended for use by regular applications.
19  * Some of them may become public in the future; others may stay private,
20  * change in an incompatible way, or even disappear.
21  * Although the libpng users are not forbidden to include this header,
22  * they should be well aware of the issues that may arise from doing so.
23  */
24 
25 #ifndef PNGPRIV_H
26 #define PNGPRIV_H
27 
28 /* Feature Test Macros. The following are defined here to ensure that correctly
29  * implemented libraries reveal the APIs libpng needs to build and hide those
30  * that are not needed and potentially damaging to the compilation.
31  *
32  * Feature Test Macros must be defined before any system header is included (see
33  * POSIX 1003.1 2.8.2 "POSIX Symbols."
34  *
35  * These macros only have an effect if the operating system supports either
36  * POSIX 1003.1 or C99, or both. On other operating systems (particularly
37  * Windows/Visual Studio) there is no effect; the OS specific tests below are
38  * still required (as of 2011-05-02.)
39  */
40 #define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
41 
42 /* This is required for the definition of abort(), used as a last ditch
43  * error handler when all else fails.
44  */
45 #include <stdlib.h>
46 
47 /* This is used to find 'offsetof', used below for alignment tests. */
48 #include <stddef.h>
49 
50 #define PNGLIB_BUILD /*libpng is being built, not used*/
51 
52 #ifdef PNG_USER_CONFIG
53 # include "pngusr.h"
54  /* These should have been defined in pngusr.h */
55 # ifndef PNG_USER_PRIVATEBUILD
56 # define PNG_USER_PRIVATEBUILD "Custom libpng build"
57 # endif
58 # ifndef PNG_USER_DLLFNAME_POSTFIX
59 # define PNG_USER_DLLFNAME_POSTFIX "Cb"
60 # endif
61 #endif
62 
63 /* Is this a build of a DLL where compilation of the object modules requires
64  * different preprocessor settings to those required for a simple library? If
65  * so PNG_BUILD_DLL must be set.
66  *
67  * If libpng is used inside a DLL but that DLL does not export the libpng APIs
68  * PNG_BUILD_DLL must not be set. To avoid the code below kicking in build a
69  * static library of libpng then link the DLL against that.
70  */
71 #ifndef PNG_BUILD_DLL
72 # ifdef DLL_EXPORT
73  /* This is set by libtool when files are compiled for a DLL; libtool
74  * always compiles twice, even on systems where it isn't necessary. Set
75  * PNG_BUILD_DLL in case it is necessary:
76  */
77 # define PNG_BUILD_DLL
78 # else
79 # ifdef _WINDLL
80  /* This is set by the Microsoft Visual Studio IDE in projects that
81  * build a DLL. It can't easily be removed from those projects (it
82  * isn't visible in the Visual Studio UI) so it is a fairly reliable
83  * indication that PNG_IMPEXP needs to be set to the DLL export
84  * attributes.
85  */
86 # define PNG_BUILD_DLL
87 # else
88 # ifdef __DLL__
89  /* This is set by the Borland C system when compiling for a DLL
90  * (as above.)
91  */
92 # define PNG_BUILD_DLL
93 # else
94  /* Add additional compiler cases here. */
95 # endif
96 # endif
97 # endif
98 #endif /* Setting PNG_BUILD_DLL if required */
99 
100 /* See pngconf.h for more details: the builder of the library may set this on
101  * the command line to the right thing for the specific compilation system or it
102  * may be automagically set above (at present we know of no system where it does
103  * need to be set on the command line.)
104  *
105  * PNG_IMPEXP must be set here when building the library to prevent pngconf.h
106  * setting it to the "import" setting for a DLL build.
107  */
108 #ifndef PNG_IMPEXP
109 # ifdef PNG_BUILD_DLL
110 # define PNG_IMPEXP PNG_DLL_EXPORT
111 # else
112  /* Not building a DLL, or the DLL doesn't require specific export
113  * definitions.
114  */
115 # define PNG_IMPEXP
116 # endif
117 #endif
118 
119 /* No warnings for private or deprecated functions in the build: */
120 #ifndef PNG_DEPRECATED
121 # define PNG_DEPRECATED
122 #endif
123 #ifndef PNG_PRIVATE
124 # define PNG_PRIVATE
125 #endif
126 
127 #include "png.h"
128 #include "pnginfo.h"
129 #include "pngstruct.h"
130 
131 /* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */
132 #ifndef PNG_DLL_EXPORT
133 # define PNG_DLL_EXPORT
134 #endif
135 
136 /* This is used for 16 bit gamma tables - only the top level pointers are const,
137  * this could be changed:
138  */
140 
141 /* Added at libpng-1.2.9 */
142 /* Moved to pngpriv.h at libpng-1.5.0 */
143 
144 /* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure"
145  * script. We may need it here to get the correct configuration on things
146  * like limits.
147  */
148 #ifdef PNG_CONFIGURE_LIBPNG
149 # ifdef HAVE_CONFIG_H
150 # include "config.h"
151 # endif
152 #endif
153 
154 /* Moved to pngpriv.h at libpng-1.5.0 */
155 /* NOTE: some of these may have been used in external applications as
156  * these definitions were exposed in pngconf.h prior to 1.5.
157  */
158 
159 /* If you are running on a machine where you cannot allocate more
160  * than 64K of memory at once, uncomment this. While libpng will not
161  * normally need that much memory in a chunk (unless you load up a very
162  * large file), zlib needs to know how big of a chunk it can use, and
163  * libpng thus makes sure to check any memory allocation to verify it
164  * will fit into memory.
165  *
166  * zlib provides 'MAXSEG_64K' which, if defined, indicates the
167  * same limit and pngconf.h (already included) sets the limit
168  * if certain operating systems are detected.
169  */
170 #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
171 # define PNG_MAX_MALLOC_64K
172 #endif
173 
174 #ifndef PNG_UNUSED
175 /* Unused formal parameter warnings are silenced using the following macro
176  * which is expected to have no bad effects on performance (optimizing
177  * compilers will probably remove it entirely). Note that if you replace
178  * it with something other than whitespace, you must include the terminating
179  * semicolon.
180  */
181 # define PNG_UNUSED(param) (void)param;
182 #endif
183 
184 /* Just a little check that someone hasn't tried to define something
185  * contradictory.
186  */
187 #if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
188 # undef PNG_ZBUF_SIZE
189 # define PNG_ZBUF_SIZE 65536L
190 #endif
191 
192 /* PNG_STATIC is used to mark internal file scope functions if they need to be
193  * accessed for implementation tests (see the code in tests/?*).
194  */
195 #ifndef PNG_STATIC
196 # define PNG_STATIC static
197 #endif
198 
199 /* C99 restrict is used where possible, to do this 'restrict' is defined as
200  * empty if we can't be sure it is supported. configure builds have already
201  * done this work.
202  */
203 #ifdef PNG_CONFIGURE_LIBPNG
204 # define PNG_RESTRICT restrict
205 #else
206  /* Modern compilers support restrict, but assume not for anything not
207  * recognized here:
208  */
209 # if defined __GNUC__ || defined _MSC_VER || defined __WATCOMC__
210 # define PNG_RESTRICT restrict
211 # else
212 # define PNG_RESTRICT
213 # endif
214 #endif
215 
216 /* If warnings or errors are turned off the code is disabled or redirected here.
217  * From 1.5.4 functions have been added to allow very limited formatting of
218  * error and warning messages - this code will also be disabled here.
219  */
220 #ifdef PNG_WARNINGS_SUPPORTED
221 # define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;
222 #else
223 # define png_warning(s1,s2) ((void)(s1))
224 # define png_chunk_warning(s1,s2) ((void)(s1))
225 # define png_warning_parameter(p,number,string) ((void)0)
226 # define png_warning_parameter_unsigned(p,number,format,value) ((void)0)
227 # define png_warning_parameter_signed(p,number,format,value) ((void)0)
228 # define png_formatted_warning(pp,p,message) ((void)(pp))
229 # define PNG_WARNING_PARAMETERS(p)
230 #endif
231 #ifndef PNG_ERROR_TEXT_SUPPORTED
232 # define png_error(s1,s2) png_err(s1)
233 # define png_chunk_error(s1,s2) png_err(s1)
234 # define png_fixed_error(s1,s2) png_err(s1)
235 #endif
236 
237 /* C allows up-casts from (void*) to any pointer and (const void*) to any
238  * pointer to a const object. C++ regards this as a type error and requires an
239  * explicit, static, cast and provides the static_cast<> rune to ensure that
240  * const is not cast away.
241  */
242 #ifdef __cplusplus
243 # define png_voidcast(type, value) static_cast<type>(value)
244 #else
245 # define png_voidcast(type, value) (value)
246 #endif /* __cplusplus */
247 
248 #ifndef PNG_EXTERN
249 /* The functions exported by PNG_EXTERN are internal functions, which
250  * aren't usually used outside the library (as far as I know), so it is
251  * debatable if they should be exported at all. In the future, when it
252  * is possible to have run-time registry of chunk-handling functions,
253  * some of these might be made available again.
254  *
255  * 1.5.7: turned the use of 'extern' back on, since it is localized to pngpriv.h
256  * it should be safe now (it is unclear why it was turned off.)
257  */
258 # define PNG_EXTERN extern
259 #endif
260 
261 /* Some fixed point APIs are still required even if not exported because
262  * they get used by the corresponding floating point APIs. This magic
263  * deals with this:
264  */
265 #ifdef PNG_FIXED_POINT_SUPPORTED
266 # define PNGFAPI PNGAPI
267 #else
268 # define PNGFAPI /* PRIVATE */
269 #endif
270 
271 /* Other defines specific to compilers can go here. Try to keep
272  * them inside an appropriate ifdef/endif pair for portability.
273  */
274 #if defined(PNG_FLOATING_POINT_SUPPORTED) ||\
275  defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
276  /* png.c requires the following ANSI-C constants if the conversion of
277  * floating point to ASCII is implemented therein:
278  *
279  * DBL_DIG Maximum number of decimal digits (can be set to any constant)
280  * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value)
281  * DBL_MAX Maximum floating point number (can be set to an arbitrary value)
282  */
283 # include <float.h>
284 
285 # if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
286  defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
287  /* We need to check that <math.h> hasn't already been included earlier
288  * as it seems it doesn't agree with <fp.h>, yet we should really use
289  * <fp.h> if possible.
290  */
291 # if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
292 # include <fp.h>
293 # endif
294 # else
295 # include <math.h>
296 # endif
297 # if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
298  /* Amiga SAS/C: We must include builtin FPU functions when compiling using
299  * MATH=68881
300  */
301 # include <m68881.h>
302 # endif
303 #endif
304 
305 /* This provides the non-ANSI (far) memory allocation routines. */
306 #if defined(__TURBOC__) && defined(__MSDOS__)
307 # include <mem.h>
308 # include <alloc.h>
309 #endif
310 
311 #if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
312  defined(_WIN32) || defined(__WIN32__)
313 # include <windows.h> /* defines _WINDOWS_ macro */
314 #endif
315 
316 /* Moved here around 1.5.0beta36 from pngconf.h */
317 /* Users may want to use these so they are not private. Any library
318  * functions that are passed far data must be model-independent.
319  */
320 
321 /* Memory model/platform independent fns */
322 #ifndef PNG_ABORT
323 # ifdef _WINDOWS_
324 # define PNG_ABORT() ExitProcess(0)
325 # else
326 # define PNG_ABORT() abort()
327 # endif
328 #endif
329 
330 #ifdef USE_FAR_KEYWORD
331 /* Use this to make far-to-near assignments */
332 # define CHECK 1
333 # define NOCHECK 0
334 # define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
335 # define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
336 # define png_strlen _fstrlen
337 # define png_memcmp _fmemcmp /* SJT: added */
338 # define png_memcpy _fmemcpy
339 # define png_memset _fmemset
340 #else
341 # ifdef _WINDOWS_ /* Favor Windows over C runtime fns */
342 # define CVT_PTR(ptr) (ptr)
343 # define CVT_PTR_NOCHECK(ptr) (ptr)
344 # define png_strlen lstrlenA
345 # define png_memcmp memcmp
346 # define png_memcpy CopyMemory
347 # define png_memset memset
348 # else
349 # define CVT_PTR(ptr) (ptr)
350 # define CVT_PTR_NOCHECK(ptr) (ptr)
351 # define png_strlen strlen
352 # define png_memcmp memcmp /* SJT: added */
353 # define png_memcpy memcpy
354 # define png_memset memset
355 # endif
356 #endif
357 
358 /* These macros may need to be architecture dependent. */
359 #define PNG_ALIGN_NONE 0 /* do not use data alignment */
360 #define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
361 #ifdef offsetof
362 # define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */
363 #else
364 # define PNG_ALIGN_OFFSET -1 /* prevent the use of this */
365 #endif
366 #define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */
367 
368 #ifndef PNG_ALIGN_TYPE
369  /* Default to using aligned access optimizations and requiring alignment to a
370  * multiple of the data type size. Override in a compiler specific fashion
371  * if necessary by inserting tests here:
372  */
373 # define PNG_ALIGN_TYPE PNG_ALIGN_SIZE
374 #endif
375 
376 #if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE
377  /* This is used because in some compiler implementations non-aligned
378  * structure members are supported, so the offsetof approach below fails.
379  * Set PNG_ALIGN_TO_SIZE=0 for compiler combinations where unaligned access
380  * is good for performance. Do not do this unless you have tested the result
381  * and understand it.
382  */
383 # define png_alignof(type) (sizeof (type))
384 #else
385 # if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET
386 # define png_alignof(type) offsetof(struct{char c; type t;}, t)
387 # else
388 # if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS
389 # define png_alignof(type) (1)
390 # endif
391  /* Else leave png_alignof undefined to prevent use thereof */
392 # endif
393 #endif
394 
395 /* This implicitly assumes alignment is always to a power of 2. */
396 #ifdef png_alignof
397 # define png_isaligned(ptr, type)\
398  ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)
399 #else
400 # define png_isaligned(ptr, type) 0
401 #endif
402 
403 /* End of memory model/platform independent support */
404 /* End of 1.5.0beta36 move from pngconf.h */
405 
406 /* CONSTANTS and UTILITY MACROS
407  * These are used internally by libpng and not exposed in the API
408  */
409 
410 /* Various modes of operation. Note that after an init, mode is set to
411  * zero automatically when the structure is created. Three of these
412  * are defined in png.h because they need to be visible to applications
413  * that call png_set_unknown_chunk().
414  */
415 /* #define PNG_HAVE_IHDR 0x01 (defined in png.h) */
416 /* #define PNG_HAVE_PLTE 0x02 (defined in png.h) */
417 #define PNG_HAVE_IDAT 0x04
418 /* #define PNG_AFTER_IDAT 0x08 (defined in png.h) */
419 #define PNG_HAVE_IEND 0x10
420 #define PNG_HAVE_gAMA 0x20
421 #define PNG_HAVE_cHRM 0x40
422 #define PNG_HAVE_sRGB 0x80
423 #define PNG_HAVE_CHUNK_HEADER 0x100
424 #define PNG_WROTE_tIME 0x200
425 #define PNG_WROTE_INFO_BEFORE_PLTE 0x400
426 #define PNG_BACKGROUND_IS_GRAY 0x800
427 #define PNG_HAVE_PNG_SIGNATURE 0x1000
428 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
429 
430 /* Flags for the transformations the PNG library does on the image data */
431 #define PNG_BGR 0x0001
432 #define PNG_INTERLACE 0x0002
433 #define PNG_PACK 0x0004
434 #define PNG_SHIFT 0x0008
435 #define PNG_SWAP_BYTES 0x0010
436 #define PNG_INVERT_MONO 0x0020
437 #define PNG_QUANTIZE 0x0040
438 #define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
439 #define PNG_BACKGROUND_EXPAND 0x0100
440 #define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
441 #define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
442 #define PNG_RGBA 0x0800
443 #define PNG_EXPAND 0x1000
444 #define PNG_GAMMA 0x2000
445 #define PNG_GRAY_TO_RGB 0x4000
446 #define PNG_FILLER 0x8000
447 #define PNG_PACKSWAP 0x10000
448 #define PNG_SWAP_ALPHA 0x20000
449 #define PNG_STRIP_ALPHA 0x40000
450 #define PNG_INVERT_ALPHA 0x80000
451 #define PNG_USER_TRANSFORM 0x100000
452 #define PNG_RGB_TO_GRAY_ERR 0x200000
453 #define PNG_RGB_TO_GRAY_WARN 0x400000
454 #define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
455 #define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */
456 #define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
457 #define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
458 #define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
459  /* 0x8000000 unused */
460  /* 0x10000000 unused */
461  /* 0x20000000 unused */
462  /* 0x40000000 unused */
463 /* Flags for png_create_struct */
464 #define PNG_STRUCT_PNG 0x0001
465 #define PNG_STRUCT_INFO 0x0002
466 
467 /* Scaling factor for filter heuristic weighting calculations */
468 #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
469 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
470 
471 /* Flags for the png_ptr->flags rather than declaring a byte for each one */
472 #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
473 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002
474 #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004
475 #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008
476 #define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010
477 #define PNG_FLAG_ZLIB_FINISHED 0x0020
478 #define PNG_FLAG_ROW_INIT 0x0040
479 #define PNG_FLAG_FILLER_AFTER 0x0080
480 #define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
481 #define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
482 #define PNG_FLAG_CRC_CRITICAL_USE 0x0400
483 #define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
484 #define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */
485 #define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */
486 #define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */
487 #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000
488 #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000
489 #define PNG_FLAG_LIBRARY_MISMATCH 0x20000
490 #define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000
491 #define PNG_FLAG_STRIP_ERROR_TEXT 0x80000
492 #define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000
493  /* 0x200000 unused */
494  /* 0x400000 unused */
495 #define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000 /* Added to libpng-1.4.0 */
496 #define PNG_FLAG_ZTXT_CUSTOM_STRATEGY 0x1000000 /* 5 lines added */
497 #define PNG_FLAG_ZTXT_CUSTOM_LEVEL 0x2000000 /* to libpng-1.5.4 */
498 #define PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL 0x4000000
499 #define PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS 0x8000000
500 #define PNG_FLAG_ZTXT_CUSTOM_METHOD 0x10000000
501  /* 0x20000000 unused */
502  /* 0x40000000 unused */
503 
504 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
505  PNG_FLAG_CRC_ANCILLARY_NOWARN)
506 
507 #define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
508  PNG_FLAG_CRC_CRITICAL_IGNORE)
509 
510 #define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
511  PNG_FLAG_CRC_CRITICAL_MASK)
512 
513 /* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
514  * can handle at once. This type need be no larger than 16 bits (so maximum of
515  * 65535), this define allows us to discover how big it is, but limited by the
516  * maximuum for png_size_t. The value can be overriden in a library build
517  * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
518  * lower value (e.g. 255 works). A lower value may help memory usage (slightly)
519  * and may even improve performance on some systems (and degrade it on others.)
520  */
521 #ifndef ZLIB_IO_MAX
522 # define ZLIB_IO_MAX ((uInt)-1)
523 #endif
524 
525 /* Save typing and make code easier to understand */
526 
527 #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
528  abs((int)((c1).green) - (int)((c2).green)) + \
529  abs((int)((c1).blue) - (int)((c2).blue)))
530 
531 /* Added to libpng-1.2.6 JB */
532 #define PNG_ROWBYTES(pixel_bits, width) \
533  ((pixel_bits) >= 8 ? \
534  ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
535  (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )
536 
537 /* PNG_OUT_OF_RANGE returns true if value is outside the range
538  * ideal-delta..ideal+delta. Each argument is evaluated twice.
539  * "ideal" and "delta" should be constants, normally simple
540  * integers, "value" a variable. Added to libpng-1.2.6 JB
541  */
542 #define PNG_OUT_OF_RANGE(value, ideal, delta) \
543  ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
544 
545 /* Conversions between fixed and floating point, only defined if
546  * required (to make sure the code doesn't accidentally use float
547  * when it is supposedly disabled.)
548  */
549 #ifdef PNG_FLOATING_POINT_SUPPORTED
550 /* The floating point conversion can't overflow, though it can and
551  * does lose accuracy relative to the original fixed point value.
552  * In practice this doesn't matter because png_fixed_point only
553  * stores numbers with very low precision. The png_ptr and s
554  * arguments are unused by default but are there in case error
555  * checking becomes a requirement.
556  */
557 #define png_float(png_ptr, fixed, s) (.00001 * (fixed))
558 
559 /* The fixed point conversion performs range checking and evaluates
560  * its argument multiple times, so must be used with care. The
561  * range checking uses the PNG specification values for a signed
562  * 32 bit fixed point value except that the values are deliberately
563  * rounded-to-zero to an integral value - 21474 (21474.83 is roughly
564  * (2^31-1) * 100000). 's' is a string that describes the value being
565  * converted.
566  *
567  * NOTE: this macro will raise a png_error if the range check fails,
568  * therefore it is normally only appropriate to use this on values
569  * that come from API calls or other sources where an out of range
570  * error indicates a programming error, not a data error!
571  *
572  * NOTE: by default this is off - the macro is not used - because the
573  * function call saves a lot of code.
574  */
575 #ifdef PNG_FIXED_POINT_MACRO_SUPPORTED
576 #define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\
577  ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0))
578 #else
580  png_const_charp text));
581 #endif
582 #endif
583 
584 /* Constants for known chunk types. If you need to add a chunk, define the name
585  * here. For historical reasons these constants have the form png_<name>; i.e.
586  * the prefix is lower case. Please use decimal values as the parameters to
587  * match the ISO PNG specification and to avoid relying on the C locale
588  * interpretation of character values.
589  *
590  * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values
591  * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string
592  * to be generated if required.
593  *
594  * PNG_32b correctly produces a value shifted by up to 24 bits, even on
595  * architectures where (int) is only 16 bits.
596  */
597 #define PNG_32b(b,s) ((png_uint_32)(b) << (s))
598 #define PNG_CHUNK(b1,b2,b3,b4) \
599  (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
600 
601 #define png_IHDR PNG_CHUNK( 73, 72, 68, 82)
602 #define png_IDAT PNG_CHUNK( 73, 68, 65, 84)
603 #define png_IEND PNG_CHUNK( 73, 69, 78, 68)
604 #define png_PLTE PNG_CHUNK( 80, 76, 84, 69)
605 #define png_bKGD PNG_CHUNK( 98, 75, 71, 68)
606 #define png_cHRM PNG_CHUNK( 99, 72, 82, 77)
607 #define png_gAMA PNG_CHUNK(103, 65, 77, 65)
608 #define png_hIST PNG_CHUNK(104, 73, 83, 84)
609 #define png_iCCP PNG_CHUNK(105, 67, 67, 80)
610 #define png_iTXt PNG_CHUNK(105, 84, 88, 116)
611 #define png_oFFs PNG_CHUNK(111, 70, 70, 115)
612 #define png_pCAL PNG_CHUNK(112, 67, 65, 76)
613 #define png_sCAL PNG_CHUNK(115, 67, 65, 76)
614 #define png_pHYs PNG_CHUNK(112, 72, 89, 115)
615 #define png_sBIT PNG_CHUNK(115, 66, 73, 84)
616 #define png_sPLT PNG_CHUNK(115, 80, 76, 84)
617 #define png_sRGB PNG_CHUNK(115, 82, 71, 66)
618 #define png_sTER PNG_CHUNK(115, 84, 69, 82)
619 #define png_tEXt PNG_CHUNK(116, 69, 88, 116)
620 #define png_tIME PNG_CHUNK(116, 73, 77, 69)
621 #define png_tRNS PNG_CHUNK(116, 82, 78, 83)
622 #define png_zTXt PNG_CHUNK(122, 84, 88, 116)
623 
624 /* The following will work on (signed char*) strings, whereas the get_uint_32
625  * macro will fail on top-bit-set values because of the sign extension.
626  */
627 #define PNG_CHUNK_FROM_STRING(s)\
628  PNG_CHUNK(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
629 
630 /* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
631  * signed and the argument is a (char[]) This macro will fail miserably on
632  * systems where (char) is more than 8 bits.
633  */
634 #define PNG_STRING_FROM_CHUNK(s,c)\
635  (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\
636  ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))
637 
638 /* Do the same but terminate with a null character. */
639 #define PNG_CSTRING_FROM_CHUNK(s,c)\
640  (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)
641 
642 /* Test on flag values as defined in the spec (section 5.4): */
643 #define PNG_CHUNK_ANCILLIARY(c) (1 & ((c) >> 29))
644 #define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLIARY(c))
645 #define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
646 #define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
647 #define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
648 
649 /* Gamma values (new at libpng-1.5.4): */
650 #define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */
651 #define PNG_GAMMA_MAC_INVERSE 65909
652 #define PNG_GAMMA_sRGB_INVERSE 45455
653 
654 
655 /* Inhibit C++ name-mangling for libpng functions but not for system calls. */
656 #ifdef __cplusplus
657 extern "C" {
658 #endif /* __cplusplus */
659 
660 /* These functions are used internally in the code. They generally
661  * shouldn't be used unless you are writing code to add or replace some
662  * functionality in libpng. More information about most functions can
663  * be found in the files where the functions are located.
664  */
665 
666 /* Check the user version string for compatibility, returns false if the version
667  * numbers aren't compatible.
668  */
670  png_const_charp user_png_ver);
671 
672 /* Allocate memory for an internal libpng struct */
673 PNG_EXTERN PNG_FUNCTION(png_voidp,png_create_struct,PNGARG((int type)),
674  PNG_ALLOCATED);
675 
676 /* Free memory from internal libpng struct */
677 PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
678 
679 PNG_EXTERN PNG_FUNCTION(png_voidp,png_create_struct_2,
680  PNGARG((int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)),
681  PNG_ALLOCATED);
683  png_free_ptr free_fn, png_voidp mem_ptr));
684 
685 /* Free any memory that info_ptr points to and reset struct. */
687  png_infop info_ptr));
688 
689 /* Function to allocate memory for zlib. PNGAPI is disallowed. */
690 PNG_EXTERN PNG_FUNCTION(voidpf,png_zalloc,PNGARG((voidpf png_ptr, uInt items,
692 
693 /* Function to free memory for zlib. PNGAPI is disallowed. */
694 PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
695 
696 /* Next four functions are used internally as callbacks. PNGCBAPI is required
697  * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to
698  * PNGCBAPI at 1.5.0
699  */
700 
703 
704 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
706  png_bytep buffer, png_size_t length));
707 #endif
708 
710  png_bytep data, png_size_t length));
711 
712 #ifdef PNG_WRITE_FLUSH_SUPPORTED
713 # ifdef PNG_STDIO_SUPPORTED
715 # endif
716 #endif
717 
718 /* Reset the CRC variable */
720 
721 /* Write the "data" buffer to whatever output you are using */
723  png_const_bytep data, png_size_t length));
724 
725 /* Read and check the PNG file signature */
726 PNG_EXTERN void png_read_sig PNGARG((png_structp png_ptr, png_infop info_ptr));
727 
728 /* Read the chunk header (length + type name) */
730 
731 /* Read data from whatever input you are using into the "data" buffer */
733  png_size_t length));
734 
735 /* Read bytes into buf, and update png_ptr->crc */
737  png_size_t length));
738 
739 /* Decompress data in a chunk that uses compression */
740 #if defined(PNG_READ_COMPRESSED_TEXT_SUPPORTED)
742  int comp_type, png_size_t chunklength, png_size_t prefix_length,
744 #endif
745 
746 /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
748 
749 /* Read the CRC from the file and compare it to the libpng calculated CRC */
751 
752 /* Calculate the CRC over a section of data. Note that we are only
753  * passing a maximum of 64K on systems that have this as a memory limit,
754  * since this is the maximum buffer size we can specify.
755  */
757  png_const_bytep ptr, png_size_t length));
758 
759 #ifdef PNG_WRITE_FLUSH_SUPPORTED
760 PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
761 #endif
762 
763 /* Write various chunks */
764 
765 /* Write the IHDR chunk, and update the png_struct with the necessary
766  * information.
767  */
770  int bit_depth, int color_type, int compression_method, int filter_method,
771  int interlace_method));
772 
774  png_const_colorp palette, png_uint_32 num_pal));
775 
777  png_size_t length));
778 
780 
781 #ifdef PNG_WRITE_gAMA_SUPPORTED
782 # ifdef PNG_FLOATING_POINT_SUPPORTED
783 PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
784 # endif
785 # ifdef PNG_FIXED_POINT_SUPPORTED
787  png_fixed_point file_gamma));
788 # endif
789 #endif
790 
791 #ifdef PNG_WRITE_sBIT_SUPPORTED
793  png_const_color_8p sbit, int color_type));
794 #endif
795 
796 #ifdef PNG_WRITE_cHRM_SUPPORTED
797 # ifdef PNG_FLOATING_POINT_SUPPORTED
798 PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
799  double white_x, double white_y,
800  double red_x, double red_y, double green_x, double green_y,
801  double blue_x, double blue_y));
802 # endif
804  png_fixed_point int_white_x, png_fixed_point int_white_y,
805  png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
806  int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
807  png_fixed_point int_blue_y));
808 #endif
809 
810 #ifdef PNG_WRITE_sRGB_SUPPORTED
812  int intent));
813 #endif
814 
815 #ifdef PNG_WRITE_iCCP_SUPPORTED
818  png_const_charp profile, int proflen));
819  /* Note to maintainer: profile should be png_bytep */
820 #endif
821 
822 #ifdef PNG_WRITE_sPLT_SUPPORTED
824  png_const_sPLT_tp palette));
825 #endif
826 
827 #ifdef PNG_WRITE_tRNS_SUPPORTED
829  png_const_bytep trans, png_const_color_16p values, int number,
830  int color_type));
831 #endif
832 
833 #ifdef PNG_WRITE_bKGD_SUPPORTED
835  png_const_color_16p values, int color_type));
836 #endif
837 
838 #ifdef PNG_WRITE_hIST_SUPPORTED
840  png_const_uint_16p hist, int num_hist));
841 #endif
842 
843 /* Chunks that have keywords */
844 #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
845  defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
847  png_const_charp key, png_charpp new_key));
848 #endif
849 
850 #ifdef PNG_WRITE_tEXt_SUPPORTED
852  png_const_charp text, png_size_t text_len));
853 #endif
854 
855 #ifdef PNG_WRITE_zTXt_SUPPORTED
857  png_const_charp text, png_size_t text_len, int compression));
858 #endif
859 
860 #ifdef PNG_WRITE_iTXt_SUPPORTED
862  int compression, png_const_charp key, png_const_charp lang,
863  png_const_charp lang_key, png_const_charp text));
864 #endif
865 
866 #ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
868  png_infop info_ptr, png_const_textp text_ptr, int num_text));
869 #endif
870 
871 #ifdef PNG_WRITE_oFFs_SUPPORTED
873  png_int_32 x_offset, png_int_32 y_offset, int unit_type));
874 #endif
875 
876 #ifdef PNG_WRITE_pCAL_SUPPORTED
877 PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
878  png_int_32 X0, png_int_32 X1, int type, int nparams,
880 #endif
881 
882 #ifdef PNG_WRITE_pHYs_SUPPORTED
884  png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
885  int unit_type));
886 #endif
887 
888 #ifdef PNG_WRITE_tIME_SUPPORTED
890  png_const_timep mod_time));
891 #endif
892 
893 #ifdef PNG_WRITE_sCAL_SUPPORTED
895  int unit, png_const_charp width, png_const_charp height));
896 #endif
897 
898 /* Called when finished processing a row of data */
900 
901 /* Internal use only. Called before first row of data */
903 
904 /* Combine a row of data, dealing with alpha, etc. if requested. 'row' is an
905  * array of png_ptr->width pixels. If the image is not interlaced or this
906  * is the final pass this just does a png_memcpy, otherwise the "display" flag
907  * is used to determine whether to copy pixels that are not in the current pass.
908  *
909  * Because 'png_do_read_interlace' (below) replicates pixels this allows this
910  * function to achieve the documented 'blocky' appearance during interlaced read
911  * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row'
912  * are not changed if they are not in the current pass, when display is 0.
913  *
914  * 'display' must be 0 or 1, otherwise the memcpy will be done regardless.
915  *
916  * The API always reads from the png_struct row buffer and always assumes that
917  * it is full width (png_do_read_interlace has already been called.)
918  *
919  * This function is only ever used to write to row buffers provided by the
920  * caller of the relevant libpng API and the row must have already been
921  * transformed by the read transformations.
922  *
923  * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed
924  * bitmasks for use within the code, otherwise runtime generated masks are used.
925  * The default is compile time masks.
926  */
927 #ifndef PNG_USE_COMPILE_TIME_MASKS
928 # define PNG_USE_COMPILE_TIME_MASKS 1
929 #endif
931  int display));
932 
933 #ifdef PNG_READ_INTERLACING_SUPPORTED
934 /* Expand an interlaced row: the 'row_info' describes the pass data that has
935  * been read in and must correspond to the pixels in 'row', the pixels are
936  * expanded (moved apart) in 'row' to match the final layout, when doing this
937  * the pixels are *replicated* to the intervening space. This is essential for
938  * the correct operation of png_combine_row, above.
939  */
941  png_bytep row, int pass, png_uint_32 transformations));
942 #endif
943 
944 /* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */
945 
946 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
947 /* Grab pixels out of a row for an interlaced pass */
949  png_bytep row, int pass));
950 #endif
951 
952 /* Unfilter a row: check the filter value before calling this, there is no point
953  * calling it for PNG_FILTER_VALUE_NONE.
954  */
956  png_bytep row, png_const_bytep prev_row, int filter));
957 
958 PNG_EXTERN void png_read_filter_row_up_neon PNGARG((png_row_infop row_info,
959  png_bytep row, png_const_bytep prev_row));
960 PNG_EXTERN void png_read_filter_row_sub3_neon PNGARG((png_row_infop row_info,
961  png_bytep row, png_const_bytep prev_row));
962 PNG_EXTERN void png_read_filter_row_sub4_neon PNGARG((png_row_infop row_info,
963  png_bytep row, png_const_bytep prev_row));
964 PNG_EXTERN void png_read_filter_row_avg3_neon PNGARG((png_row_infop row_info,
965  png_bytep row, png_const_bytep prev_row));
966 PNG_EXTERN void png_read_filter_row_avg4_neon PNGARG((png_row_infop row_info,
967  png_bytep row, png_const_bytep prev_row));
968 PNG_EXTERN void png_read_filter_row_paeth3_neon PNGARG((png_row_infop row_info,
969  png_bytep row, png_const_bytep prev_row));
970 PNG_EXTERN void png_read_filter_row_paeth4_neon PNGARG((png_row_infop row_info,
971  png_bytep row, png_const_bytep prev_row));
972 
973 /* Choose the best filter to use and filter the row data */
975  png_row_infop row_info));
976 
977 /* Finish a row while reading, dealing with interlacing passes, etc. */
979 
980 /* Initialize the row buffers, etc. */
982 
983 #ifdef PNG_READ_TRANSFORMS_SUPPORTED
984 /* Optional call to update the users info structure */
986  png_infop info_ptr));
987 #endif
988 
989 /* These are the functions that do the transformations */
990 #ifdef PNG_READ_FILLER_SUPPORTED
993 #endif
994 
995 #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
997  png_bytep row));
998 #endif
999 
1000 #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
1002  png_bytep row));
1003 #endif
1004 
1005 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
1007  png_bytep row));
1008 #endif
1009 
1010 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
1012  png_bytep row));
1013 #endif
1014 
1015 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
1016  defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
1018  png_bytep row, int at_start));
1019 #endif
1020 
1021 #ifdef PNG_16BIT_SUPPORTED
1022 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
1024  png_bytep row));
1025 #endif
1026 #endif
1027 
1028 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
1029  defined(PNG_WRITE_PACKSWAP_SUPPORTED)
1031  png_bytep row));
1032 #endif
1033 
1034 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1036  png_row_infop row_info, png_bytep row));
1037 #endif
1038 
1039 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
1041  png_bytep row));
1042 #endif
1043 
1044 #ifdef PNG_READ_PACK_SUPPORTED
1046  png_bytep row));
1047 #endif
1048 
1049 #ifdef PNG_READ_SHIFT_SUPPORTED
1051  png_bytep row, png_const_color_8p sig_bits));
1052 #endif
1053 
1054 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
1056  png_bytep row));
1057 #endif
1058 
1059 #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
1061  png_bytep row));
1062 #endif
1063 
1064 #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
1066  png_bytep row));
1067 #endif
1068 
1069 #ifdef PNG_READ_QUANTIZE_SUPPORTED
1071  png_bytep row, png_const_bytep palette_lookup,
1072  png_const_bytep quantize_lookup));
1073 
1074 # ifdef PNG_CORRECT_PALETTE_SUPPORTED
1075 PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
1076  png_colorp palette, int num_palette));
1077 # endif
1078 #endif
1079 
1080 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
1081 PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info,
1082  png_bytep row));
1083 #endif
1084 
1085 #ifdef PNG_WRITE_PACK_SUPPORTED
1087  png_bytep row, png_uint_32 bit_depth));
1088 #endif
1089 
1090 #ifdef PNG_WRITE_SHIFT_SUPPORTED
1092  png_bytep row, png_const_color_8p bit_depth));
1093 #endif
1094 
1095 #if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
1096  defined(PNG_READ_ALPHA_MODE_SUPPORTED)
1098  png_bytep row, png_structp png_ptr));
1099 #endif
1100 
1101 #ifdef PNG_READ_GAMMA_SUPPORTED
1103  png_bytep row, png_structp png_ptr));
1104 #endif
1105 
1106 #ifdef PNG_READ_ALPHA_MODE_SUPPORTED
1108  png_bytep row, png_structp png_ptr));
1109 #endif
1110 
1111 #ifdef PNG_READ_EXPAND_SUPPORTED
1114  int num_trans));
1116  png_bytep row, png_const_color_16p trans_color));
1117 #endif
1118 
1119 #ifdef PNG_READ_EXPAND_16_SUPPORTED
1121  png_bytep row));
1122 #endif
1123 
1124 /* The following decodes the appropriate chunks, and does error correction,
1125  * then calls the appropriate callback for the chunk if it is valid.
1126  */
1127 
1128 /* Decode the IHDR chunk */
1129 PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
1130  png_uint_32 length));
1131 PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
1132  png_uint_32 length));
1133 PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
1134  png_uint_32 length));
1135 
1136 #ifdef PNG_READ_bKGD_SUPPORTED
1137 PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
1138  png_uint_32 length));
1139 #endif
1140 
1141 #ifdef PNG_READ_cHRM_SUPPORTED
1142 PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
1143  png_uint_32 length));
1144 #endif
1145 
1146 #ifdef PNG_READ_gAMA_SUPPORTED
1147 PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
1148  png_uint_32 length));
1149 #endif
1150 
1151 #ifdef PNG_READ_hIST_SUPPORTED
1152 PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
1153  png_uint_32 length));
1154 #endif
1155 
1156 #ifdef PNG_READ_iCCP_SUPPORTED
1157 PNG_EXTERN void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
1158  png_uint_32 length));
1159 #endif /* PNG_READ_iCCP_SUPPORTED */
1160 
1161 #ifdef PNG_READ_iTXt_SUPPORTED
1162 PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
1163  png_uint_32 length));
1164 #endif
1165 
1166 #ifdef PNG_READ_oFFs_SUPPORTED
1167 PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
1168  png_uint_32 length));
1169 #endif
1170 
1171 #ifdef PNG_READ_pCAL_SUPPORTED
1172 PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
1173  png_uint_32 length));
1174 #endif
1175 
1176 #ifdef PNG_READ_pHYs_SUPPORTED
1177 PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
1178  png_uint_32 length));
1179 #endif
1180 
1181 #ifdef PNG_READ_sBIT_SUPPORTED
1182 PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
1183  png_uint_32 length));
1184 #endif
1185 
1186 #ifdef PNG_READ_sCAL_SUPPORTED
1187 PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
1188  png_uint_32 length));
1189 #endif
1190 
1191 #ifdef PNG_READ_sPLT_SUPPORTED
1192 PNG_EXTERN void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
1193  png_uint_32 length));
1194 #endif /* PNG_READ_sPLT_SUPPORTED */
1195 
1196 #ifdef PNG_READ_sRGB_SUPPORTED
1197 PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
1198  png_uint_32 length));
1199 #endif
1200 
1201 #ifdef PNG_READ_tEXt_SUPPORTED
1202 PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
1203  png_uint_32 length));
1204 #endif
1205 
1206 #ifdef PNG_READ_tIME_SUPPORTED
1207 PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
1208  png_uint_32 length));
1209 #endif
1210 
1211 #ifdef PNG_READ_tRNS_SUPPORTED
1212 PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
1213  png_uint_32 length));
1214 #endif
1215 
1216 #ifdef PNG_READ_zTXt_SUPPORTED
1217 PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
1218  png_uint_32 length));
1219 #endif
1220 
1221 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1223  png_infop info_ptr, png_uint_32 length));
1224 #endif
1225 
1227  png_uint_32 chunk_name));
1228 
1229 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
1230 /* Exactly as png_handle_as_unknown() except that the argument is a 32-bit chunk
1231  * name, not a string.
1232  */
1234  png_uint_32 chunk_name));
1235 #endif
1236 
1237 /* Handle the transformations for reading and writing */
1238 #ifdef PNG_READ_TRANSFORMS_SUPPORTED
1240  png_row_infop row_info));
1241 #endif
1242 #ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
1244  png_row_infop row_info));
1245 #endif
1246 
1247 #ifdef PNG_READ_TRANSFORMS_SUPPORTED
1249 #endif
1250 
1251 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
1253  png_infop info_ptr));
1255  png_infop info_ptr));
1256 PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
1258  png_uint_32 length));
1262  png_bytep buffer, png_size_t buffer_length));
1265  png_bytep buffer, png_size_t buffer_length));
1268  png_infop info_ptr, png_uint_32 length));
1270  png_infop info_ptr));
1272  png_infop info_ptr));
1274 PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
1275  png_infop info_ptr));
1277  png_infop info_ptr));
1279 # ifdef PNG_READ_tEXt_SUPPORTED
1281  png_infop info_ptr, png_uint_32 length));
1283  png_infop info_ptr));
1284 # endif
1285 # ifdef PNG_READ_zTXt_SUPPORTED
1287  png_infop info_ptr, png_uint_32 length));
1289  png_infop info_ptr));
1290 # endif
1291 # ifdef PNG_READ_iTXt_SUPPORTED
1293  png_infop info_ptr, png_uint_32 length));
1295  png_infop info_ptr));
1296 # endif
1297 
1298 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
1299 
1300 #ifdef PNG_MNG_FEATURES_SUPPORTED
1302  png_bytep row));
1304  png_bytep row));
1305 #endif
1306 
1307 /* Added at libpng version 1.4.0 */
1308 #ifdef PNG_CHECK_cHRM_SUPPORTED
1310  png_fixed_point int_white_x, png_fixed_point int_white_y,
1311  png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
1312  int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
1313  png_fixed_point int_blue_y));
1314 #endif
1315 
1316 #ifdef PNG_CHECK_cHRM_SUPPORTED
1317 /* Added at libpng version 1.2.34 and 1.4.0 */
1318 /* Currently only used by png_check_cHRM_fixed */
1319 PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
1320  unsigned long *hi_product, unsigned long *lo_product));
1321 #endif
1322 
1323 #ifdef PNG_cHRM_SUPPORTED
1324 /* Added at libpng version 1.5.5 */
1325 typedef struct png_xy
1326 {
1331 } png_xy;
1332 
1333 typedef struct png_XYZ
1334 {
1338 } png_XYZ;
1339 
1340 /* The conversion APIs return 0 on success, non-zero on a parameter error. They
1341  * allow conversion between the above representations of a color encoding. When
1342  * converting from XYZ end points to chromaticities the absolute magnitude of
1343  * the end points is lost, when converting back the sum of the Y values of the
1344  * three end points will be 1.0
1345  */
1349  png_XYZ *XYZ, png_xy xy));
1350 #endif
1351 
1352 /* Added at libpng version 1.4.0 */
1354  png_uint_32 width, png_uint_32 height, int bit_depth,
1355  int color_type, int interlace_type, int compression_type,
1356  int filter_type));
1357 
1358 /* Free all memory used by the read (old method - NOT DLL EXPORTED) */
1360  png_infop info_ptr, png_infop end_info_ptr));
1361 
1362 /* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
1364 
1365 #ifdef USE_FAR_KEYWORD /* memory model conversion function */
1366 PNG_EXTERN void *png_far_to_near PNGARG((png_structp png_ptr, png_voidp ptr,
1367  int check));
1368 #endif /* USE_FAR_KEYWORD */
1369 
1370 #if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
1371 PNG_EXTERN PNG_FUNCTION(void, png_fixed_error, (png_structp png_ptr,
1373 #endif
1374 
1375 /* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite
1376  * the end. Always leaves the buffer nul terminated. Never errors out (and
1377  * there is no error code.)
1378  */
1379 PNG_EXTERN size_t png_safecat(png_charp buffer, size_t bufsize, size_t pos,
1380  png_const_charp string);
1381 
1382 /* Various internal functions to handle formatted warning messages, currently
1383  * only implemented for warnings.
1384  */
1385 #if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)
1386 /* Utility to dump an unsigned value into a buffer, given a start pointer and
1387  * and end pointer (which should point just *beyond* the end of the buffer!)
1388  * Returns the pointer to the start of the formatted string. This utility only
1389  * does unsigned values.
1390  */
1392  int format, png_alloc_size_t number);
1393 
1394 /* Convenience macro that takes an array: */
1395 #define PNG_FORMAT_NUMBER(buffer,format,number) \
1396  png_format_number(buffer, buffer + (sizeof buffer), format, number)
1397 
1398 /* Suggested size for a number buffer (enough for 64 bits and a sign!) */
1399 #define PNG_NUMBER_BUFFER_SIZE 24
1400 
1401 /* These are the integer formats currently supported, the name is formed from
1402  * the standard printf(3) format string.
1403  */
1404 #define PNG_NUMBER_FORMAT_u 1 /* chose unsigned API! */
1405 #define PNG_NUMBER_FORMAT_02u 2
1406 #define PNG_NUMBER_FORMAT_d 1 /* chose signed API! */
1407 #define PNG_NUMBER_FORMAT_02d 2
1408 #define PNG_NUMBER_FORMAT_x 3
1409 #define PNG_NUMBER_FORMAT_02x 4
1410 #define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */
1411 #endif
1412 
1413 #ifdef PNG_WARNINGS_SUPPORTED
1414 /* New defines and members adding in libpng-1.5.4 */
1415 # define PNG_WARNING_PARAMETER_SIZE 32
1416 # define PNG_WARNING_PARAMETER_COUNT 8
1417 
1418 /* An l-value of this type has to be passed to the APIs below to cache the
1419  * values of the parameters to a formatted warning message.
1420  */
1423 
1424 PNG_EXTERN void png_warning_parameter(png_warning_parameters p, int number,
1425  png_const_charp string);
1426  /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,
1427  * including the trailing '\0'.
1428  */
1429 PNG_EXTERN void png_warning_parameter_unsigned(png_warning_parameters p,
1430  int number, int format, png_alloc_size_t value);
1431  /* Use png_alloc_size_t because it is an unsigned type as big as any we
1432  * need to output. Use the following for a signed value.
1433  */
1434 PNG_EXTERN void png_warning_parameter_signed(png_warning_parameters p,
1435  int number, int format, png_int_32 value);
1436 
1438  png_warning_parameters p, png_const_charp message);
1439  /* 'message' follows the X/Open approach of using @1, @2 to insert
1440  * parameters previously supplied using the above functions. Errors in
1441  * specifying the paramters will simple result in garbage substitutions.
1442  */
1443 #endif
1444 
1445 /* ASCII to FP interfaces, currently only implemented if sCAL
1446  * support is required.
1447  */
1448 #if defined(PNG_READ_sCAL_SUPPORTED)
1449 /* MAX_DIGITS is actually the maximum number of characters in an sCAL
1450  * width or height, derived from the precision (number of significant
1451  * digits - a build time settable option) and assumpitions about the
1452  * maximum ridiculous exponent.
1453  */
1454 #define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)
1455 
1456 #ifdef PNG_FLOATING_POINT_SUPPORTED
1458  png_size_t size, double fp, unsigned int precision));
1459 #endif /* FLOATING_POINT */
1460 
1461 #ifdef PNG_FIXED_POINT_SUPPORTED
1463  png_charp ascii, png_size_t size, png_fixed_point fp));
1464 #endif /* FIXED_POINT */
1465 #endif /* READ_sCAL */
1466 
1467 #if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)
1468 /* An internal API to validate the format of a floating point number.
1469  * The result is the index of the next character. If the number is
1470  * not valid it will be the index of a character in the supposed number.
1471  *
1472  * The format of a number is defined in the PNG extensions specification
1473  * and this API is strictly conformant to that spec, not anyone elses!
1474  *
1475  * The format as a regular expression is:
1476  *
1477  * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?
1478  *
1479  * or:
1480  *
1481  * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?
1482  *
1483  * The complexity is that either integer or fraction must be present and the
1484  * fraction is permitted to have no digits only if the integer is present.
1485  *
1486  * NOTE: The dangling E problem.
1487  * There is a PNG valid floating point number in the following:
1488  *
1489  * PNG floating point numb1.ers are not greedy.
1490  *
1491  * Working this out requires *TWO* character lookahead (because of the
1492  * sign), the parser does not do this - it will fail at the 'r' - this
1493  * doesn't matter for PNG sCAL chunk values, but it requires more care
1494  * if the value were ever to be embedded in something more complex. Use
1495  * ANSI-C strtod if you need the lookahead.
1496  */
1497 /* State table for the parser. */
1498 #define PNG_FP_INTEGER 0 /* before or in integer */
1499 #define PNG_FP_FRACTION 1 /* before or in fraction */
1500 #define PNG_FP_EXPONENT 2 /* before or in exponent */
1501 #define PNG_FP_STATE 3 /* mask for the above */
1502 #define PNG_FP_SAW_SIGN 4 /* Saw +/- in current state */
1503 #define PNG_FP_SAW_DIGIT 8 /* Saw a digit in current state */
1504 #define PNG_FP_SAW_DOT 16 /* Saw a dot in current state */
1505 #define PNG_FP_SAW_E 32 /* Saw an E (or e) in current state */
1506 #define PNG_FP_SAW_ANY 60 /* Saw any of the above 4 */
1507 
1508 /* These three values don't affect the parser. They are set but not used.
1509  */
1510 #define PNG_FP_WAS_VALID 64 /* Preceding substring is a valid fp number */
1511 #define PNG_FP_NEGATIVE 128 /* A negative number, including "-0" */
1512 #define PNG_FP_NONZERO 256 /* A non-zero value */
1513 #define PNG_FP_STICKY 448 /* The above three flags */
1514 
1515 /* This is available for the caller to store in 'state' if required. Do not
1516  * call the parser after setting it (the parser sometimes clears it.)
1517  */
1518 #define PNG_FP_INVALID 512 /* Available for callers as a distinct value */
1519 
1520 /* Result codes for the parser (boolean - true meants ok, false means
1521  * not ok yet.)
1522  */
1523 #define PNG_FP_MAYBE 0 /* The number may be valid in the future */
1524 #define PNG_FP_OK 1 /* The number is valid */
1525 
1526 /* Tests on the sticky non-zero and negative flags. To pass these checks
1527  * the state must also indicate that the whole number is valid - this is
1528  * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this
1529  * is equivalent to PNG_FP_OK above.)
1530  */
1531 #define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)
1532  /* NZ_MASK: the string is valid and a non-zero negative value */
1533 #define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)
1534  /* Z MASK: the string is valid and a non-zero value. */
1535  /* PNG_FP_SAW_DIGIT: the string is valid. */
1536 #define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)
1537 #define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)
1538 #define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)
1539 
1540 /* The actual parser. This can be called repeatedly, it updates
1541  * the index into the string and the state variable (which must
1542  * be initialzed to 0). It returns a result code, as above. There
1543  * is no point calling the parser any more if it fails to advance to
1544  * the end of the string - it is stuck on an invalid character (or
1545  * terminated by '\0').
1546  *
1547  * Note that the pointer will consume an E or even an E+ then leave
1548  * a 'maybe' state even though a preceding integer.fraction is valid.
1549  * The PNG_FP_WAS_VALID flag indicates that a preceding substring was
1550  * a valid number. It's possible to recover from this by calling
1551  * the parser again (from the start, with state 0) but with a string
1552  * that omits the last character (i.e. set the size to the index of
1553  * the problem character.) This has not been tested within libpng.
1554  */
1556  png_size_t size, int *statep, png_size_tp whereami));
1557 
1558 /* This is the same but it checks a complete string and returns true
1559  * only if it just contains a floating point number. As of 1.5.4 this
1560  * function also returns the state at the end of parsing the number if
1561  * it was valid (otherwise it returns 0.) This can be used for testing
1562  * for negative or zero values using the sticky flag.
1563  */
1565  png_size_t size));
1566 #endif /* pCAL || sCAL */
1567 
1568 #if defined(PNG_READ_GAMMA_SUPPORTED) ||\
1569  defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
1570 /* Added at libpng version 1.5.0 */
1571 /* This is a utility to provide a*times/div (rounded) and indicate
1572  * if there is an overflow. The result is a boolean - false (0)
1573  * for overflow, true (1) if no overflow, in which case *res
1574  * holds the result.
1575  */
1577  png_int_32 multiplied_by, png_int_32 divided_by));
1578 #endif
1579 
1580 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
1581 /* Same deal, but issue a warning on overflow and return 0. */
1583  png_fixed_point a, png_int_32 multiplied_by, png_int_32 divided_by));
1584 #endif
1585 
1586 #ifdef PNG_READ_GAMMA_SUPPORTED
1587 /* Calculate a reciprocal - used for gamma values. This returns
1588  * 0 if the argument is 0 in order to maintain an undefined value,
1589  * there are no warnings.
1590  */
1592 
1593 /* The same but gives a reciprocal of the product of two fixed point
1594  * values. Accuracy is suitable for gamma calculations but this is
1595  * not exact - use png_muldiv for that.
1596  */
1598  png_fixed_point b));
1599 #endif
1600 
1601 #ifdef PNG_READ_GAMMA_SUPPORTED
1602 /* Internal fixed point gamma correction. These APIs are called as
1603  * required to convert single values - they don't need to be fast,
1604  * they are not used when processing image pixel values.
1605  *
1606  * While the input is an 'unsigned' value it must actually be the
1607  * correct bit value - 0..255 or 0..65535 as required.
1608  */
1610  unsigned int value, png_fixed_point gamma_value));
1613  png_fixed_point gamma_value));
1615  png_fixed_point gamma_value));
1618  int bit_depth));
1619 #endif
1620 
1621 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
1622 
1623 #include "pngdebug.h"
1624 
1625 #ifdef __cplusplus
1626 }
1627 #endif
1628 
1629 #endif /* PNGPRIV_H */
void png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:4963
void png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
Definition: pngwtran.c:572
png_size_t data_length
Definition: pngrutil.c:1244
void png_push_read_IDAT(png_structp png_ptr)
Definition: pngpread.c:767
void PNGCBAPI png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
Definition: pngpread.c:658
void png_do_packswap(png_row_infop row_info, png_bytep row)
Definition: pngtrans.c:396
png_fixed_point greenx
Definition: pngpriv.h:1328
void png_read_filter_row(png_structp pp, png_row_infop row_info, png_bytep row, png_const_bytep prev_row, int filter)
Definition: pngrutil.c:3743
void png_write_start_row(png_structp png_ptr)
Definition: pngwutil.c:2003
png_fixed_point whitex
Definition: pngpriv.h:1330
void png_zfree(voidpf png_ptr, voidpf ptr)
Definition: png.c:99
png_charp profile
Definition: pngrutil.c:1240
GLfloat GLfloat v1
Definition: glew.h:1838
void png_push_have_row(png_structp png_ptr, png_bytep row)
Definition: pngpread.c:1796
png_fixed_point greenY
Definition: pngpriv.h:1336
void png_write_sPLT(png_structp png_ptr, png_const_sPLT_tp spalette)
Definition: pngwutil.c:1179
void png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:746
png_fixed_point redx
Definition: pngpriv.h:1327
void png_write_PLTE(png_structp png_ptr, png_const_colorp palette, png_uint_32 num_pal)
Definition: pngwutil.c:895
#define PNG_NORETURN
Definition: pngconf.h:392
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
PNG_CONST png_uint_16p FAR * png_const_uint_16pp
Definition: pngpriv.h:139
void png_do_invert(png_row_infop row_info, png_bytep row)
Definition: pngtrans.c:210
png_fixed_point bluey
Definition: pngpriv.h:1329
int png_user_version_check(png_structp png_ptr, png_const_charp user_png_ver)
Definition: png.c:172
PNG_CONST png_time FAR * png_const_timep
Definition: png.h:683
void png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, double fp, unsigned int precision)
Definition: png.c:1504
GLsizei GLenum GLuint GLuint GLsizei GLchar * message
Definition: glew.h:2540
void png_write_sBIT(png_structp png_ptr, png_const_color_8p sbit, int color_type)
Definition: pngwutil.c:1263
void png_do_read_filler(png_row_infop row_info, png_bytep row, png_uint_32 filler, png_uint_32 flags)
Definition: pngrtran.c:2891
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: gl2ext.h:961
png_size_t FAR * png_size_tp
Definition: pngconf.h:540
void png_do_unshift(png_row_infop row_info, png_bytep row, png_const_color_8p sig_bits)
Definition: pngrtran.c:2467
void png_warning_parameter(png_warning_parameters p, int number, png_const_charp string)
Definition: pngerror.c:244
char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][PNG_WARNING_PARAMETER_SIZE]
Definition: pngpriv.h:1422
void png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
Definition: pngpread.c:176
GLuint start
Definition: glew.h:1239
png_fixed_point greenX
Definition: pngpriv.h:1336
void png_do_gamma(png_row_infop row_info, png_bytep row, png_structp png_ptr)
Definition: pngrtran.c:4189
void png_push_have_end(png_structp png_ptr, png_infop info_ptr)
Definition: pngpread.c:1789
void png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
Definition: pngtrans.c:436
void png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
Definition: pngwutil.c:1061
#define PNGCBAPI
Definition: pngconf.h:257
char FAR * png_charp
Definition: pngconf.h:536
void png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
Definition: pngwtran.c:101
void png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:523
png_fixed_point png_fixed(png_structp png_ptr, double fp, png_const_charp text)
Definition: png.c:1891
void png_check_chunk_name(png_structp png_ptr, png_uint_32 chunk_name)
Definition: pngrutil.c:2759
png_fixed_point blueZ
Definition: pngpriv.h:1337
void png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
Definition: pngpread.c:1597
png_fixed_point FAR * png_fixed_point_p
Definition: pngconf.h:538
png_sPLT_entryp pp
Definition: pngrutil.c:1375
void png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2789
int png_int_32
Definition: pngconf.h:442
png_fixed_point png_reciprocal(png_fixed_point a)
Definition: png.c:2046
void png_write_zTXt(png_structp png_ptr, png_const_charp key, png_const_charp text, png_size_t text_len, int compression)
Definition: pngwutil.c:1687
int png_XYZ_from_xy_checked(png_structp png_ptr, png_XYZ *XYZ, png_xy xy)
Definition: png.c:1139
EGLSurface EGLint EGLint EGLint EGLint height
Definition: eglext.h:293
unsigned int png_uint_32
Definition: pngconf.h:441
void png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2606
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8736
PNG_CONST png_color FAR * png_const_colorp
Definition: png.h:558
EGLImageKHR EGLint * name
Definition: eglext.h:284
png_size_t prefix_length
Definition: pngrutil.c:1244
PNG_CONST char FAR * png_const_charp
Definition: pngconf.h:537
void png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, int unit_type)
Definition: pngwutil.c:1842
png_charp png_format_number(png_const_charp start, png_charp end, int format, png_alloc_size_t number)
Definition: pngerror.c:131
Byte FAR * voidpf
Definition: zconf.h:239
void png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
Definition: pngrutil.c:189
void png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
Definition: pngwutil.c:965
void PNGCBAPI png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
Definition: pngwio.c:51
char * display
Definition: visualinfo.c:85
void png_do_chop(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2667
void png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
Definition: pngread.c:1013
void png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:2062
PNG_CONST png_color_8 FAR * png_const_color_8p
Definition: png.h:582
#define PNG_ALLOCATED
Definition: pngconf.h:395
int png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:3217
#define PNG_WARNING_PARAMETER_COUNT
Definition: pngpriv.h:1416
unsigned int uInt
Definition: zconf.h:221
void png_do_quantize(png_row_infop row_info, png_bytep row, png_const_bytep palette_lookup, png_const_bytep quantize_lookup)
Definition: pngrtran.c:4867
png_fixed_point redY
Definition: pngpriv.h:1335
void png_read_finish_row(png_structp png_ptr)
Definition: pngrutil.c:3754
void png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
Definition: pngpread.c:209
void png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)
Definition: pngwutil.c:1862
size_t png_safecat(png_charp buffer, size_t bufsize, size_t pos, png_const_charp string)
Definition: pngerror.c:110
void png_flush(png_structp png_ptr)
Definition: pngwio.c:129
void png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:2449
png_size_t png_alloc_size_t
Definition: pngconf.h:591
void png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
Definition: pngwio.c:33
GLenum GLvoid ** params
Definition: gl2ext.h:806
#define PNGARG(arglist)
Definition: pngconf.h:91
void png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, int unit_type)
Definition: pngwutil.c:1952
void png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:2319
void png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:3078
void png_init_read_transformations(png_structp png_ptr)
Definition: pngrtran.c:1245
void png_do_read_transformations(png_structp png_ptr, png_row_infop row_info)
Definition: pngrtran.c:2077
void png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:922
EGLContext EGLenum EGLClientBuffer buffer
Definition: eglext.h:87
int png_xy_from_XYZ(png_xy *xy, png_XYZ XYZ)
Definition: png.c:854
png_fixed_point bluex
Definition: pngpriv.h:1329
void png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:1767
void png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngpread.c:1364
void png_push_save_buffer(png_structp png_ptr)
Definition: pngpread.c:701
png_fixed_point blueX
Definition: pngpriv.h:1337
void png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
Definition: pngrtran.c:1877
GLenum GLenum GLvoid * row
Definition: glew.h:4447
void png_check_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type)
Definition: png.c:1169
png_struct FAR * png_structp
Definition: png.h:849
void png_read_start_row(png_structp png_ptr)
Definition: pngrutil.c:3886
void png_write_tIME(png_structp png_ptr, png_const_timep mod_time)
Definition: pngwutil.c:1976
struct png_XYZ png_XYZ
void png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y)
Definition: pngwutil.c:1322
void PNGCBAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
Definition: pngrio.c:51
void png_write_tEXt(png_structp png_ptr, png_const_charp key, png_const_charp text, png_size_t text_len)
Definition: pngwutil.c:1646
void png_info_destroy(png_structp png_ptr, png_infop info_ptr)
Definition: png.c:536
void png_warning_parameter_signed(png_warning_parameters p, int number, int format, png_int_32 value)
Definition: pngerror.c:260
PNG_CONST png_text FAR * png_const_textp
Definition: png.h:653
#define PNG_CONST
Definition: pngconf.h:426
png_info FAR * png_infop
Definition: png.h:721
png_fixed_point whitey
Definition: pngpriv.h:1330
void png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:2212
int png_check_fp_number(png_const_charp string, png_size_t size, int *statep, png_size_tp whereami)
Definition: png.c:1321
png_fixed_point png_muldiv_warn(png_structp png_ptr, png_fixed_point a, png_int_32 times, png_int_32 divisor)
Definition: png.c:2030
void png_destroy_struct(png_voidp struct_ptr)
Definition: pngmem.c:438
GLsizei GLsizei * length
Definition: gl2ext.h:792
void png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2692
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl2ext.h:848
EGLSurface EGLint EGLint EGLint width
Definition: eglext.h:293
void png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
Definition: pngwutil.c:2425
void png_push_crc_finish(png_structp png_ptr)
Definition: pngpread.c:597
void png_build_gamma_table(png_structp png_ptr, int bit_depth)
Definition: png.c:2739
unsigned char png_byte
Definition: pngconf.h:449
unsigned short png_uint_16
Definition: pngconf.h:447
void png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:1918
struct png_xy png_xy
png_fixed_point redX
Definition: pngpriv.h:1335
png_fixed_point redZ
Definition: pngpriv.h:1335
void png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int compression_type, int filter_type, int interlace_type)
Definition: pngwutil.c:676
GLfloat GLfloat p
Definition: glew.h:14938
void png_combine_row(png_structp png_ptr, png_bytep dp, int display)
Definition: pngrutil.c:2784
int png_check_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y)
Definition: png.c:780
void png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngpread.c:1567
void png_ascii_from_fixed(png_structp png_ptr, png_charp ascii, png_size_t size, png_fixed_point fp)
Definition: png.c:1818
void png_do_bgr(png_row_infop row_info, png_bytep row)
Definition: pngtrans.c:546
void PNGCBAPI png_default_flush(png_structp png_ptr)
Definition: pngwio.c:137
png_uint_16 FAR * png_uint_16p
Definition: pngconf.h:532
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl2ext.h:845
PNG_CONST png_byte FAR * png_const_bytep
Definition: pngconf.h:527
#define FAR
Definition: zconf.h:215
void png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngpread.c:1268
void png_push_crc_skip(png_structp png_ptr, png_uint_32 skip)
Definition: pngpread.c:590
int png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, png_int_32 divisor)
Definition: png.c:1911
void png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, png_size_t buffer_length)
Definition: pngpread.c:868
void png_read_push_finish_row(png_structp png_ptr)
Definition: pngpread.c:1201
void png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:2623
compression_type
Definition: pngrutil.c:1309
PNG_CONST png_color_16 FAR * png_const_color_16p
Definition: png.h:570
void png_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type, png_const_charp profile, int profile_len)
Definition: pngwutil.c:1094
void png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
Definition: pngrtran.c:3477
void png_read_sig(png_structp png_ptr, png_infop info_ptr)
Definition: pngrutil.c:117
int png_crc_finish(png_structp png_ptr, png_uint_32 skip)
Definition: pngrutil.c:204
png_fixed_point png_reciprocal2(png_fixed_point a, png_fixed_point b)
Definition: png.c:2087
void png_do_shift(png_row_infop row_info, png_bytep row, png_const_color_8p bit_depth)
Definition: pngwtran.c:246
png_size_t png_check_keyword(png_structp png_ptr, png_const_charp key, png_charpp new_key)
Definition: pngwutil.c:1524
int png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_const_textp text_ptr, int num_text)
Definition: pngset.c:679
png_byte FAR * png_bytep
Definition: pngconf.h:526
void png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:1557
void png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, png_size_t buffer_length)
Definition: pngpread.c:757
void png_do_unpack(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2369
void png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:1107
void png_do_expand(png_row_infop row_info, png_bytep row, png_const_color_16p trans_color)
Definition: pngrtran.c:4609
void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
Definition: pngrio.c:32
void png_write_destroy(png_structp png_ptr)
Definition: pngwrite.c:941
void png_do_expand_palette(png_row_infop row_info, png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)
Definition: pngrtran.c:4456
int png_XYZ_from_xy(png_XYZ *XYZ, png_xy xy)
Definition: png.c:888
EGLSurface EGLint void ** value
Definition: eglext.h:301
png_row_info FAR * png_row_infop
Definition: png.h:840
void png_64bit_product(long v1, long v2, unsigned long *hi_product, unsigned long *lo_product)
Definition: png.c:2132
void png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structp png_ptr)
Definition: pngrtran.c:4390
void png_write_sRGB(png_structp png_ptr, int srgb_intent)
Definition: pngwutil.c:1076
void png_do_swap(png_row_infop row_info, png_bytep row)
Definition: pngtrans.c:267
GLenum GLuint GLsizei const GLchar * buf
Definition: glew.h:2539
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2767
png_byte png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
Definition: png.c:2451
void png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:2166
void png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:1871
void png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha, png_const_color_16p tran, int num_trans, int color_type)
Definition: pngwutil.c:1357
void png_process_some_data(png_structp png_ptr, png_infop info_ptr)
Definition: pngpread.c:106
void FAR * png_voidp
Definition: pngconf.h:524
void png_write_IEND(png_structp png_ptr)
Definition: pngwutil.c:1050
void png_write_iTXt(png_structp png_ptr, int compression, png_const_charp key, png_const_charp lang, png_const_charp lang_key, png_const_charp text)
Definition: pngwutil.c:1749
png_int_32 png_fixed_point
Definition: pngconf.h:521
void png_destroy_gamma_table(png_structp png_ptr)
Definition: png.c:2683
char FAR *FAR * png_charpp
Definition: pngconf.h:559
void png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:1661
void png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_voidp mem_ptr)
Definition: pngmem.c:446
void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_uint_32 transformations)
Definition: pngrutil.c:3264
GLdouble GLdouble GLdouble b
Definition: glew.h:8383
GLuint GLuint end
Definition: glew.h:1239
void png_calculate_crc(png_structp png_ptr, png_const_bytep ptr, png_size_t length)
Definition: png.c:120
png_fixed_point redy
Definition: pngpriv.h:1327
void png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:769
size_t png_size_t
Definition: pngconf.h:454
int png_crc_error(png_structp png_ptr)
Definition: pngrutil.c:244
void png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:849
png_fixed_point greenZ
Definition: pngpriv.h:1336
void png_push_process_row(png_structp png_ptr)
Definition: pngpread.c:972
png_uint_32 skip
Definition: pngrutil.c:1241
void png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
Definition: pngwtran.c:23
#define PNG_FUNCTION(type, name, args, attributes)
Definition: pngconf.h:286
void png_write_hIST(png_structp png_ptr, png_const_uint_16p hist, int num_hist)
Definition: pngwutil.c:1483
void png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngpread.c:1692
PNG_CONST png_sPLT_t FAR * png_const_sPLT_tp
Definition: png.h:614
#define PNG_WARNING_PARAMETER_SIZE
Definition: pngpriv.h:1415
void png_decompress_chunk(png_structp png_ptr, int comp_type, png_size_t chunklength, png_size_t prefix_size, png_size_t *newlength)
Definition: pngrutil.c:412
int png_check_fp_string(png_const_charp string, png_size_t size)
Definition: png.c:1448
void png_write_finish_row(png_structp png_ptr)
Definition: pngwutil.c:2113
GLenum GLint GLint * precision
Definition: glew.h:3391
void png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:598
GLsizei bufsize
Definition: gl2ext.h:994
void png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
Definition: pngpread.c:1298
int png_chunk_unknown_handling(png_structp png_ptr, png_uint_32 chunk_name)
Definition: png.c:740
void png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
Definition: pngpread.c:1396
png_fixed_point blueY
Definition: pngpriv.h:1337
png_uint_16 png_gamma_correct(png_structp png_ptr, unsigned int value, png_fixed_point gamma_val)
Definition: png.c:2502
png_fixed_point greeny
Definition: pngpriv.h:1328
void png_push_have_info(png_structp png_ptr, png_infop info_ptr)
Definition: pngpread.c:1782
png_uint_16 png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)
Definition: png.c:2474
void png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
Definition: pngrutil.c:1825
GLfloat units
Definition: glew.h:12417
void png_write_sCAL_s(png_structp png_ptr, int unit, png_const_charp width, png_const_charp height)
Definition: pngwutil.c:1922
void png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
Definition: pngwutil.c:2241
void png_formatted_warning(png_structp png_ptr, png_warning_parameters p, png_const_charp message)
Definition: pngerror.c:281
PNG_CONST png_uint_16 FAR * png_const_uint_16p
Definition: pngconf.h:533
GLint GLsizei const GLuint64 * values
Definition: glew.h:3473
void png_reset_crc(png_structp png_ptr)
Definition: png.c:108
GLfloat GLfloat GLfloat v2
Definition: glew.h:1842
void png_do_expand_16(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:4839
int png_gamma_significant(png_fixed_point gamma_val)
Definition: png.c:2516
void png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, png_alloc_size_t value)
Definition: pngerror.c:252
GLuint res
Definition: glew.h:10669
#define PNG_EXTERN
Definition: pngpriv.h:258
png_uint_32 png_read_chunk_header(png_structp png_ptr)
Definition: pngrutil.c:152
void png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
Definition: pngwtran.c:381
void png_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type)
Definition: pngwutil.c:1421
void png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
Definition: pngwtran.c:475
png_color FAR * png_colorp
Definition: png.h:557
GLsizei size
Definition: gl2ext.h:1467