7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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.35, July 15, 2018
33 *
34 * Copyright (c) 1998-2002,2004,2006-2018 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.35, July 15, 2018:
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.35, July 15, 2018 are
57 * Copyright (c) 2000-2002, 2004, 2006-2018 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 * Google Inc.
70 * Vadim Barkov
71 *
72 * and with the following additions to the disclaimer:
73 *
74 * There is no warranty against interference with your enjoyment of the
75 * library or against infringement. There is no warranty that our
76 * efforts or the library will fulfill any of your particular purposes
77 * or needs. This library is provided with all faults, and the entire
78 * risk of satisfactory quality, performance, accuracy, and effort is with
79 * the user.
80 *
81 * Some files in the "contrib" directory and some configure-generated
82 * files that are distributed with libpng have other copyright owners and
83 * are released under other open source licenses.
84 *
85 * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
86 * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
87 * libpng-0.96, and are distributed according to the same disclaimer and
88 * license as libpng-0.96, with the following individuals added to the list
89 * of Contributing Authors:
90 *
91 * Tom Lane
92 * Glenn Randers-Pehrson
93 * Willem van Schaik
94 *
95 * libpng versions 0.89, June 1996, through 0.96, May 1997, are
96 * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
97 * and are distributed according to the same disclaimer and license as
98 * libpng-0.88, with the following individuals added to the list of
99 * Contributing Authors:
100 *
101 * John Bowler
102 * Kevin Bracey
103 * Sam Bushell
104 * Magnus Holmgren
105 * Greg Roelofs
106 * Tom Tanner
107 *
108 * Some files in the "scripts" directory have other copyright owners
109 * but are released under this license.
110 *
111 * libpng versions 0.5, May 1995, through 0.88, January 1996, are
112 * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
113 *
114 * For the purposes of this copyright and license, "Contributing Authors"
115 * is defined as the following set of individuals:
116 *
117 * Andreas Dilger
118 * Dave Martindale
119 * Guy Eric Schalnat
120 * Paul Schmidt
121 * Tim Wegner
122 *
123 * The PNG Reference Library is supplied "AS IS". The Contributing Authors
124 * and Group 42, Inc. disclaim all warranties, expressed or implied,
125 * including, without limitation, the warranties of merchantability and of
126 * fitness for any purpose. The Contributing Authors and Group 42, Inc.
127 * assume no liability for direct, indirect, incidental, special, exemplary,
128 * or consequential damages, which may result from the use of the PNG
129 * Reference Library, even if advised of the possibility of such damage.
130 *
131 * Permission is hereby granted to use, copy, modify, and distribute this
132 * source code, or portions hereof, for any purpose, without fee, subject
133 * to the following restrictions:
134 *
135 * 1. The origin of this source code must not be misrepresented.
136 *
137 * 2. Altered versions must be plainly marked as such and must not
138 * be misrepresented as being the original source.
139 *
140 * 3. This Copyright notice may not be removed or altered from any
141 * source or altered source distribution.
142 *
143 * The Contributing Authors and Group 42, Inc. specifically permit, without
144 * fee, and encourage the use of this source code as a component to
145 * supporting the PNG file format in commercial products. If you use this
146 * source code in a product, acknowledgment is not required but would be
147 * appreciated.
148 *
149 * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
150 *
151 * TRADEMARK:
152 *
153 * The name "libpng" has not been registered by the Copyright owner
154 * as a trademark in any jurisdiction. However, because libpng has
155 * been distributed and maintained world-wide, continually since 1995,
156 * the Copyright owner claims "common-law trademark protection" in any
157 * jurisdiction where common-law trademark is recognized.
158 *
159 * OSI CERTIFICATION:
160 *
161 * Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
162 * a certification mark of the Open Source Initiative. OSI has not addressed
163 * the additional disclaimers inserted at version 1.0.7.
164 *
165 * EXPORT CONTROL:
166 *
167 * The Copyright owner believes that the Export Control Classification
168 * Number (ECCN) for libpng is EAR99, which means not subject to export
169 * controls or International Traffic in Arms Regulations (ITAR) because
170 * it is open source, publicly available software, that does not contain
171 * any encryption software. See the EAR, paragraphs 734.3(b)(3) and
172 * 734.7(b).
173 */
174
175 /*
176 * A "png_get_copyright" function is available, for convenient use in "about"
177 * boxes and the like:
178 *
179 * printf("%s", png_get_copyright(NULL));
180 *
181 * Also, the PNG logo (in PNG format, of course) is supplied in the
182 * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
183 */
184
185 /*
186 * The contributing authors would like to thank all those who helped
187 * with testing, bug fixes, and patience. This wouldn't have been
188 * possible without all of you.
189 *
190 * Thanks to Frank J. T. Wojcik for helping with the documentation.
191 */
192
218 * 1.0.2a-b 10003 version, except as noted.
219 * 1.0.3 10003
220 * 1.0.3a-d 10004
221 * 1.0.4 10004
222 * 1.0.4a-f 10005
223 * 1.0.5 (+ 2 patches) 10005
224 * 1.0.5a-d 10006
225 * 1.0.5e-r 10100 (not source compatible)
226 * 1.0.5s-v 10006 (not binary compatible)
227 * 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
228 * 1.0.6d-f 10007 (still binary incompatible)
229 * 1.0.6g 10007
230 * 1.0.6h 10007 10.6h (testing xy.z so-numbering)
231 * 1.0.6i 10007 10.6i
232 * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
233 * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible)
234 * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
235 * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
236 * 1.0.7 1 10007 (still compatible)
237 * ...
238 * 1.0.19 10 10019 10.so.0.19[.0]
239 * ...
240 * 1.2.59 13 10257 12.so.0.59[.0]
241 * ...
242 * 1.5.30 15 10527 15.so.15.30[.0]
243 * ...
244 * 1.6.35 16 10635 16.so.16.35[.0]
245 *
246 * Henceforth the source version will match the shared-library major
247 * and minor numbers; the shared-library major version number will be
248 * used for changes in backward compatibility, as it is intended. The
249 * PNG_LIBPNG_VER macro, which is not used within libpng but is available
250 * for applications, is an unsigned integer of the form xyyzz corresponding
251 * to the source version x.y.z (leading zeros in y and z). Beta versions
252 * were given the previous public release number plus a letter, until
253 * version 1.0.6j; from then on they were given the upcoming public
254 * release number plus "betaNN" or "rcNN".
255 *
256 * Binary incompatibility exists only when applications make direct access
257 * to the info_ptr or png_ptr members through png.h, and the compiled
258 * application is loaded with a different version of the library.
259 *
260 * DLLNUM will change each time there are forward or backward changes
261 * in binary compatibility (e.g., when a new feature is added).
262 *
263 * See libpng.txt or libpng.3 for more information. The PNG specification
264 * is available as a W3C Recommendation and as an ISO Specification,
265 * <https://www.w3.org/TR/2003/REC-PNG-20031110/
266 */
267
268 /*
269 * Y2K compliance in libpng:
270 * =========================
271 *
272 * July 15, 2018
273 *
274 * Since the PNG Development group is an ad-hoc body, we can't make
275 * an official declaration.
276 *
277 * This is your unofficial assurance that libpng from version 0.71 and
278 * upward through 1.6.35 are Y2K compliant. It is my belief that
279 * earlier versions were also Y2K compliant.
280 *
281 * Libpng only has two year fields. One is a 2-byte unsigned integer
282 * that will hold years up to 65535. The other, which is deprecated,
283 * holds the date in text format, and will hold years up to 9999.
284 *
285 * The integer is
286 * "png_uint_16 year" in png_time_struct.
287 *
288 * The string is
289 * "char time_buffer[29]" in png_struct. This is no longer used
290 * in libpng-1.6.x and will be removed from libpng-1.7.0.
291 *
292 * There are seven time-related functions:
293 * png.c: png_convert_to_rfc_1123_buffer() in png.c
294 * (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
295 * png_convert_to_rfc_1152() in error prior to libpng-0.98)
296 * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
297 * png_convert_from_time_t() in pngwrite.c
298 * png_get_tIME() in pngget.c
299 * png_handle_tIME() in pngrutil.c, called in pngread.c
300 * png_set_tIME() in pngset.c
301 * png_write_tIME() in pngwutil.c, called in pngwrite.c
302 *
303 * All handle dates properly in a Y2K environment. The
304 * png_convert_from_time_t() function calls gmtime() to convert from system
305 * clock time, which returns (year - 1900), which we properly convert to
306 * the full 4-digit year. There is a possibility that libpng applications
307 * are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()
308 * function, or that they are incorrectly passing only a 2-digit year
309 * instead of "year - 1900" into the png_convert_from_struct_tm() function,
310 * but this is not under our control. The libpng documentation has always
311 * stated that it works with 4-digit years, and the APIs have been
312 * documented as such.
313 *
314 * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
315 * integer to hold the year, and can hold years as large as 65535.
316 *
317 * zlib, upon which libpng depends, is also Y2K compliant. It contains
318 * no date-related code.
319 *
320 * Glenn Randers-Pehrson
321 * libpng maintainer
322 * PNG Development Group
323 */
324
325 #ifndef PNG_H
326 #define PNG_H
327
328 /* This is not the place to learn how to use libpng. The file libpng-manual.txt
329 * describes how to use libpng, and the file example.c summarizes it
330 * with some code on which to build. This file is useful for looking
331 * at the actual function definitions and structure components. If that
332 * file has been stripped from your copy of libpng, you can find it at
333 * <http://www.libpng.org/pub/png/libpng-manual.txt>
334 *
335 * If you just need to read a PNG file and don't want to read the documentation
336 * skip to the end of this file and read the section entitled 'simplified API'.
337 */
338
339 /* Version information for png.h - this should match the version in png.c */
340 #define PNG_LIBPNG_VER_STRING "1.6.35"
341 #define PNG_HEADER_VERSION_STRING " libpng version 1.6.35 - July 15, 2018\n"
342
343 #define PNG_LIBPNG_VER_SONUM 16
344 #define PNG_LIBPNG_VER_DLLNUM 16
345
346 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
347 #define PNG_LIBPNG_VER_MAJOR 1
348 #define PNG_LIBPNG_VER_MINOR 6
349 #define PNG_LIBPNG_VER_RELEASE 35
350
351 /* This should match the numeric part of the final component of
352 * PNG_LIBPNG_VER_STRING, omitting any leading zero:
353 */
354
355 #define PNG_LIBPNG_VER_BUILD 02
356
357 /* Release Status */
358 #define PNG_LIBPNG_BUILD_ALPHA 1
359 #define PNG_LIBPNG_BUILD_BETA 2
360 #define PNG_LIBPNG_BUILD_RC 3
361 #define PNG_LIBPNG_BUILD_STABLE 4
362 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
363
364 /* Release-Specific Flags */
365 #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
366 PNG_LIBPNG_BUILD_STABLE only */
367 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
368 PNG_LIBPNG_BUILD_SPECIAL */
369 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
370 PNG_LIBPNG_BUILD_PRIVATE */
371
372 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
373
374 /* Careful here. At one time, Guy wanted to use 082, but that would be octal.
375 * We must not include leading zeros.
376 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
377 * version 1.0.0 was mis-numbered 100 instead of 10000). From
378 * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
379 */
380 #define PNG_LIBPNG_VER 10635 /* 1.6.35 */
381
382 /* Library configuration: these options cannot be changed after
383 * the library has been built.
384 */
385 #ifndef PNGLCONF_H
386 /* If pnglibconf.h is missing, you can
387 * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
388 */
389 # include "pnglibconf.h"
390 #endif
391
392 #ifndef PNG_VERSION_INFO_ONLY
393 /* Machine specific configuration. */
394 # include "pngconf.h"
395 #endif
396
397 /*
398 * Added at libpng-1.2.8
399 *
400 * Ref MSDN: Private as priority over Special
470 * does not use division?
471 * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'
472 * algorithm.
473 * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.
474 *
475 * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is
476 * false?
477 * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error
478 * APIs to png_warning.
479 * Otherwise the calls are mapped to png_error.
480 */
481
482 /* Section 3: type definitions, including structures and compile time
483 * constants.
484 * See pngconf.h for base types that vary by machine/system
485 */
486
487 /* This triggers a compiler error in png.c, if png.c and png.h
488 * do not agree upon the version number.
489 */
490 typedef char* png_libpng_version_1_6_35;
491
492 /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
493 *
494 * png_struct is the cache of information used while reading or writing a single
495 * PNG file. One of these is always required, although the simplified API
496 * (below) hides the creation and destruction of it.
497 */
498 typedef struct png_struct_def png_struct;
499 typedef const png_struct * png_const_structp;
500 typedef png_struct * png_structp;
501 typedef png_struct * * png_structpp;
502
503 /* png_info contains information read from or to be written to a PNG file. One
504 * or more of these must exist while reading or creating a PNG file. The
505 * information is not used by libpng during read but is used to control what
506 * gets written when a PNG file is created. "png_get_" function calls read
507 * information during read and "png_set_" functions calls write information
508 * when creating a PNG.
509 * been moved into a separate header file that is not accessible to
510 * applications. Read libpng-manual.txt or libpng.3 for more info.
2024 double green_X, double green_Y, double green_Z, double blue_X,
2025 double blue_Y, double blue_Z))
2026 PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,
2027 png_inforp info_ptr, png_fixed_point int_white_x,
2028 png_fixed_point int_white_y, png_fixed_point int_red_x,
2029 png_fixed_point int_red_y, png_fixed_point int_green_x,
2030 png_fixed_point int_green_y, png_fixed_point int_blue_x,
2031 png_fixed_point int_blue_y))
2032 PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
2033 png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,
2034 png_fixed_point int_red_Z, png_fixed_point int_green_X,
2035 png_fixed_point int_green_Y, png_fixed_point int_green_Z,
2036 png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
2037 png_fixed_point int_blue_Z))
2038 #endif
2039
2040 #ifdef PNG_eXIf_SUPPORTED
2041 PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
2042 png_inforp info_ptr, png_bytep *exif));
2043 PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
2044 png_inforp info_ptr, const png_bytep exif));
2045
2046 PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr,
2047 png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif));
2048 PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr,
2049 png_inforp info_ptr, const png_uint_32 num_exif, const png_bytep exif));
2050 #endif
2051
2052 #ifdef PNG_gAMA_SUPPORTED
2053 PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,
2054 png_const_inforp info_ptr, double *file_gamma))
2055 PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,
2056 (png_const_structrp png_ptr, png_const_inforp info_ptr,
2057 png_fixed_point *int_file_gamma))
2058 #endif
2059
2060 #ifdef PNG_gAMA_SUPPORTED
2061 PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,
2062 png_inforp info_ptr, double file_gamma))
2063 PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,
2064 png_inforp info_ptr, png_fixed_point int_file_gamma))
2065 #endif
2066
2067 #ifdef PNG_hIST_SUPPORTED
2068 PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
2069 png_inforp info_ptr, png_uint_16p *hist));
2775 * 4: Three color channels and an alpha channel (RGBA).
2776 *
2777 * The components are encoded in one of two ways:
2778 *
2779 * a) As a small integer, value 0..255, contained in a single byte. For the
2780 * alpha channel the original value is simply value/255. For the color or
2781 * luminance channels the value is encoded according to the sRGB specification
2782 * and matches the 8-bit format expected by typical display devices.
2783 *
2784 * The color/gray channels are not scaled (pre-multiplied) by the alpha
2785 * channel and are suitable for passing to color management software.
2786 *
2787 * b) As a value in the range 0..65535, contained in a 2-byte integer. All
2788 * channels can be converted to the original value by dividing by 65535; all
2789 * channels are linear. Color channels use the RGB encoding (RGB end-points) of
2790 * the sRGB specification. This encoding is identified by the
2791 * PNG_FORMAT_FLAG_LINEAR flag below.
2792 *
2793 * When the simplified API needs to convert between sRGB and linear colorspaces,
2794 * the actual sRGB transfer curve defined in the sRGB specification (see the
2795 * article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
2796 * approximation used elsewhere in libpng.
2797 *
2798 * When an alpha channel is present it is expected to denote pixel coverage
2799 * of the color or luminance channels and is returned as an associated alpha
2800 * channel: the color/gray channels are scaled (pre-multiplied) by the alpha
2801 * value.
2802 *
2803 * The samples are either contained directly in the image data, between 1 and 8
2804 * bytes per pixel according to the encoding, or are held in a color-map indexed
2805 * by bytes in the image data. In the case of a color-map the color-map entries
2806 * are individual samples, encoded as above, and the image data has one byte per
2807 * pixel to select the relevant sample from the color-map.
2808 */
2809
2810 /* PNG_FORMAT_*
2811 *
2812 * #defines to be used in png_image::format. Each #define identifies a
2813 * particular layout of sample data and, if present, alpha values. There are
2814 * separate defines for each of the two component encodings.
2815 *
2978 #define PNG_IMAGE_SIZE(image)\
2979 PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
2980 /* Return the size, in bytes, of the image in memory given just a png_image;
2981 * the row stride is the minimum stride required for the image.
2982 */
2983
2984 #define PNG_IMAGE_COLORMAP_SIZE(image)\
2985 (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
2986 /* Return the size, in bytes, of the color-map of this image. If the image
2987 * format is not a color-map format this will return a size sufficient for
2988 * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if
2989 * you don't want to allocate a color-map in this case.
2990 */
2991
2992 /* PNG_IMAGE_FLAG_*
2993 *
2994 * Flags containing additional information about the image are held in the
2995 * 'flags' field of png_image.
2996 */
2997 #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01
2998 /* This indicates the the RGB values of the in-memory bitmap do not
2999 * correspond to the red, green and blue end-points defined by sRGB.
3000 */
3001
3002 #define PNG_IMAGE_FLAG_FAST 0x02
3003 /* On write emphasise speed over compression; the resultant PNG file will be
3004 * larger but will be produced significantly faster, particular for large
3005 * images. Do not use this option for images which will be distributed, only
3006 * used it when producing intermediate files that will be read back in
3007 * repeatedly. For a typical 24-bit image the option will double the read
3008 * speed at the cost of increasing the image size by 25%, however for many
3009 * more compressible images the PNG file can be 10 times larger with only a
3010 * slight speed gain.
3011 */
3012
3013 #define PNG_IMAGE_FLAG_16BIT_sRGB 0x04
3014 /* On read if the image is a 16-bit per component image and there is no gAMA
3015 * or sRGB chunk assume that the components are sRGB encoded. Notice that
3016 * images output by the simplified API always have gamma information; setting
3017 * this flag only affects the interpretation of 16-bit images from an
3018 * external source. It is recommended that the application expose this flag
|
7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 * libpng version 1.6.37 - April 14, 2019
28 *
29 * Copyright (c) 2018-2019 Cosmin Truta
30 * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
31 * Copyright (c) 1996-1997 Andreas Dilger
32 * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
33 *
34 * This code is released under the libpng license. (See LICENSE, below.)
35 *
36 * Authors and maintainers:
37 * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
38 * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
39 * libpng versions 0.97, January 1998, through 1.6.35, July 2018:
40 * Glenn Randers-Pehrson
41 * libpng versions 1.6.36, December 2018, through 1.6.37, April 2019:
42 * Cosmin Truta
43 * See also "Contributing Authors", below.
44 */
45
46 /*
47 * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
48 * =========================================
49 *
50 * PNG Reference Library License version 2
51 * ---------------------------------------
52 *
53 * * Copyright (c) 1995-2019 The PNG Reference Library Authors.
54 * * Copyright (c) 2018-2019 Cosmin Truta.
55 * * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
56 * * Copyright (c) 1996-1997 Andreas Dilger.
57 * * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
58 *
59 * The software is supplied "as is", without warranty of any kind,
60 * express or implied, including, without limitation, the warranties
61 * of merchantability, fitness for a particular purpose, title, and
62 * non-infringement. In no event shall the Copyright owners, or
63 * anyone distributing the software, be liable for any damages or
64 * other liability, whether in contract, tort or otherwise, arising
65 * from, out of, or in connection with the software, or the use or
66 * other dealings in the software, even if advised of the possibility
67 * of such damage.
68 *
69 * Permission is hereby granted to use, copy, modify, and distribute
70 * this software, or portions hereof, for any purpose, without fee,
71 * subject to the following restrictions:
72 *
73 * 1. The origin of this software must not be misrepresented; you
74 * must not claim that you wrote the original software. If you
75 * use this software in a product, an acknowledgment in the product
76 * documentation would be appreciated, but is not required.
77 *
78 * 2. Altered source versions must be plainly marked as such, and must
79 * not be misrepresented as being the original software.
80 *
81 * 3. This Copyright notice may not be removed or altered from any
82 * source or altered source distribution.
83 *
84 *
85 * PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
86 * -----------------------------------------------------------------------
87 *
88 * libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
89 * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
90 * derived from libpng-1.0.6, and are distributed according to the same
91 * disclaimer and license as libpng-1.0.6 with the following individuals
92 * added to the list of Contributing Authors:
93 *
94 * Simon-Pierre Cadieux
95 * Eric S. Raymond
96 * Mans Rullgard
97 * Cosmin Truta
98 * Gilles Vollant
99 * James Yu
100 * Mandar Sahastrabuddhe
101 * Google Inc.
102 * Vadim Barkov
103 *
104 * and with the following additions to the disclaimer:
105 *
106 * There is no warranty against interference with your enjoyment of
107 * the library or against infringement. There is no warranty that our
108 * efforts or the library will fulfill any of your particular purposes
109 * or needs. This library is provided with all faults, and the entire
110 * risk of satisfactory quality, performance, accuracy, and effort is
111 * with the user.
112 *
113 * Some files in the "contrib" directory and some configure-generated
114 * files that are distributed with libpng have other copyright owners, and
115 * are released under other open source licenses.
116 *
117 * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
118 * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
119 * libpng-0.96, and are distributed according to the same disclaimer and
120 * license as libpng-0.96, with the following individuals added to the
121 * list of Contributing Authors:
122 *
123 * Tom Lane
124 * Glenn Randers-Pehrson
125 * Willem van Schaik
126 *
127 * libpng versions 0.89, June 1996, through 0.96, May 1997, are
128 * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
129 * and are distributed according to the same disclaimer and license as
130 * libpng-0.88, with the following individuals added to the list of
131 * Contributing Authors:
132 *
133 * John Bowler
134 * Kevin Bracey
135 * Sam Bushell
136 * Magnus Holmgren
137 * Greg Roelofs
138 * Tom Tanner
139 *
140 * Some files in the "scripts" directory have other copyright owners,
141 * but are released under this license.
142 *
143 * libpng versions 0.5, May 1995, through 0.88, January 1996, are
144 * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
145 *
146 * For the purposes of this copyright and license, "Contributing Authors"
147 * is defined as the following set of individuals:
148 *
149 * Andreas Dilger
150 * Dave Martindale
151 * Guy Eric Schalnat
152 * Paul Schmidt
153 * Tim Wegner
154 *
155 * The PNG Reference Library is supplied "AS IS". The Contributing
156 * Authors and Group 42, Inc. disclaim all warranties, expressed or
157 * implied, including, without limitation, the warranties of
158 * merchantability and of fitness for any purpose. The Contributing
159 * Authors and Group 42, Inc. assume no liability for direct, indirect,
160 * incidental, special, exemplary, or consequential damages, which may
161 * result from the use of the PNG Reference Library, even if advised of
162 * the possibility of such damage.
163 *
164 * Permission is hereby granted to use, copy, modify, and distribute this
165 * source code, or portions hereof, for any purpose, without fee, subject
166 * to the following restrictions:
167 *
168 * 1. The origin of this source code must not be misrepresented.
169 *
170 * 2. Altered versions must be plainly marked as such and must not
171 * be misrepresented as being the original source.
172 *
173 * 3. This Copyright notice may not be removed or altered from any
174 * source or altered source distribution.
175 *
176 * The Contributing Authors and Group 42, Inc. specifically permit,
177 * without fee, and encourage the use of this source code as a component
178 * to supporting the PNG file format in commercial products. If you use
179 * this source code in a product, acknowledgment is not required but would
180 * be appreciated.
181 *
182 * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
183 *
184 * TRADEMARK
185 * =========
186 *
187 * The name "libpng" has not been registered by the Copyright owners
188 * as a trademark in any jurisdiction. However, because libpng has
189 * been distributed and maintained world-wide, continually since 1995,
190 * the Copyright owners claim "common-law trademark protection" in any
191 * jurisdiction where common-law trademark is recognized.
192 */
193
194 /*
195 * A "png_get_copyright" function is available, for convenient use in "about"
196 * boxes and the like:
197 *
198 * printf("%s", png_get_copyright(NULL));
199 *
200 * Also, the PNG logo (in PNG format, of course) is supplied in the
201 * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
202 */
203
204 /*
205 * The contributing authors would like to thank all those who helped
206 * with testing, bug fixes, and patience. This wouldn't have been
207 * possible without all of you.
208 *
209 * Thanks to Frank J. T. Wojcik for helping with the documentation.
210 */
211
237 * 1.0.2a-b 10003 version, except as noted.
238 * 1.0.3 10003
239 * 1.0.3a-d 10004
240 * 1.0.4 10004
241 * 1.0.4a-f 10005
242 * 1.0.5 (+ 2 patches) 10005
243 * 1.0.5a-d 10006
244 * 1.0.5e-r 10100 (not source compatible)
245 * 1.0.5s-v 10006 (not binary compatible)
246 * 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
247 * 1.0.6d-f 10007 (still binary incompatible)
248 * 1.0.6g 10007
249 * 1.0.6h 10007 10.6h (testing xy.z so-numbering)
250 * 1.0.6i 10007 10.6i
251 * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
252 * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible)
253 * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
254 * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
255 * 1.0.7 1 10007 (still compatible)
256 * ...
257 * 1.0.69 10 10069 10.so.0.69[.0]
258 * ...
259 * 1.2.59 13 10259 12.so.0.59[.0]
260 * ...
261 * 1.4.20 14 10420 14.so.0.20[.0]
262 * ...
263 * 1.5.30 15 10530 15.so.15.30[.0]
264 * ...
265 * 1.6.37 16 10637 16.so.16.37[.0]
266 *
267 * Henceforth the source version will match the shared-library major and
268 * minor numbers; the shared-library major version number will be used for
269 * changes in backward compatibility, as it is intended.
270 * The PNG_LIBPNG_VER macro, which is not used within libpng but is
271 * available for applications, is an unsigned integer of the form XYYZZ
272 * corresponding to the source version X.Y.Z (leading zeros in Y and Z).
273 * Beta versions were given the previous public release number plus a
274 * letter, until version 1.0.6j; from then on they were given the upcoming
275 * public release number plus "betaNN" or "rcNN".
276 *
277 * Binary incompatibility exists only when applications make direct access
278 * to the info_ptr or png_ptr members through png.h, and the compiled
279 * application is loaded with a different version of the library.
280 *
281 * DLLNUM will change each time there are forward or backward changes
282 * in binary compatibility (e.g., when a new feature is added).
283 *
284 * See libpng.txt or libpng.3 for more information. The PNG specification
285 * is available as a W3C Recommendation and as an ISO/IEC Standard; see
286 * <https://www.w3.org/TR/2003/REC-PNG-20031110/>
287 */
288
289 #ifndef PNG_H
290 #define PNG_H
291
292 /* This is not the place to learn how to use libpng. The file libpng-manual.txt
293 * describes how to use libpng, and the file example.c summarizes it
294 * with some code on which to build. This file is useful for looking
295 * at the actual function definitions and structure components. If that
296 * file has been stripped from your copy of libpng, you can find it at
297 * <http://www.libpng.org/pub/png/libpng-manual.txt>
298 *
299 * If you just need to read a PNG file and don't want to read the documentation
300 * skip to the end of this file and read the section entitled 'simplified API'.
301 */
302
303 /* Version information for png.h - this should match the version in png.c */
304 #define PNG_LIBPNG_VER_STRING "1.6.37"
305 #define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n"
306
307 #define PNG_LIBPNG_VER_SONUM 16
308 #define PNG_LIBPNG_VER_DLLNUM 16
309
310 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
311 #define PNG_LIBPNG_VER_MAJOR 1
312 #define PNG_LIBPNG_VER_MINOR 6
313 #define PNG_LIBPNG_VER_RELEASE 37
314
315 /* This should be zero for a public release, or non-zero for a
316 * development version. [Deprecated]
317 */
318 #define PNG_LIBPNG_VER_BUILD 0
319
320 /* Release Status */
321 #define PNG_LIBPNG_BUILD_ALPHA 1
322 #define PNG_LIBPNG_BUILD_BETA 2
323 #define PNG_LIBPNG_BUILD_RC 3
324 #define PNG_LIBPNG_BUILD_STABLE 4
325 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
326
327 /* Release-Specific Flags */
328 #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
329 PNG_LIBPNG_BUILD_STABLE only */
330 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
331 PNG_LIBPNG_BUILD_SPECIAL */
332 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
333 PNG_LIBPNG_BUILD_PRIVATE */
334
335 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
336
337 /* Careful here. At one time, Guy wanted to use 082, but that
338 * would be octal. We must not include leading zeros.
339 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here
340 * (only version 1.0.0 was mis-numbered 100 instead of 10000).
341 * From version 1.0.1 it is:
342 * XXYYZZ, where XX=major, YY=minor, ZZ=release
343 */
344 #define PNG_LIBPNG_VER 10637 /* 1.6.37 */
345
346 /* Library configuration: these options cannot be changed after
347 * the library has been built.
348 */
349 #ifndef PNGLCONF_H
350 /* If pnglibconf.h is missing, you can
351 * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
352 */
353 # include "pnglibconf.h"
354 #endif
355
356 #ifndef PNG_VERSION_INFO_ONLY
357 /* Machine specific configuration. */
358 # include "pngconf.h"
359 #endif
360
361 /*
362 * Added at libpng-1.2.8
363 *
364 * Ref MSDN: Private as priority over Special
434 * does not use division?
435 * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'
436 * algorithm.
437 * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.
438 *
439 * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is
440 * false?
441 * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error
442 * APIs to png_warning.
443 * Otherwise the calls are mapped to png_error.
444 */
445
446 /* Section 3: type definitions, including structures and compile time
447 * constants.
448 * See pngconf.h for base types that vary by machine/system
449 */
450
451 /* This triggers a compiler error in png.c, if png.c and png.h
452 * do not agree upon the version number.
453 */
454 typedef char* png_libpng_version_1_6_37;
455
456 /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
457 *
458 * png_struct is the cache of information used while reading or writing a single
459 * PNG file. One of these is always required, although the simplified API
460 * (below) hides the creation and destruction of it.
461 */
462 typedef struct png_struct_def png_struct;
463 typedef const png_struct * png_const_structp;
464 typedef png_struct * png_structp;
465 typedef png_struct * * png_structpp;
466
467 /* png_info contains information read from or to be written to a PNG file. One
468 * or more of these must exist while reading or creating a PNG file. The
469 * information is not used by libpng during read but is used to control what
470 * gets written when a PNG file is created. "png_get_" function calls read
471 * information during read and "png_set_" functions calls write information
472 * when creating a PNG.
473 * been moved into a separate header file that is not accessible to
474 * applications. Read libpng-manual.txt or libpng.3 for more info.
1988 double green_X, double green_Y, double green_Z, double blue_X,
1989 double blue_Y, double blue_Z))
1990 PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,
1991 png_inforp info_ptr, png_fixed_point int_white_x,
1992 png_fixed_point int_white_y, png_fixed_point int_red_x,
1993 png_fixed_point int_red_y, png_fixed_point int_green_x,
1994 png_fixed_point int_green_y, png_fixed_point int_blue_x,
1995 png_fixed_point int_blue_y))
1996 PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
1997 png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,
1998 png_fixed_point int_red_Z, png_fixed_point int_green_X,
1999 png_fixed_point int_green_Y, png_fixed_point int_green_Z,
2000 png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
2001 png_fixed_point int_blue_Z))
2002 #endif
2003
2004 #ifdef PNG_eXIf_SUPPORTED
2005 PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
2006 png_inforp info_ptr, png_bytep *exif));
2007 PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
2008 png_inforp info_ptr, png_bytep exif));
2009
2010 PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr,
2011 png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif));
2012 PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr,
2013 png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif));
2014 #endif
2015
2016 #ifdef PNG_gAMA_SUPPORTED
2017 PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,
2018 png_const_inforp info_ptr, double *file_gamma))
2019 PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,
2020 (png_const_structrp png_ptr, png_const_inforp info_ptr,
2021 png_fixed_point *int_file_gamma))
2022 #endif
2023
2024 #ifdef PNG_gAMA_SUPPORTED
2025 PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,
2026 png_inforp info_ptr, double file_gamma))
2027 PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,
2028 png_inforp info_ptr, png_fixed_point int_file_gamma))
2029 #endif
2030
2031 #ifdef PNG_hIST_SUPPORTED
2032 PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
2033 png_inforp info_ptr, png_uint_16p *hist));
2739 * 4: Three color channels and an alpha channel (RGBA).
2740 *
2741 * The components are encoded in one of two ways:
2742 *
2743 * a) As a small integer, value 0..255, contained in a single byte. For the
2744 * alpha channel the original value is simply value/255. For the color or
2745 * luminance channels the value is encoded according to the sRGB specification
2746 * and matches the 8-bit format expected by typical display devices.
2747 *
2748 * The color/gray channels are not scaled (pre-multiplied) by the alpha
2749 * channel and are suitable for passing to color management software.
2750 *
2751 * b) As a value in the range 0..65535, contained in a 2-byte integer. All
2752 * channels can be converted to the original value by dividing by 65535; all
2753 * channels are linear. Color channels use the RGB encoding (RGB end-points) of
2754 * the sRGB specification. This encoding is identified by the
2755 * PNG_FORMAT_FLAG_LINEAR flag below.
2756 *
2757 * When the simplified API needs to convert between sRGB and linear colorspaces,
2758 * the actual sRGB transfer curve defined in the sRGB specification (see the
2759 * article at <https://en.wikipedia.org/wiki/SRGB>) is used, not the gamma=1/2.2
2760 * approximation used elsewhere in libpng.
2761 *
2762 * When an alpha channel is present it is expected to denote pixel coverage
2763 * of the color or luminance channels and is returned as an associated alpha
2764 * channel: the color/gray channels are scaled (pre-multiplied) by the alpha
2765 * value.
2766 *
2767 * The samples are either contained directly in the image data, between 1 and 8
2768 * bytes per pixel according to the encoding, or are held in a color-map indexed
2769 * by bytes in the image data. In the case of a color-map the color-map entries
2770 * are individual samples, encoded as above, and the image data has one byte per
2771 * pixel to select the relevant sample from the color-map.
2772 */
2773
2774 /* PNG_FORMAT_*
2775 *
2776 * #defines to be used in png_image::format. Each #define identifies a
2777 * particular layout of sample data and, if present, alpha values. There are
2778 * separate defines for each of the two component encodings.
2779 *
2942 #define PNG_IMAGE_SIZE(image)\
2943 PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
2944 /* Return the size, in bytes, of the image in memory given just a png_image;
2945 * the row stride is the minimum stride required for the image.
2946 */
2947
2948 #define PNG_IMAGE_COLORMAP_SIZE(image)\
2949 (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
2950 /* Return the size, in bytes, of the color-map of this image. If the image
2951 * format is not a color-map format this will return a size sufficient for
2952 * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if
2953 * you don't want to allocate a color-map in this case.
2954 */
2955
2956 /* PNG_IMAGE_FLAG_*
2957 *
2958 * Flags containing additional information about the image are held in the
2959 * 'flags' field of png_image.
2960 */
2961 #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01
2962 /* This indicates that the RGB values of the in-memory bitmap do not
2963 * correspond to the red, green and blue end-points defined by sRGB.
2964 */
2965
2966 #define PNG_IMAGE_FLAG_FAST 0x02
2967 /* On write emphasise speed over compression; the resultant PNG file will be
2968 * larger but will be produced significantly faster, particular for large
2969 * images. Do not use this option for images which will be distributed, only
2970 * used it when producing intermediate files that will be read back in
2971 * repeatedly. For a typical 24-bit image the option will double the read
2972 * speed at the cost of increasing the image size by 25%, however for many
2973 * more compressible images the PNG file can be 10 times larger with only a
2974 * slight speed gain.
2975 */
2976
2977 #define PNG_IMAGE_FLAG_16BIT_sRGB 0x04
2978 /* On read if the image is a 16-bit per component image and there is no gAMA
2979 * or sRGB chunk assume that the components are sRGB encoded. Notice that
2980 * images output by the simplified API always have gamma information; setting
2981 * this flag only affects the interpretation of 16-bit images from an
2982 * external source. It is recommended that the application expose this flag
|