12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /* png.h - header file for PNG reference library
26 *
27 * This file is available under and governed by the GNU General Public
28 * License version 2 only, as published by the Free Software Foundation.
29 * However, the following notice accompanied the original version of this
30 * file and, per its terms, should not be removed:
31 *
32 * libpng version 1.6.23, June 9, 2016
33 *
34 * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
35 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
36 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
37 *
38 * This code is released under the libpng license (See LICENSE, below)
39 *
40 * Authors and maintainers:
41 * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
42 * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
43 * libpng versions 0.97, January 1998, through 1.6.23, June 9, 2016:
44 * Glenn Randers-Pehrson.
45 * See also "Contributing Authors", below.
46 */
47
48 /*
49 * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
50 *
51 * If you modify libpng you may insert additional notices immediately following
52 * this sentence.
53 *
54 * This code is released under the libpng license.
55 *
56 * Some files in the "contrib" directory and some configure-generated
57 * files that are distributed with libpng have other copyright owners and
58 * are released under other open source licenses.
59 *
60 * libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
61 * Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
62 * derived from libpng-1.0.6, and are distributed according to the same
63 * disclaimer and license as libpng-1.0.6 with the following individuals
64 * added to the list of Contributing Authors:
65 *
66 * Simon-Pierre Cadieux
67 * Eric S. Raymond
68 * Mans Rullgard
69 * Cosmin Truta
70 * Gilles Vollant
71 * James Yu
72 *
73 * and with the following additions to the disclaimer:
74 *
75 * There is no warranty against interference with your enjoyment of the
76 * library or against infringement. There is no warranty that our
77 * efforts or the library will fulfill any of your particular purposes
78 * or needs. This library is provided with all faults, and the entire
79 * risk of satisfactory quality, performance, accuracy, and effort is with
80 * the user.
81 *
82 * Some files in the "contrib" directory have other copyright owners and
83 * are released under other open source licenses.
84 *
85 *
86 * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
87 * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
88 * libpng-0.96, and are distributed according to the same disclaimer and
89 * license as libpng-0.96, with the following individuals added to the list
90 * of Contributing Authors:
91 *
92 * Tom Lane
93 * Glenn Randers-Pehrson
94 * Willem van Schaik
95 *
96 * Some files in the "scripts" directory have different copyright owners
97 * but are also released under this license.
98 *
99 * libpng versions 0.89, June 1996, through 0.96, May 1997, are
100 * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
101 * and are distributed according to the same disclaimer and license as
102 * libpng-0.88, with the following individuals added to the list of
103 * Contributing Authors:
104 *
105 * John Bowler
106 * Kevin Bracey
107 * Sam Bushell
108 * Magnus Holmgren
109 * Greg Roelofs
110 * Tom Tanner
111 *
112 * Some files in the "scripts" directory have other copyright owners
113 * but are released under this license.
114 *
115 * libpng versions 0.5, May 1995, through 0.88, January 1996, are
116 * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
117 *
118 * For the purposes of this copyright and license, "Contributing Authors"
224 * 1.0.3a-d 10004
225 * 1.0.4 10004
226 * 1.0.4a-f 10005
227 * 1.0.5 (+ 2 patches) 10005
228 * 1.0.5a-d 10006
229 * 1.0.5e-r 10100 (not source compatible)
230 * 1.0.5s-v 10006 (not binary compatible)
231 * 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
232 * 1.0.6d-f 10007 (still binary incompatible)
233 * 1.0.6g 10007
234 * 1.0.6h 10007 10.6h (testing xy.z so-numbering)
235 * 1.0.6i 10007 10.6i
236 * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
237 * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible)
238 * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
239 * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
240 * 1.0.7 1 10007 (still compatible)
241 * ...
242 * 1.0.19 10 10019 10.so.0.19[.0]
243 * ...
244 * 1.2.56 13 10256 12.so.0.56[.0]
245 * ...
246 * 1.5.27 15 10527 15.so.15.27[.0]
247 * ...
248 * 1.6.23 16 10623 16.so.16.23[.0]
249 *
250 * Henceforth the source version will match the shared-library major
251 * and minor numbers; the shared-library major version number will be
252 * used for changes in backward compatibility, as it is intended. The
253 * PNG_LIBPNG_VER macro, which is not used within libpng but is available
254 * for applications, is an unsigned integer of the form xyyzz corresponding
255 * to the source version x.y.z (leading zeros in y and z). Beta versions
256 * were given the previous public release number plus a letter, until
257 * version 1.0.6j; from then on they were given the upcoming public
258 * release number plus "betaNN" or "rcNN".
259 *
260 * Binary incompatibility exists only when applications make direct access
261 * to the info_ptr or png_ptr members through png.h, and the compiled
262 * application is loaded with a different version of the library.
263 *
264 * DLLNUM will change each time there are forward or backward changes
265 * in binary compatibility (e.g., when a new feature is added).
266 *
267 * See libpng.txt or libpng.3 for more information. The PNG specification
268 * is available as a W3C Recommendation and as an ISO Specification,
269 * <http://www.w3.org/TR/2003/REC-PNG-20031110/
270 */
271
272 /*
273 * Y2K compliance in libpng:
274 * =========================
275 *
276 * June 9, 2016
277 *
278 * Since the PNG Development group is an ad-hoc body, we can't make
279 * an official declaration.
280 *
281 * This is your unofficial assurance that libpng from version 0.71 and
282 * upward through 1.6.23 are Y2K compliant. It is my belief that
283 * earlier versions were also Y2K compliant.
284 *
285 * Libpng only has two year fields. One is a 2-byte unsigned integer
286 * that will hold years up to 65535. The other, which is deprecated,
287 * holds the date in text format, and will hold years up to 9999.
288 *
289 * The integer is
290 * "png_uint_16 year" in png_time_struct.
291 *
292 * The string is
293 * "char time_buffer[29]" in png_struct. This is no longer used
294 * in libpng-1.6.x and will be removed from libpng-1.7.0.
295 *
296 * There are seven time-related functions:
297 * png.c: png_convert_to_rfc_1123_buffer() in png.c
298 * (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
299 * png_convert_to_rfc_1152() in error prior to libpng-0.98)
300 * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
301 * png_convert_from_time_t() in pngwrite.c
302 * png_get_tIME() in pngget.c
324 * Glenn Randers-Pehrson
325 * libpng maintainer
326 * PNG Development Group
327 */
328
329 #ifndef PNG_H
330 #define PNG_H
331
332 /* This is not the place to learn how to use libpng. The file libpng-manual.txt
333 * describes how to use libpng, and the file example.c summarizes it
334 * with some code on which to build. This file is useful for looking
335 * at the actual function definitions and structure components. If that
336 * file has been stripped from your copy of libpng, you can find it at
337 * <http://www.libpng.org/pub/png/libpng-manual.txt>
338 *
339 * If you just need to read a PNG file and don't want to read the documentation
340 * skip to the end of this file and read the section entitled 'simplified API'.
341 */
342
343 /* Version information for png.h - this should match the version in png.c */
344 #define PNG_LIBPNG_VER_STRING "1.6.23"
345 #define PNG_HEADER_VERSION_STRING \
346 " libpng version 1.6.23 - June 9, 2016\n"
347
348 #define PNG_LIBPNG_VER_SONUM 16
349 #define PNG_LIBPNG_VER_DLLNUM 16
350
351 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
352 #define PNG_LIBPNG_VER_MAJOR 1
353 #define PNG_LIBPNG_VER_MINOR 6
354 #define PNG_LIBPNG_VER_RELEASE 23
355
356 /* This should match the numeric part of the final component of
357 * PNG_LIBPNG_VER_STRING, omitting any leading zero:
358 */
359
360 #define PNG_LIBPNG_VER_BUILD 0
361
362 /* Release Status */
363 #define PNG_LIBPNG_BUILD_ALPHA 1
364 #define PNG_LIBPNG_BUILD_BETA 2
365 #define PNG_LIBPNG_BUILD_RC 3
366 #define PNG_LIBPNG_BUILD_STABLE 4
367 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
368
369 /* Release-Specific Flags */
370 #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
371 PNG_LIBPNG_BUILD_STABLE only */
372 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
373 PNG_LIBPNG_BUILD_SPECIAL */
374 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
375 PNG_LIBPNG_BUILD_PRIVATE */
376
377 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
378
379 /* Careful here. At one time, Guy wanted to use 082, but that would be octal.
380 * We must not include leading zeros.
381 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
382 * version 1.0.0 was mis-numbered 100 instead of 10000). From
383 * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
384 */
385 #define PNG_LIBPNG_VER 10623 /* 1.6.23 */
386
387 /* Library configuration: these options cannot be changed after
388 * the library has been built.
389 */
390 #ifndef PNGLCONF_H
391 /* If pnglibconf.h is missing, you can
392 * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
393 */
394 # include "pnglibconf.h"
395 #endif
396
397 #ifndef PNG_VERSION_INFO_ONLY
398 /* Machine specific configuration. */
399 # include "pngconf.h"
400 #endif
401
402 /*
403 * Added at libpng-1.2.8
404 *
405 * Ref MSDN: Private as priority over Special
406 * VS_FF_PRIVATEBUILD File *was not* built using standard release
407 * procedures. If this value is given, the StringFileInfo block must
408 * contain a PrivateBuild string.
409 *
410 * VS_FF_SPECIALBUILD File *was* built by the original company using
411 * standard release procedures but is a variation of the standard
412 * file of the same version number. If this value is given, the
413 * StringFileInfo block must contain a SpecialBuild string.
414 */
415
416 #ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */
417 # define PNG_LIBPNG_BUILD_TYPE \
418 (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
475 * does not use division?
476 * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'
477 * algorithm.
478 * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.
479 *
480 * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is
481 * false?
482 * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error
483 * APIs to png_warning.
484 * Otherwise the calls are mapped to png_error.
485 */
486
487 /* Section 3: type definitions, including structures and compile time
488 * constants.
489 * See pngconf.h for base types that vary by machine/system
490 */
491
492 /* This triggers a compiler error in png.c, if png.c and png.h
493 * do not agree upon the version number.
494 */
495 typedef char* png_libpng_version_1_6_23;
496
497 /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
498 *
499 * png_struct is the cache of information used while reading or writing a single
500 * PNG file. One of these is always required, although the simplified API
501 * (below) hides the creation and destruction of it.
502 */
503 typedef struct png_struct_def png_struct;
504 typedef const png_struct * png_const_structp;
505 typedef png_struct * png_structp;
506 typedef png_struct * * png_structpp;
507
508 /* png_info contains information read from or to be written to a PNG file. One
509 * or more of these must exist while reading or creating a PNG file. The
510 * information is not used by libpng during read but is used to control what
511 * gets written when a PNG file is created. "png_get_" function calls read
512 * information during read and "png_set_" functions calls write information
513 * when creating a PNG.
514 * been moved into a separate header file that is not accessible to
515 * applications. Read libpng-manual.txt or libpng.3 for more info.
2311 * Note that the default behavior is effectively the opposite of the read case -
2312 * in read unknown chunks are not stored by default, in write they are written
2313 * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different
2314 * - on write the safe-to-copy bit is checked, on read the critical bit is
2315 * checked and on read if the chunk is critical an error will be raised.
2316 *
2317 * num_chunks:
2318 * ===========
2319 * If num_chunks is positive, then the "keep" parameter specifies the manner
2320 * for handling only those chunks appearing in the chunk_list array,
2321 * otherwise the chunk list array is ignored.
2322 *
2323 * If num_chunks is 0 the "keep" parameter specifies the default behavior for
2324 * unknown chunks, as described above.
2325 *
2326 * If num_chunks is negative, then the "keep" parameter specifies the manner
2327 * for handling all unknown chunks plus all chunks recognized by libpng
2328 * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
2329 * be processed by libpng.
2330 */
2331 PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
2332 int keep, png_const_bytep chunk_list, int num_chunks));
2333
2334 /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
2335 * the result is therefore true (non-zero) if special handling is required,
2336 * false for the default handling.
2337 */
2338 PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
2339 png_const_bytep chunk_name));
2340 #endif
2341
2342 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
2343 PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
2344 png_inforp info_ptr, png_const_unknown_chunkp unknowns,
2345 int num_unknowns));
2346 /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added
2347 * unknowns to the location currently stored in the png_struct. This is
2348 * invariably the wrong value on write. To fix this call the following API
2349 * for each chunk in the list with the correct location. If you know your
2350 * code won't be compiled on earlier versions you can rely on
2351 * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing
2352 * the correct thing.
2353 */
2354
2355 PNG_EXPORT(175, void, png_set_unknown_chunk_location,
2356 (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));
2357
2358 PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,
2359 png_inforp info_ptr, png_unknown_chunkpp entries));
2360 #endif
2542 ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
2543 #define PNG_COL_IN_INTERLACE_PASS(x, pass) \
2544 ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
2545
2546 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
2547 /* With these routines we avoid an integer divide, which will be slower on
2548 * most machines. However, it does take more operations than the corresponding
2549 * divide method, so it may be slower on a few RISC systems. There are two
2550 * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
2551 *
2552 * Note that the rounding factors are NOT supposed to be the same! 128 and
2553 * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
2554 * standard method.
2555 *
2556 * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
2557 */
2558
2559 /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
2560
2561 # define png_composite(composite, fg, alpha, bg) \
2562 { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
2563 * (png_uint_16)(alpha) \
2564 + (png_uint_16)(bg)*(png_uint_16)(255 \
2565 - (png_uint_16)(alpha)) + 128); \
2566 (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); }
2567
2568 # define png_composite_16(composite, fg, alpha, bg) \
2569 { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
2570 * (png_uint_32)(alpha) \
2571 + (png_uint_32)(bg)*(65535 \
2572 - (png_uint_32)(alpha)) + 32768); \
2573 (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); }
2574
2575 #else /* Standard method using integer division */
2576
2577 # define png_composite(composite, fg, alpha, bg) \
2578 (composite) = \
2579 (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \
2580 (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
2581 127) / 255))
2582
2583 # define png_composite_16(composite, fg, alpha, bg) \
2584 (composite) = \
2585 (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
2586 (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
2587 32767) / 65535))
2588 #endif /* READ_COMPOSITE_NODIV */
2589
2590 #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
2591 PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
2592 PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
2593 PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));
2621 */
2622 # define PNG_get_uint_32(buf) \
2623 (((png_uint_32)(*(buf)) << 24) + \
2624 ((png_uint_32)(*((buf) + 1)) << 16) + \
2625 ((png_uint_32)(*((buf) + 2)) << 8) + \
2626 ((png_uint_32)(*((buf) + 3))))
2627
2628 /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
2629 * function) incorrectly returned a value of type png_uint_32.
2630 */
2631 # define PNG_get_uint_16(buf) \
2632 ((png_uint_16) \
2633 (((unsigned int)(*(buf)) << 8) + \
2634 ((unsigned int)(*((buf) + 1)))))
2635
2636 # define PNG_get_int_32(buf) \
2637 ((png_int_32)((*(buf) & 0x80) \
2638 ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
2639 : (png_int_32)png_get_uint_32(buf)))
2640
2641 /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
2642 * but defining a macro name prefixed with PNG_PREFIX.
2643 */
2644 # ifndef PNG_PREFIX
2645 # define png_get_uint_32(buf) PNG_get_uint_32(buf)
2646 # define png_get_uint_16(buf) PNG_get_uint_16(buf)
2647 # define png_get_int_32(buf) PNG_get_int_32(buf)
2648 # endif
2649 #else
2650 # ifdef PNG_PREFIX
2651 /* No macros; revert to the (redefined) function */
2652 # define PNG_get_uint_32 (png_get_uint_32)
2653 # define PNG_get_uint_16 (png_get_uint_16)
2654 # define PNG_get_int_32 (png_get_int_32)
2655 # endif
2656 #endif
2657
2658 #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
2659 PNG_EXPORT(242, void, png_set_check_for_invalid_index,
2660 (png_structrp png_ptr, int allowed));
2661 # ifdef PNG_GET_PALETTE_MAX_SUPPORTED
3232 * by the PNG_OPTION_ defines below.
3233 *
3234 * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
3235 * are detected at run time, however sometimes it may be impossible
3236 * to do this in user mode, in which case it is necessary to discover
3237 * the capabilities in an OS specific way. Such capabilities are
3238 * listed here when libpng has support for them and must be turned
3239 * ON by the application if present.
3240 *
3241 * SOFTWARE: sometimes software optimizations actually result in performance
3242 * decrease on some architectures or systems, or with some sets of
3243 * PNG images. 'Software' options allow such optimizations to be
3244 * selected at run time.
3245 */
3246 #ifdef PNG_SET_OPTION_SUPPORTED
3247 #ifdef PNG_ARM_NEON_API_SUPPORTED
3248 # define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
3249 #endif
3250 #define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
3251 #define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
3252 #define PNG_OPTION_NEXT 6 /* Next option - numbers must be even */
3253
3254 /* Return values: NOTE: there are four values and 'off' is *not* zero */
3255 #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
3256 #define PNG_OPTION_INVALID 1 /* Option number out of range */
3257 #define PNG_OPTION_OFF 2
3258 #define PNG_OPTION_ON 3
3259
3260 PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
3261 int onoff));
3262 #endif /* SET_OPTION */
3263
3264 /*******************************************************************************
3265 * END OF HARDWARE AND SOFTWARE OPTIONS
3266 ******************************************************************************/
3267
3268 /* Maintainer: Put new public prototypes here ^, in libpng.3, in project
3269 * defs, and in scripts/symbols.def.
3270 */
3271
3272 /* The last ordinal number (this is the *last* one already used; the next
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /* png.h - header file for PNG reference library
26 *
27 * This file is available under and governed by the GNU General Public
28 * License version 2 only, as published by the Free Software Foundation.
29 * However, the following notice accompanied the original version of this
30 * file and, per its terms, should not be removed:
31 *
32 * libpng version 1.6.28, January 5, 2017
33 *
34 * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
35 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
36 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
37 *
38 * This code is released under the libpng license (See LICENSE, below)
39 *
40 * Authors and maintainers:
41 * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
42 * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
43 * libpng versions 0.97, January 1998, through 1.6.28, January 5, 2017:
44 * Glenn Randers-Pehrson.
45 * See also "Contributing Authors", below.
46 */
47
48 /*
49 * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
50 *
51 * If you modify libpng you may insert additional notices immediately following
52 * this sentence.
53 *
54 * This code is released under the libpng license.
55 *
56 * libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
57 * Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
58 * derived from libpng-1.0.6, and are distributed according to the same
59 * disclaimer and license as libpng-1.0.6 with the following individuals
60 * added to the list of Contributing Authors:
61 *
62 * Simon-Pierre Cadieux
63 * Eric S. Raymond
64 * Mans Rullgard
65 * Cosmin Truta
66 * Gilles Vollant
67 * James Yu
68 * Mandar Sahastrabuddhe
69 *
70 * and with the following additions to the disclaimer:
71 *
72 * There is no warranty against interference with your enjoyment of the
73 * library or against infringement. There is no warranty that our
74 * efforts or the library will fulfill any of your particular purposes
75 * or needs. This library is provided with all faults, and the entire
76 * risk of satisfactory quality, performance, accuracy, and effort is with
77 * the user.
78 *
79 * Some files in the "contrib" directory and some configure-generated
80 * files that are distributed with libpng have other copyright owners and
81 * are released under other open source licenses.
82 *
83 * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
84 * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
85 * libpng-0.96, and are distributed according to the same disclaimer and
86 * license as libpng-0.96, with the following individuals added to the list
87 * of Contributing Authors:
88 *
89 * Tom Lane
90 * Glenn Randers-Pehrson
91 * Willem van Schaik
92 *
93 * libpng versions 0.89, June 1996, through 0.96, May 1997, are
94 * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
95 * and are distributed according to the same disclaimer and license as
96 * libpng-0.88, with the following individuals added to the list of
97 * Contributing Authors:
98 *
99 * John Bowler
100 * Kevin Bracey
101 * Sam Bushell
102 * Magnus Holmgren
103 * Greg Roelofs
104 * Tom Tanner
105 *
106 * Some files in the "scripts" directory have other copyright owners
107 * but are released under this license.
108 *
109 * libpng versions 0.5, May 1995, through 0.88, January 1996, are
110 * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
111 *
112 * For the purposes of this copyright and license, "Contributing Authors"
218 * 1.0.3a-d 10004
219 * 1.0.4 10004
220 * 1.0.4a-f 10005
221 * 1.0.5 (+ 2 patches) 10005
222 * 1.0.5a-d 10006
223 * 1.0.5e-r 10100 (not source compatible)
224 * 1.0.5s-v 10006 (not binary compatible)
225 * 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
226 * 1.0.6d-f 10007 (still binary incompatible)
227 * 1.0.6g 10007
228 * 1.0.6h 10007 10.6h (testing xy.z so-numbering)
229 * 1.0.6i 10007 10.6i
230 * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
231 * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible)
232 * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
233 * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
234 * 1.0.7 1 10007 (still compatible)
235 * ...
236 * 1.0.19 10 10019 10.so.0.19[.0]
237 * ...
238 * 1.2.57 13 10257 12.so.0.57[.0]
239 * ...
240 * 1.5.28 15 10527 15.so.15.28[.0]
241 * ...
242 * 1.6.28 16 10628 16.so.16.28[.0]
243 *
244 * Henceforth the source version will match the shared-library major
245 * and minor numbers; the shared-library major version number will be
246 * used for changes in backward compatibility, as it is intended. The
247 * PNG_LIBPNG_VER macro, which is not used within libpng but is available
248 * for applications, is an unsigned integer of the form xyyzz corresponding
249 * to the source version x.y.z (leading zeros in y and z). Beta versions
250 * were given the previous public release number plus a letter, until
251 * version 1.0.6j; from then on they were given the upcoming public
252 * release number plus "betaNN" or "rcNN".
253 *
254 * Binary incompatibility exists only when applications make direct access
255 * to the info_ptr or png_ptr members through png.h, and the compiled
256 * application is loaded with a different version of the library.
257 *
258 * DLLNUM will change each time there are forward or backward changes
259 * in binary compatibility (e.g., when a new feature is added).
260 *
261 * See libpng.txt or libpng.3 for more information. The PNG specification
262 * is available as a W3C Recommendation and as an ISO Specification,
263 * <http://www.w3.org/TR/2003/REC-PNG-20031110/
264 */
265
266 /*
267 * Y2K compliance in libpng:
268 * =========================
269 *
270 * January 5, 2017
271 *
272 * Since the PNG Development group is an ad-hoc body, we can't make
273 * an official declaration.
274 *
275 * This is your unofficial assurance that libpng from version 0.71 and
276 * upward through 1.6.28 are Y2K compliant. It is my belief that
277 * earlier versions were also Y2K compliant.
278 *
279 * Libpng only has two year fields. One is a 2-byte unsigned integer
280 * that will hold years up to 65535. The other, which is deprecated,
281 * holds the date in text format, and will hold years up to 9999.
282 *
283 * The integer is
284 * "png_uint_16 year" in png_time_struct.
285 *
286 * The string is
287 * "char time_buffer[29]" in png_struct. This is no longer used
288 * in libpng-1.6.x and will be removed from libpng-1.7.0.
289 *
290 * There are seven time-related functions:
291 * png.c: png_convert_to_rfc_1123_buffer() in png.c
292 * (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
293 * png_convert_to_rfc_1152() in error prior to libpng-0.98)
294 * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
295 * png_convert_from_time_t() in pngwrite.c
296 * png_get_tIME() in pngget.c
318 * Glenn Randers-Pehrson
319 * libpng maintainer
320 * PNG Development Group
321 */
322
323 #ifndef PNG_H
324 #define PNG_H
325
326 /* This is not the place to learn how to use libpng. The file libpng-manual.txt
327 * describes how to use libpng, and the file example.c summarizes it
328 * with some code on which to build. This file is useful for looking
329 * at the actual function definitions and structure components. If that
330 * file has been stripped from your copy of libpng, you can find it at
331 * <http://www.libpng.org/pub/png/libpng-manual.txt>
332 *
333 * If you just need to read a PNG file and don't want to read the documentation
334 * skip to the end of this file and read the section entitled 'simplified API'.
335 */
336
337 /* Version information for png.h - this should match the version in png.c */
338 #define PNG_LIBPNG_VER_STRING "1.6.28"
339 #define PNG_HEADER_VERSION_STRING " libpng version 1.6.28 - January 5, 2017\n"
340
341 #define PNG_LIBPNG_VER_SONUM 16
342 #define PNG_LIBPNG_VER_DLLNUM 16
343
344 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
345 #define PNG_LIBPNG_VER_MAJOR 1
346 #define PNG_LIBPNG_VER_MINOR 6
347 #define PNG_LIBPNG_VER_RELEASE 28
348
349 /* This should match the numeric part of the final component of
350 * PNG_LIBPNG_VER_STRING, omitting any leading zero:
351 */
352
353 #define PNG_LIBPNG_VER_BUILD 0
354
355 /* Release Status */
356 #define PNG_LIBPNG_BUILD_ALPHA 1
357 #define PNG_LIBPNG_BUILD_BETA 2
358 #define PNG_LIBPNG_BUILD_RC 3
359 #define PNG_LIBPNG_BUILD_STABLE 4
360 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
361
362 /* Release-Specific Flags */
363 #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
364 PNG_LIBPNG_BUILD_STABLE only */
365 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
366 PNG_LIBPNG_BUILD_SPECIAL */
367 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
368 PNG_LIBPNG_BUILD_PRIVATE */
369
370 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
371
372 /* Careful here. At one time, Guy wanted to use 082, but that would be octal.
373 * We must not include leading zeros.
374 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
375 * version 1.0.0 was mis-numbered 100 instead of 10000). From
376 * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
377 */
378 #define PNG_LIBPNG_VER 10628 /* 1.6.28 */
379
380 /* Library configuration: these options cannot be changed after
381 * the library has been built.
382 */
383 #ifndef PNGLCONF_H
384 /* If pnglibconf.h is missing, you can
385 * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
386 */
387 # include "pnglibconf.h"
388 #endif
389
390 #ifndef PNG_VERSION_INFO_ONLY
391 /* Machine specific configuration. */
392 # include "pngconf.h"
393 #endif
394
395 /*
396 * Added at libpng-1.2.8
397 *
398 * Ref MSDN: Private as priority over Special
399 * VS_FF_PRIVATEBUILD File *was not* built using standard release
400 * procedures. If this value is given, the StringFileInfo block must
401 * contain a PrivateBuild string.
402 *
403 * VS_FF_SPECIALBUILD File *was* built by the original company using
404 * standard release procedures but is a variation of the standard
405 * file of the same version number. If this value is given, the
406 * StringFileInfo block must contain a SpecialBuild string.
407 */
408
409 #ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */
410 # define PNG_LIBPNG_BUILD_TYPE \
411 (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
468 * does not use division?
469 * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'
470 * algorithm.
471 * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.
472 *
473 * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is
474 * false?
475 * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error
476 * APIs to png_warning.
477 * Otherwise the calls are mapped to png_error.
478 */
479
480 /* Section 3: type definitions, including structures and compile time
481 * constants.
482 * See pngconf.h for base types that vary by machine/system
483 */
484
485 /* This triggers a compiler error in png.c, if png.c and png.h
486 * do not agree upon the version number.
487 */
488 typedef char* png_libpng_version_1_6_28;
489
490 /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
491 *
492 * png_struct is the cache of information used while reading or writing a single
493 * PNG file. One of these is always required, although the simplified API
494 * (below) hides the creation and destruction of it.
495 */
496 typedef struct png_struct_def png_struct;
497 typedef const png_struct * png_const_structp;
498 typedef png_struct * png_structp;
499 typedef png_struct * * png_structpp;
500
501 /* png_info contains information read from or to be written to a PNG file. One
502 * or more of these must exist while reading or creating a PNG file. The
503 * information is not used by libpng during read but is used to control what
504 * gets written when a PNG file is created. "png_get_" function calls read
505 * information during read and "png_set_" functions calls write information
506 * when creating a PNG.
507 * been moved into a separate header file that is not accessible to
508 * applications. Read libpng-manual.txt or libpng.3 for more info.
2304 * Note that the default behavior is effectively the opposite of the read case -
2305 * in read unknown chunks are not stored by default, in write they are written
2306 * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different
2307 * - on write the safe-to-copy bit is checked, on read the critical bit is
2308 * checked and on read if the chunk is critical an error will be raised.
2309 *
2310 * num_chunks:
2311 * ===========
2312 * If num_chunks is positive, then the "keep" parameter specifies the manner
2313 * for handling only those chunks appearing in the chunk_list array,
2314 * otherwise the chunk list array is ignored.
2315 *
2316 * If num_chunks is 0 the "keep" parameter specifies the default behavior for
2317 * unknown chunks, as described above.
2318 *
2319 * If num_chunks is negative, then the "keep" parameter specifies the manner
2320 * for handling all unknown chunks plus all chunks recognized by libpng
2321 * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
2322 * be processed by libpng.
2323 */
2324 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
2325 PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
2326 int keep, png_const_bytep chunk_list, int num_chunks));
2327 #endif /* HANDLE_AS_UNKNOWN */
2328
2329 /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
2330 * the result is therefore true (non-zero) if special handling is required,
2331 * false for the default handling.
2332 */
2333 PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
2334 png_const_bytep chunk_name));
2335 #endif /* SET_UNKNOWN_CHUNKS */
2336
2337 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
2338 PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
2339 png_inforp info_ptr, png_const_unknown_chunkp unknowns,
2340 int num_unknowns));
2341 /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added
2342 * unknowns to the location currently stored in the png_struct. This is
2343 * invariably the wrong value on write. To fix this call the following API
2344 * for each chunk in the list with the correct location. If you know your
2345 * code won't be compiled on earlier versions you can rely on
2346 * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing
2347 * the correct thing.
2348 */
2349
2350 PNG_EXPORT(175, void, png_set_unknown_chunk_location,
2351 (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));
2352
2353 PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,
2354 png_inforp info_ptr, png_unknown_chunkpp entries));
2355 #endif
2537 ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
2538 #define PNG_COL_IN_INTERLACE_PASS(x, pass) \
2539 ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)
2540
2541 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
2542 /* With these routines we avoid an integer divide, which will be slower on
2543 * most machines. However, it does take more operations than the corresponding
2544 * divide method, so it may be slower on a few RISC systems. There are two
2545 * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
2546 *
2547 * Note that the rounding factors are NOT supposed to be the same! 128 and
2548 * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
2549 * standard method.
2550 *
2551 * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
2552 */
2553
2554 /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
2555
2556 # define png_composite(composite, fg, alpha, bg) \
2557 { \
2558 png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
2559 * (png_uint_16)(alpha) \
2560 + (png_uint_16)(bg)*(png_uint_16)(255 \
2561 - (png_uint_16)(alpha)) + 128); \
2562 (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \
2563 }
2564
2565 # define png_composite_16(composite, fg, alpha, bg) \
2566 { \
2567 png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
2568 * (png_uint_32)(alpha) \
2569 + (png_uint_32)(bg)*(65535 \
2570 - (png_uint_32)(alpha)) + 32768); \
2571 (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \
2572 }
2573
2574 #else /* Standard method using integer division */
2575
2576 # define png_composite(composite, fg, alpha, bg) \
2577 (composite) = \
2578 (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \
2579 (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
2580 127) / 255))
2581
2582 # define png_composite_16(composite, fg, alpha, bg) \
2583 (composite) = \
2584 (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
2585 (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
2586 32767) / 65535))
2587 #endif /* READ_COMPOSITE_NODIV */
2588
2589 #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
2590 PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
2591 PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
2592 PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));
2620 */
2621 # define PNG_get_uint_32(buf) \
2622 (((png_uint_32)(*(buf)) << 24) + \
2623 ((png_uint_32)(*((buf) + 1)) << 16) + \
2624 ((png_uint_32)(*((buf) + 2)) << 8) + \
2625 ((png_uint_32)(*((buf) + 3))))
2626
2627 /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
2628 * function) incorrectly returned a value of type png_uint_32.
2629 */
2630 # define PNG_get_uint_16(buf) \
2631 ((png_uint_16) \
2632 (((unsigned int)(*(buf)) << 8) + \
2633 ((unsigned int)(*((buf) + 1)))))
2634
2635 # define PNG_get_int_32(buf) \
2636 ((png_int_32)((*(buf) & 0x80) \
2637 ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
2638 : (png_int_32)png_get_uint_32(buf)))
2639
2640 /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
2641 * but defining a macro name prefixed with PNG_PREFIX.
2642 */
2643 # ifndef PNG_PREFIX
2644 # define png_get_uint_32(buf) PNG_get_uint_32(buf)
2645 # define png_get_uint_16(buf) PNG_get_uint_16(buf)
2646 # define png_get_int_32(buf) PNG_get_int_32(buf)
2647 # endif
2648 #else
2649 # ifdef PNG_PREFIX
2650 /* No macros; revert to the (redefined) function */
2651 # define PNG_get_uint_32 (png_get_uint_32)
2652 # define PNG_get_uint_16 (png_get_uint_16)
2653 # define PNG_get_int_32 (png_get_int_32)
2654 # endif
2655 #endif
2656
2657 #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
2658 PNG_EXPORT(242, void, png_set_check_for_invalid_index,
2659 (png_structrp png_ptr, int allowed));
2660 # ifdef PNG_GET_PALETTE_MAX_SUPPORTED
3231 * by the PNG_OPTION_ defines below.
3232 *
3233 * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
3234 * are detected at run time, however sometimes it may be impossible
3235 * to do this in user mode, in which case it is necessary to discover
3236 * the capabilities in an OS specific way. Such capabilities are
3237 * listed here when libpng has support for them and must be turned
3238 * ON by the application if present.
3239 *
3240 * SOFTWARE: sometimes software optimizations actually result in performance
3241 * decrease on some architectures or systems, or with some sets of
3242 * PNG images. 'Software' options allow such optimizations to be
3243 * selected at run time.
3244 */
3245 #ifdef PNG_SET_OPTION_SUPPORTED
3246 #ifdef PNG_ARM_NEON_API_SUPPORTED
3247 # define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
3248 #endif
3249 #define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
3250 #define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
3251 #ifdef PNG_MIPS_MSA_API_SUPPORTED
3252 # define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
3253 #endif
3254 #define PNG_IGNORE_ADLER32 8
3255 #define PNG_OPTION_NEXT 10 /* Next option - numbers must be even */
3256
3257 /* Return values: NOTE: there are four values and 'off' is *not* zero */
3258 #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
3259 #define PNG_OPTION_INVALID 1 /* Option number out of range */
3260 #define PNG_OPTION_OFF 2
3261 #define PNG_OPTION_ON 3
3262
3263 PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
3264 int onoff));
3265 #endif /* SET_OPTION */
3266
3267 /*******************************************************************************
3268 * END OF HARDWARE AND SOFTWARE OPTIONS
3269 ******************************************************************************/
3270
3271 /* Maintainer: Put new public prototypes here ^, in libpng.3, in project
3272 * defs, and in scripts/symbols.def.
3273 */
3274
3275 /* The last ordinal number (this is the *last* one already used; the next
|