< prev index next >

src/java.desktop/share/native/libsplashscreen/libpng/png.h

Print this page




  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.20, December 3, 2015
  33  *
  34  * Copyright (c) 1998-2015 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.20, December 3, 2015:
  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.20, December 3, 2015, are
  57  * Copyright (c) 2000-2002, 2004, 2006-2015 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  *
  69  * and with the following additions to the disclaimer:
  70  *
  71  *    There is no warranty against interference with your enjoyment of the
  72  *    library or against infringement.  There is no warranty that our
  73  *    efforts or the library will fulfill any of your particular purposes
  74  *    or needs.  This library is provided with all faults, and the entire
  75  *    risk of satisfactory quality, performance, accuracy, and effort is with
  76  *    the user.
  77  *




  78  * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  79  * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
  80  * libpng-0.96, and are distributed according to the same disclaimer and
  81  * license as libpng-0.96, with the following individuals added to the list
  82  * of Contributing Authors:
  83  *
  84  *    Tom Lane
  85  *    Glenn Randers-Pehrson
  86  *    Willem van Schaik
  87  *



  88  * libpng versions 0.89, June 1996, through 0.96, May 1997, are
  89  * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
  90  * and are distributed according to the same disclaimer and license as
  91  * libpng-0.88, with the following individuals added to the list of
  92  * Contributing Authors:
  93  *
  94  *    John Bowler
  95  *    Kevin Bracey
  96  *    Sam Bushell
  97  *    Magnus Holmgren
  98  *    Greg Roelofs
  99  *    Tom Tanner
 100  *



 101  * libpng versions 0.5, May 1995, through 0.88, January 1996, are
 102  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
 103  *
 104  * For the purposes of this copyright and license, "Contributing Authors"
 105  * is defined as the following set of individuals:
 106  *
 107  *    Andreas Dilger
 108  *    Dave Martindale
 109  *    Guy Eric Schalnat
 110  *    Paul Schmidt
 111  *    Tim Wegner
 112  *
 113  * The PNG Reference Library is supplied "AS IS".  The Contributing Authors
 114  * and Group 42, Inc. disclaim all warranties, expressed or implied,
 115  * including, without limitation, the warranties of merchantability and of
 116  * fitness for any purpose.  The Contributing Authors and Group 42, Inc.
 117  * assume no liability for direct, indirect, incidental, special, exemplary,
 118  * or consequential damages, which may result from the use of the PNG
 119  * Reference Library, even if advised of the possibility of such damage.
 120  *
 121  * Permission is hereby granted to use, copy, modify, and distribute this
 122  * source code, or portions hereof, for any purpose, without fee, subject
 123  * to the following restrictions:
 124  *
 125  *   1. The origin of this source code must not be misrepresented.
 126  *
 127  *   2. Altered versions must be plainly marked as such and must not
 128  *      be misrepresented as being the original source.
 129  *
 130  *   3. This Copyright notice may not be removed or altered from any
 131  *      source or altered source distribution.
 132  *
 133  * The Contributing Authors and Group 42, Inc. specifically permit, without
 134  * fee, and encourage the use of this source code as a component to
 135  * supporting the PNG file format in commercial products.  If you use this
 136  * source code in a product, acknowledgment is not required but would be
 137  * appreciated.
 138  *
 139  * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.























 140  */
 141 
 142 /*
 143  * A "png_get_copyright" function is available, for convenient use in "about"
 144  * boxes and the like:
 145  *
 146  *    printf("%s", png_get_copyright(NULL));
 147  *
 148  * Also, the PNG logo (in PNG format, of course) is supplied in the
 149  * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
 150  */
 151 
 152 /*
 153  * Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
 154  * a certification mark of the Open Source Initiative. OSI has not addressed
 155  * the additional disclaimers inserted at version 1.0.7.
 156  */
 157 
 158 /*
 159  * The contributing authors would like to thank all those who helped
 160  * with testing, bug fixes, and patience.  This wouldn't have been
 161  * possible without all of you.
 162  *
 163  * Thanks to Frank J. T. Wojcik for helping with the documentation.
 164  */
 165 
 166 /* Note about libpng version numbers:
 167  *
 168  *    Due to various miscommunications, unforeseen code incompatibilities
 169  *    and occasional factors outside the authors' control, version numbering
 170  *    on the library has not always been consistent and straightforward.
 171  *    The following table summarizes matters since version 0.89c, which was
 172  *    the first widely used release:
 173  *
 174  *    source                 png.h  png.h  shared-lib
 175  *    version                string   int  version
 176  *    -------                ------ -----  ----------
 177  *    0.89c "1.0 beta 3"     0.89      89  1.0.89
 178  *    0.90  "1.0 beta 4"     0.90      90  0.90  [should have been 2.0.90]


 193  *    1.0.3a-d                      10004
 194  *    1.0.4                         10004
 195  *    1.0.4a-f                      10005
 196  *    1.0.5 (+ 2 patches)           10005
 197  *    1.0.5a-d                      10006
 198  *    1.0.5e-r                      10100 (not source compatible)
 199  *    1.0.5s-v                      10006 (not binary compatible)
 200  *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)
 201  *    1.0.6d-f                      10007 (still binary incompatible)
 202  *    1.0.6g                        10007
 203  *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)
 204  *    1.0.6i                        10007  10.6i
 205  *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)
 206  *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)
 207  *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)
 208  *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
 209  *    1.0.7                    1    10007  (still compatible)
 210  *    ...
 211  *    1.0.19                  10    10019  10.so.0.19[.0]
 212  *    ...
 213  *    1.2.53                  13    10253  12.so.0.53[.0]
 214  *    ...
 215  *    1.5.23                  15    10523  15.so.15.23[.0]
 216  *    ...
 217  *    1.6.20                  16    10620  16.so.16.20[.0]
 218  *
 219  *    Henceforth the source version will match the shared-library major
 220  *    and minor numbers; the shared-library major version number will be
 221  *    used for changes in backward compatibility, as it is intended.  The
 222  *    PNG_LIBPNG_VER macro, which is not used within libpng but is available
 223  *    for applications, is an unsigned integer of the form xyyzz corresponding
 224  *    to the source version x.y.z (leading zeros in y and z).  Beta versions
 225  *    were given the previous public release number plus a letter, until
 226  *    version 1.0.6j; from then on they were given the upcoming public
 227  *    release number plus "betaNN" or "rcNN".
 228  *
 229  *    Binary incompatibility exists only when applications make direct access
 230  *    to the info_ptr or png_ptr members through png.h, and the compiled
 231  *    application is loaded with a different version of the library.
 232  *
 233  *    DLLNUM will change each time there are forward or backward changes
 234  *    in binary compatibility (e.g., when a new feature is added).
 235  *
 236  * See libpng.txt or libpng.3 for more information.  The PNG specification
 237  * is available as a W3C Recommendation and as an ISO Specification,
 238  * <http://www.w3.org/TR/2003/REC-PNG-20031110/
 239  */
 240 
 241 /*
 242  * Y2K compliance in libpng:
 243  * =========================
 244  *
 245  *    December 3, 2015
 246  *
 247  *    Since the PNG Development group is an ad-hoc body, we can't make
 248  *    an official declaration.
 249  *
 250  *    This is your unofficial assurance that libpng from version 0.71 and
 251  *    upward through 1.6.20 are Y2K compliant.  It is my belief that
 252  *    earlier versions were also Y2K compliant.
 253  *
 254  *    Libpng only has two year fields.  One is a 2-byte unsigned integer
 255  *    that will hold years up to 65535.  The other, which is deprecated,
 256  *    holds the date in text format, and will hold years up to 9999.
 257  *
 258  *    The integer is
 259  *        "png_uint_16 year" in png_time_struct.
 260  *
 261  *    The string is
 262  *        "char time_buffer[29]" in png_struct.  This is no longer used
 263  *    in libpng-1.6.x and will be removed from libpng-1.7.0.
 264  *
 265  *    There are seven time-related functions:
 266  *        png.c: png_convert_to_rfc_1123_buffer() in png.c
 267  *          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
 268  *          png_convert_to_rfc_1152() in error prior to libpng-0.98)
 269  *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
 270  *        png_convert_from_time_t() in pngwrite.c
 271  *        png_get_tIME() in pngget.c


 293  *       Glenn Randers-Pehrson
 294  *       libpng maintainer
 295  *       PNG Development Group
 296  */
 297 
 298 #ifndef PNG_H
 299 #define PNG_H
 300 
 301 /* This is not the place to learn how to use libpng. The file libpng-manual.txt
 302  * describes how to use libpng, and the file example.c summarizes it
 303  * with some code on which to build.  This file is useful for looking
 304  * at the actual function definitions and structure components.  If that
 305  * file has been stripped from your copy of libpng, you can find it at
 306  * <http://www.libpng.org/pub/png/libpng-manual.txt>
 307  *
 308  * If you just need to read a PNG file and don't want to read the documentation
 309  * skip to the end of this file and read the section entitled 'simplified API'.
 310  */
 311 
 312 /* Version information for png.h - this should match the version in png.c */
 313 #define PNG_LIBPNG_VER_STRING "1.6.20"
 314 #define PNG_HEADER_VERSION_STRING \
 315      " libpng version 1.6.20 - December 3, 2015\n"
 316 
 317 #define PNG_LIBPNG_VER_SONUM   16
 318 #define PNG_LIBPNG_VER_DLLNUM  16
 319 
 320 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 321 #define PNG_LIBPNG_VER_MAJOR   1
 322 #define PNG_LIBPNG_VER_MINOR   6
 323 #define PNG_LIBPNG_VER_RELEASE 20
 324 
 325 /* This should match the numeric part of the final component of
 326  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
 327  */
 328 
 329 #define PNG_LIBPNG_VER_BUILD  0
 330 
 331 /* Release Status */
 332 #define PNG_LIBPNG_BUILD_ALPHA    1
 333 #define PNG_LIBPNG_BUILD_BETA     2
 334 #define PNG_LIBPNG_BUILD_RC       3
 335 #define PNG_LIBPNG_BUILD_STABLE   4
 336 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
 337 
 338 /* Release-Specific Flags */
 339 #define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with
 340                                        PNG_LIBPNG_BUILD_STABLE only */
 341 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
 342                                        PNG_LIBPNG_BUILD_SPECIAL */
 343 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
 344                                        PNG_LIBPNG_BUILD_PRIVATE */
 345 
 346 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
 347 
 348 /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
 349  * We must not include leading zeros.
 350  * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
 351  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
 352  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
 353  */
 354 #define PNG_LIBPNG_VER 10620 /* 1.6.20 */
 355 
 356 /* Library configuration: these options cannot be changed after
 357  * the library has been built.
 358  */
 359 #ifndef PNGLCONF_H
 360     /* If pnglibconf.h is missing, you can
 361      * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
 362      */
 363 #   include "pnglibconf.h"
 364 #endif
 365 
 366 #ifndef PNG_VERSION_INFO_ONLY
 367    /* Machine specific configuration. */
 368 #  include "pngconf.h"
 369 #endif
 370 
 371 /*
 372  * Added at libpng-1.2.8
 373  *
 374  * Ref MSDN: Private as priority over Special


 444  * does not use division?
 445  *   PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'
 446  *      algorithm.
 447  *   PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.
 448  *
 449  * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is
 450  * false?
 451  *   PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error
 452  *      APIs to png_warning.
 453  * Otherwise the calls are mapped to png_error.
 454  */
 455 
 456 /* Section 3: type definitions, including structures and compile time
 457  * constants.
 458  * See pngconf.h for base types that vary by machine/system
 459  */
 460 
 461 /* This triggers a compiler error in png.c, if png.c and png.h
 462  * do not agree upon the version number.
 463  */
 464 typedef char* png_libpng_version_1_6_20;
 465 
 466 /* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
 467  *
 468  * png_struct is the cache of information used while reading or writing a single
 469  * PNG file.  One of these is always required, although the simplified API
 470  * (below) hides the creation and destruction of it.
 471  */
 472 typedef struct png_struct_def png_struct;
 473 typedef const png_struct * png_const_structp;
 474 typedef png_struct * png_structp;
 475 typedef png_struct * * png_structpp;
 476 
 477 /* png_info contains information read from or to be written to a PNG file.  One
 478  * or more of these must exist while reading or creating a PNG file.  The
 479  * information is not used by libpng during read but is used to control what
 480  * gets written when a PNG file is created.  "png_get_" function calls read
 481  * information during read and "png_set_" functions calls write information
 482  * when creating a PNG.
 483  * been moved into a separate header file that is not accessible to
 484  * applications.  Read libpng-manual.txt or libpng.3 for more info.


 745 #define PNG_RESOLUTION_LAST       2 /* Not a valid value */
 746 
 747 /* These are for the sRGB chunk.  These values should NOT be changed. */
 748 #define PNG_sRGB_INTENT_PERCEPTUAL 0
 749 #define PNG_sRGB_INTENT_RELATIVE   1
 750 #define PNG_sRGB_INTENT_SATURATION 2
 751 #define PNG_sRGB_INTENT_ABSOLUTE   3
 752 #define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */
 753 
 754 /* This is for text chunks */
 755 #define PNG_KEYWORD_MAX_LENGTH     79
 756 
 757 /* Maximum number of entries in PLTE/sPLT/tRNS arrays */
 758 #define PNG_MAX_PALETTE_LENGTH    256
 759 
 760 /* These determine if an ancillary chunk's data has been successfully read
 761  * from the PNG header, or if the application has filled in the corresponding
 762  * data in the info_struct to be written into the output file.  The values
 763  * of the PNG_INFO_<chunk> defines should NOT be changed.
 764  */
 765 #define PNG_INFO_gAMA 0x0001
 766 #define PNG_INFO_sBIT 0x0002
 767 #define PNG_INFO_cHRM 0x0004
 768 #define PNG_INFO_PLTE 0x0008
 769 #define PNG_INFO_tRNS 0x0010
 770 #define PNG_INFO_bKGD 0x0020
 771 #define PNG_INFO_hIST 0x0040
 772 #define PNG_INFO_pHYs 0x0080
 773 #define PNG_INFO_oFFs 0x0100
 774 #define PNG_INFO_tIME 0x0200
 775 #define PNG_INFO_pCAL 0x0400
 776 #define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */
 777 #define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */
 778 #define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
 779 #define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
 780 #if INT_MAX >= 0x8000 /* else this might break */
 781 #define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */
 782 #endif
 783 
 784 /* This is used for the transformation routines, as some of them
 785  * change these values for the row.  It also should enable using
 786  * the routines for other purposes.
 787  */
 788 typedef struct png_row_info_struct
 789 {
 790    png_uint_32 width;    /* width of row */
 791    png_size_t rowbytes;  /* number of bytes in row */
 792    png_byte color_type;  /* color type of row */
 793    png_byte bit_depth;   /* bit depth of row */
 794    png_byte channels;    /* number of channels (1, 2, 3, or 4) */
 795    png_byte pixel_depth; /* bits per pixel (depth * channels) */
 796 } png_row_info;
 797 
 798 typedef png_row_info * png_row_infop;
 799 typedef png_row_info * * png_row_infopp;
 800 
 801 /* These are the function types for the I/O functions and for the functions
 802  * that allow the user to override the default I/O functions with his or her


1333 PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,
1334     png_const_color_16p background_color, int background_gamma_code,
1335     int need_expand, double background_gamma))
1336 PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,
1337     png_const_color_16p background_color, int background_gamma_code,
1338     int need_expand, png_fixed_point background_gamma))
1339 #endif
1340 #ifdef PNG_READ_BACKGROUND_SUPPORTED
1341 #  define PNG_BACKGROUND_GAMMA_UNKNOWN 0
1342 #  define PNG_BACKGROUND_GAMMA_SCREEN  1
1343 #  define PNG_BACKGROUND_GAMMA_FILE    2
1344 #  define PNG_BACKGROUND_GAMMA_UNIQUE  3
1345 #endif
1346 
1347 #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
1348 /* Scale a 16-bit depth file down to 8-bit, accurately. */
1349 PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));
1350 #endif
1351 
1352 #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
1353 #define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
1354 /* Strip the second byte of information from a 16-bit depth file. */
1355 PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
1356 #endif
1357 
1358 #ifdef PNG_READ_QUANTIZE_SUPPORTED
1359 /* Turn on quantizing, and reduce the palette to the number of colors
1360  * available.
1361  */
1362 PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,
1363     png_colorp palette, int num_palette, int maximum_colors,
1364     png_const_uint_16p histogram, int full_quantize));
1365 #endif
1366 
1367 #ifdef PNG_READ_GAMMA_SUPPORTED
1368 /* The threshold on gamma processing is configurable but hard-wired into the
1369  * library.  The following is the floating point variant.
1370  */
1371 #define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)
1372 
1373 /* Handle gamma correction. Screen_gamma=(display_exponent).


1484  */
1485 
1486 /* Set the filtering method(s) used by libpng.  Currently, the only valid
1487  * value for "method" is 0.
1488  */
1489 PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
1490     int filters));
1491 #endif /* WRITE */
1492 
1493 /* Flags for png_set_filter() to say which filters to use.  The flags
1494  * are chosen so that they don't conflict with real filter types
1495  * below, in case they are supplied instead of the #defined constants.
1496  * These values should NOT be changed.
1497  */
1498 #define PNG_NO_FILTERS     0x00
1499 #define PNG_FILTER_NONE    0x08
1500 #define PNG_FILTER_SUB     0x10
1501 #define PNG_FILTER_UP      0x20
1502 #define PNG_FILTER_AVG     0x40
1503 #define PNG_FILTER_PAETH   0x80
1504 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
1505                          PNG_FILTER_AVG | PNG_FILTER_PAETH)
1506 
1507 /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
1508  * These defines should NOT be changed.
1509  */
1510 #define PNG_FILTER_VALUE_NONE  0
1511 #define PNG_FILTER_VALUE_SUB   1
1512 #define PNG_FILTER_VALUE_UP    2
1513 #define PNG_FILTER_VALUE_AVG   3
1514 #define PNG_FILTER_VALUE_PAETH 4
1515 #define PNG_FILTER_VALUE_LAST  5
1516 
1517 #ifdef PNG_WRITE_SUPPORTED
1518 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
1519 PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
1520     int heuristic_method, int num_weights, png_const_doublep filter_weights,
1521     png_const_doublep filter_costs))
1522 PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
1523     (png_structrp png_ptr, int heuristic_method, int num_weights,
1524     png_const_fixed_point_p filter_weights,
1525     png_const_fixed_point_p filter_costs))


1762 
1763 /* Free data that was allocated internally */
1764 PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
1765     png_inforp info_ptr, png_uint_32 free_me, int num));
1766 
1767 /* Reassign responsibility for freeing existing data, whether allocated
1768  * by libpng or by the application; this works on the png_info structure passed
1769  * in, it does not change the state for other png_info structures.
1770  *
1771  * It is unlikely that this function works correctly as of 1.6.0 and using it
1772  * may result either in memory leaks or double free of allocated data.
1773  */
1774 PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
1775     png_inforp info_ptr, int freer, png_uint_32 mask));
1776 
1777 /* Assignments for png_data_freer */
1778 #define PNG_DESTROY_WILL_FREE_DATA 1
1779 #define PNG_SET_WILL_FREE_DATA 1
1780 #define PNG_USER_WILL_FREE_DATA 2
1781 /* Flags for png_ptr->free_me and info_ptr->free_me */
1782 #define PNG_FREE_HIST 0x0008
1783 #define PNG_FREE_ICCP 0x0010
1784 #define PNG_FREE_SPLT 0x0020
1785 #define PNG_FREE_ROWS 0x0040
1786 #define PNG_FREE_PCAL 0x0080
1787 #define PNG_FREE_SCAL 0x0100
1788 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
1789 #  define PNG_FREE_UNKN 0x0200
1790 #endif
1791 /*      PNG_FREE_LIST 0x0400    removed in 1.6.0 because it is ignored */
1792 #define PNG_FREE_PLTE 0x1000
1793 #define PNG_FREE_TRNS 0x2000
1794 #define PNG_FREE_TEXT 0x4000
1795 #define PNG_FREE_ALL  0x7fff
1796 #define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
1797 
1798 #ifdef PNG_USER_MEM_SUPPORTED
1799 PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
1800     png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);
1801 PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,
1802     png_voidp ptr), PNG_DEPRECATED);
1803 #endif
1804 
1805 #ifdef PNG_ERROR_TEXT_SUPPORTED
1806 /* Fatal error in PNG image of libpng - can't continue */
1807 PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,
1808     png_const_charp error_message), PNG_NORETURN);
1809 
1810 /* The same, but the chunk name is prepended to the error string. */
1811 PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,
1812     png_const_charp error_message), PNG_NORETURN);
1813 
1814 #else
1815 /* Fatal error in PNG image of libpng - can't continue */
1816 PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);


2900    /* The number of separate channels (components) in a pixel; 1 for a
2901     * color-mapped image.
2902     */
2903 
2904 #define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\
2905    PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)
2906    /* The size, in bytes, of each component in a pixel; 1 for a color-mapped
2907     * image.
2908     */
2909 
2910 #define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)
2911    /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */
2912 
2913 /* Information about the whole row, or whole image */
2914 #define PNG_IMAGE_ROW_STRIDE(image)\
2915    (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)
2916    /* Return the total number of components in a single row of the image; this
2917     * is the minimum 'row stride', the minimum count of components between each
2918     * row.  For a color-mapped image this is the minimum number of bytes in a
2919     * row.




2920     */
2921 
2922 #define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
2923    (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
2924    /* Return the size, in bytes, of an image buffer given a png_image and a row
2925     * stride - the number of components to leave space for in each row.



2926     */
2927 
2928 #define PNG_IMAGE_SIZE(image)\
2929    PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
2930    /* Return the size, in bytes, of the image in memory given just a png_image;
2931     * the row stride is the minimum stride required for the image.
2932     */
2933 
2934 #define PNG_IMAGE_COLORMAP_SIZE(image)\
2935    (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
2936    /* Return the size, in bytes, of the color-map of this image.  If the image
2937     * format is not a color-map format this will return a size sufficient for
2938     * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if
2939     * you don't want to allocate a color-map in this case.
2940     */
2941 
2942 /* PNG_IMAGE_FLAG_*
2943  *
2944  * Flags containing additional information about the image are held in the
2945  * 'flags' field of png_image.


3026     * 2) The format set by the application does not.
3027     * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and
3028     *    PNG_FORMAT_FLAG_LINEAR *not* set.
3029     *
3030     * For linear output removing the alpha channel is always done by compositing
3031     * on black and background is ignored.
3032     *
3033     * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set.  It must
3034     * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.
3035     * image->colormap_entries will be updated to the actual number of entries
3036     * written to the colormap; this may be less than the original value.
3037     */
3038 
3039 PNG_EXPORT(238, void, png_image_free, (png_imagep image));
3040    /* Free any data allocated by libpng in image->opaque, setting the pointer to
3041     * NULL.  May be called at any time after the structure is initialized.
3042     */
3043 #endif /* SIMPLIFIED_READ */
3044 
3045 #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
3046 #ifdef PNG_STDIO_SUPPORTED
3047 /* WRITE APIS
3048  * ----------
3049  * For write you must initialize a png_image structure to describe the image to
3050  * be written.  To do this use memset to set the whole structure to 0 then
3051  * initialize fields describing your image.
3052  *
3053  * version: must be set to PNG_IMAGE_VERSION
3054  * opaque: must be initialized to NULL
3055  * width: image width in pixels
3056  * height: image height in rows
3057  * format: the format of the data (image and color-map) you wish to write
3058  * flags: set to 0 unless one of the defined flags applies; set
3059  *    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB
3060  *    values do not correspond to the colors in sRGB.
3061  * colormap_entries: set to the number of entries in the color-map (0 to 256)
3062  */

3063 PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
3064    const char *file, int convert_to_8bit, const void *buffer,
3065    png_int_32 row_stride, const void *colormap));
3066    /* Write the image to the named file. */
3067 
3068 PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
3069    int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
3070    const void *colormap));
3071    /* Write the image to the given (FILE*). */

3072 
3073 /* With both write APIs if image is in one of the linear formats with 16-bit
3074  * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
3075  * gamma encoded according to the sRGB specification, otherwise a 16-bit linear
3076  * encoded PNG file is written.
3077  *
3078  * With color-mapped data formats the colormap parameter point to a color-map
3079  * with at least image->colormap_entries encoded in the specified format.  If
3080  * the format is linear the written PNG color-map will be converted to sRGB
3081  * regardless of the convert_to_8_bit flag.
3082  *
3083  * With all APIs row_stride is handled as in the read APIs - it is the spacing
3084  * from one row to the next in component sized units (1 or 2 bytes) and if
3085  * negative indicates a bottom-up row layout in the buffer.  If row_stride is zero,
3086  * libpng will calculate it for you from the image width and number of channels.
3087  *
3088  * Note that the write API does not support interlacing, sub-8-bit pixels, indexed
3089  * PNG (color_type 3) or most ancillary chunks.



























































































3090  */
3091 #endif /* STDIO */
3092 #endif /* SIMPLIFIED_WRITE */
3093 /*******************************************************************************
3094  *  END OF SIMPLIFIED API
3095  ******************************************************************************/
3096 #endif /* SIMPLIFIED_{READ|WRITE} */
3097 
3098 /*******************************************************************************
3099  * Section 6: IMPLEMENTATION OPTIONS
3100  *******************************************************************************
3101  *
3102  * Support for arbitrary implementation-specific optimizations.  The API allows
3103  * particular options to be turned on or off.  'Option' is the number of the
3104  * option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given
3105  * by the PNG_OPTION_ defines below.
3106  *
3107  * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
3108  *           are detected at run time, however sometimes it may be impossible
3109  *           to do this in user mode, in which case it is necessary to discover
3110  *           the capabilities in an OS specific way.  Such capabilities are
3111  *           listed here when libpng has support for them and must be turned


3129 #define PNG_OPTION_INVALID 1 /* Option number out of range */
3130 #define PNG_OPTION_OFF     2
3131 #define PNG_OPTION_ON      3
3132 
3133 PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
3134    int onoff));
3135 #endif /* SET_OPTION */
3136 
3137 /*******************************************************************************
3138  *  END OF HARDWARE AND SOFTWARE OPTIONS
3139  ******************************************************************************/
3140 
3141 /* Maintainer: Put new public prototypes here ^, in libpng.3, in project
3142  * defs, and in scripts/symbols.def.
3143  */
3144 
3145 /* The last ordinal number (this is the *last* one already used; the next
3146  * one to use is one more than this.)
3147  */
3148 #ifdef PNG_EXPORT_LAST_ORDINAL
3149   PNG_EXPORT_LAST_ORDINAL(244);
3150 #endif
3151 
3152 #ifdef __cplusplus
3153 }
3154 #endif
3155 
3156 #endif /* PNG_VERSION_INFO_ONLY */
3157 /* Do not put anything past this line */
3158 #endif /* PNG_H */


  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"
 119  * is defined as the following set of individuals:
 120  *
 121  *    Andreas Dilger
 122  *    Dave Martindale
 123  *    Guy Eric Schalnat
 124  *    Paul Schmidt
 125  *    Tim Wegner
 126  *
 127  * The PNG Reference Library is supplied "AS IS".  The Contributing Authors
 128  * and Group 42, Inc. disclaim all warranties, expressed or implied,
 129  * including, without limitation, the warranties of merchantability and of
 130  * fitness for any purpose.  The Contributing Authors and Group 42, Inc.
 131  * assume no liability for direct, indirect, incidental, special, exemplary,
 132  * or consequential damages, which may result from the use of the PNG
 133  * Reference Library, even if advised of the possibility of such damage.
 134  *
 135  * Permission is hereby granted to use, copy, modify, and distribute this
 136  * source code, or portions hereof, for any purpose, without fee, subject
 137  * to the following restrictions:
 138  *
 139  *   1. The origin of this source code must not be misrepresented.
 140  *
 141  *   2. Altered versions must be plainly marked as such and must not
 142  *      be misrepresented as being the original source.
 143  *
 144  *   3. This Copyright notice may not be removed or altered from any
 145  *      source or altered source distribution.
 146  *
 147  * The Contributing Authors and Group 42, Inc. specifically permit, without
 148  * fee, and encourage the use of this source code as a component to
 149  * supporting the PNG file format in commercial products.  If you use this
 150  * source code in a product, acknowledgment is not required but would be
 151  * appreciated.
 152  *
 153  * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
 154  *
 155  * TRADEMARK:
 156  *
 157  * The name "libpng" has not been registered by the Copyright owner
 158  * as a trademark in any jurisdiction.  However, because libpng has
 159  * been distributed and maintained world-wide, continually since 1995,
 160  * the Copyright owner claims "common-law trademark protection" in any
 161  * jurisdiction where common-law trademark is recognized.
 162  *
 163  * OSI CERTIFICATION:
 164  *
 165  * Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
 166  * a certification mark of the Open Source Initiative. OSI has not addressed
 167  * the additional disclaimers inserted at version 1.0.7.
 168  *
 169  * EXPORT CONTROL:
 170  *
 171  * The Copyright owner believes that the Export Control Classification
 172  * Number (ECCN) for libpng is EAR99, which means not subject to export
 173  * controls or International Traffic in Arms Regulations (ITAR) because
 174  * it is open source, publicly available software, that does not contain
 175  * any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
 176  * 734.7(b).
 177  */
 178 
 179 /*
 180  * A "png_get_copyright" function is available, for convenient use in "about"
 181  * boxes and the like:
 182  *
 183  *    printf("%s", png_get_copyright(NULL));
 184  *
 185  * Also, the PNG logo (in PNG format, of course) is supplied in the
 186  * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
 187  */
 188 
 189 /*






 190  * The contributing authors would like to thank all those who helped
 191  * with testing, bug fixes, and patience.  This wouldn't have been
 192  * possible without all of you.
 193  *
 194  * Thanks to Frank J. T. Wojcik for helping with the documentation.
 195  */
 196 
 197 /* Note about libpng version numbers:
 198  *
 199  *    Due to various miscommunications, unforeseen code incompatibilities
 200  *    and occasional factors outside the authors' control, version numbering
 201  *    on the library has not always been consistent and straightforward.
 202  *    The following table summarizes matters since version 0.89c, which was
 203  *    the first widely used release:
 204  *
 205  *    source                 png.h  png.h  shared-lib
 206  *    version                string   int  version
 207  *    -------                ------ -----  ----------
 208  *    0.89c "1.0 beta 3"     0.89      89  1.0.89
 209  *    0.90  "1.0 beta 4"     0.90      90  0.90  [should have been 2.0.90]


 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


 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.


 776 #define PNG_RESOLUTION_LAST       2 /* Not a valid value */
 777 
 778 /* These are for the sRGB chunk.  These values should NOT be changed. */
 779 #define PNG_sRGB_INTENT_PERCEPTUAL 0
 780 #define PNG_sRGB_INTENT_RELATIVE   1
 781 #define PNG_sRGB_INTENT_SATURATION 2
 782 #define PNG_sRGB_INTENT_ABSOLUTE   3
 783 #define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */
 784 
 785 /* This is for text chunks */
 786 #define PNG_KEYWORD_MAX_LENGTH     79
 787 
 788 /* Maximum number of entries in PLTE/sPLT/tRNS arrays */
 789 #define PNG_MAX_PALETTE_LENGTH    256
 790 
 791 /* These determine if an ancillary chunk's data has been successfully read
 792  * from the PNG header, or if the application has filled in the corresponding
 793  * data in the info_struct to be written into the output file.  The values
 794  * of the PNG_INFO_<chunk> defines should NOT be changed.
 795  */
 796 #define PNG_INFO_gAMA 0x0001U
 797 #define PNG_INFO_sBIT 0x0002U
 798 #define PNG_INFO_cHRM 0x0004U
 799 #define PNG_INFO_PLTE 0x0008U
 800 #define PNG_INFO_tRNS 0x0010U
 801 #define PNG_INFO_bKGD 0x0020U
 802 #define PNG_INFO_hIST 0x0040U
 803 #define PNG_INFO_pHYs 0x0080U
 804 #define PNG_INFO_oFFs 0x0100U
 805 #define PNG_INFO_tIME 0x0200U
 806 #define PNG_INFO_pCAL 0x0400U
 807 #define PNG_INFO_sRGB 0x0800U  /* GR-P, 0.96a */
 808 #define PNG_INFO_iCCP 0x1000U  /* ESR, 1.0.6 */
 809 #define PNG_INFO_sPLT 0x2000U  /* ESR, 1.0.6 */
 810 #define PNG_INFO_sCAL 0x4000U  /* ESR, 1.0.6 */
 811 #define PNG_INFO_IDAT 0x8000U  /* ESR, 1.0.6 */


 812 
 813 /* This is used for the transformation routines, as some of them
 814  * change these values for the row.  It also should enable using
 815  * the routines for other purposes.
 816  */
 817 typedef struct png_row_info_struct
 818 {
 819    png_uint_32 width;    /* width of row */
 820    png_size_t rowbytes;  /* number of bytes in row */
 821    png_byte color_type;  /* color type of row */
 822    png_byte bit_depth;   /* bit depth of row */
 823    png_byte channels;    /* number of channels (1, 2, 3, or 4) */
 824    png_byte pixel_depth; /* bits per pixel (depth * channels) */
 825 } png_row_info;
 826 
 827 typedef png_row_info * png_row_infop;
 828 typedef png_row_info * * png_row_infopp;
 829 
 830 /* These are the function types for the I/O functions and for the functions
 831  * that allow the user to override the default I/O functions with his or her


1362 PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,
1363     png_const_color_16p background_color, int background_gamma_code,
1364     int need_expand, double background_gamma))
1365 PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,
1366     png_const_color_16p background_color, int background_gamma_code,
1367     int need_expand, png_fixed_point background_gamma))
1368 #endif
1369 #ifdef PNG_READ_BACKGROUND_SUPPORTED
1370 #  define PNG_BACKGROUND_GAMMA_UNKNOWN 0
1371 #  define PNG_BACKGROUND_GAMMA_SCREEN  1
1372 #  define PNG_BACKGROUND_GAMMA_FILE    2
1373 #  define PNG_BACKGROUND_GAMMA_UNIQUE  3
1374 #endif
1375 
1376 #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
1377 /* Scale a 16-bit depth file down to 8-bit, accurately. */
1378 PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));
1379 #endif
1380 
1381 #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
1382 #define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */
1383 /* Strip the second byte of information from a 16-bit depth file. */
1384 PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
1385 #endif
1386 
1387 #ifdef PNG_READ_QUANTIZE_SUPPORTED
1388 /* Turn on quantizing, and reduce the palette to the number of colors
1389  * available.
1390  */
1391 PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,
1392     png_colorp palette, int num_palette, int maximum_colors,
1393     png_const_uint_16p histogram, int full_quantize));
1394 #endif
1395 
1396 #ifdef PNG_READ_GAMMA_SUPPORTED
1397 /* The threshold on gamma processing is configurable but hard-wired into the
1398  * library.  The following is the floating point variant.
1399  */
1400 #define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)
1401 
1402 /* Handle gamma correction. Screen_gamma=(display_exponent).


1513  */
1514 
1515 /* Set the filtering method(s) used by libpng.  Currently, the only valid
1516  * value for "method" is 0.
1517  */
1518 PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
1519     int filters));
1520 #endif /* WRITE */
1521 
1522 /* Flags for png_set_filter() to say which filters to use.  The flags
1523  * are chosen so that they don't conflict with real filter types
1524  * below, in case they are supplied instead of the #defined constants.
1525  * These values should NOT be changed.
1526  */
1527 #define PNG_NO_FILTERS     0x00
1528 #define PNG_FILTER_NONE    0x08
1529 #define PNG_FILTER_SUB     0x10
1530 #define PNG_FILTER_UP      0x20
1531 #define PNG_FILTER_AVG     0x40
1532 #define PNG_FILTER_PAETH   0x80
1533 #define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP)
1534 #define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH)
1535 
1536 /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
1537  * These defines should NOT be changed.
1538  */
1539 #define PNG_FILTER_VALUE_NONE  0
1540 #define PNG_FILTER_VALUE_SUB   1
1541 #define PNG_FILTER_VALUE_UP    2
1542 #define PNG_FILTER_VALUE_AVG   3
1543 #define PNG_FILTER_VALUE_PAETH 4
1544 #define PNG_FILTER_VALUE_LAST  5
1545 
1546 #ifdef PNG_WRITE_SUPPORTED
1547 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
1548 PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
1549     int heuristic_method, int num_weights, png_const_doublep filter_weights,
1550     png_const_doublep filter_costs))
1551 PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
1552     (png_structrp png_ptr, int heuristic_method, int num_weights,
1553     png_const_fixed_point_p filter_weights,
1554     png_const_fixed_point_p filter_costs))


1791 
1792 /* Free data that was allocated internally */
1793 PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
1794     png_inforp info_ptr, png_uint_32 free_me, int num));
1795 
1796 /* Reassign responsibility for freeing existing data, whether allocated
1797  * by libpng or by the application; this works on the png_info structure passed
1798  * in, it does not change the state for other png_info structures.
1799  *
1800  * It is unlikely that this function works correctly as of 1.6.0 and using it
1801  * may result either in memory leaks or double free of allocated data.
1802  */
1803 PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
1804     png_inforp info_ptr, int freer, png_uint_32 mask));
1805 
1806 /* Assignments for png_data_freer */
1807 #define PNG_DESTROY_WILL_FREE_DATA 1
1808 #define PNG_SET_WILL_FREE_DATA 1
1809 #define PNG_USER_WILL_FREE_DATA 2
1810 /* Flags for png_ptr->free_me and info_ptr->free_me */
1811 #define PNG_FREE_HIST 0x0008U
1812 #define PNG_FREE_ICCP 0x0010U
1813 #define PNG_FREE_SPLT 0x0020U
1814 #define PNG_FREE_ROWS 0x0040U
1815 #define PNG_FREE_PCAL 0x0080U
1816 #define PNG_FREE_SCAL 0x0100U
1817 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
1818 #  define PNG_FREE_UNKN 0x0200U
1819 #endif
1820 /*      PNG_FREE_LIST 0x0400U   removed in 1.6.0 because it is ignored */
1821 #define PNG_FREE_PLTE 0x1000U
1822 #define PNG_FREE_TRNS 0x2000U
1823 #define PNG_FREE_TEXT 0x4000U
1824 #define PNG_FREE_ALL  0x7fffU
1825 #define PNG_FREE_MUL  0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
1826 
1827 #ifdef PNG_USER_MEM_SUPPORTED
1828 PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
1829     png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);
1830 PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,
1831     png_voidp ptr), PNG_DEPRECATED);
1832 #endif
1833 
1834 #ifdef PNG_ERROR_TEXT_SUPPORTED
1835 /* Fatal error in PNG image of libpng - can't continue */
1836 PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,
1837     png_const_charp error_message), PNG_NORETURN);
1838 
1839 /* The same, but the chunk name is prepended to the error string. */
1840 PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,
1841     png_const_charp error_message), PNG_NORETURN);
1842 
1843 #else
1844 /* Fatal error in PNG image of libpng - can't continue */
1845 PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);


2929    /* The number of separate channels (components) in a pixel; 1 for a
2930     * color-mapped image.
2931     */
2932 
2933 #define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\
2934    PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)
2935    /* The size, in bytes, of each component in a pixel; 1 for a color-mapped
2936     * image.
2937     */
2938 
2939 #define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)
2940    /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */
2941 
2942 /* Information about the whole row, or whole image */
2943 #define PNG_IMAGE_ROW_STRIDE(image)\
2944    (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)
2945    /* Return the total number of components in a single row of the image; this
2946     * is the minimum 'row stride', the minimum count of components between each
2947     * row.  For a color-mapped image this is the minimum number of bytes in a
2948     * row.
2949     *
2950     * WARNING: this macro overflows for some images with more than one component
2951     * and very large image widths.  libpng will refuse to process an image where
2952     * this macro would overflow.
2953     */
2954 
2955 #define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
2956    (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
2957    /* Return the size, in bytes, of an image buffer given a png_image and a row
2958     * stride - the number of components to leave space for in each row.
2959     *
2960     * WARNING: this macro overflows a 32-bit integer for some large PNG images,
2961     * libpng will refuse to process an image where such an overflow would occur.
2962     */
2963 
2964 #define PNG_IMAGE_SIZE(image)\
2965    PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
2966    /* Return the size, in bytes, of the image in memory given just a png_image;
2967     * the row stride is the minimum stride required for the image.
2968     */
2969 
2970 #define PNG_IMAGE_COLORMAP_SIZE(image)\
2971    (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
2972    /* Return the size, in bytes, of the color-map of this image.  If the image
2973     * format is not a color-map format this will return a size sufficient for
2974     * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if
2975     * you don't want to allocate a color-map in this case.
2976     */
2977 
2978 /* PNG_IMAGE_FLAG_*
2979  *
2980  * Flags containing additional information about the image are held in the
2981  * 'flags' field of png_image.


3062     * 2) The format set by the application does not.
3063     * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and
3064     *    PNG_FORMAT_FLAG_LINEAR *not* set.
3065     *
3066     * For linear output removing the alpha channel is always done by compositing
3067     * on black and background is ignored.
3068     *
3069     * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set.  It must
3070     * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.
3071     * image->colormap_entries will be updated to the actual number of entries
3072     * written to the colormap; this may be less than the original value.
3073     */
3074 
3075 PNG_EXPORT(238, void, png_image_free, (png_imagep image));
3076    /* Free any data allocated by libpng in image->opaque, setting the pointer to
3077     * NULL.  May be called at any time after the structure is initialized.
3078     */
3079 #endif /* SIMPLIFIED_READ */
3080 
3081 #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED

3082 /* WRITE APIS
3083  * ----------
3084  * For write you must initialize a png_image structure to describe the image to
3085  * be written.  To do this use memset to set the whole structure to 0 then
3086  * initialize fields describing your image.
3087  *
3088  * version: must be set to PNG_IMAGE_VERSION
3089  * opaque: must be initialized to NULL
3090  * width: image width in pixels
3091  * height: image height in rows
3092  * format: the format of the data (image and color-map) you wish to write
3093  * flags: set to 0 unless one of the defined flags applies; set
3094  *    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB
3095  *    values do not correspond to the colors in sRGB.
3096  * colormap_entries: set to the number of entries in the color-map (0 to 256)
3097  */
3098 #ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
3099 PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
3100    const char *file, int convert_to_8bit, const void *buffer,
3101    png_int_32 row_stride, const void *colormap));
3102    /* Write the image to the named file. */
3103 
3104 PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
3105    int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
3106    const void *colormap));
3107    /* Write the image to the given (FILE*). */
3108 #endif /* SIMPLIFIED_WRITE_STDIO */
3109 
3110 /* With all write APIs if image is in one of the linear formats with 16-bit
3111  * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
3112  * gamma encoded according to the sRGB specification, otherwise a 16-bit linear
3113  * encoded PNG file is written.
3114  *
3115  * With color-mapped data formats the colormap parameter point to a color-map
3116  * with at least image->colormap_entries encoded in the specified format.  If
3117  * the format is linear the written PNG color-map will be converted to sRGB
3118  * regardless of the convert_to_8_bit flag.
3119  *
3120  * With all APIs row_stride is handled as in the read APIs - it is the spacing
3121  * from one row to the next in component sized units (1 or 2 bytes) and if
3122  * negative indicates a bottom-up row layout in the buffer.  If row_stride is
3123  * zero, libpng will calculate it for you from the image width and number of
3124  * channels.
3125  *
3126  * Note that the write API does not support interlacing, sub-8-bit pixels or
3127  * most ancillary chunks.  If you need to write text chunks (e.g. for copyright
3128  * notices) you need to use one of the other APIs.
3129  */
3130 
3131 PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
3132    png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit,
3133    const void *buffer, png_int_32 row_stride, const void *colormap));
3134    /* Write the image to the given memory buffer.  The function both writes the
3135     * whole PNG data stream to *memory and updates *memory_bytes with the count
3136     * of bytes written.
3137     *
3138     * 'memory' may be NULL.  In this case *memory_bytes is not read however on
3139     * success the number of bytes which would have been written will still be
3140     * stored in *memory_bytes.  On failure *memory_bytes will contain 0.
3141     *
3142     * If 'memory' is not NULL it must point to memory[*memory_bytes] of
3143     * writeable memory.
3144     *
3145     * If the function returns success memory[*memory_bytes] (if 'memory' is not
3146     * NULL) contains the written PNG data.  *memory_bytes will always be less
3147     * than or equal to the original value.
3148     *
3149     * If the function returns false and *memory_bytes was not changed an error
3150     * occured during write.  If *memory_bytes was changed, or is not 0 if
3151     * 'memory' was NULL, the write would have succeeded but for the memory
3152     * buffer being too small.  *memory_bytes contains the required number of
3153     * bytes and will be bigger that the original value.
3154     */
3155 
3156 #define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\
3157    row_stride, colormap)\
3158    png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\
3159          row_stride, colormap)
3160    /* Return the amount of memory in 'size' required to compress this image.
3161     * The png_image structure 'image' must be filled in as in the above
3162     * function and must not be changed before the actual write call, the buffer
3163     * and all other parameters must also be identical to that in the final
3164     * write call.  The 'size' variable need not be initialized.
3165     *
3166     * NOTE: the macro returns true/false, if false is returned 'size' will be
3167     * set to zero and the write failed and probably will fail if tried again.
3168     */
3169 
3170 /* You can pre-allocate the buffer by making sure it is of sufficient size
3171  * regardless of the amount of compression achieved.  The buffer size will
3172  * always be bigger than the original image and it will never be filled.  The
3173  * following macros are provided to assist in allocating the buffer.
3174  */
3175 #define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height)
3176    /* The number of uncompressed bytes in the PNG byte encoding of the image;
3177     * uncompressing the PNG IDAT data will give this number of bytes.
3178     *
3179     * NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this
3180     * macro can because of the extra bytes used in the PNG byte encoding.  You
3181     * need to avoid this macro if your image size approaches 2^30 in width or
3182     * height.  The same goes for the remainder of these macros; they all produce
3183     * bigger numbers than the actual in-memory image size.
3184     */
3185 #ifndef PNG_ZLIB_MAX_SIZE
3186 #  define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U)
3187    /* An upper bound on the number of compressed bytes given 'b' uncompressed
3188     * bytes.  This is based on deflateBounds() in zlib; different
3189     * implementations of zlib compression may conceivably produce more data so
3190     * if your zlib implementation is not zlib itself redefine this macro
3191     * appropriately.
3192     */
3193 #endif
3194 
3195 #define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\
3196    PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image))
3197    /* An upper bound on the size of the data in the PNG IDAT chunks. */
3198 
3199 #define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
3200    ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
3201     (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
3202      12U+3U*(image).colormap_entries/*PLTE data*/+\
3203      (((image).format&PNG_FORMAT_FLAG_ALPHA)?\
3204       12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
3205     12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
3206    /* A helper for the following macro; if your compiler cannot handle the
3207     * following macro use this one with the result of
3208     * PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most
3209     * compilers should handle this just fine.)
3210     */
3211 
3212 #define PNG_IMAGE_PNG_SIZE_MAX(image)\
3213    PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image))
3214    /* An upper bound on the total length of the PNG data stream for 'image'.
3215     * The result is of type png_alloc_size_t, on 32-bit systems this may
3216     * overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will
3217     * run out of buffer space but return a corrected size which should work.
3218     */

3219 #endif /* SIMPLIFIED_WRITE */
3220 /*******************************************************************************
3221  *  END OF SIMPLIFIED API
3222  ******************************************************************************/
3223 #endif /* SIMPLIFIED_{READ|WRITE} */
3224 
3225 /*******************************************************************************
3226  * Section 6: IMPLEMENTATION OPTIONS
3227  *******************************************************************************
3228  *
3229  * Support for arbitrary implementation-specific optimizations.  The API allows
3230  * particular options to be turned on or off.  'Option' is the number of the
3231  * option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given
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


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
3273  * one to use is one more than this.)
3274  */
3275 #ifdef PNG_EXPORT_LAST_ORDINAL
3276   PNG_EXPORT_LAST_ORDINAL(245);
3277 #endif
3278 
3279 #ifdef __cplusplus
3280 }
3281 #endif
3282 
3283 #endif /* PNG_VERSION_INFO_ONLY */
3284 /* Do not put anything past this line */
3285 #endif /* PNG_H */
< prev index next >