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