PageRenderTime 57ms CodeModel.GetById 17ms app.highlight 24ms RepoModel.GetById 1ms app.codeStats 2ms

/thirdparty/libpng/png.h

http://crashrpt.googlecode.com/
C++ Header | 3361 lines | 1991 code | 449 blank | 921 comment | 64 complexity | e0a27785c50bd7a2bee6b814a9522388 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/* png.h - header file for PNG reference library
   2 *
   3 * libpng version 1.2.7 - September 12, 2004
   4 * Copyright (c) 1998-2004 Glenn Randers-Pehrson
   5 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
   6 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
   7 *
   8 * Authors and maintainers:
   9 *  libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  10 *  libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
  11 *  libpng versions 0.97, January 1998, through 1.2.7 - September 12, 2004: Glenn
  12 *  See also "Contributing Authors", below.
  13 *
  14 * Note about libpng version numbers:
  15 *
  16 *    Due to various miscommunications, unforeseen code incompatibilities
  17 *    and occasional factors outside the authors' control, version numbering
  18 *    on the library has not always been consistent and straightforward.
  19 *    The following table summarizes matters since version 0.89c, which was
  20 *    the first widely used release:
  21 *
  22 *    source                 png.h  png.h  shared-lib
  23 *    version                string   int  version
  24 *    -------                ------ -----  ----------
  25 *    0.89c "1.0 beta 3"     0.89      89  1.0.89
  26 *    0.90  "1.0 beta 4"     0.90      90  0.90  [should have been 2.0.90]
  27 *    0.95  "1.0 beta 5"     0.95      95  0.95  [should have been 2.0.95]
  28 *    0.96  "1.0 beta 6"     0.96      96  0.96  [should have been 2.0.96]
  29 *    0.97b "1.00.97 beta 7" 1.00.97   97  1.0.1 [should have been 2.0.97]
  30 *    0.97c                  0.97      97  2.0.97
  31 *    0.98                   0.98      98  2.0.98
  32 *    0.99                   0.99      98  2.0.99
  33 *    0.99a-m                0.99      99  2.0.99
  34 *    1.00                   1.00     100  2.1.0 [100 should be 10000]
  35 *    1.0.0      (from here on, the   100  2.1.0 [100 should be 10000]
  36 *    1.0.1       png.h string is   10001  2.1.0
  37 *    1.0.1a-e    identical to the  10002  from here on, the shared library
  38 *    1.0.2       source version)   10002  is 2.V where V is the source code
  39 *    1.0.2a-b                      10003  version, except as noted.
  40 *    1.0.3                         10003
  41 *    1.0.3a-d                      10004
  42 *    1.0.4                         10004
  43 *    1.0.4a-f                      10005
  44 *    1.0.5 (+ 2 patches)           10005
  45 *    1.0.5a-d                      10006
  46 *    1.0.5e-r                      10100 (not source compatible)
  47 *    1.0.5s-v                      10006 (not binary compatible)
  48 *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)
  49 *    1.0.6d-f                      10007 (still binary incompatible)
  50 *    1.0.6g                        10007
  51 *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)
  52 *    1.0.6i                        10007  10.6i
  53 *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)
  54 *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)
  55 *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)
  56 *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
  57 *    1.0.7                    1    10007  (still compatible)
  58 *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4
  59 *    1.0.8rc1                 1    10008  2.1.0.8rc1
  60 *    1.0.8                    1    10008  2.1.0.8
  61 *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6
  62 *    1.0.9rc1                 1    10009  2.1.0.9rc1
  63 *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10
  64 *    1.0.9rc2                 1    10009  2.1.0.9rc2
  65 *    1.0.9                    1    10009  2.1.0.9
  66 *    1.0.10beta1              1    10010  2.1.0.10beta1
  67 *    1.0.10rc1                1    10010  2.1.0.10rc1
  68 *    1.0.10                   1    10010  2.1.0.10
  69 *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3
  70 *    1.0.11rc1                1    10011  2.1.0.11rc1
  71 *    1.0.11                   1    10011  2.1.0.11
  72 *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2
  73 *    1.0.12rc1                2    10012  2.1.0.12rc1
  74 *    1.0.12                   2    10012  2.1.0.12
  75 *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)
  76 *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2
  77 *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5
  78 *    1.2.0rc1                 3    10200  3.1.2.0rc1
  79 *    1.2.0                    3    10200  3.1.2.0
  80 *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4
  81 *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2
  82 *    1.2.1                    3    10201  3.1.2.1
  83 *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6
  84 *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1
  85 *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1
  86 *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1
  87 *    1.0.13                  10    10013  10.so.0.1.0.13
  88 *    1.2.2                   12    10202  12.so.0.1.2.2
  89 *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6
  90 *    1.2.3                   12    10203  12.so.0.1.2.3
  91 *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3
  92 *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1
  93 *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1
  94 *    1.0.14                  10    10014  10.so.0.1.0.14
  95 *    1.2.4                   13    10204  12.so.0.1.2.4
  96 *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2
  97 *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3
  98 *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3
  99 *    1.0.15                  10    10015  10.so.0.1.0.15
 100 *    1.2.5                   13    10205  12.so.0.1.2.5
 101 *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4
 102 *    1.0.16                  10    10016  10.so.0.1.0.16
 103 *    1.2.6                   13    10206  12.so.0.1.2.6
 104 *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2
 105 *    1.0.17rc1               10    10017  12.so.0.1.0.17rc1
 106 *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1
 107 *    1.0.17                  10    10017  12.so.0.1.0.17
 108 *    1.2.7                   13    10207  12.so.0.1.2.7
 109 *
 110 *    Henceforth the source version will match the shared-library major
 111 *    and minor numbers; the shared-library major version number will be
 112 *    used for changes in backward compatibility, as it is intended.  The
 113 *    PNG_LIBPNG_VER macro, which is not used within libpng but is available
 114 *    for applications, is an unsigned integer of the form xyyzz corresponding
 115 *    to the source version x.y.z (leading zeros in y and z).  Beta versions
 116 *    were given the previous public release number plus a letter, until
 117 *    version 1.0.6j; from then on they were given the upcoming public
 118 *    release number plus "betaNN" or "rcN".
 119 *
 120 *    Binary incompatibility exists only when applications make direct access
 121 *    to the info_ptr or png_ptr members through png.h, and the compiled
 122 *    application is loaded with a different version of the library.
 123 *
 124 *    DLLNUM will change each time there are forward or backward changes
 125 *    in binary compatibility (e.g., when a new feature is added).
 126 *
 127 * See libpng.txt or libpng.3 for more information.  The PNG specification
 128 * is available as a W3C Recommendation and as an ISO Specification,
 129 * <http://www.w3.org/TR/2003/REC-PNG-20031110/
 130 */
 131
 132/*
 133 * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
 134 *
 135 * If you modify libpng you may insert additional notices immediately following
 136 * this sentence.
 137 *
 138 * libpng versions 1.2.6, August 15, 2004, through 1.2.7, September 12, 2004, are
 139 * Copyright (c) 2004 Glenn Randers-Pehrson, and are
 140 * distributed according to the same disclaimer and license as libpng-1.2.5
 141 * with the following individual added to the list of Contributing Authors:
 142 *
 143 *    Cosmin Truta
 144 *
 145 * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
 146 * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
 147 * distributed according to the same disclaimer and license as libpng-1.0.6
 148 * with the following individuals added to the list of Contributing Authors:
 149 *
 150 *    Simon-Pierre Cadieux
 151 *    Eric S. Raymond
 152 *    Gilles Vollant
 153 *
 154 * and with the following additions to the disclaimer:
 155 *
 156 *    There is no warranty against interference with your enjoyment of the
 157 *    library or against infringement.  There is no warranty that our
 158 *    efforts or the library will fulfill any of your particular purposes
 159 *    or needs.  This library is provided with all faults, and the entire
 160 *    risk of satisfactory quality, performance, accuracy, and effort is with
 161 *    the user.
 162 *
 163 * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
 164 * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
 165 * distributed according to the same disclaimer and license as libpng-0.96,
 166 * with the following individuals added to the list of Contributing Authors:
 167 *
 168 *    Tom Lane
 169 *    Glenn Randers-Pehrson
 170 *    Willem van Schaik
 171 *
 172 * libpng versions 0.89, June 1996, through 0.96, May 1997, are
 173 * Copyright (c) 1996, 1997 Andreas Dilger
 174 * Distributed according to the same disclaimer and license as libpng-0.88,
 175 * with the following individuals added to the list of Contributing Authors:
 176 *
 177 *    John Bowler
 178 *    Kevin Bracey
 179 *    Sam Bushell
 180 *    Magnus Holmgren
 181 *    Greg Roelofs
 182 *    Tom Tanner
 183 *
 184 * libpng versions 0.5, May 1995, through 0.88, January 1996, are
 185 * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
 186 *
 187 * For the purposes of this copyright and license, "Contributing Authors"
 188 * is defined as the following set of individuals:
 189 *
 190 *    Andreas Dilger
 191 *    Dave Martindale
 192 *    Guy Eric Schalnat
 193 *    Paul Schmidt
 194 *    Tim Wegner
 195 *
 196 * The PNG Reference Library is supplied "AS IS".  The Contributing Authors
 197 * and Group 42, Inc. disclaim all warranties, expressed or implied,
 198 * including, without limitation, the warranties of merchantability and of
 199 * fitness for any purpose.  The Contributing Authors and Group 42, Inc.
 200 * assume no liability for direct, indirect, incidental, special, exemplary,
 201 * or consequential damages, which may result from the use of the PNG
 202 * Reference Library, even if advised of the possibility of such damage.
 203 *
 204 * Permission is hereby granted to use, copy, modify, and distribute this
 205 * source code, or portions hereof, for any purpose, without fee, subject
 206 * to the following restrictions:
 207 *
 208 * 1. The origin of this source code must not be misrepresented.
 209 *
 210 * 2. Altered versions must be plainly marked as such and
 211 * must not be misrepresented as being the original source.
 212 *
 213 * 3. This Copyright notice may not be removed or altered from
 214 *    any source or altered source distribution.
 215 *
 216 * The Contributing Authors and Group 42, Inc. specifically permit, without
 217 * fee, and encourage the use of this source code as a component to
 218 * supporting the PNG file format in commercial products.  If you use this
 219 * source code in a product, acknowledgment is not required but would be
 220 * appreciated.
 221 */
 222
 223/*
 224 * A "png_get_copyright" function is available, for convenient use in "about"
 225 * boxes and the like:
 226 *
 227 * printf("%s",png_get_copyright(NULL));
 228 *
 229 * Also, the PNG logo (in PNG format, of course) is supplied in the
 230 * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
 231 */
 232
 233/*
 234 * Libpng is OSI Certified Open Source Software.  OSI Certified is a
 235 * certification mark of the Open Source Initiative.
 236 */
 237
 238/*
 239 * The contributing authors would like to thank all those who helped
 240 * with testing, bug fixes, and patience.  This wouldn't have been
 241 * possible without all of you.
 242 *
 243 * Thanks to Frank J. T. Wojcik for helping with the documentation.
 244 */
 245
 246/*
 247 * Y2K compliance in libpng:
 248 * =========================
 249 *
 250 *    September 12, 2004
 251 *
 252 *    Since the PNG Development group is an ad-hoc body, we can't make
 253 *    an official declaration.
 254 *
 255 *    This is your unofficial assurance that libpng from version 0.71 and
 256 *    upward through 1.2.7 are Y2K compliant.  It is my belief that earlier
 257 *    versions were also Y2K compliant.
 258 *
 259 *    Libpng only has three year fields.  One is a 2-byte unsigned integer
 260 *    that will hold years up to 65535.  The other two hold the date in text
 261 *    format, and will hold years up to 9999.
 262 *
 263 *    The integer is
 264 *        "png_uint_16 year" in png_time_struct.
 265 *
 266 *    The strings are
 267 *        "png_charp time_buffer" in png_struct and
 268 *        "near_time_buffer", which is a local character string in png.c.
 269 *
 270 *    There are seven time-related functions:
 271 *        png.c: png_convert_to_rfc_1123() in png.c
 272 *          (formerly png_convert_to_rfc_1152() in error)
 273 *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
 274 *        png_convert_from_time_t() in pngwrite.c
 275 *        png_get_tIME() in pngget.c
 276 *        png_handle_tIME() in pngrutil.c, called in pngread.c
 277 *        png_set_tIME() in pngset.c
 278 *        png_write_tIME() in pngwutil.c, called in pngwrite.c
 279 *
 280 *    All handle dates properly in a Y2K environment.  The
 281 *    png_convert_from_time_t() function calls gmtime() to convert from system
 282 *    clock time, which returns (year - 1900), which we properly convert to
 283 *    the full 4-digit year.  There is a possibility that applications using
 284 *    libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
 285 *    function, or that they are incorrectly passing only a 2-digit year
 286 *    instead of "year - 1900" into the png_convert_from_struct_tm() function,
 287 *    but this is not under our control.  The libpng documentation has always
 288 *    stated that it works with 4-digit years, and the APIs have been
 289 *    documented as such.
 290 *
 291 *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
 292 *    integer to hold the year, and can hold years as large as 65535.
 293 *
 294 *    zlib, upon which libpng depends, is also Y2K compliant.  It contains
 295 *    no date-related code.
 296 *
 297 *       Glenn Randers-Pehrson
 298 *       libpng maintainer
 299 *       PNG Development Group
 300 */
 301
 302#ifndef PNG_H
 303#define PNG_H
 304
 305/* This is not the place to learn how to use libpng.  The file libpng.txt
 306 * describes how to use libpng, and the file example.c summarizes it
 307 * with some code on which to build.  This file is useful for looking
 308 * at the actual function definitions and structure components.
 309 */
 310
 311/* Version information for png.h - this should match the version in png.c */
 312#define PNG_LIBPNG_VER_STRING "1.2.7"
 313#define PNG_HEADER_VERSION_STRING \
 314   " libpng version 1.2.7 - September 12, 2004 (header)\n"
 315
 316#define PNG_LIBPNG_VER_SONUM   0
 317#define PNG_LIBPNG_VER_DLLNUM  %DLLNUM%
 318
 319/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 320#define PNG_LIBPNG_VER_MAJOR   1
 321#define PNG_LIBPNG_VER_MINOR   2
 322#define PNG_LIBPNG_VER_RELEASE 7
 323/* This should match the numeric part of the final component of
 324 * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
 325
 326#define PNG_LIBPNG_VER_BUILD  0
 327
 328#define PNG_LIBPNG_BUILD_ALPHA    1
 329#define PNG_LIBPNG_BUILD_BETA     2
 330#define PNG_LIBPNG_BUILD_RC       3
 331#define PNG_LIBPNG_BUILD_STABLE   4
 332#define PNG_LIBPNG_BUILD_TYPEMASK 7
 333#define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with STABLE only */
 334#define PNG_LIBPNG_BUILD_TYPE 4
 335
 336/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
 337 * We must not include leading zeros.
 338 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
 339 * version 1.0.0 was mis-numbered 100 instead of 10000).  From
 340 * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release */
 341#define PNG_LIBPNG_VER 10207 /* 1.2.7 */
 342
 343#ifndef PNG_VERSION_INFO_ONLY
 344
 345/* include the compression library's header */
 346#include "zlib.h"
 347
 348/* include all user configurable info, including optional assembler routines */
 349#include "pngconf.h"
 350
 351/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
 352#ifdef __cplusplus
 353extern "C" {
 354#endif /* __cplusplus */
 355
 356/* This file is arranged in several sections.  The first section contains
 357 * structure and type definitions.  The second section contains the external
 358 * library functions, while the third has the internal library functions,
 359 * which applications aren't expected to use directly.
 360 */
 361
 362#ifndef PNG_NO_TYPECAST_NULL
 363#define int_p_NULL                (int *)NULL
 364#define png_bytep_NULL            (png_bytep)NULL
 365#define png_bytepp_NULL           (png_bytepp)NULL
 366#define png_doublep_NULL          (png_doublep)NULL
 367#define png_error_ptr_NULL        (png_error_ptr)NULL
 368#define png_flush_ptr_NULL        (png_flush_ptr)NULL
 369#define png_free_ptr_NULL         (png_free_ptr)NULL
 370#define png_infopp_NULL           (png_infopp)NULL
 371#define png_malloc_ptr_NULL       (png_malloc_ptr)NULL
 372#define png_read_status_ptr_NULL  (png_read_status_ptr)NULL
 373#define png_rw_ptr_NULL           (png_rw_ptr)NULL
 374#define png_structp_NULL          (png_structp)NULL
 375#define png_uint_16p_NULL         (png_uint_16p)NULL
 376#define png_voidp_NULL            (png_voidp)NULL
 377#define png_write_status_ptr_NULL (png_write_status_ptr)NULL
 378#else
 379#define int_p_NULL                NULL
 380#define png_bytep_NULL            NULL
 381#define png_bytepp_NULL           NULL
 382#define png_doublep_NULL          NULL
 383#define png_error_ptr_NULL        NULL
 384#define png_flush_ptr_NULL        NULL
 385#define png_free_ptr_NULL         NULL
 386#define png_infopp_NULL           NULL
 387#define png_malloc_ptr_NULL       NULL
 388#define png_read_status_ptr_NULL  NULL
 389#define png_rw_ptr_NULL           NULL
 390#define png_structp_NULL          NULL
 391#define png_uint_16p_NULL         NULL
 392#define png_voidp_NULL            NULL
 393#define png_write_status_ptr_NULL NULL
 394#endif
 395
 396/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
 397#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
 398/* Version information for C files, stored in png.c.  This had better match
 399 * the version above.
 400 */
 401#ifdef PNG_USE_GLOBAL_ARRAYS
 402PNG_EXPORT_VAR (const char) png_libpng_ver[18];
 403  /* need room for 99.99.99beta99z */
 404#else
 405#define png_libpng_ver png_get_header_ver(NULL)
 406#endif
 407
 408#ifdef PNG_USE_GLOBAL_ARRAYS
 409/* This was removed in version 1.0.5c */
 410/* Structures to facilitate easy interlacing.  See png.c for more details */
 411PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7];
 412PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7];
 413PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7];
 414PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7];
 415PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7];
 416PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7];
 417#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
 418PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7];
 419#endif
 420/* This isn't currently used.  If you need it, see png.c for more details.
 421PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7];
 422*/
 423#endif
 424
 425#endif /* PNG_NO_EXTERN */
 426
 427/* Three color definitions.  The order of the red, green, and blue, (and the
 428 * exact size) is not important, although the size of the fields need to
 429 * be png_byte or png_uint_16 (as defined below).
 430 */
 431typedef struct png_color_struct
 432{
 433   png_byte red;
 434   png_byte green;
 435   png_byte blue;
 436} png_color;
 437typedef png_color FAR * png_colorp;
 438typedef png_color FAR * FAR * png_colorpp;
 439
 440typedef struct png_color_16_struct
 441{
 442   png_byte index;    /* used for palette files */
 443   png_uint_16 red;   /* for use in red green blue files */
 444   png_uint_16 green;
 445   png_uint_16 blue;
 446   png_uint_16 gray;  /* for use in grayscale files */
 447} png_color_16;
 448typedef png_color_16 FAR * png_color_16p;
 449typedef png_color_16 FAR * FAR * png_color_16pp;
 450
 451typedef struct png_color_8_struct
 452{
 453   png_byte red;   /* for use in red green blue files */
 454   png_byte green;
 455   png_byte blue;
 456   png_byte gray;  /* for use in grayscale files */
 457   png_byte alpha; /* for alpha channel files */
 458} png_color_8;
 459typedef png_color_8 FAR * png_color_8p;
 460typedef png_color_8 FAR * FAR * png_color_8pp;
 461
 462/*
 463 * The following two structures are used for the in-core representation
 464 * of sPLT chunks.
 465 */
 466typedef struct png_sPLT_entry_struct
 467{
 468   png_uint_16 red;
 469   png_uint_16 green;
 470   png_uint_16 blue;
 471   png_uint_16 alpha;
 472   png_uint_16 frequency;
 473} png_sPLT_entry;
 474typedef png_sPLT_entry FAR * png_sPLT_entryp;
 475typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
 476
 477/*  When the depth of the sPLT palette is 8 bits, the color and alpha samples
 478 *  occupy the LSB of their respective members, and the MSB of each member
 479 *  is zero-filled.  The frequency member always occupies the full 16 bits.
 480 */
 481
 482typedef struct png_sPLT_struct
 483{
 484   png_charp name;           /* palette name */
 485   png_byte depth;           /* depth of palette samples */
 486   png_sPLT_entryp entries;  /* palette entries */
 487   png_int_32 nentries;      /* number of palette entries */
 488} png_sPLT_t;
 489typedef png_sPLT_t FAR * png_sPLT_tp;
 490typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
 491
 492#ifdef PNG_TEXT_SUPPORTED
 493/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
 494 * and whether that contents is compressed or not.  The "key" field
 495 * points to a regular zero-terminated C string.  The "text", "lang", and
 496 * "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
 497 * However, the * structure returned by png_get_text() will always contain
 498 * regular zero-terminated C strings (possibly empty), never NULL pointers,
 499 * so they can be safely used in printf() and other string-handling functions.
 500 */
 501typedef struct png_text_struct
 502{
 503   int  compression;       /* compression value:
 504                             -1: tEXt, none
 505                              0: zTXt, deflate
 506                              1: iTXt, none
 507                              2: iTXt, deflate  */
 508   png_charp key;          /* keyword, 1-79 character description of "text" */
 509   png_charp text;         /* comment, may be an empty string (ie "")
 510                              or a NULL pointer */
 511   png_size_t text_length; /* length of the text string */
 512#ifdef PNG_iTXt_SUPPORTED
 513   png_size_t itxt_length; /* length of the itxt string */
 514   png_charp lang;         /* language code, 0-79 characters
 515                              or a NULL pointer */
 516   png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more
 517                              chars or a NULL pointer */
 518#endif
 519} png_text;
 520typedef png_text FAR * png_textp;
 521typedef png_text FAR * FAR * png_textpp;
 522#endif
 523
 524/* Supported compression types for text in PNG files (tEXt, and zTXt).
 525 * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
 526#define PNG_TEXT_COMPRESSION_NONE_WR -3
 527#define PNG_TEXT_COMPRESSION_zTXt_WR -2
 528#define PNG_TEXT_COMPRESSION_NONE    -1
 529#define PNG_TEXT_COMPRESSION_zTXt     0
 530#define PNG_ITXT_COMPRESSION_NONE     1
 531#define PNG_ITXT_COMPRESSION_zTXt     2
 532#define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */
 533
 534/* png_time is a way to hold the time in an machine independent way.
 535 * Two conversions are provided, both from time_t and struct tm.  There
 536 * is no portable way to convert to either of these structures, as far
 537 * as I know.  If you know of a portable way, send it to me.  As a side
 538 * note - PNG has always been Year 2000 compliant!
 539 */
 540typedef struct png_time_struct
 541{
 542   png_uint_16 year; /* full year, as in, 1995 */
 543   png_byte month;   /* month of year, 1 - 12 */
 544   png_byte day;     /* day of month, 1 - 31 */
 545   png_byte hour;    /* hour of day, 0 - 23 */
 546   png_byte minute;  /* minute of hour, 0 - 59 */
 547   png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */
 548} png_time;
 549typedef png_time FAR * png_timep;
 550typedef png_time FAR * FAR * png_timepp;
 551
 552#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
 553/* png_unknown_chunk is a structure to hold queued chunks for which there is
 554 * no specific support.  The idea is that we can use this to queue
 555 * up private chunks for output even though the library doesn't actually
 556 * know about their semantics.
 557 */
 558typedef struct png_unknown_chunk_t
 559{
 560    png_byte name[5];
 561    png_byte *data;
 562    png_size_t size;
 563
 564    /* libpng-using applications should NOT directly modify this byte. */
 565    png_byte location; /* mode of operation at read time */
 566}
 567png_unknown_chunk;
 568typedef png_unknown_chunk FAR * png_unknown_chunkp;
 569typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
 570#endif
 571
 572/* png_info is a structure that holds the information in a PNG file so
 573 * that the application can find out the characteristics of the image.
 574 * If you are reading the file, this structure will tell you what is
 575 * in the PNG file.  If you are writing the file, fill in the information
 576 * you want to put into the PNG file, then call png_write_info().
 577 * The names chosen should be very close to the PNG specification, so
 578 * consult that document for information about the meaning of each field.
 579 *
 580 * With libpng < 0.95, it was only possible to directly set and read the
 581 * the values in the png_info_struct, which meant that the contents and
 582 * order of the values had to remain fixed.  With libpng 0.95 and later,
 583 * however, there are now functions that abstract the contents of
 584 * png_info_struct from the application, so this makes it easier to use
 585 * libpng with dynamic libraries, and even makes it possible to use
 586 * libraries that don't have all of the libpng ancillary chunk-handing
 587 * functionality.
 588 *
 589 * In any case, the order of the parameters in png_info_struct should NOT
 590 * be changed for as long as possible to keep compatibility with applications
 591 * that use the old direct-access method with png_info_struct.
 592 *
 593 * The following members may have allocated storage attached that should be
 594 * cleaned up before the structure is discarded: palette, trans, text,
 595 * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
 596 * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these
 597 * are automatically freed when the info structure is deallocated, if they were
 598 * allocated internally by libpng.  This behavior can be changed by means
 599 * of the png_data_freer() function.
 600 *
 601 * More allocation details: all the chunk-reading functions that
 602 * change these members go through the corresponding png_set_*
 603 * functions.  A function to clear these members is available: see
 604 * png_free_data().  The png_set_* functions do not depend on being
 605 * able to point info structure members to any of the storage they are
 606 * passed (they make their own copies), EXCEPT that the png_set_text
 607 * functions use the same storage passed to them in the text_ptr or
 608 * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
 609 * functions do not make their own copies.
 610 */
 611typedef struct png_info_struct
 612{
 613   /* the following are necessary for every PNG file */
 614   png_uint_32 width;       /* width of image in pixels (from IHDR) */
 615   png_uint_32 height;      /* height of image in pixels (from IHDR) */
 616   png_uint_32 valid;       /* valid chunk data (see PNG_INFO_ below) */
 617   png_uint_32 rowbytes;    /* bytes needed to hold an untransformed row */
 618   png_colorp palette;      /* array of color values (valid & PNG_INFO_PLTE) */
 619   png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
 620   png_uint_16 num_trans;   /* number of transparent palette color (tRNS) */
 621   png_byte bit_depth;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
 622   png_byte color_type;     /* see PNG_COLOR_TYPE_ below (from IHDR) */
 623   /* The following three should have been named *_method not *_type */
 624   png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
 625   png_byte filter_type;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
 626   png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
 627
 628   /* The following is informational only on read, and not used on writes. */
 629   png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4) */
 630   png_byte pixel_depth;    /* number of bits per pixel */
 631   png_byte spare_byte;     /* to align the data, and for future use */
 632   png_byte signature[8];   /* magic bytes read by libpng from start of file */
 633
 634   /* The rest of the data is optional.  If you are reading, check the
 635    * valid field to see if the information in these are valid.  If you
 636    * are writing, set the valid field to those chunks you want written,
 637    * and initialize the appropriate fields below.
 638    */
 639
 640#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
 641   /* The gAMA chunk describes the gamma characteristics of the system
 642    * on which the image was created, normally in the range [1.0, 2.5].
 643    * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
 644    */
 645   float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
 646#endif
 647
 648#if defined(PNG_sRGB_SUPPORTED)
 649    /* GR-P, 0.96a */
 650    /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
 651   png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
 652#endif
 653
 654#if defined(PNG_TEXT_SUPPORTED)
 655   /* The tEXt, and zTXt chunks contain human-readable textual data in
 656    * uncompressed, compressed, and optionally compressed forms, respectively.
 657    * The data in "text" is an array of pointers to uncompressed,
 658    * null-terminated C strings. Each chunk has a keyword that describes the
 659    * textual data contained in that chunk.  Keywords are not required to be
 660    * unique, and the text string may be empty.  Any number of text chunks may
 661    * be in an image.
 662    */
 663   int num_text; /* number of comments read/to write */
 664   int max_text; /* current size of text array */
 665   png_textp text; /* array of comments read/to write */
 666#endif /* PNG_TEXT_SUPPORTED */
 667
 668#if defined(PNG_tIME_SUPPORTED)
 669   /* The tIME chunk holds the last time the displayed image data was
 670    * modified.  See the png_time struct for the contents of this struct.
 671    */
 672   png_time mod_time;
 673#endif
 674
 675#if defined(PNG_sBIT_SUPPORTED)
 676   /* The sBIT chunk specifies the number of significant high-order bits
 677    * in the pixel data.  Values are in the range [1, bit_depth], and are
 678    * only specified for the channels in the pixel data.  The contents of
 679    * the low-order bits is not specified.  Data is valid if
 680    * (valid & PNG_INFO_sBIT) is non-zero.
 681    */
 682   png_color_8 sig_bit; /* significant bits in color channels */
 683#endif
 684
 685#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
 686defined(PNG_READ_BACKGROUND_SUPPORTED)
 687   /* The tRNS chunk supplies transparency data for paletted images and
 688    * other image types that don't need a full alpha channel.  There are
 689    * "num_trans" transparency values for a paletted image, stored in the
 690    * same order as the palette colors, starting from index 0.  Values
 691    * for the data are in the range [0, 255], ranging from fully transparent
 692    * to fully opaque, respectively.  For non-paletted images, there is a
 693    * single color specified that should be treated as fully transparent.
 694    * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
 695    */
 696   png_bytep trans; /* transparent values for paletted image */
 697   png_color_16 trans_values; /* transparent color for non-palette image */
 698#endif
 699
 700#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
 701   /* The bKGD chunk gives the suggested image background color if the
 702    * display program does not have its own background color and the image
 703    * is needs to composited onto a background before display.  The colors
 704    * in "background" are normally in the same color space/depth as the
 705    * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
 706    */
 707   png_color_16 background;
 708#endif
 709
 710#if defined(PNG_oFFs_SUPPORTED)
 711   /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
 712    * and downwards from the top-left corner of the display, page, or other
 713    * application-specific co-ordinate space.  See the PNG_OFFSET_ defines
 714    * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.
 715    */
 716   png_int_32 x_offset; /* x offset on page */
 717   png_int_32 y_offset; /* y offset on page */
 718   png_byte offset_unit_type; /* offset units type */
 719#endif
 720
 721#if defined(PNG_pHYs_SUPPORTED)
 722   /* The pHYs chunk gives the physical pixel density of the image for
 723    * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
 724    * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
 725    */
 726   png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
 727   png_uint_32 y_pixels_per_unit; /* vertical pixel density */
 728   png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
 729#endif
 730
 731#if defined(PNG_hIST_SUPPORTED)
 732   /* The hIST chunk contains the relative frequency or importance of the
 733    * various palette entries, so that a viewer can intelligently select a
 734    * reduced-color palette, if required.  Data is an array of "num_palette"
 735    * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
 736    * is non-zero.
 737    */
 738   png_uint_16p hist;
 739#endif
 740
 741#ifdef PNG_cHRM_SUPPORTED
 742   /* The cHRM chunk describes the CIE color characteristics of the monitor
 743    * on which the PNG was created.  This data allows the viewer to do gamut
 744    * mapping of the input image to ensure that the viewer sees the same
 745    * colors in the image as the creator.  Values are in the range
 746    * [0.0, 0.8].  Data valid if (valid & PNG_INFO_cHRM) non-zero.
 747    */
 748#ifdef PNG_FLOATING_POINT_SUPPORTED
 749   float x_white;
 750   float y_white;
 751   float x_red;
 752   float y_red;
 753   float x_green;
 754   float y_green;
 755   float x_blue;
 756   float y_blue;
 757#endif
 758#endif
 759
 760#if defined(PNG_pCAL_SUPPORTED)
 761   /* The pCAL chunk describes a transformation between the stored pixel
 762    * values and original physical data values used to create the image.
 763    * The integer range [0, 2^bit_depth - 1] maps to the floating-point
 764    * range given by [pcal_X0, pcal_X1], and are further transformed by a
 765    * (possibly non-linear) transformation function given by "pcal_type"
 766    * and "pcal_params" into "pcal_units".  Please see the PNG_EQUATION_
 767    * defines below, and the PNG-Group's PNG extensions document for a
 768    * complete description of the transformations and how they should be
 769    * implemented, and for a description of the ASCII parameter strings.
 770    * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
 771    */
 772   png_charp pcal_purpose;  /* pCAL chunk description string */
 773   png_int_32 pcal_X0;      /* minimum value */
 774   png_int_32 pcal_X1;      /* maximum value */
 775   png_charp pcal_units;    /* Latin-1 string giving physical units */
 776   png_charpp pcal_params;  /* ASCII strings containing parameter values */
 777   png_byte pcal_type;      /* equation type (see PNG_EQUATION_ below) */
 778   png_byte pcal_nparams;   /* number of parameters given in pcal_params */
 779#endif
 780
 781/* New members added in libpng-1.0.6 */
 782#ifdef PNG_FREE_ME_SUPPORTED
 783   png_uint_32 free_me;     /* flags items libpng is responsible for freeing */
 784#endif
 785
 786#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
 787   /* storage for unknown chunks that the library doesn't recognize. */
 788   png_unknown_chunkp unknown_chunks;
 789   png_size_t unknown_chunks_num;
 790#endif
 791
 792#if defined(PNG_iCCP_SUPPORTED)
 793   /* iCCP chunk data. */
 794   png_charp iccp_name;     /* profile name */
 795   png_charp iccp_profile;  /* International Color Consortium profile data */
 796                            /* Note to maintainer: should be png_bytep */
 797   png_uint_32 iccp_proflen;  /* ICC profile data length */
 798   png_byte iccp_compression; /* Always zero */
 799#endif
 800
 801#if defined(PNG_sPLT_SUPPORTED)
 802   /* data on sPLT chunks (there may be more than one). */
 803   png_sPLT_tp splt_palettes;
 804   png_uint_32 splt_palettes_num;
 805#endif
 806
 807#if defined(PNG_sCAL_SUPPORTED)
 808   /* The sCAL chunk describes the actual physical dimensions of the
 809    * subject matter of the graphic.  The chunk contains a unit specification
 810    * a byte value, and two ASCII strings representing floating-point
 811    * values.  The values are width and height corresponsing to one pixel
 812    * in the image.  This external representation is converted to double
 813    * here.  Data values are valid if (valid & PNG_INFO_sCAL) is non-zero.
 814    */
 815   png_byte scal_unit;         /* unit of physical scale */
 816#ifdef PNG_FLOATING_POINT_SUPPORTED
 817   double scal_pixel_width;    /* width of one pixel */
 818   double scal_pixel_height;   /* height of one pixel */
 819#endif
 820#ifdef PNG_FIXED_POINT_SUPPORTED
 821   png_charp scal_s_width;     /* string containing height */
 822   png_charp scal_s_height;    /* string containing width */
 823#endif
 824#endif
 825
 826#if defined(PNG_INFO_IMAGE_SUPPORTED)
 827   /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */
 828   /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
 829   png_bytepp row_pointers;        /* the image bits */
 830#endif
 831
 832#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED)
 833   png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */
 834#endif
 835
 836#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED)
 837   png_fixed_point int_x_white;
 838   png_fixed_point int_y_white;
 839   png_fixed_point int_x_red;
 840   png_fixed_point int_y_red;
 841   png_fixed_point int_x_green;
 842   png_fixed_point int_y_green;
 843   png_fixed_point int_x_blue;
 844   png_fixed_point int_y_blue;
 845#endif
 846
 847} png_info;
 848
 849typedef png_info FAR * png_infop;
 850typedef png_info FAR * FAR * png_infopp;
 851
 852/* Maximum positive integer used in PNG is (2^31)-1 */
 853#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
 854#define PNG_UINT_32_MAX (~((png_uint_32)0))
 855#define PNG_SIZE_MAX (~((png_size_t)0))
 856/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
 857#define PNG_MAX_UINT PNG_UINT_31_MAX
 858
 859/* These describe the color_type field in png_info. */
 860/* color type masks */
 861#define PNG_COLOR_MASK_PALETTE    1
 862#define PNG_COLOR_MASK_COLOR      2
 863#define PNG_COLOR_MASK_ALPHA      4
 864
 865/* color types.  Note that not all combinations are legal */
 866#define PNG_COLOR_TYPE_GRAY 0
 867#define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
 868#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
 869#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
 870#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
 871/* aliases */
 872#define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA
 873#define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA
 874
 875/* This is for compression type. PNG 1.0-1.2 only define the single type. */
 876#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
 877#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
 878
 879/* This is for filter type. PNG 1.0-1.2 only define the single type. */
 880#define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */
 881#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
 882#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE
 883
 884/* These are for the interlacing type.  These values should NOT be changed. */
 885#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */
 886#define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */
 887#define PNG_INTERLACE_LAST        2 /* Not a valid value */
 888
 889/* These are for the oFFs chunk.  These values should NOT be changed. */
 890#define PNG_OFFSET_PIXEL          0 /* Offset in pixels */
 891#define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */
 892#define PNG_OFFSET_LAST           2 /* Not a valid value */
 893
 894/* These are for the pCAL chunk.  These values should NOT be changed. */
 895#define PNG_EQUATION_LINEAR       0 /* Linear transformation */
 896#define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */
 897#define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */
 898#define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */
 899#define PNG_EQUATION_LAST         4 /* Not a valid value */
 900
 901/* These are for the sCAL chunk.  These values should NOT be changed. */
 902#define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */
 903#define PNG_SCALE_METER           1 /* meters per pixel */
 904#define PNG_SCALE_RADIAN          2 /* radians per pixel */
 905#define PNG_SCALE_LAST            3 /* Not a valid value */
 906
 907/* These are for the pHYs chunk.  These values should NOT be changed. */
 908#define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */
 909#define PNG_RESOLUTION_METER      1 /* pixels/meter */
 910#define PNG_RESOLUTION_LAST       2 /* Not a valid value */
 911
 912/* These are for the sRGB chunk.  These values should NOT be changed. */
 913#define PNG_sRGB_INTENT_PERCEPTUAL 0
 914#define PNG_sRGB_INTENT_RELATIVE   1
 915#define PNG_sRGB_INTENT_SATURATION 2
 916#define PNG_sRGB_INTENT_ABSOLUTE   3
 917#define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */
 918
 919/* This is for text chunks */
 920#define PNG_KEYWORD_MAX_LENGTH     79
 921
 922/* Maximum number of entries in PLTE/sPLT/tRNS arrays */
 923#define PNG_MAX_PALETTE_LENGTH    256
 924
 925/* These determine if an ancillary chunk's data has been successfully read
 926 * from the PNG header, or if the application has filled in the corresponding
 927 * data in the info_struct to be written into the output file.  The values
 928 * of the PNG_INFO_<chunk> defines should NOT be changed.
 929 */
 930#define PNG_INFO_gAMA 0x0001
 931#define PNG_INFO_sBIT 0x0002
 932#define PNG_INFO_cHRM 0x0004
 933#define PNG_INFO_PLTE 0x0008
 934#define PNG_INFO_tRNS 0x0010
 935#define PNG_INFO_bKGD 0x0020
 936#define PNG_INFO_hIST 0x0040
 937#define PNG_INFO_pHYs 0x0080
 938#define PNG_INFO_oFFs 0x0100
 939#define PNG_INFO_tIME 0x0200
 940#define PNG_INFO_pCAL 0x0400
 941#define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */
 942#define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */
 943#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
 944#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
 945#define PNG_INFO_IDAT 0x8000L  /* ESR, 1.0.6 */
 946
 947/* This is used for the transformation routines, as some of them
 948 * change these values for the row.  It also should enable using
 949 * the routines for other purposes.
 950 */
 951typedef struct png_row_info_struct
 952{
 953   png_uint_32 width; /* width of row */
 954   png_uint_32 rowbytes; /* number of bytes in row */
 955   png_byte color_type; /* color type of row */
 956   png_byte bit_depth; /* bit depth of row */
 957   png_byte channels; /* number of channels (1, 2, 3, or 4) */
 958   png_byte pixel_depth; /* bits per pixel (depth * channels) */
 959} png_row_info;
 960
 961typedef png_row_info FAR * png_row_infop;
 962typedef png_row_info FAR * FAR * png_row_infopp;
 963
 964/* These are the function types for the I/O functions and for the functions
 965 * that allow the user to override the default I/O functions with his or her
 966 * own.  The png_error_ptr type should match that of user-supplied warning
 967 * and error functions, while the png_rw_ptr type should match that of the
 968 * user read/write data functions.
 969 */
 970typedef struct png_struct_def png_struct;
 971typedef png_struct FAR * png_structp;
 972
 973typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp));
 974typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
 975typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp));
 976typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32,
 977   int));
 978typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32,
 979   int));
 980
 981#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
 982typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop));
 983typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
 984typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
 985   png_uint_32, int));
 986#endif
 987
 988#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
 989    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
 990    defined(PNG_LEGACY_SUPPORTED)
 991typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp,
 992    png_row_infop, png_bytep));
 993#endif
 994
 995#if defined(PNG_USER_CHUNKS_SUPPORTED)
 996typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp));
 997#endif
 998#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
 999typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
1000#endif
1001
1002/* Transform masks for the high-level interface */
1003#define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */
1004#define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */
1005#define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */
1006#define PNG_TRANSFORM_PACKING        0x0004    /* read and write */
1007#define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */
1008#define PNG_TRANSFORM_EXPAND         0x0010    /* read only */
1009#define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */
1010#define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */
1011#define PNG_TRANSFORM_BGR            0x0080    /* read and write */
1012#define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */
1013#define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */
1014#define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */
1015#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* WRITE only */
1016
1017/* Flags for MNG supported features */
1018#define PNG_FLAG_MNG_EMPTY_PLTE     0x01
1019#define PNG_FLAG_MNG_FILTER_64      0x04
1020#define PNG_ALL_MNG_FEATURES        0x05
1021
1022typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
1023typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
1024
1025/* The structure that holds the information to read and write PNG files.
1026 * The only people who need to care about what is inside of this are the
1027 * people who will be modifying the library for their own special needs.
1028 * It should NOT be accessed directly by an application, except to store
1029 * the jmp_buf.
1030 */
1031
1032struct png_struct_def
1033{
1034#ifdef PNG_SETJMP_SUPPORTED
1035   jmp_buf jmpbuf;            /* used in png_error */
1036#endif
1037   png_error_ptr error_fn;    /* function for printing errors and aborting */
1038   png_error_ptr warning_fn;  /* function for printing warnings */
1039   png_voidp error_ptr;       /* user supplied struct for error functions */
1040   png_rw_ptr write_data_fn;  /* function for writing output data */
1041   png_rw_ptr read_data_fn;   /* function for reading input data */
1042   png_voidp io_ptr;          /* ptr to application struct for I/O functions */
1043
1044#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
1045   png_user_transform_ptr read_user_transform_fn; /* user read transform */
1046#endif
1047
1048#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
1049   png_user_transform_ptr write_user_transform_fn; /* user write transform */
1050#endif
1051
1052/* These were added in libpng-1.0.2 */
1053#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
1054#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
1055    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
1056   png_voidp user_transform_ptr; /* user supplied struct for user transform */
1057   png_byte user_transform_depth;    /* bit depth of user transformed pixels */
1058   png_byte user_transform_channels; /* channels in user transformed pixels */
1059#endif
1060#endif
1061
1062   png_uint_32 mode;          /* tells us where we are in the PNG file */
1063   png_uint_32 flags;         /* flags indicating various things to libpng */
1064   png_uint_32 transformations; /* which transformations to perform */
1065
1066   z_stream zstream;          /* pointer to decompression structure (below) */
1067   png_bytep zbuf;            /* buffer for zlib */
1068   png_size_t zbuf_size;      /* size of zbuf */
1069   int zlib_level;            /* holds zlib compression level */
1070   int zlib_method;           /* holds zlib compression method */
1071   int zlib_window_bits;      /* holds zlib compression window bits */
1072   int zlib_mem_level;        /* holds zlib compression memory level */
1073   int zlib_strategy;         /* holds zlib compression strategy */
1074
1075   png_uint_32 width;         /* width of image in pixels */
1076   png_uint_32 height;        /* height of image in pixels */
1077   png_uint_32 num_rows;      /* number of rows in current pass */
1078   png_uint_32 usr_width;     /* width of row at start of write */
1079   png_uint_32 rowbytes;      /* size of row in bytes */
1080   png_uint_32 irowbytes;     /* size of current interlaced row in bytes */
1081   png_uint_32 iwidth;        /* width of current interlaced row in pixels */
1082   png_uint_32 row_number;    /* current row in interlace pass */
1083   png_bytep prev_row;        /* buffer to save previous (unfiltered) row */
1084   png_bytep row_buf;         /* buffer to save current (unfiltered) row */
1085   png_bytep sub_row;         /* buffer to save "sub" row when filtering */
1086   png_bytep up_row;          /* buffer to save "up" row when filtering */
1087   png_bytep avg_row;         /* buffer to save "avg" row when filtering */
1088   png_bytep paeth_row;       /* buffer to save "Paeth" row when filtering */
1089   png_row_info row_info;     /* used for transformation routines */
1090
1091   png_uint_32 idat_size;     /* current IDAT size for read */
1092   png_uint_32 crc;           /* current chunk CRC value */
1093   png_colorp palette;        /* palette from the input file */
1094   png_uint_16 num_palette;   /* number of color entries in palette */
1095   png_uint_16 num_trans;     /* number of transparency values */
1096   png_byte chunk_name[5];    /* null-terminated name of current chunk */
1097   png_byte compression;      /* file compression type (always 0) */
1098   png_byte filter;           /* file filter …

Large files files are truncated, but you can click here to view the full file