Back to index

tetex-bin  3.0
png.h
Go to the documentation of this file.
00001 /* png.h - header file for PNG reference library
00002  *
00003  * libpng version 1.2.8 - December 3, 2004
00004  * Copyright (c) 1998-2004 Glenn Randers-Pehrson
00005  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
00006  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
00007  *
00008  * Authors and maintainers:
00009  *  libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
00010  *  libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
00011  *  libpng versions 0.97, January 1998, through 1.2.8 - December 3, 2004: Glenn
00012  *  See also "Contributing Authors", below.
00013  *
00014  * Note about libpng version numbers:
00015  *
00016  *    Due to various miscommunications, unforeseen code incompatibilities
00017  *    and occasional factors outside the authors' control, version numbering
00018  *    on the library has not always been consistent and straightforward.
00019  *    The following table summarizes matters since version 0.89c, which was
00020  *    the first widely used release:
00021  *
00022  *    source                 png.h  png.h  shared-lib
00023  *    version                string   int  version
00024  *    -------                ------ -----  ----------
00025  *    0.89c "1.0 beta 3"     0.89      89  1.0.89
00026  *    0.90  "1.0 beta 4"     0.90      90  0.90  [should have been 2.0.90]
00027  *    0.95  "1.0 beta 5"     0.95      95  0.95  [should have been 2.0.95]
00028  *    0.96  "1.0 beta 6"     0.96      96  0.96  [should have been 2.0.96]
00029  *    0.97b "1.00.97 beta 7" 1.00.97   97  1.0.1 [should have been 2.0.97]
00030  *    0.97c                  0.97      97  2.0.97
00031  *    0.98                   0.98      98  2.0.98
00032  *    0.99                   0.99      98  2.0.99
00033  *    0.99a-m                0.99      99  2.0.99
00034  *    1.00                   1.00     100  2.1.0 [100 should be 10000]
00035  *    1.0.0      (from here on, the   100  2.1.0 [100 should be 10000]
00036  *    1.0.1       png.h string is   10001  2.1.0
00037  *    1.0.1a-e    identical to the  10002  from here on, the shared library
00038  *    1.0.2       source version)   10002  is 2.V where V is the source code
00039  *    1.0.2a-b                      10003  version, except as noted.
00040  *    1.0.3                         10003
00041  *    1.0.3a-d                      10004
00042  *    1.0.4                         10004
00043  *    1.0.4a-f                      10005
00044  *    1.0.5 (+ 2 patches)           10005
00045  *    1.0.5a-d                      10006
00046  *    1.0.5e-r                      10100 (not source compatible)
00047  *    1.0.5s-v                      10006 (not binary compatible)
00048  *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)
00049  *    1.0.6d-f                      10007 (still binary incompatible)
00050  *    1.0.6g                        10007
00051  *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)
00052  *    1.0.6i                        10007  10.6i
00053  *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)
00054  *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)
00055  *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)
00056  *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
00057  *    1.0.7                    1    10007  (still compatible)
00058  *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4
00059  *    1.0.8rc1                 1    10008  2.1.0.8rc1
00060  *    1.0.8                    1    10008  2.1.0.8
00061  *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6
00062  *    1.0.9rc1                 1    10009  2.1.0.9rc1
00063  *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10
00064  *    1.0.9rc2                 1    10009  2.1.0.9rc2
00065  *    1.0.9                    1    10009  2.1.0.9
00066  *    1.0.10beta1              1    10010  2.1.0.10beta1
00067  *    1.0.10rc1                1    10010  2.1.0.10rc1
00068  *    1.0.10                   1    10010  2.1.0.10
00069  *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3
00070  *    1.0.11rc1                1    10011  2.1.0.11rc1
00071  *    1.0.11                   1    10011  2.1.0.11
00072  *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2
00073  *    1.0.12rc1                2    10012  2.1.0.12rc1
00074  *    1.0.12                   2    10012  2.1.0.12
00075  *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)
00076  *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2
00077  *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5
00078  *    1.2.0rc1                 3    10200  3.1.2.0rc1
00079  *    1.2.0                    3    10200  3.1.2.0
00080  *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4
00081  *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2
00082  *    1.2.1                    3    10201  3.1.2.1
00083  *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6
00084  *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1
00085  *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1
00086  *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1
00087  *    1.0.13                  10    10013  10.so.0.1.0.13
00088  *    1.2.2                   12    10202  12.so.0.1.2.2
00089  *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6
00090  *    1.2.3                   12    10203  12.so.0.1.2.3
00091  *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3
00092  *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1
00093  *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1
00094  *    1.0.14                  10    10014  10.so.0.1.0.14
00095  *    1.2.4                   13    10204  12.so.0.1.2.4
00096  *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2
00097  *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3
00098  *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3
00099  *    1.0.15                  10    10015  10.so.0.1.0.15
00100  *    1.2.5                   13    10205  12.so.0.1.2.5
00101  *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4
00102  *    1.0.16                  10    10016  10.so.0.1.0.16
00103  *    1.2.6                   13    10206  12.so.0.1.2.6
00104  *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2
00105  *    1.0.17rc1               10    10017  12.so.0.1.0.17rc1
00106  *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1
00107  *    1.0.17                  10    10017  12.so.0.1.0.17
00108  *    1.2.7                   13    10207  12.so.0.1.2.7
00109  *    1.2.8beta1-5            13    10208  12.so.0.1.2.8beta1-5
00110  *    1.0.18rc1-5             10    10018  12.so.0.1.0.18rc1-5
00111  *    1.2.8rc1-5              13    10208  12.so.0.1.2.8rc1-5
00112  *    1.0.18                  10    10018  12.so.0.1.0.18
00113  *    1.2.8                   13    10208  12.so.0.1.2.8
00114  *
00115  *    Henceforth the source version will match the shared-library major
00116  *    and minor numbers; the shared-library major version number will be
00117  *    used for changes in backward compatibility, as it is intended.  The
00118  *    PNG_LIBPNG_VER macro, which is not used within libpng but is available
00119  *    for applications, is an unsigned integer of the form xyyzz corresponding
00120  *    to the source version x.y.z (leading zeros in y and z).  Beta versions
00121  *    were given the previous public release number plus a letter, until
00122  *    version 1.0.6j; from then on they were given the upcoming public
00123  *    release number plus "betaNN" or "rcN".
00124  *
00125  *    Binary incompatibility exists only when applications make direct access
00126  *    to the info_ptr or png_ptr members through png.h, and the compiled
00127  *    application is loaded with a different version of the library.
00128  *
00129  *    DLLNUM will change each time there are forward or backward changes
00130  *    in binary compatibility (e.g., when a new feature is added).
00131  *
00132  * See libpng.txt or libpng.3 for more information.  The PNG specification
00133  * is available as a W3C Recommendation and as an ISO Specification,
00134  * <http://www.w3.org/TR/2003/REC-PNG-20031110/
00135  */
00136 
00137 /*
00138  * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
00139  *
00140  * If you modify libpng you may insert additional notices immediately following
00141  * this sentence.
00142  *
00143  * libpng versions 1.2.6, August 15, 2004, through 1.2.8, December 3, 2004, are
00144  * Copyright (c) 2004 Glenn Randers-Pehrson, and are
00145  * distributed according to the same disclaimer and license as libpng-1.2.5
00146  * with the following individual added to the list of Contributing Authors:
00147  *
00148  *    Cosmin Truta
00149  *
00150  * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
00151  * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
00152  * distributed according to the same disclaimer and license as libpng-1.0.6
00153  * with the following individuals added to the list of Contributing Authors:
00154  *
00155  *    Simon-Pierre Cadieux
00156  *    Eric S. Raymond
00157  *    Gilles Vollant
00158  *
00159  * and with the following additions to the disclaimer:
00160  *
00161  *    There is no warranty against interference with your enjoyment of the
00162  *    library or against infringement.  There is no warranty that our
00163  *    efforts or the library will fulfill any of your particular purposes
00164  *    or needs.  This library is provided with all faults, and the entire
00165  *    risk of satisfactory quality, performance, accuracy, and effort is with
00166  *    the user.
00167  *
00168  * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
00169  * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
00170  * distributed according to the same disclaimer and license as libpng-0.96,
00171  * with the following individuals added to the list of Contributing Authors:
00172  *
00173  *    Tom Lane
00174  *    Glenn Randers-Pehrson
00175  *    Willem van Schaik
00176  *
00177  * libpng versions 0.89, June 1996, through 0.96, May 1997, are
00178  * Copyright (c) 1996, 1997 Andreas Dilger
00179  * Distributed according to the same disclaimer and license as libpng-0.88,
00180  * with the following individuals added to the list of Contributing Authors:
00181  *
00182  *    John Bowler
00183  *    Kevin Bracey
00184  *    Sam Bushell
00185  *    Magnus Holmgren
00186  *    Greg Roelofs
00187  *    Tom Tanner
00188  *
00189  * libpng versions 0.5, May 1995, through 0.88, January 1996, are
00190  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
00191  *
00192  * For the purposes of this copyright and license, "Contributing Authors"
00193  * is defined as the following set of individuals:
00194  *
00195  *    Andreas Dilger
00196  *    Dave Martindale
00197  *    Guy Eric Schalnat
00198  *    Paul Schmidt
00199  *    Tim Wegner
00200  *
00201  * The PNG Reference Library is supplied "AS IS".  The Contributing Authors
00202  * and Group 42, Inc. disclaim all warranties, expressed or implied,
00203  * including, without limitation, the warranties of merchantability and of
00204  * fitness for any purpose.  The Contributing Authors and Group 42, Inc.
00205  * assume no liability for direct, indirect, incidental, special, exemplary,
00206  * or consequential damages, which may result from the use of the PNG
00207  * Reference Library, even if advised of the possibility of such damage.
00208  *
00209  * Permission is hereby granted to use, copy, modify, and distribute this
00210  * source code, or portions hereof, for any purpose, without fee, subject
00211  * to the following restrictions:
00212  *
00213  * 1. The origin of this source code must not be misrepresented.
00214  *
00215  * 2. Altered versions must be plainly marked as such and
00216  * must not be misrepresented as being the original source.
00217  *
00218  * 3. This Copyright notice may not be removed or altered from
00219  *    any source or altered source distribution.
00220  *
00221  * The Contributing Authors and Group 42, Inc. specifically permit, without
00222  * fee, and encourage the use of this source code as a component to
00223  * supporting the PNG file format in commercial products.  If you use this
00224  * source code in a product, acknowledgment is not required but would be
00225  * appreciated.
00226  */
00227 
00228 /*
00229  * A "png_get_copyright" function is available, for convenient use in "about"
00230  * boxes and the like:
00231  *
00232  * printf("%s",png_get_copyright(NULL));
00233  *
00234  * Also, the PNG logo (in PNG format, of course) is supplied in the
00235  * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
00236  */
00237 
00238 /*
00239  * Libpng is OSI Certified Open Source Software.  OSI Certified is a
00240  * certification mark of the Open Source Initiative.
00241  */
00242 
00243 /*
00244  * The contributing authors would like to thank all those who helped
00245  * with testing, bug fixes, and patience.  This wouldn't have been
00246  * possible without all of you.
00247  *
00248  * Thanks to Frank J. T. Wojcik for helping with the documentation.
00249  */
00250 
00251 /*
00252  * Y2K compliance in libpng:
00253  * =========================
00254  *
00255  *    December 3, 2004
00256  *
00257  *    Since the PNG Development group is an ad-hoc body, we can't make
00258  *    an official declaration.
00259  *
00260  *    This is your unofficial assurance that libpng from version 0.71 and
00261  *    upward through 1.2.8 are Y2K compliant.  It is my belief that earlier
00262  *    versions were also Y2K compliant.
00263  *
00264  *    Libpng only has three year fields.  One is a 2-byte unsigned integer
00265  *    that will hold years up to 65535.  The other two hold the date in text
00266  *    format, and will hold years up to 9999.
00267  *
00268  *    The integer is
00269  *        "png_uint_16 year" in png_time_struct.
00270  *
00271  *    The strings are
00272  *        "png_charp time_buffer" in png_struct and
00273  *        "near_time_buffer", which is a local character string in png.c.
00274  *
00275  *    There are seven time-related functions:
00276  *        png.c: png_convert_to_rfc_1123() in png.c
00277  *          (formerly png_convert_to_rfc_1152() in error)
00278  *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
00279  *        png_convert_from_time_t() in pngwrite.c
00280  *        png_get_tIME() in pngget.c
00281  *        png_handle_tIME() in pngrutil.c, called in pngread.c
00282  *        png_set_tIME() in pngset.c
00283  *        png_write_tIME() in pngwutil.c, called in pngwrite.c
00284  *
00285  *    All handle dates properly in a Y2K environment.  The
00286  *    png_convert_from_time_t() function calls gmtime() to convert from system
00287  *    clock time, which returns (year - 1900), which we properly convert to
00288  *    the full 4-digit year.  There is a possibility that applications using
00289  *    libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
00290  *    function, or that they are incorrectly passing only a 2-digit year
00291  *    instead of "year - 1900" into the png_convert_from_struct_tm() function,
00292  *    but this is not under our control.  The libpng documentation has always
00293  *    stated that it works with 4-digit years, and the APIs have been
00294  *    documented as such.
00295  *
00296  *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
00297  *    integer to hold the year, and can hold years as large as 65535.
00298  *
00299  *    zlib, upon which libpng depends, is also Y2K compliant.  It contains
00300  *    no date-related code.
00301  *
00302  *       Glenn Randers-Pehrson
00303  *       libpng maintainer
00304  *       PNG Development Group
00305  */
00306 
00307 #ifndef PNG_H
00308 #define PNG_H
00309 
00310 /* This is not the place to learn how to use libpng.  The file libpng.txt
00311  * describes how to use libpng, and the file example.c summarizes it
00312  * with some code on which to build.  This file is useful for looking
00313  * at the actual function definitions and structure components.
00314  */
00315 
00316 /* Version information for png.h - this should match the version in png.c */
00317 #define PNG_LIBPNG_VER_STRING "1.2.8"
00318 #define PNG_HEADER_VERSION_STRING \
00319    " libpng version 1.2.8 - December 3, 2004 (header)\n"
00320 
00321 #define PNG_LIBPNG_VER_SONUM   0
00322 #define PNG_LIBPNG_VER_DLLNUM  13
00323 
00324 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
00325 #define PNG_LIBPNG_VER_MAJOR   1
00326 #define PNG_LIBPNG_VER_MINOR   2
00327 #define PNG_LIBPNG_VER_RELEASE 8
00328 /* This should match the numeric part of the final component of
00329  * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
00330 
00331 #define PNG_LIBPNG_VER_BUILD  0
00332 
00333 /* Release Status */
00334 #define PNG_LIBPNG_BUILD_ALPHA    1
00335 #define PNG_LIBPNG_BUILD_BETA     2
00336 #define PNG_LIBPNG_BUILD_RC       3
00337 #define PNG_LIBPNG_BUILD_STABLE   4
00338 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
00339   
00340 /* Release-Specific Flags */
00341 #define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with
00342                                        PNG_LIBPNG_BUILD_STABLE only */
00343 #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
00344                                        PNG_LIBPNG_BUILD_SPECIAL */
00345 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
00346                                        PNG_LIBPNG_BUILD_PRIVATE */
00347 
00348 #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
00349 
00350 /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
00351  * We must not include leading zeros.
00352  * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
00353  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
00354  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release */
00355 #define PNG_LIBPNG_VER 10208 /* 1.2.8 */
00356 
00357 #ifndef PNG_VERSION_INFO_ONLY
00358 /* include the compression library's header */
00359 #include "zlib.h"
00360 #endif
00361 
00362 /* include all user configurable info, including optional assembler routines */
00363 #include "pngconf.h"
00364 
00365 /*
00366  * Added at libpng-1.2.8 */
00367 /* Ref MSDN: Private as priority over Special
00368  * VS_FF_PRIVATEBUILD File *was not* built using standard release
00369  * procedures. If this value is given, the StringFileInfo block must
00370  * contain a PrivateBuild string. 
00371  *
00372  * VS_FF_SPECIALBUILD File *was* built by the original company using
00373  * standard release procedures but is a variation of the standard
00374  * file of the same version number. If this value is given, the
00375  * StringFileInfo block must contain a SpecialBuild string. 
00376  */
00377 
00378 #if defined(PNG_USER_PRIVATEBUILD)
00379 #  define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE | \
00380           PNG_LIBPNG_BUILD_PRIVATE
00381 #else
00382 #  if defined(PNG_LIBPNG_SPECIALBUILD)
00383 #    define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE | \
00384             PNG_LIBPNG_BUILD_SPECIAL
00385 #  else
00386 #    define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE
00387 #  endif
00388 #endif
00389 
00390 #ifndef PNG_VERSION_INFO_ONLY
00391 
00392 /* Inhibit C++ name-mangling for libpng functions but not for system calls. */
00393 #ifdef __cplusplus
00394 extern "C" {
00395 #endif /* __cplusplus */
00396 
00397 /* This file is arranged in several sections.  The first section contains
00398  * structure and type definitions.  The second section contains the external
00399  * library functions, while the third has the internal library functions,
00400  * which applications aren't expected to use directly.
00401  */
00402 
00403 #ifndef PNG_NO_TYPECAST_NULL
00404 #define int_p_NULL                (int *)NULL
00405 #define png_bytep_NULL            (png_bytep)NULL
00406 #define png_bytepp_NULL           (png_bytepp)NULL
00407 #define png_doublep_NULL          (png_doublep)NULL
00408 #define png_error_ptr_NULL        (png_error_ptr)NULL
00409 #define png_flush_ptr_NULL        (png_flush_ptr)NULL
00410 #define png_free_ptr_NULL         (png_free_ptr)NULL
00411 #define png_infopp_NULL           (png_infopp)NULL
00412 #define png_malloc_ptr_NULL       (png_malloc_ptr)NULL
00413 #define png_read_status_ptr_NULL  (png_read_status_ptr)NULL
00414 #define png_rw_ptr_NULL           (png_rw_ptr)NULL
00415 #define png_structp_NULL          (png_structp)NULL
00416 #define png_uint_16p_NULL         (png_uint_16p)NULL
00417 #define png_voidp_NULL            (png_voidp)NULL
00418 #define png_write_status_ptr_NULL (png_write_status_ptr)NULL
00419 #else
00420 #define int_p_NULL                NULL
00421 #define png_bytep_NULL            NULL
00422 #define png_bytepp_NULL           NULL
00423 #define png_doublep_NULL          NULL
00424 #define png_error_ptr_NULL        NULL
00425 #define png_flush_ptr_NULL        NULL
00426 #define png_free_ptr_NULL         NULL
00427 #define png_infopp_NULL           NULL
00428 #define png_malloc_ptr_NULL       NULL
00429 #define png_read_status_ptr_NULL  NULL
00430 #define png_rw_ptr_NULL           NULL
00431 #define png_structp_NULL          NULL
00432 #define png_uint_16p_NULL         NULL
00433 #define png_voidp_NULL            NULL
00434 #define png_write_status_ptr_NULL NULL
00435 #endif
00436 
00437 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
00438 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
00439 /* Version information for C files, stored in png.c.  This had better match
00440  * the version above.
00441  */
00442 #ifdef PNG_USE_GLOBAL_ARRAYS
00443 PNG_EXPORT_VAR (const char) png_libpng_ver[18];
00444   /* need room for 99.99.99beta99z */
00445 #else
00446 #define png_libpng_ver png_get_header_ver(NULL)
00447 #endif
00448 
00449 #ifdef PNG_USE_GLOBAL_ARRAYS
00450 /* This was removed in version 1.0.5c */
00451 /* Structures to facilitate easy interlacing.  See png.c for more details */
00452 PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7];
00453 PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7];
00454 PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7];
00455 PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7];
00456 PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7];
00457 PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7];
00458 #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
00459 PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7];
00460 #endif
00461 /* This isn't currently used.  If you need it, see png.c for more details.
00462 PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7];
00463 */
00464 #endif
00465 
00466 #endif /* PNG_NO_EXTERN */
00467 
00468 /* Three color definitions.  The order of the red, green, and blue, (and the
00469  * exact size) is not important, although the size of the fields need to
00470  * be png_byte or png_uint_16 (as defined below).
00471  */
00472 typedef struct png_color_struct
00473 {
00474    png_byte red;
00475    png_byte green;
00476    png_byte blue;
00477 } png_color;
00478 typedef png_color FAR * png_colorp;
00479 typedef png_color FAR * FAR * png_colorpp;
00480 
00481 typedef struct png_color_16_struct
00482 {
00483    png_byte index;    /* used for palette files */
00484    png_uint_16 red;   /* for use in red green blue files */
00485    png_uint_16 green;
00486    png_uint_16 blue;
00487    png_uint_16 gray;  /* for use in grayscale files */
00488 } png_color_16;
00489 typedef png_color_16 FAR * png_color_16p;
00490 typedef png_color_16 FAR * FAR * png_color_16pp;
00491 
00492 typedef struct png_color_8_struct
00493 {
00494    png_byte red;   /* for use in red green blue files */
00495    png_byte green;
00496    png_byte blue;
00497    png_byte gray;  /* for use in grayscale files */
00498    png_byte alpha; /* for alpha channel files */
00499 } png_color_8;
00500 typedef png_color_8 FAR * png_color_8p;
00501 typedef png_color_8 FAR * FAR * png_color_8pp;
00502 
00503 /*
00504  * The following two structures are used for the in-core representation
00505  * of sPLT chunks.
00506  */
00507 typedef struct png_sPLT_entry_struct
00508 {
00509    png_uint_16 red;
00510    png_uint_16 green;
00511    png_uint_16 blue;
00512    png_uint_16 alpha;
00513    png_uint_16 frequency;
00514 } png_sPLT_entry;
00515 typedef png_sPLT_entry FAR * png_sPLT_entryp;
00516 typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
00517 
00518 /*  When the depth of the sPLT palette is 8 bits, the color and alpha samples
00519  *  occupy the LSB of their respective members, and the MSB of each member
00520  *  is zero-filled.  The frequency member always occupies the full 16 bits.
00521  */
00522 
00523 typedef struct png_sPLT_struct
00524 {
00525    png_charp name;           /* palette name */
00526    png_byte depth;           /* depth of palette samples */
00527    png_sPLT_entryp entries;  /* palette entries */
00528    png_int_32 nentries;      /* number of palette entries */
00529 } png_sPLT_t;
00530 typedef png_sPLT_t FAR * png_sPLT_tp;
00531 typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
00532 
00533 #ifdef PNG_TEXT_SUPPORTED
00534 /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
00535  * and whether that contents is compressed or not.  The "key" field
00536  * points to a regular zero-terminated C string.  The "text", "lang", and
00537  * "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
00538  * However, the * structure returned by png_get_text() will always contain
00539  * regular zero-terminated C strings (possibly empty), never NULL pointers,
00540  * so they can be safely used in printf() and other string-handling functions.
00541  */
00542 typedef struct png_text_struct
00543 {
00544    int  compression;       /* compression value:
00545                              -1: tEXt, none
00546                               0: zTXt, deflate
00547                               1: iTXt, none
00548                               2: iTXt, deflate  */
00549    png_charp key;          /* keyword, 1-79 character description of "text" */
00550    png_charp text;         /* comment, may be an empty string (ie "")
00551                               or a NULL pointer */
00552    png_size_t text_length; /* length of the text string */
00553 #ifdef PNG_iTXt_SUPPORTED
00554    png_size_t itxt_length; /* length of the itxt string */
00555    png_charp lang;         /* language code, 0-79 characters
00556                               or a NULL pointer */
00557    png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more
00558                               chars or a NULL pointer */
00559 #endif
00560 } png_text;
00561 typedef png_text FAR * png_textp;
00562 typedef png_text FAR * FAR * png_textpp;
00563 #endif
00564 
00565 /* Supported compression types for text in PNG files (tEXt, and zTXt).
00566  * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
00567 #define PNG_TEXT_COMPRESSION_NONE_WR -3
00568 #define PNG_TEXT_COMPRESSION_zTXt_WR -2
00569 #define PNG_TEXT_COMPRESSION_NONE    -1
00570 #define PNG_TEXT_COMPRESSION_zTXt     0
00571 #define PNG_ITXT_COMPRESSION_NONE     1
00572 #define PNG_ITXT_COMPRESSION_zTXt     2
00573 #define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */
00574 
00575 /* png_time is a way to hold the time in an machine independent way.
00576  * Two conversions are provided, both from time_t and struct tm.  There
00577  * is no portable way to convert to either of these structures, as far
00578  * as I know.  If you know of a portable way, send it to me.  As a side
00579  * note - PNG has always been Year 2000 compliant!
00580  */
00581 typedef struct png_time_struct
00582 {
00583    png_uint_16 year; /* full year, as in, 1995 */
00584    png_byte month;   /* month of year, 1 - 12 */
00585    png_byte day;     /* day of month, 1 - 31 */
00586    png_byte hour;    /* hour of day, 0 - 23 */
00587    png_byte minute;  /* minute of hour, 0 - 59 */
00588    png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */
00589 } png_time;
00590 typedef png_time FAR * png_timep;
00591 typedef png_time FAR * FAR * png_timepp;
00592 
00593 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
00594 /* png_unknown_chunk is a structure to hold queued chunks for which there is
00595  * no specific support.  The idea is that we can use this to queue
00596  * up private chunks for output even though the library doesn't actually
00597  * know about their semantics.
00598  */
00599 typedef struct png_unknown_chunk_t
00600 {
00601     png_byte name[5];
00602     png_byte *data;
00603     png_size_t size;
00604 
00605     /* libpng-using applications should NOT directly modify this byte. */
00606     png_byte location; /* mode of operation at read time */
00607 }
00608 png_unknown_chunk;
00609 typedef png_unknown_chunk FAR * png_unknown_chunkp;
00610 typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
00611 #endif
00612 
00613 /* png_info is a structure that holds the information in a PNG file so
00614  * that the application can find out the characteristics of the image.
00615  * If you are reading the file, this structure will tell you what is
00616  * in the PNG file.  If you are writing the file, fill in the information
00617  * you want to put into the PNG file, then call png_write_info().
00618  * The names chosen should be very close to the PNG specification, so
00619  * consult that document for information about the meaning of each field.
00620  *
00621  * With libpng < 0.95, it was only possible to directly set and read the
00622  * the values in the png_info_struct, which meant that the contents and
00623  * order of the values had to remain fixed.  With libpng 0.95 and later,
00624  * however, there are now functions that abstract the contents of
00625  * png_info_struct from the application, so this makes it easier to use
00626  * libpng with dynamic libraries, and even makes it possible to use
00627  * libraries that don't have all of the libpng ancillary chunk-handing
00628  * functionality.
00629  *
00630  * In any case, the order of the parameters in png_info_struct should NOT
00631  * be changed for as long as possible to keep compatibility with applications
00632  * that use the old direct-access method with png_info_struct.
00633  *
00634  * The following members may have allocated storage attached that should be
00635  * cleaned up before the structure is discarded: palette, trans, text,
00636  * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
00637  * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these
00638  * are automatically freed when the info structure is deallocated, if they were
00639  * allocated internally by libpng.  This behavior can be changed by means
00640  * of the png_data_freer() function.
00641  *
00642  * More allocation details: all the chunk-reading functions that
00643  * change these members go through the corresponding png_set_*
00644  * functions.  A function to clear these members is available: see
00645  * png_free_data().  The png_set_* functions do not depend on being
00646  * able to point info structure members to any of the storage they are
00647  * passed (they make their own copies), EXCEPT that the png_set_text
00648  * functions use the same storage passed to them in the text_ptr or
00649  * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
00650  * functions do not make their own copies.
00651  */
00652 typedef struct png_info_struct
00653 {
00654    /* the following are necessary for every PNG file */
00655    png_uint_32 width;       /* width of image in pixels (from IHDR) */
00656    png_uint_32 height;      /* height of image in pixels (from IHDR) */
00657    png_uint_32 valid;       /* valid chunk data (see PNG_INFO_ below) */
00658    png_uint_32 rowbytes;    /* bytes needed to hold an untransformed row */
00659    png_colorp palette;      /* array of color values (valid & PNG_INFO_PLTE) */
00660    png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
00661    png_uint_16 num_trans;   /* number of transparent palette color (tRNS) */
00662    png_byte bit_depth;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
00663    png_byte color_type;     /* see PNG_COLOR_TYPE_ below (from IHDR) */
00664    /* The following three should have been named *_method not *_type */
00665    png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
00666    png_byte filter_type;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
00667    png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
00668 
00669    /* The following is informational only on read, and not used on writes. */
00670    png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4) */
00671    png_byte pixel_depth;    /* number of bits per pixel */
00672    png_byte spare_byte;     /* to align the data, and for future use */
00673    png_byte signature[8];   /* magic bytes read by libpng from start of file */
00674 
00675    /* The rest of the data is optional.  If you are reading, check the
00676     * valid field to see if the information in these are valid.  If you
00677     * are writing, set the valid field to those chunks you want written,
00678     * and initialize the appropriate fields below.
00679     */
00680 
00681 #if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
00682    /* The gAMA chunk describes the gamma characteristics of the system
00683     * on which the image was created, normally in the range [1.0, 2.5].
00684     * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
00685     */
00686    float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
00687 #endif
00688 
00689 #if defined(PNG_sRGB_SUPPORTED)
00690     /* GR-P, 0.96a */
00691     /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
00692    png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
00693 #endif
00694 
00695 #if defined(PNG_TEXT_SUPPORTED)
00696    /* The tEXt, and zTXt chunks contain human-readable textual data in
00697     * uncompressed, compressed, and optionally compressed forms, respectively.
00698     * The data in "text" is an array of pointers to uncompressed,
00699     * null-terminated C strings. Each chunk has a keyword that describes the
00700     * textual data contained in that chunk.  Keywords are not required to be
00701     * unique, and the text string may be empty.  Any number of text chunks may
00702     * be in an image.
00703     */
00704    int num_text; /* number of comments read/to write */
00705    int max_text; /* current size of text array */
00706    png_textp text; /* array of comments read/to write */
00707 #endif /* PNG_TEXT_SUPPORTED */
00708 
00709 #if defined(PNG_tIME_SUPPORTED)
00710    /* The tIME chunk holds the last time the displayed image data was
00711     * modified.  See the png_time struct for the contents of this struct.
00712     */
00713    png_time mod_time;
00714 #endif
00715 
00716 #if defined(PNG_sBIT_SUPPORTED)
00717    /* The sBIT chunk specifies the number of significant high-order bits
00718     * in the pixel data.  Values are in the range [1, bit_depth], and are
00719     * only specified for the channels in the pixel data.  The contents of
00720     * the low-order bits is not specified.  Data is valid if
00721     * (valid & PNG_INFO_sBIT) is non-zero.
00722     */
00723    png_color_8 sig_bit; /* significant bits in color channels */
00724 #endif
00725 
00726 #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
00727 defined(PNG_READ_BACKGROUND_SUPPORTED)
00728    /* The tRNS chunk supplies transparency data for paletted images and
00729     * other image types that don't need a full alpha channel.  There are
00730     * "num_trans" transparency values for a paletted image, stored in the
00731     * same order as the palette colors, starting from index 0.  Values
00732     * for the data are in the range [0, 255], ranging from fully transparent
00733     * to fully opaque, respectively.  For non-paletted images, there is a
00734     * single color specified that should be treated as fully transparent.
00735     * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
00736     */
00737    png_bytep trans; /* transparent values for paletted image */
00738    png_color_16 trans_values; /* transparent color for non-palette image */
00739 #endif
00740 
00741 #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
00742    /* The bKGD chunk gives the suggested image background color if the
00743     * display program does not have its own background color and the image
00744     * is needs to composited onto a background before display.  The colors
00745     * in "background" are normally in the same color space/depth as the
00746     * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
00747     */
00748    png_color_16 background;
00749 #endif
00750 
00751 #if defined(PNG_oFFs_SUPPORTED)
00752    /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
00753     * and downwards from the top-left corner of the display, page, or other
00754     * application-specific co-ordinate space.  See the PNG_OFFSET_ defines
00755     * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.
00756     */
00757    png_int_32 x_offset; /* x offset on page */
00758    png_int_32 y_offset; /* y offset on page */
00759    png_byte offset_unit_type; /* offset units type */
00760 #endif
00761 
00762 #if defined(PNG_pHYs_SUPPORTED)
00763    /* The pHYs chunk gives the physical pixel density of the image for
00764     * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
00765     * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
00766     */
00767    png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
00768    png_uint_32 y_pixels_per_unit; /* vertical pixel density */
00769    png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
00770 #endif
00771 
00772 #if defined(PNG_hIST_SUPPORTED)
00773    /* The hIST chunk contains the relative frequency or importance of the
00774     * various palette entries, so that a viewer can intelligently select a
00775     * reduced-color palette, if required.  Data is an array of "num_palette"
00776     * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
00777     * is non-zero.
00778     */
00779    png_uint_16p hist;
00780 #endif
00781 
00782 #ifdef PNG_cHRM_SUPPORTED
00783    /* The cHRM chunk describes the CIE color characteristics of the monitor
00784     * on which the PNG was created.  This data allows the viewer to do gamut
00785     * mapping of the input image to ensure that the viewer sees the same
00786     * colors in the image as the creator.  Values are in the range
00787     * [0.0, 0.8].  Data valid if (valid & PNG_INFO_cHRM) non-zero.
00788     */
00789 #ifdef PNG_FLOATING_POINT_SUPPORTED
00790    float x_white;
00791    float y_white;
00792    float x_red;
00793    float y_red;
00794    float x_green;
00795    float y_green;
00796    float x_blue;
00797    float y_blue;
00798 #endif
00799 #endif
00800 
00801 #if defined(PNG_pCAL_SUPPORTED)
00802    /* The pCAL chunk describes a transformation between the stored pixel
00803     * values and original physical data values used to create the image.
00804     * The integer range [0, 2^bit_depth - 1] maps to the floating-point
00805     * range given by [pcal_X0, pcal_X1], and are further transformed by a
00806     * (possibly non-linear) transformation function given by "pcal_type"
00807     * and "pcal_params" into "pcal_units".  Please see the PNG_EQUATION_
00808     * defines below, and the PNG-Group's PNG extensions document for a
00809     * complete description of the transformations and how they should be
00810     * implemented, and for a description of the ASCII parameter strings.
00811     * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
00812     */
00813    png_charp pcal_purpose;  /* pCAL chunk description string */
00814    png_int_32 pcal_X0;      /* minimum value */
00815    png_int_32 pcal_X1;      /* maximum value */
00816    png_charp pcal_units;    /* Latin-1 string giving physical units */
00817    png_charpp pcal_params;  /* ASCII strings containing parameter values */
00818    png_byte pcal_type;      /* equation type (see PNG_EQUATION_ below) */
00819    png_byte pcal_nparams;   /* number of parameters given in pcal_params */
00820 #endif
00821 
00822 /* New members added in libpng-1.0.6 */
00823 #ifdef PNG_FREE_ME_SUPPORTED
00824    png_uint_32 free_me;     /* flags items libpng is responsible for freeing */
00825 #endif
00826 
00827 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
00828    /* storage for unknown chunks that the library doesn't recognize. */
00829    png_unknown_chunkp unknown_chunks;
00830    png_size_t unknown_chunks_num;
00831 #endif
00832 
00833 #if defined(PNG_iCCP_SUPPORTED)
00834    /* iCCP chunk data. */
00835    png_charp iccp_name;     /* profile name */
00836    png_charp iccp_profile;  /* International Color Consortium profile data */
00837                             /* Note to maintainer: should be png_bytep */
00838    png_uint_32 iccp_proflen;  /* ICC profile data length */
00839    png_byte iccp_compression; /* Always zero */
00840 #endif
00841 
00842 #if defined(PNG_sPLT_SUPPORTED)
00843    /* data on sPLT chunks (there may be more than one). */
00844    png_sPLT_tp splt_palettes;
00845    png_uint_32 splt_palettes_num;
00846 #endif
00847 
00848 #if defined(PNG_sCAL_SUPPORTED)
00849    /* The sCAL chunk describes the actual physical dimensions of the
00850     * subject matter of the graphic.  The chunk contains a unit specification
00851     * a byte value, and two ASCII strings representing floating-point
00852     * values.  The values are width and height corresponsing to one pixel
00853     * in the image.  This external representation is converted to double
00854     * here.  Data values are valid if (valid & PNG_INFO_sCAL) is non-zero.
00855     */
00856    png_byte scal_unit;         /* unit of physical scale */
00857 #ifdef PNG_FLOATING_POINT_SUPPORTED
00858    double scal_pixel_width;    /* width of one pixel */
00859    double scal_pixel_height;   /* height of one pixel */
00860 #endif
00861 #ifdef PNG_FIXED_POINT_SUPPORTED
00862    png_charp scal_s_width;     /* string containing height */
00863    png_charp scal_s_height;    /* string containing width */
00864 #endif
00865 #endif
00866 
00867 #if defined(PNG_INFO_IMAGE_SUPPORTED)
00868    /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */
00869    /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
00870    png_bytepp row_pointers;        /* the image bits */
00871 #endif
00872 
00873 #if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED)
00874    png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */
00875 #endif
00876 
00877 #if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED)
00878    png_fixed_point int_x_white;
00879    png_fixed_point int_y_white;
00880    png_fixed_point int_x_red;
00881    png_fixed_point int_y_red;
00882    png_fixed_point int_x_green;
00883    png_fixed_point int_y_green;
00884    png_fixed_point int_x_blue;
00885    png_fixed_point int_y_blue;
00886 #endif
00887 
00888 } png_info;
00889 
00890 typedef png_info FAR * png_infop;
00891 typedef png_info FAR * FAR * png_infopp;
00892 
00893 /* Maximum positive integer used in PNG is (2^31)-1 */
00894 #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
00895 #define PNG_UINT_32_MAX ((png_uint_32)(-1))
00896 #define PNG_SIZE_MAX ((png_size_t)(-1))
00897 /* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
00898 #define PNG_MAX_UINT PNG_UINT_31_MAX
00899 
00900 /* These describe the color_type field in png_info. */
00901 /* color type masks */
00902 #define PNG_COLOR_MASK_PALETTE    1
00903 #define PNG_COLOR_MASK_COLOR      2
00904 #define PNG_COLOR_MASK_ALPHA      4
00905 
00906 /* color types.  Note that not all combinations are legal */
00907 #define PNG_COLOR_TYPE_GRAY 0
00908 #define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
00909 #define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
00910 #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
00911 #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
00912 /* aliases */
00913 #define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA
00914 #define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA
00915 
00916 /* This is for compression type. PNG 1.0-1.2 only define the single type. */
00917 #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
00918 #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
00919 
00920 /* This is for filter type. PNG 1.0-1.2 only define the single type. */
00921 #define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */
00922 #define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
00923 #define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE
00924 
00925 /* These are for the interlacing type.  These values should NOT be changed. */
00926 #define PNG_INTERLACE_NONE        0 /* Non-interlaced image */
00927 #define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */
00928 #define PNG_INTERLACE_LAST        2 /* Not a valid value */
00929 
00930 /* These are for the oFFs chunk.  These values should NOT be changed. */
00931 #define PNG_OFFSET_PIXEL          0 /* Offset in pixels */
00932 #define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */
00933 #define PNG_OFFSET_LAST           2 /* Not a valid value */
00934 
00935 /* These are for the pCAL chunk.  These values should NOT be changed. */
00936 #define PNG_EQUATION_LINEAR       0 /* Linear transformation */
00937 #define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */
00938 #define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */
00939 #define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */
00940 #define PNG_EQUATION_LAST         4 /* Not a valid value */
00941 
00942 /* These are for the sCAL chunk.  These values should NOT be changed. */
00943 #define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */
00944 #define PNG_SCALE_METER           1 /* meters per pixel */
00945 #define PNG_SCALE_RADIAN          2 /* radians per pixel */
00946 #define PNG_SCALE_LAST            3 /* Not a valid value */
00947 
00948 /* These are for the pHYs chunk.  These values should NOT be changed. */
00949 #define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */
00950 #define PNG_RESOLUTION_METER      1 /* pixels/meter */
00951 #define PNG_RESOLUTION_LAST       2 /* Not a valid value */
00952 
00953 /* These are for the sRGB chunk.  These values should NOT be changed. */
00954 #define PNG_sRGB_INTENT_PERCEPTUAL 0
00955 #define PNG_sRGB_INTENT_RELATIVE   1
00956 #define PNG_sRGB_INTENT_SATURATION 2
00957 #define PNG_sRGB_INTENT_ABSOLUTE   3
00958 #define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */
00959 
00960 /* This is for text chunks */
00961 #define PNG_KEYWORD_MAX_LENGTH     79
00962 
00963 /* Maximum number of entries in PLTE/sPLT/tRNS arrays */
00964 #define PNG_MAX_PALETTE_LENGTH    256
00965 
00966 /* These determine if an ancillary chunk's data has been successfully read
00967  * from the PNG header, or if the application has filled in the corresponding
00968  * data in the info_struct to be written into the output file.  The values
00969  * of the PNG_INFO_<chunk> defines should NOT be changed.
00970  */
00971 #define PNG_INFO_gAMA 0x0001
00972 #define PNG_INFO_sBIT 0x0002
00973 #define PNG_INFO_cHRM 0x0004
00974 #define PNG_INFO_PLTE 0x0008
00975 #define PNG_INFO_tRNS 0x0010
00976 #define PNG_INFO_bKGD 0x0020
00977 #define PNG_INFO_hIST 0x0040
00978 #define PNG_INFO_pHYs 0x0080
00979 #define PNG_INFO_oFFs 0x0100
00980 #define PNG_INFO_tIME 0x0200
00981 #define PNG_INFO_pCAL 0x0400
00982 #define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */
00983 #define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */
00984 #define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
00985 #define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
00986 #define PNG_INFO_IDAT 0x8000L  /* ESR, 1.0.6 */
00987 
00988 /* This is used for the transformation routines, as some of them
00989  * change these values for the row.  It also should enable using
00990  * the routines for other purposes.
00991  */
00992 typedef struct png_row_info_struct
00993 {
00994    png_uint_32 width; /* width of row */
00995    png_uint_32 rowbytes; /* number of bytes in row */
00996    png_byte color_type; /* color type of row */
00997    png_byte bit_depth; /* bit depth of row */
00998    png_byte channels; /* number of channels (1, 2, 3, or 4) */
00999    png_byte pixel_depth; /* bits per pixel (depth * channels) */
01000 } png_row_info;
01001 
01002 typedef png_row_info FAR * png_row_infop;
01003 typedef png_row_info FAR * FAR * png_row_infopp;
01004 
01005 /* These are the function types for the I/O functions and for the functions
01006  * that allow the user to override the default I/O functions with his or her
01007  * own.  The png_error_ptr type should match that of user-supplied warning
01008  * and error functions, while the png_rw_ptr type should match that of the
01009  * user read/write data functions.
01010  */
01011 typedef struct png_struct_def png_struct;
01012 typedef png_struct FAR * png_structp;
01013 
01014 typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp));
01015 typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
01016 typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp));
01017 typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32,
01018    int));
01019 typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32,
01020    int));
01021 
01022 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
01023 typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop));
01024 typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
01025 typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
01026    png_uint_32, int));
01027 #endif
01028 
01029 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
01030     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
01031     defined(PNG_LEGACY_SUPPORTED)
01032 typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp,
01033     png_row_infop, png_bytep));
01034 #endif
01035 
01036 #if defined(PNG_USER_CHUNKS_SUPPORTED)
01037 typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp));
01038 #endif
01039 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
01040 typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
01041 #endif
01042 
01043 /* Transform masks for the high-level interface */
01044 #define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */
01045 #define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */
01046 #define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */
01047 #define PNG_TRANSFORM_PACKING        0x0004    /* read and write */
01048 #define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */
01049 #define PNG_TRANSFORM_EXPAND         0x0010    /* read only */
01050 #define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */
01051 #define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */
01052 #define PNG_TRANSFORM_BGR            0x0080    /* read and write */
01053 #define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */
01054 #define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */
01055 #define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */
01056 #define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* WRITE only */
01057 
01058 /* Flags for MNG supported features */
01059 #define PNG_FLAG_MNG_EMPTY_PLTE     0x01
01060 #define PNG_FLAG_MNG_FILTER_64      0x04
01061 #define PNG_ALL_MNG_FEATURES        0x05
01062 
01063 typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
01064 typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
01065 
01066 /* The structure that holds the information to read and write PNG files.
01067  * The only people who need to care about what is inside of this are the
01068  * people who will be modifying the library for their own special needs.
01069  * It should NOT be accessed directly by an application, except to store
01070  * the jmp_buf.
01071  */
01072 
01073 struct png_struct_def
01074 {
01075 #ifdef PNG_SETJMP_SUPPORTED
01076    jmp_buf jmpbuf;            /* used in png_error */
01077 #endif
01078    png_error_ptr error_fn;    /* function for printing errors and aborting */
01079    png_error_ptr warning_fn;  /* function for printing warnings */
01080    png_voidp error_ptr;       /* user supplied struct for error functions */
01081    png_rw_ptr write_data_fn;  /* function for writing output data */
01082    png_rw_ptr read_data_fn;   /* function for reading input data */
01083    png_voidp io_ptr;          /* ptr to application struct for I/O functions */
01084 
01085 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
01086    png_user_transform_ptr read_user_transform_fn; /* user read transform */
01087 #endif
01088 
01089 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
01090    png_user_transform_ptr write_user_transform_fn; /* user write transform */
01091 #endif
01092 
01093 /* These were added in libpng-1.0.2 */
01094 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
01095 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
01096     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
01097    png_voidp user_transform_ptr; /* user supplied struct for user transform */
01098    png_byte user_transform_depth;    /* bit depth of user transformed pixels */
01099    png_byte user_transform_channels; /* channels in user transformed pixels */
01100 #endif
01101 #endif
01102 
01103    png_uint_32 mode;          /* tells us where we are in the PNG file */
01104    png_uint_32 flags;         /* flags indicating various things to libpng */
01105    png_uint_32 transformations; /* which transformations to perform */
01106 
01107    z_stream zstream;          /* pointer to decompression structure (below) */
01108    png_bytep zbuf;            /* buffer for zlib */
01109    png_size_t zbuf_size;      /* size of zbuf */
01110    int zlib_level;            /* holds zlib compression level */
01111    int zlib_method;           /* holds zlib compression method */
01112    int zlib_window_bits;      /* holds zlib compression window bits */
01113    int zlib_mem_level;        /* holds zlib compression memory level */
01114    int zlib_strategy;         /* holds zlib compression strategy */
01115 
01116    png_uint_32 width;         /* width of image in pixels */
01117    png_uint_32 height;        /* height of image in pixels */
01118    png_uint_32 num_rows;      /* number of rows in current pass */
01119    png_uint_32 usr_width;     /* width of row at start of write */
01120    png_uint_32 rowbytes;      /* size of row in bytes */
01121    png_uint_32 irowbytes;     /* size of current interlaced row in bytes */
01122    png_uint_32 iwidth;        /* width of current interlaced row in pixels */
01123    png_uint_32 row_number;    /* current row in interlace pass */
01124    png_bytep prev_row;        /* buffer to save previous (unfiltered) row */
01125    png_bytep row_buf;         /* buffer to save current (unfiltered) row */
01126    png_bytep sub_row;         /* buffer to save "sub" row when filtering */
01127    png_bytep up_row;          /* buffer to save "up" row when filtering */
01128    png_bytep avg_row;         /* buffer to save "avg" row when filtering */
01129    png_bytep paeth_row;       /* buffer to save "Paeth" row when filtering */
01130    png_row_info row_info;     /* used for transformation routines */
01131 
01132    png_uint_32 idat_size;     /* current IDAT size for read */
01133    png_uint_32 crc;           /* current chunk CRC value */
01134    png_colorp palette;        /* palette from the input file */
01135    png_uint_16 num_palette;   /* number of color entries in palette */
01136    png_uint_16 num_trans;     /* number of transparency values */
01137    png_byte chunk_name[5];    /* null-terminated name of current chunk */
01138    png_byte compression;      /* file compression type (always 0) */
01139    png_byte filter;           /* file filter type (always 0) */
01140    png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
01141    png_byte pass;             /* current interlace pass (0 - 6) */
01142    png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */
01143    png_byte color_type;       /* color type of file */
01144    png_byte bit_depth;        /* bit depth of file */
01145    png_byte usr_bit_depth;    /* bit depth of users row */
01146    png_byte pixel_depth;      /* number of bits per pixel */
01147    png_byte channels;         /* number of channels in file */
01148    png_byte usr_channels;     /* channels at start of write */
01149    png_byte sig_bytes;        /* magic bytes read/written from start of file */
01150 
01151 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
01152 #ifdef PNG_LEGACY_SUPPORTED
01153    png_byte filler;           /* filler byte for pixel expansion */
01154 #else
01155    png_uint_16 filler;           /* filler bytes for pixel expansion */
01156 #endif
01157 #endif
01158 
01159 #if defined(PNG_bKGD_SUPPORTED)
01160    png_byte background_gamma_type;
01161 #  ifdef PNG_FLOATING_POINT_SUPPORTED
01162    float background_gamma;
01163 #  endif
01164    png_color_16 background;   /* background color in screen gamma space */
01165 #if defined(PNG_READ_GAMMA_SUPPORTED)
01166    png_color_16 background_1; /* background normalized to gamma 1.0 */
01167 #endif
01168 #endif /* PNG_bKGD_SUPPORTED */
01169 
01170 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
01171    png_flush_ptr output_flush_fn;/* Function for flushing output */
01172    png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */
01173    png_uint_32 flush_rows;    /* number of rows written since last flush */
01174 #endif
01175 
01176 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
01177    int gamma_shift;      /* number of "insignificant" bits 16-bit gamma */
01178 #ifdef PNG_FLOATING_POINT_SUPPORTED
01179    float gamma;          /* file gamma value */
01180    float screen_gamma;   /* screen gamma value (display_exponent) */
01181 #endif
01182 #endif
01183 
01184 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
01185    png_bytep gamma_table;     /* gamma table for 8-bit depth files */
01186    png_bytep gamma_from_1;    /* converts from 1.0 to screen */
01187    png_bytep gamma_to_1;      /* converts from file to 1.0 */
01188    png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
01189    png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
01190    png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
01191 #endif
01192 
01193 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
01194    png_color_8 sig_bit;       /* significant bits in each available channel */
01195 #endif
01196 
01197 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
01198    png_color_8 shift;         /* shift for significant bit tranformation */
01199 #endif
01200 
01201 #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
01202  || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
01203    png_bytep trans;           /* transparency values for paletted files */
01204    png_color_16 trans_values; /* transparency values for non-paletted files */
01205 #endif
01206 
01207    png_read_status_ptr read_row_fn;   /* called after each row is decoded */
01208    png_write_status_ptr write_row_fn; /* called after each row is encoded */
01209 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
01210    png_progressive_info_ptr info_fn; /* called after header data fully read */
01211    png_progressive_row_ptr row_fn;   /* called after each prog. row is decoded */
01212    png_progressive_end_ptr end_fn;   /* called after image is complete */
01213    png_bytep save_buffer_ptr;        /* current location in save_buffer */
01214    png_bytep save_buffer;            /* buffer for previously read data */
01215    png_bytep current_buffer_ptr;     /* current location in current_buffer */
01216    png_bytep current_buffer;         /* buffer for recently used data */
01217    png_uint_32 push_length;          /* size of current input chunk */
01218    png_uint_32 skip_length;          /* bytes to skip in input data */
01219    png_size_t save_buffer_size;      /* amount of data now in save_buffer */
01220    png_size_t save_buffer_max;       /* total size of save_buffer */
01221    png_size_t buffer_size;           /* total amount of available input data */
01222    png_size_t current_buffer_size;   /* amount of data now in current_buffer */
01223    int process_mode;                 /* what push library is currently doing */
01224    int cur_palette;                  /* current push library palette index */
01225 
01226 #  if defined(PNG_TEXT_SUPPORTED)
01227      png_size_t current_text_size;   /* current size of text input data */
01228      png_size_t current_text_left;   /* how much text left to read in input */
01229      png_charp current_text;         /* current text chunk buffer */
01230      png_charp current_text_ptr;     /* current location in current_text */
01231 #  endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
01232 
01233 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
01234 
01235 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
01236 /* for the Borland special 64K segment handler */
01237    png_bytepp offset_table_ptr;
01238    png_bytep offset_table;
01239    png_uint_16 offset_table_number;
01240    png_uint_16 offset_table_count;
01241    png_uint_16 offset_table_count_free;
01242 #endif
01243 
01244 #if defined(PNG_READ_DITHER_SUPPORTED)
01245    png_bytep palette_lookup;         /* lookup table for dithering */
01246    png_bytep dither_index;           /* index translation for palette files */
01247 #endif
01248 
01249 #if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
01250    png_uint_16p hist;                /* histogram */
01251 #endif
01252 
01253 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
01254    png_byte heuristic_method;        /* heuristic for row filter selection */
01255    png_byte num_prev_filters;        /* number of weights for previous rows */
01256    png_bytep prev_filters;           /* filter type(s) of previous row(s) */
01257    png_uint_16p filter_weights;      /* weight(s) for previous line(s) */
01258    png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */
01259    png_uint_16p filter_costs;        /* relative filter calculation cost */
01260    png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */
01261 #endif
01262 
01263 #if defined(PNG_TIME_RFC1123_SUPPORTED)
01264    png_charp time_buffer;            /* String to hold RFC 1123 time text */
01265 #endif
01266 
01267 /* New members added in libpng-1.0.6 */
01268 
01269 #ifdef PNG_FREE_ME_SUPPORTED
01270    png_uint_32 free_me;       /* flags items libpng is responsible for freeing */
01271 #endif
01272 
01273 #if defined(PNG_USER_CHUNKS_SUPPORTED)
01274    png_voidp user_chunk_ptr;
01275    png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
01276 #endif
01277 
01278 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
01279    int num_chunk_list;
01280    png_bytep chunk_list;
01281 #endif
01282 
01283 /* New members added in libpng-1.0.3 */
01284 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
01285    png_byte rgb_to_gray_status;
01286    /* These were changed from png_byte in libpng-1.0.6 */
01287    png_uint_16 rgb_to_gray_red_coeff;
01288    png_uint_16 rgb_to_gray_green_coeff;
01289    png_uint_16 rgb_to_gray_blue_coeff;
01290 #endif
01291 
01292 /* New member added in libpng-1.0.4 (renamed in 1.0.9) */
01293 #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
01294     defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
01295     defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
01296 /* changed from png_byte to png_uint_32 at version 1.2.0 */
01297 #ifdef PNG_1_0_X
01298    png_byte mng_features_permitted;
01299 #else
01300    png_uint_32 mng_features_permitted;
01301 #endif /* PNG_1_0_X */
01302 #endif
01303 
01304 /* New member added in libpng-1.0.7 */
01305 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
01306    png_fixed_point int_gamma;
01307 #endif
01308 
01309 /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
01310 #if defined(PNG_MNG_FEATURES_SUPPORTED)
01311    png_byte filter_type;
01312 #endif
01313 
01314 #if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD))
01315 /* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
01316    png_uint_32 row_buf_size;
01317 #endif
01318 
01319 /* New members added in libpng-1.2.0 */
01320 #if !defined(PNG_1_0_X) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
01321    png_byte     mmx_bitdepth_threshold;
01322    png_uint_32  mmx_rowbytes_threshold;
01323    png_uint_32  asm_flags;
01324 #endif
01325 
01326 /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
01327 #ifdef PNG_USER_MEM_SUPPORTED
01328    png_voidp mem_ptr;                /* user supplied struct for mem functions */
01329    png_malloc_ptr malloc_fn;         /* function for allocating memory */
01330    png_free_ptr free_fn;             /* function for freeing memory */
01331 #endif
01332 
01333 /* New member added in libpng-1.0.13 and 1.2.0 */
01334    png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */
01335 
01336 #if defined(PNG_READ_DITHER_SUPPORTED)
01337 /* The following three members were added at version 1.0.14 and 1.2.4 */
01338    png_bytep dither_sort;            /* working sort array */
01339    png_bytep index_to_palette;       /* where the original index currently is */
01340                                      /* in the palette */
01341    png_bytep palette_to_index;       /* which original index points to this */
01342                                      /* palette color */
01343 #endif
01344 
01345 /* New members added in libpng-1.0.16 and 1.2.6 */
01346    png_byte compression_type;
01347 
01348 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
01349    png_uint_32 user_width_max;
01350    png_uint_32 user_height_max;
01351 #endif
01352 
01353 };
01354 
01355 
01356 /* This triggers a compiler error in png.c, if png.c and png.h
01357  * do not agree upon the version number.
01358  */
01359 typedef png_structp version_1_2_8;
01360 
01361 typedef png_struct FAR * FAR * png_structpp;
01362 
01363 /* Here are the function definitions most commonly used.  This is not
01364  * the place to find out how to use libpng.  See libpng.txt for the
01365  * full explanation, see example.c for the summary.  This just provides
01366  * a simple one line description of the use of each function.
01367  */
01368 
01369 /* Returns the version number of the library */
01370 extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void));
01371 
01372 /* Tell lib we have already handled the first <num_bytes> magic bytes.
01373  * Handling more than 8 bytes from the beginning of the file is an error.
01374  */
01375 extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
01376    int num_bytes));
01377 
01378 /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
01379  * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG
01380  * signature, and non-zero otherwise.  Having num_to_check == 0 or
01381  * start > 7 will always fail (ie return non-zero).
01382  */
01383 extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
01384    png_size_t num_to_check));
01385 
01386 /* Simple signature checking function.  This is the same as calling
01387  * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
01388  */
01389 extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
01390 
01391 /* Allocate and initialize png_ptr struct for reading, and any other memory. */
01392 extern PNG_EXPORT(png_structp,png_create_read_struct)
01393    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
01394    png_error_ptr error_fn, png_error_ptr warn_fn));
01395 
01396 /* Allocate and initialize png_ptr struct for writing, and any other memory */
01397 extern PNG_EXPORT(png_structp,png_create_write_struct)
01398    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
01399    png_error_ptr error_fn, png_error_ptr warn_fn));
01400 
01401 #ifdef PNG_WRITE_SUPPORTED
01402 extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size)
01403    PNGARG((png_structp png_ptr));
01404 #endif
01405 
01406 #ifdef PNG_WRITE_SUPPORTED
01407 extern PNG_EXPORT(void,png_set_compression_buffer_size)
01408    PNGARG((png_structp png_ptr, png_uint_32 size));
01409 #endif
01410 
01411 /* Reset the compression stream */
01412 extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
01413 
01414 /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
01415 #ifdef PNG_USER_MEM_SUPPORTED
01416 extern PNG_EXPORT(png_structp,png_create_read_struct_2)
01417    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
01418    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
01419    png_malloc_ptr malloc_fn, png_free_ptr free_fn));
01420 extern PNG_EXPORT(png_structp,png_create_write_struct_2)
01421    PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
01422    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
01423    png_malloc_ptr malloc_fn, png_free_ptr free_fn));
01424 #endif
01425 
01426 /* Write a PNG chunk - size, type, (optional) data, CRC. */
01427 extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
01428    png_bytep chunk_name, png_bytep data, png_size_t length));
01429 
01430 /* Write the start of a PNG chunk - length and chunk name. */
01431 extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
01432    png_bytep chunk_name, png_uint_32 length));
01433 
01434 /* Write the data of a PNG chunk started with png_write_chunk_start(). */
01435 extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
01436    png_bytep data, png_size_t length));
01437 
01438 /* Finish a chunk started with png_write_chunk_start() (includes CRC). */
01439 extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
01440 
01441 /* Allocate and initialize the info structure */
01442 extern PNG_EXPORT(png_infop,png_create_info_struct)
01443    PNGARG((png_structp png_ptr));
01444 
01445 /* Initialize the info structure (old interface - DEPRECATED) */
01446 extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr));
01447 #undef png_info_init
01448 #define png_info_init(info_ptr) png_info_init_3(&info_ptr,\
01449     png_sizeof(png_info));
01450 extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
01451     png_size_t png_info_struct_size));
01452 
01453 /* Writes all the PNG information before the image. */
01454 extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr,
01455    png_infop info_ptr));
01456 extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
01457    png_infop info_ptr));
01458 
01459 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
01460 /* read the information before the actual image data. */
01461 extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
01462    png_infop info_ptr));
01463 #endif
01464 
01465 #if defined(PNG_TIME_RFC1123_SUPPORTED)
01466 extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
01467    PNGARG((png_structp png_ptr, png_timep ptime));
01468 #endif
01469 
01470 #if !defined(_WIN32_WCE)
01471 /* "time.h" functions are not supported on WindowsCE */
01472 #if defined(PNG_WRITE_tIME_SUPPORTED)
01473 /* convert from a struct tm to png_time */
01474 extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
01475    struct tm FAR * ttime));
01476 
01477 /* convert from time_t to png_time.  Uses gmtime() */
01478 extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
01479    time_t ttime));
01480 #endif /* PNG_WRITE_tIME_SUPPORTED */
01481 #endif /* _WIN32_WCE */
01482 
01483 #if defined(PNG_READ_EXPAND_SUPPORTED)
01484 /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
01485 extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
01486 extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
01487 extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
01488 extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
01489 #endif
01490 
01491 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
01492 /* Use blue, green, red order for pixels. */
01493 extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
01494 #endif
01495 
01496 #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
01497 /* Expand the grayscale to 24-bit RGB if necessary. */
01498 extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
01499 #endif
01500 
01501 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
01502 /* Reduce RGB to grayscale. */
01503 #ifdef PNG_FLOATING_POINT_SUPPORTED
01504 extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
01505    int error_action, double red, double green ));
01506 #endif
01507 extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr,
01508    int error_action, png_fixed_point red, png_fixed_point green ));
01509 extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
01510    png_ptr));
01511 #endif
01512 
01513 extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
01514    png_colorp palette));
01515 
01516 #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
01517 extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
01518 #endif
01519 
01520 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
01521     defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
01522 extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
01523 #endif
01524 
01525 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
01526     defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
01527 extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
01528 #endif
01529 
01530 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
01531 /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
01532 extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
01533    png_uint_32 filler, int flags));
01534 /* The values of the PNG_FILLER_ defines should NOT be changed */
01535 #define PNG_FILLER_BEFORE 0
01536 #define PNG_FILLER_AFTER 1
01537 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
01538 #if !defined(PNG_1_0_X)
01539 extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr,
01540    png_uint_32 filler, int flags));
01541 #endif
01542 #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
01543 
01544 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
01545 /* Swap bytes in 16-bit depth files. */
01546 extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
01547 #endif
01548 
01549 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
01550 /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
01551 extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
01552 #endif
01553 
01554 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
01555 /* Swap packing order of pixels in bytes. */
01556 extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
01557 #endif
01558 
01559 #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
01560 /* Converts files to legal bit depths. */
01561 extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
01562    png_color_8p true_bits));
01563 #endif
01564 
01565 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
01566     defined(PNG_WRITE_INTERLACING_SUPPORTED)
01567 /* Have the code handle the interlacing.  Returns the number of passes. */
01568 extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
01569 #endif
01570 
01571 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
01572 /* Invert monochrome files */
01573 extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
01574 #endif
01575 
01576 #if defined(PNG_READ_BACKGROUND_SUPPORTED)
01577 /* Handle alpha and tRNS by replacing with a background color. */
01578 #ifdef PNG_FLOATING_POINT_SUPPORTED
01579 extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
01580    png_color_16p background_color, int background_gamma_code,
01581    int need_expand, double background_gamma));
01582 #endif
01583 #define PNG_BACKGROUND_GAMMA_UNKNOWN 0
01584 #define PNG_BACKGROUND_GAMMA_SCREEN  1
01585 #define PNG_BACKGROUND_GAMMA_FILE    2
01586 #define PNG_BACKGROUND_GAMMA_UNIQUE  3
01587 #endif
01588 
01589 #if defined(PNG_READ_16_TO_8_SUPPORTED)
01590 /* strip the second byte of information from a 16-bit depth file. */
01591 extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
01592 #endif
01593 
01594 #if defined(PNG_READ_DITHER_SUPPORTED)
01595 /* Turn on dithering, and reduce the palette to the number of colors available. */
01596 extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
01597    png_colorp palette, int num_palette, int maximum_colors,
01598    png_uint_16p histogram, int full_dither));
01599 #endif
01600 
01601 #if defined(PNG_READ_GAMMA_SUPPORTED)
01602 /* Handle gamma correction. Screen_gamma=(display_exponent) */
01603 #ifdef PNG_FLOATING_POINT_SUPPORTED
01604 extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
01605    double screen_gamma, double default_file_gamma));
01606 #endif
01607 #endif
01608 
01609 #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
01610     defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
01611 /* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
01612 /* Deprecated and will be removed.  Use png_permit_mng_features() instead. */
01613 extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
01614    int empty_plte_permitted));
01615 #endif
01616 
01617 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
01618 /* Set how many lines between output flushes - 0 for no flushing */
01619 extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
01620 /* Flush the current PNG output buffer */
01621 extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
01622 #endif
01623 
01624 /* optional update palette with requested transformations */
01625 extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
01626 
01627 /* optional call to update the users info structure */
01628 extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
01629    png_infop info_ptr));
01630 
01631 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
01632 /* read one or more rows of image data. */
01633 extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
01634    png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
01635 #endif
01636 
01637 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
01638 /* read a row of data. */
01639 extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
01640    png_bytep row,
01641    png_bytep display_row));
01642 #endif
01643 
01644 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
01645 /* read the whole image into memory at once. */
01646 extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
01647    png_bytepp image));
01648 #endif
01649 
01650 /* write a row of image data */
01651 extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
01652    png_bytep row));
01653 
01654 /* write a few rows of image data */
01655 extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
01656    png_bytepp row, png_uint_32 num_rows));
01657 
01658 /* write the image data */
01659 extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
01660    png_bytepp image));
01661 
01662 /* writes the end of the PNG file. */
01663 extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
01664    png_infop info_ptr));
01665 
01666 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
01667 /* read the end of the PNG file. */
01668 extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
01669    png_infop info_ptr));
01670 #endif
01671 
01672 /* free any memory associated with the png_info_struct */
01673 extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
01674    png_infopp info_ptr_ptr));
01675 
01676 /* free any memory associated with the png_struct and the png_info_structs */
01677 extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
01678    png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
01679 
01680 /* free all memory used by the read (old method - NOT DLL EXPORTED) */
01681 extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
01682    png_infop end_info_ptr));
01683 
01684 /* free any memory associated with the png_struct and the png_info_structs */
01685 extern PNG_EXPORT(void,png_destroy_write_struct)
01686    PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
01687 
01688 /* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
01689 extern void png_write_destroy PNGARG((png_structp png_ptr));
01690 
01691 /* set the libpng method of handling chunk CRC errors */
01692 extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
01693    int crit_action, int ancil_action));
01694 
01695 /* Values for png_set_crc_action() to say how to handle CRC errors in
01696  * ancillary and critical chunks, and whether to use the data contained
01697  * therein.  Note that it is impossible to "discard" data in a critical
01698  * chunk.  For versions prior to 0.90, the action was always error/quit,
01699  * whereas in version 0.90 and later, the action for CRC errors in ancillary
01700  * chunks is warn/discard.  These values should NOT be changed.
01701  *
01702  *      value                       action:critical     action:ancillary
01703  */
01704 #define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */
01705 #define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */
01706 #define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */
01707 #define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */
01708 #define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */
01709 #define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */
01710 
01711 /* These functions give the user control over the scan-line filtering in
01712  * libpng and the compression methods used by zlib.  These functions are
01713  * mainly useful for testing, as the defaults should work with most users.
01714  * Those users who are tight on memory or want faster performance at the
01715  * expense of compression can modify them.  See the compression library
01716  * header file (zlib.h) for an explination of the compression functions.
01717  */
01718 
01719 /* set the filtering method(s) used by libpng.  Currently, the only valid
01720  * value for "method" is 0.
01721  */
01722 extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
01723    int filters));
01724 
01725 /* Flags for png_set_filter() to say which filters to use.  The flags
01726  * are chosen so that they don't conflict with real filter types
01727  * below, in case they are supplied instead of the #defined constants.
01728  * These values should NOT be changed.
01729  */
01730 #define PNG_NO_FILTERS     0x00
01731 #define PNG_FILTER_NONE    0x08
01732 #define PNG_FILTER_SUB     0x10
01733 #define PNG_FILTER_UP      0x20
01734 #define PNG_FILTER_AVG     0x40
01735 #define PNG_FILTER_PAETH   0x80
01736 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
01737                          PNG_FILTER_AVG | PNG_FILTER_PAETH)
01738 
01739 /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
01740  * These defines should NOT be changed.
01741  */
01742 #define PNG_FILTER_VALUE_NONE  0
01743 #define PNG_FILTER_VALUE_SUB   1
01744 #define PNG_FILTER_VALUE_UP    2
01745 #define PNG_FILTER_VALUE_AVG   3
01746 #define PNG_FILTER_VALUE_PAETH 4
01747 #define PNG_FILTER_VALUE_LAST  5
01748 
01749 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
01750 /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
01751  * defines, either the default (minimum-sum-of-absolute-differences), or
01752  * the experimental method (weighted-minimum-sum-of-absolute-differences).
01753  *
01754  * Weights are factors >= 1.0, indicating how important it is to keep the
01755  * filter type consistent between rows.  Larger numbers mean the current
01756  * filter is that many times as likely to be the same as the "num_weights"
01757  * previous filters.  This is cumulative for each previous row with a weight.
01758  * There needs to be "num_weights" values in "filter_weights", or it can be
01759  * NULL if the weights aren't being specified.  Weights have no influence on
01760  * the selection of the first row filter.  Well chosen weights can (in theory)
01761  * improve the compression for a given image.
01762  *
01763  * Costs are factors >= 1.0 indicating the relative decoding costs of a
01764  * filter type.  Higher costs indicate more decoding expense, and are
01765  * therefore less likely to be selected over a filter with lower computational
01766  * costs.  There needs to be a value in "filter_costs" for each valid filter
01767  * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
01768  * setting the costs.  Costs try to improve the speed of decompression without
01769  * unduly increasing the compressed image size.
01770  *
01771  * A negative weight or cost indicates the default value is to be used, and
01772  * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
01773  * The default values for both weights and costs are currently 1.0, but may
01774  * change if good general weighting/cost heuristics can be found.  If both
01775  * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
01776  * to the UNWEIGHTED method, but with added encoding time/computation.
01777  */
01778 #ifdef PNG_FLOATING_POINT_SUPPORTED
01779 extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
01780    int heuristic_method, int num_weights, png_doublep filter_weights,
01781    png_doublep filter_costs));
01782 #endif
01783 #endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
01784 
01785 /* Heuristic used for row filter selection.  These defines should NOT be
01786  * changed.
01787  */
01788 #define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently "UNWEIGHTED" */
01789 #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */
01790 #define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */
01791 #define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */
01792 
01793 /* Set the library compression level.  Currently, valid values range from
01794  * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
01795  * (0 - no compression, 9 - "maximal" compression).  Note that tests have
01796  * shown that zlib compression levels 3-6 usually perform as well as level 9
01797  * for PNG images, and do considerably fewer caclulations.  In the future,
01798  * these values may not correspond directly to the zlib compression levels.
01799  */
01800 extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
01801    int level));
01802 
01803 extern PNG_EXPORT(void,png_set_compression_mem_level)
01804    PNGARG((png_structp png_ptr, int mem_level));
01805 
01806 extern PNG_EXPORT(void,png_set_compression_strategy)
01807    PNGARG((png_structp png_ptr, int strategy));
01808 
01809 extern PNG_EXPORT(void,png_set_compression_window_bits)
01810    PNGARG((png_structp png_ptr, int window_bits));
01811 
01812 extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
01813    int method));
01814 
01815 /* These next functions are called for input/output, memory, and error
01816  * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,
01817  * and call standard C I/O routines such as fread(), fwrite(), and
01818  * fprintf().  These functions can be made to use other I/O routines
01819  * at run time for those applications that need to handle I/O in a
01820  * different manner by calling png_set_???_fn().  See libpng.txt for
01821  * more information.
01822  */
01823 
01824 #if !defined(PNG_NO_STDIO)
01825 /* Initialize the input/output for the PNG file to the default functions. */
01826 extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp));
01827 #endif
01828 
01829 /* Replace the (error and abort), and warning functions with user
01830  * supplied functions.  If no messages are to be printed you must still
01831  * write and use replacement functions. The replacement error_fn should
01832  * still do a longjmp to the last setjmp location if you are using this
01833  * method of error handling.  If error_fn or warning_fn is NULL, the
01834  * default function will be used.
01835  */
01836 
01837 extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
01838    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
01839 
01840 /* Return the user pointer associated with the error functions */
01841 extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
01842 
01843 /* Replace the default data output functions with a user supplied one(s).
01844  * If buffered output is not used, then output_flush_fn can be set to NULL.
01845  * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
01846  * output_flush_fn will be ignored (and thus can be NULL).
01847  */
01848 extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
01849    png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
01850 
01851 /* Replace the default data input function with a user supplied one. */
01852 extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
01853    png_voidp io_ptr, png_rw_ptr read_data_fn));
01854 
01855 /* Return the user pointer associated with the I/O functions */
01856 extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
01857 
01858 extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
01859    png_read_status_ptr read_row_fn));
01860 
01861 extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
01862    png_write_status_ptr write_row_fn));
01863 
01864 #ifdef PNG_USER_MEM_SUPPORTED
01865 /* Replace the default memory allocation functions with user supplied one(s). */
01866 extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
01867    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
01868 /* Return the user pointer associated with the memory functions */
01869 extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
01870 #endif
01871 
01872 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
01873     defined(PNG_LEGACY_SUPPORTED)
01874 extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
01875    png_ptr, png_user_transform_ptr read_user_transform_fn));
01876 #endif
01877 
01878 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
01879     defined(PNG_LEGACY_SUPPORTED)
01880 extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
01881    png_ptr, png_user_transform_ptr write_user_transform_fn));
01882 #endif
01883 
01884 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
01885     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
01886     defined(PNG_LEGACY_SUPPORTED)
01887 extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
01888    png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
01889    int user_transform_channels));
01890 /* Return the user pointer associated with the user transform functions */
01891 extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
01892    PNGARG((png_structp png_ptr));
01893 #endif
01894 
01895 #ifdef PNG_USER_CHUNKS_SUPPORTED
01896 extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr,
01897    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
01898 extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp
01899    png_ptr));
01900 #endif
01901 
01902 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
01903 /* Sets the function callbacks for the push reader, and a pointer to a
01904  * user-defined structure available to the callback functions.
01905  */
01906 extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
01907    png_voidp progressive_ptr,
01908    png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
01909    png_progressive_end_ptr end_fn));
01910 
01911 /* returns the user pointer associated with the push read functions */
01912 extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
01913    PNGARG((png_structp png_ptr));
01914 
01915 /* function to be called when data becomes available */
01916 extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
01917    png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
01918 
01919 /* function that combines rows.  Not very much different than the
01920  * png_combine_row() call.  Is this even used?????
01921  */
01922 extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
01923    png_bytep old_row, png_bytep new_row));
01924 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
01925 
01926 extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
01927    png_uint_32 size));
01928 
01929 #if defined(PNG_1_0_X)
01930 #  define png_malloc_warn png_malloc
01931 #else
01932 /* Added at libpng version 1.2.4 */
01933 extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr,
01934    png_uint_32 size));
01935 #endif
01936 
01937 /* frees a pointer allocated by png_malloc() */
01938 extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
01939 
01940 #if defined(PNG_1_0_X)
01941 /* Function to allocate memory for zlib. */
01942 extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items,
01943    uInt size));
01944 
01945 /* Function to free memory for zlib */
01946 extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr));
01947 #endif
01948 
01949 /* Free data that was allocated internally */
01950 extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
01951    png_infop info_ptr, png_uint_32 free_me, int num));
01952 #ifdef PNG_FREE_ME_SUPPORTED
01953 /* Reassign responsibility for freeing existing data, whether allocated
01954  * by libpng or by the application */
01955 extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr,
01956    png_infop info_ptr, int freer, png_uint_32 mask));
01957 #endif
01958 /* assignments for png_data_freer */
01959 #define PNG_DESTROY_WILL_FREE_DATA 1
01960 #define PNG_SET_WILL_FREE_DATA 1
01961 #define PNG_USER_WILL_FREE_DATA 2
01962 /* Flags for png_ptr->free_me and info_ptr->free_me */
01963 #define PNG_FREE_HIST 0x0008
01964 #define PNG_FREE_ICCP 0x0010
01965 #define PNG_FREE_SPLT 0x0020
01966 #define PNG_FREE_ROWS 0x0040
01967 #define PNG_FREE_PCAL 0x0080
01968 #define PNG_FREE_SCAL 0x0100
01969 #define PNG_FREE_UNKN 0x0200
01970 #define PNG_FREE_LIST 0x0400
01971 #define PNG_FREE_PLTE 0x1000
01972 #define PNG_FREE_TRNS 0x2000
01973 #define PNG_FREE_TEXT 0x4000
01974 #define PNG_FREE_ALL  0x7fff
01975 #define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
01976 
01977 #ifdef PNG_USER_MEM_SUPPORTED
01978 extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
01979    png_uint_32 size));
01980 extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
01981    png_voidp ptr));
01982 #endif
01983 
01984 extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
01985    png_voidp s1, png_voidp s2, png_uint_32 size));
01986 
01987 extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr,
01988    png_voidp s1, int value, png_uint_32 size));
01989 
01990 #if defined(USE_FAR_KEYWORD)  /* memory model conversion function */
01991 extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
01992    int check));
01993 #endif /* USE_FAR_KEYWORD */
01994 
01995 /* Fatal error in PNG image of libpng - can't continue */
01996 extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
01997    png_const_charp error_message));
01998 
01999 /* The same, but the chunk name is prepended to the error string. */
02000 extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
02001    png_const_charp error_message));
02002 
02003 /* Non-fatal error in libpng.  Can continue, but may have a problem. */
02004 extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
02005    png_const_charp warning_message));
02006 
02007 /* Non-fatal error in libpng, chunk name is prepended to message. */
02008 extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
02009    png_const_charp warning_message));
02010 
02011 /* The png_set_<chunk> functions are for storing values in the png_info_struct.
02012  * Similarly, the png_get_<chunk> calls are used to read values from the
02013  * png_info_struct, either storing the parameters in the passed variables, or
02014  * setting pointers into the png_info_struct where the data is stored.  The
02015  * png_get_<chunk> functions return a non-zero value if the data was available
02016  * in info_ptr, or return zero and do not change any of the parameters if the
02017  * data was not available.
02018  *
02019  * These functions should be used instead of directly accessing png_info
02020  * to avoid problems with future changes in the size and internal layout of
02021  * png_info_struct.
02022  */
02023 /* Returns "flag" if chunk data is valid in info_ptr. */
02024 extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
02025 png_infop info_ptr, png_uint_32 flag));
02026 
02027 /* Returns number of bytes needed to hold a transformed row. */
02028 extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
02029 png_infop info_ptr));
02030 
02031 #if defined(PNG_INFO_IMAGE_SUPPORTED)
02032 /* Returns row_pointers, which is an array of pointers to scanlines that was
02033 returned from png_read_png(). */
02034 extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr,
02035 png_infop info_ptr));
02036 /* Set row_pointers, which is an array of pointers to scanlines for use
02037 by png_write_png(). */
02038 extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr,
02039    png_infop info_ptr, png_bytepp row_pointers));
02040 #endif
02041 
02042 /* Returns number of color channels in image. */
02043 extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
02044 png_infop info_ptr));
02045 
02046 #ifdef PNG_EASY_ACCESS_SUPPORTED
02047 /* Returns image width in pixels. */
02048 extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
02049 png_ptr, png_infop info_ptr));
02050 
02051 /* Returns image height in pixels. */
02052 extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
02053 png_ptr, png_infop info_ptr));
02054 
02055 /* Returns image bit_depth. */
02056 extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
02057 png_ptr, png_infop info_ptr));
02058 
02059 /* Returns image color_type. */
02060 extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
02061 png_ptr, png_infop info_ptr));
02062 
02063 /* Returns image filter_type. */
02064 extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
02065 png_ptr, png_infop info_ptr));
02066 
02067 /* Returns image interlace_type. */
02068 extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
02069 png_ptr, png_infop info_ptr));
02070 
02071 /* Returns image compression_type. */
02072 extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
02073 png_ptr, png_infop info_ptr));
02074 
02075 /* Returns image resolution in pixels per meter, from pHYs chunk data. */
02076 extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
02077 png_ptr, png_infop info_ptr));
02078 extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
02079 png_ptr, png_infop info_ptr));
02080 extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
02081 png_ptr, png_infop info_ptr));
02082 
02083 /* Returns pixel aspect ratio, computed from pHYs chunk data.  */
02084 #ifdef PNG_FLOATING_POINT_SUPPORTED
02085 extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
02086 png_ptr, png_infop info_ptr));
02087 #endif
02088 
02089 /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
02090 extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp
02091 png_ptr, png_infop info_ptr));
02092 extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp
02093 png_ptr, png_infop info_ptr));
02094 extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp
02095 png_ptr, png_infop info_ptr));
02096 extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp
02097 png_ptr, png_infop info_ptr));
02098 
02099 #endif /* PNG_EASY_ACCESS_SUPPORTED */
02100 
02101 /* Returns pointer to signature string read from PNG header */
02102 extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
02103 png_infop info_ptr));
02104 
02105 #if defined(PNG_bKGD_SUPPORTED)
02106 extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
02107    png_infop info_ptr, png_color_16p *background));
02108 #endif
02109 
02110 #if defined(PNG_bKGD_SUPPORTED)
02111 extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
02112    png_infop info_ptr, png_color_16p background));
02113 #endif
02114 
02115 #if defined(PNG_cHRM_SUPPORTED)
02116 #ifdef PNG_FLOATING_POINT_SUPPORTED
02117 extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
02118    png_infop info_ptr, double *white_x, double *white_y, double *red_x,
02119    double *red_y, double *green_x, double *green_y, double *blue_x,
02120    double *blue_y));
02121 #endif
02122 #ifdef PNG_FIXED_POINT_SUPPORTED
02123 extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr,
02124    png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point
02125    *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y,
02126    png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point
02127    *int_blue_x, png_fixed_point *int_blue_y));
02128 #endif
02129 #endif
02130 
02131 #if defined(PNG_cHRM_SUPPORTED)
02132 #ifdef PNG_FLOATING_POINT_SUPPORTED
02133 extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
02134    png_infop info_ptr, double white_x, double white_y, double red_x,
02135    double red_y, double green_x, double green_y, double blue_x, double blue_y));
02136 #endif
02137 #ifdef PNG_FIXED_POINT_SUPPORTED
02138 extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr,
02139    png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y,
02140    png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
02141    int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
02142    png_fixed_point int_blue_y));
02143 #endif
02144 #endif
02145 
02146 #if defined(PNG_gAMA_SUPPORTED)
02147 #ifdef PNG_FLOATING_POINT_SUPPORTED
02148 extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
02149    png_infop info_ptr, double *file_gamma));
02150 #endif
02151 extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr,
02152    png_infop info_ptr, png_fixed_point *int_file_gamma));
02153 #endif
02154 
02155 #if defined(PNG_gAMA_SUPPORTED)
02156 #ifdef PNG_FLOATING_POINT_SUPPORTED
02157 extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
02158    png_infop info_ptr, double file_gamma));
02159 #endif
02160 extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr,
02161    png_infop info_ptr, png_fixed_point int_file_gamma));
02162 #endif
02163 
02164 #if defined(PNG_hIST_SUPPORTED)
02165 extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
02166    png_infop info_ptr, png_uint_16p *hist));
02167 #endif
02168 
02169 #if defined(PNG_hIST_SUPPORTED)
02170 extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
02171    png_infop info_ptr, png_uint_16p hist));
02172 #endif
02173 
02174 extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
02175    png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
02176    int *bit_depth, int *color_type, int *interlace_method,
02177    int *compression_method, int *filter_method));
02178 
02179 extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
02180    png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
02181    int color_type, int interlace_method, int compression_method,
02182    int filter_method));
02183 
02184 #if defined(PNG_oFFs_SUPPORTED)
02185 extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
02186    png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
02187    int *unit_type));
02188 #endif
02189 
02190 #if defined(PNG_oFFs_SUPPORTED)
02191 extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
02192    png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y,
02193    int unit_type));
02194 #endif
02195 
02196 #if defined(PNG_pCAL_SUPPORTED)
02197 extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
02198    png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
02199    int *type, int *nparams, png_charp *units, png_charpp *params));
02200 #endif
02201 
02202 #if defined(PNG_pCAL_SUPPORTED)
02203 extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
02204    png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
02205    int type, int nparams, png_charp units, png_charpp params));
02206 #endif
02207 
02208 #if defined(PNG_pHYs_SUPPORTED)
02209 extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
02210    png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
02211 #endif
02212 
02213 #if defined(PNG_pHYs_SUPPORTED)
02214 extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
02215    png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
02216 #endif
02217 
02218 extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
02219    png_infop info_ptr, png_colorp *palette, int *num_palette));
02220 
02221 extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
02222    png_infop info_ptr, png_colorp palette, int num_palette));
02223 
02224 #if defined(PNG_sBIT_SUPPORTED)
02225 extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
02226    png_infop info_ptr, png_color_8p *sig_bit));
02227 #endif
02228 
02229 #if defined(PNG_sBIT_SUPPORTED)
02230 extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
02231    png_infop info_ptr, png_color_8p sig_bit));
02232 #endif
02233 
02234 #if defined(PNG_sRGB_SUPPORTED)
02235 extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
02236    png_infop info_ptr, int *intent));
02237 #endif
02238 
02239 #if defined(PNG_sRGB_SUPPORTED)
02240 extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
02241    png_infop info_ptr, int intent));
02242 extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
02243    png_infop info_ptr, int intent));
02244 #endif
02245 
02246 #if defined(PNG_iCCP_SUPPORTED)
02247 extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
02248    png_infop info_ptr, png_charpp name, int *compression_type,
02249    png_charpp profile, png_uint_32 *proflen));
02250    /* Note to maintainer: profile should be png_bytepp */
02251 #endif
02252 
02253 #if defined(PNG_iCCP_SUPPORTED)
02254 extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
02255    png_infop info_ptr, png_charp name, int compression_type,
02256    png_charp profile, png_uint_32 proflen));
02257    /* Note to maintainer: profile should be png_bytep */
02258 #endif
02259 
02260 #if defined(PNG_sPLT_SUPPORTED)
02261 extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr,
02262    png_infop info_ptr, png_sPLT_tpp entries));
02263 #endif
02264 
02265 #if defined(PNG_sPLT_SUPPORTED)
02266 extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr,
02267    png_infop info_ptr, png_sPLT_tp entries, int nentries));
02268 #endif
02269 
02270 #if defined(PNG_TEXT_SUPPORTED)
02271 /* png_get_text also returns the number of text chunks in *num_text */
02272 extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
02273    png_infop info_ptr, png_textp *text_ptr, int *num_text));
02274 #endif
02275 
02276 /*
02277  *  Note while png_set_text() will accept a structure whose text,
02278  *  language, and  translated keywords are NULL pointers, the structure
02279  *  returned by png_get_text will always contain regular
02280  *  zero-terminated C strings.  They might be empty strings but
02281  *  they will never be NULL pointers.
02282  */
02283 
02284 #if defined(PNG_TEXT_SUPPORTED)
02285 extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
02286    png_infop info_ptr, png_textp text_ptr, int num_text));
02287 #endif
02288 
02289 #if defined(PNG_tIME_SUPPORTED)
02290 extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
02291    png_infop info_ptr, png_timep *mod_time));
02292 #endif
02293 
02294 #if defined(PNG_tIME_SUPPORTED)
02295 extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
02296    png_infop info_ptr, png_timep mod_time));
02297 #endif
02298 
02299 #if defined(PNG_tRNS_SUPPORTED)
02300 extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
02301    png_infop info_ptr, png_bytep *trans, int *num_trans,
02302    png_color_16p *trans_values));
02303 #endif
02304 
02305 #if defined(PNG_tRNS_SUPPORTED)
02306 extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
02307    png_infop info_ptr, png_bytep trans, int num_trans,
02308    png_color_16p trans_values));
02309 #endif
02310 
02311 #if defined(PNG_tRNS_SUPPORTED)
02312 #endif
02313 
02314 #if defined(PNG_sCAL_SUPPORTED)
02315 #ifdef PNG_FLOATING_POINT_SUPPORTED
02316 extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr,
02317    png_infop info_ptr, int *unit, double *width, double *height));
02318 #else
02319 #ifdef PNG_FIXED_POINT_SUPPORTED
02320 extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr,
02321    png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
02322 #endif
02323 #endif
02324 #endif /* PNG_sCAL_SUPPORTED */
02325 
02326 #if defined(PNG_sCAL_SUPPORTED)
02327 #ifdef PNG_FLOATING_POINT_SUPPORTED
02328 extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
02329    png_infop info_ptr, int unit, double width, double height));
02330 #endif
02331 #ifdef PNG_FIXED_POINT_SUPPORTED
02332 extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
02333    png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
02334 #endif
02335 #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
02336 
02337 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
02338 /* provide a list of chunks and how they are to be handled, if the built-in
02339    handling or default unknown chunk handling is not desired.  Any chunks not
02340    listed will be handled in the default manner.  The IHDR and IEND chunks
02341    must not be listed.
02342       keep = 0: follow default behavour
02343            = 1: do not keep
02344            = 2: keep only if safe-to-copy
02345            = 3: keep even if unsafe-to-copy
02346 */
02347 extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
02348    png_ptr, int keep, png_bytep chunk_list, int num_chunks));
02349 extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
02350    png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
02351 extern PNG_EXPORT(void, png_set_unknown_chunk_location)
02352    PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location));
02353 extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
02354    png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
02355 #endif
02356 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
02357 PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
02358    chunk_name));
02359 #endif
02360 
02361 /* Png_free_data() will turn off the "valid" flag for anything it frees.
02362    If you need to turn it off for a chunk that your application has freed,
02363    you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */
02364 extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr,
02365    png_infop info_ptr, int mask));
02366 
02367 #if defined(PNG_INFO_IMAGE_SUPPORTED)
02368 /* The "params" pointer is currently not used and is for future expansion. */
02369 extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
02370                         png_infop info_ptr,
02371                         int transforms,
02372                         png_voidp params));
02373 extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
02374                         png_infop info_ptr,
02375                         int transforms,
02376                         png_voidp params));
02377 #endif
02378 
02379 /* Define PNG_DEBUG at compile time for debugging information.  Higher
02380  * numbers for PNG_DEBUG mean more debugging information.  This has
02381  * only been added since version 0.95 so it is not implemented throughout
02382  * libpng yet, but more support will be added as needed.
02383  */
02384 #ifdef PNG_DEBUG
02385 #if (PNG_DEBUG > 0)
02386 #if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
02387 #include <crtdbg.h>
02388 #if (PNG_DEBUG > 1)
02389 #define png_debug(l,m)  _RPT0(_CRT_WARN,m)
02390 #define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m,p1)
02391 #define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2)
02392 #endif
02393 #else /* PNG_DEBUG_FILE || !_MSC_VER */
02394 #ifndef PNG_DEBUG_FILE
02395 #define PNG_DEBUG_FILE stderr
02396 #endif /* PNG_DEBUG_FILE */
02397 #if (PNG_DEBUG > 1)
02398 #define png_debug(l,m) \
02399 { \
02400      int num_tabs=l; \
02401      fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
02402        (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
02403 }
02404 #define png_debug1(l,m,p1) \
02405 { \
02406      int num_tabs=l; \
02407      fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
02408        (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
02409 }
02410 #define png_debug2(l,m,p1,p2) \
02411 { \
02412      int num_tabs=l; \
02413      fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
02414        (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
02415 }
02416 #endif /* (PNG_DEBUG > 1) */
02417 #endif /* _MSC_VER */
02418 #endif /* (PNG_DEBUG > 0) */
02419 #endif /* PNG_DEBUG */
02420 #ifndef png_debug
02421 #define png_debug(l, m)
02422 #endif
02423 #ifndef png_debug1
02424 #define png_debug1(l, m, p1)
02425 #endif
02426 #ifndef png_debug2
02427 #define png_debug2(l, m, p1, p2)
02428 #endif
02429 
02430 extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
02431 
02432 extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
02433 extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
02434 extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
02435 extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
02436 
02437 #ifdef PNG_MNG_FEATURES_SUPPORTED
02438 extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
02439    png_ptr, png_uint_32 mng_features_permitted));
02440 #endif
02441 
02442 /* For use in png_set_keep_unknown, added to version 1.2.6 */
02443 #define PNG_HANDLE_CHUNK_AS_DEFAULT   0
02444 #define PNG_HANDLE_CHUNK_NEVER        1
02445 #define PNG_HANDLE_CHUNK_IF_SAFE      2
02446 #define PNG_HANDLE_CHUNK_ALWAYS       3
02447 
02448 /* Added to version 1.2.0 */
02449 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
02450 #define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED  0x01  /* not user-settable */
02451 #define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU    0x02  /* not user-settable */
02452 #define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  0x04
02453 #define PNG_ASM_FLAG_MMX_READ_INTERLACE    0x08
02454 #define PNG_ASM_FLAG_MMX_READ_FILTER_SUB   0x10
02455 #define PNG_ASM_FLAG_MMX_READ_FILTER_UP    0x20
02456 #define PNG_ASM_FLAG_MMX_READ_FILTER_AVG   0x40
02457 #define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80
02458 #define PNG_ASM_FLAGS_INITIALIZED          0x80000000  /* not user-settable */
02459 
02460 #define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  \
02461                            | PNG_ASM_FLAG_MMX_READ_INTERLACE    \
02462                            | PNG_ASM_FLAG_MMX_READ_FILTER_SUB   \
02463                            | PNG_ASM_FLAG_MMX_READ_FILTER_UP    \
02464                            | PNG_ASM_FLAG_MMX_READ_FILTER_AVG   \
02465                            | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH )
02466 #define PNG_MMX_WRITE_FLAGS ( 0 )
02467 
02468 #define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \
02469                       | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU   \
02470                       | PNG_MMX_READ_FLAGS                \
02471                       | PNG_MMX_WRITE_FLAGS )
02472 
02473 #define PNG_SELECT_READ   1
02474 #define PNG_SELECT_WRITE  2
02475 
02476 #if !defined(PNG_1_0_X)
02477 /* pngget.c */
02478 extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask)
02479    PNGARG((int flag_select, int *compilerID));
02480 
02481 /* pngget.c */
02482 extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask)
02483    PNGARG((int flag_select));
02484 
02485 /* pngget.c */
02486 extern PNG_EXPORT(png_uint_32,png_get_asm_flags)
02487    PNGARG((png_structp png_ptr));
02488 
02489 /* pngget.c */
02490 extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold)
02491    PNGARG((png_structp png_ptr));
02492 
02493 /* pngget.c */
02494 extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold)
02495    PNGARG((png_structp png_ptr));
02496 
02497 /* pngset.c */
02498 extern PNG_EXPORT(void,png_set_asm_flags)
02499    PNGARG((png_structp png_ptr, png_uint_32 asm_flags));
02500 
02501 /* pngset.c */
02502 extern PNG_EXPORT(void,png_set_mmx_thresholds)
02503    PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold,
02504    png_uint_32 mmx_rowbytes_threshold));
02505 
02506 #endif /* PNG_1_0_X */
02507 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
02508 
02509 #if !defined(PNG_1_0_X)
02510 /* png.c, pnggccrd.c, or pngvcrd.c */
02511 extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
02512 
02513 /* Strip the prepended error numbers ("#nnn ") from error and warning
02514  * messages before passing them to the error or warning handler. */
02515 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
02516 extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp
02517    png_ptr, png_uint_32 strip_mode));
02518 #endif
02519 
02520 #endif /* PNG_1_0_X */
02521 
02522 /* Added at libpng-1.2.6 */
02523 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
02524 extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp
02525    png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max));
02526 extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp
02527    png_ptr));
02528 extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp
02529    png_ptr));
02530 #endif
02531 
02532 /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
02533 
02534 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
02535 /* With these routines we avoid an integer divide, which will be slower on
02536  * most machines.  However, it does take more operations than the corresponding
02537  * divide method, so it may be slower on a few RISC systems.  There are two
02538  * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
02539  *
02540  * Note that the rounding factors are NOT supposed to be the same!  128 and
02541  * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
02542  * standard method.
02543  *
02544  * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
02545  */
02546 
02547  /* fg and bg should be in `gamma 1.0' space; alpha is the opacity          */
02548 
02549 #  define png_composite(composite, fg, alpha, bg)                            \
02550      { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \
02551                         +        (png_uint_16)(bg)*(png_uint_16)(255 -       \
02552                         (png_uint_16)(alpha)) + (png_uint_16)128);           \
02553        (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
02554 
02555 #  define png_composite_16(composite, fg, alpha, bg)                         \
02556      { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \
02557                         + (png_uint_32)(bg)*(png_uint_32)(65535L -           \
02558                         (png_uint_32)(alpha)) + (png_uint_32)32768L);        \
02559        (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
02560 
02561 #else  /* standard method using integer division */
02562 
02563 #  define png_composite(composite, fg, alpha, bg)                            \
02564      (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +    \
02565        (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \
02566        (png_uint_16)127) / 255)
02567 
02568 #  define png_composite_16(composite, fg, alpha, bg)                         \
02569      (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
02570        (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) +      \
02571        (png_uint_32)32767) / (png_uint_32)65535L)
02572 
02573 #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
02574 
02575 /* These next functions are used internally in the code.  They generally
02576  * shouldn't be used unless you are writing code to add or replace some
02577  * functionality in libpng.  More information about most functions can
02578  * be found in the files where the functions are located.
02579  */
02580 
02581 #if defined(PNG_INTERNAL)
02582 
02583 /* Various modes of operation.  Note that after an init, mode is set to
02584  * zero automatically when the structure is created.
02585  */
02586 #define PNG_HAVE_IHDR               0x01
02587 #define PNG_HAVE_PLTE               0x02
02588 #define PNG_HAVE_IDAT               0x04
02589 #define PNG_AFTER_IDAT              0x08
02590 #define PNG_HAVE_IEND               0x10
02591 #define PNG_HAVE_gAMA               0x20
02592 #define PNG_HAVE_cHRM               0x40
02593 #define PNG_HAVE_sRGB               0x80
02594 #define PNG_HAVE_CHUNK_HEADER      0x100
02595 #define PNG_WROTE_tIME             0x200
02596 #define PNG_WROTE_INFO_BEFORE_PLTE 0x400
02597 #define PNG_BACKGROUND_IS_GRAY     0x800
02598 #define PNG_HAVE_PNG_SIGNATURE    0x1000
02599 
02600 /* flags for the transformations the PNG library does on the image data */
02601 #define PNG_BGR                0x0001
02602 #define PNG_INTERLACE          0x0002
02603 #define PNG_PACK               0x0004
02604 #define PNG_SHIFT              0x0008
02605 #define PNG_SWAP_BYTES         0x0010
02606 #define PNG_INVERT_MONO        0x0020
02607 #define PNG_DITHER             0x0040
02608 #define PNG_BACKGROUND         0x0080
02609 #define PNG_BACKGROUND_EXPAND  0x0100
02610                           /*   0x0200 unused */
02611 #define PNG_16_TO_8            0x0400
02612 #define PNG_RGBA               0x0800
02613 #define PNG_EXPAND             0x1000
02614 #define PNG_GAMMA              0x2000
02615 #define PNG_GRAY_TO_RGB        0x4000
02616 #define PNG_FILLER             0x8000L
02617 #define PNG_PACKSWAP          0x10000L
02618 #define PNG_SWAP_ALPHA        0x20000L
02619 #define PNG_STRIP_ALPHA       0x40000L
02620 #define PNG_INVERT_ALPHA      0x80000L
02621 #define PNG_USER_TRANSFORM   0x100000L
02622 #define PNG_RGB_TO_GRAY_ERR  0x200000L
02623 #define PNG_RGB_TO_GRAY_WARN 0x400000L
02624 #define PNG_RGB_TO_GRAY      0x600000L  /* two bits, RGB_TO_GRAY_ERR|WARN */
02625                        /*    0x800000L     Unused */
02626 #define PNG_ADD_ALPHA       0x1000000L  /* Added to libpng-1.2.7 */
02627                        /*   0x2000000L  unused */
02628                        /*   0x4000000L  unused */
02629                        /*   0x8000000L  unused */
02630                        /*  0x10000000L  unused */
02631                        /*  0x20000000L  unused */
02632                        /*  0x40000000L  unused */
02633 
02634 /* flags for png_create_struct */
02635 #define PNG_STRUCT_PNG   0x0001
02636 #define PNG_STRUCT_INFO  0x0002
02637 
02638 /* Scaling factor for filter heuristic weighting calculations */
02639 #define PNG_WEIGHT_SHIFT 8
02640 #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
02641 #define PNG_COST_SHIFT 3
02642 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
02643 
02644 /* flags for the png_ptr->flags rather than declaring a byte for each one */
02645 #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001
02646 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL        0x0002
02647 #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL    0x0004
02648 #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS  0x0008
02649 #define PNG_FLAG_ZLIB_CUSTOM_METHOD       0x0010
02650 #define PNG_FLAG_ZLIB_FINISHED            0x0020
02651 #define PNG_FLAG_ROW_INIT                 0x0040
02652 #define PNG_FLAG_FILLER_AFTER             0x0080
02653 #define PNG_FLAG_CRC_ANCILLARY_USE        0x0100
02654 #define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200
02655 #define PNG_FLAG_CRC_CRITICAL_USE         0x0400
02656 #define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800
02657 #define PNG_FLAG_FREE_PLTE                0x1000
02658 #define PNG_FLAG_FREE_TRNS                0x2000
02659 #define PNG_FLAG_FREE_HIST                0x4000
02660 #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000L
02661 #define PNG_FLAG_KEEP_UNSAFE_CHUNKS       0x10000L
02662 #define PNG_FLAG_LIBRARY_MISMATCH         0x20000L
02663 #define PNG_FLAG_STRIP_ERROR_NUMBERS      0x40000L
02664 #define PNG_FLAG_STRIP_ERROR_TEXT         0x80000L
02665 #define PNG_FLAG_MALLOC_NULL_MEM_OK       0x100000L
02666 #define PNG_FLAG_ADD_ALPHA                0x200000L  /* Added to libpng-1.2.8 */
02667 #define PNG_FLAG_STRIP_ALPHA              0x400000L  /* Added to libpng-1.2.8 */
02668                                   /*      0x800000L  unused */
02669                                   /*     0x1000000L  unused */
02670                                   /*     0x2000000L  unused */
02671                                   /*     0x4000000L  unused */
02672                                   /*     0x8000000L  unused */
02673                                   /*    0x10000000L  unused */
02674                                   /*    0x20000000L  unused */
02675                                   /*    0x40000000L  unused */
02676 
02677 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
02678                                      PNG_FLAG_CRC_ANCILLARY_NOWARN)
02679 
02680 #define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \
02681                                      PNG_FLAG_CRC_CRITICAL_IGNORE)
02682 
02683 #define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \
02684                                      PNG_FLAG_CRC_CRITICAL_MASK)
02685 
02686 /* save typing and make code easier to understand */
02687 
02688 #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
02689    abs((int)((c1).green) - (int)((c2).green)) + \
02690    abs((int)((c1).blue) - (int)((c2).blue)))
02691 
02692 /* Added to libpng-1.2.6 JB */
02693 #define PNG_ROWBYTES(pixel_bits, width) \
02694     ((pixel_bits) >= 8 ? \
02695     ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \
02696     (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) )
02697 
02698 /* PNG_OUT_OF_RANGE returns true if value is outside the range
02699    ideal-delta..ideal+delta.  Each argument is evaluated twice.
02700    "ideal" and "delta" should be constants, normally simple
02701    integers, "value" a variable. Added to libpng-1.2.6 JB */
02702 #define PNG_OUT_OF_RANGE(value, ideal, delta) \
02703         ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
02704 
02705 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
02706 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
02707 /* place to hold the signature string for a PNG file. */
02708 #ifdef PNG_USE_GLOBAL_ARRAYS
02709    PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8];
02710 #else
02711 #define png_sig png_sig_bytes(NULL)
02712 #endif
02713 #endif /* PNG_NO_EXTERN */
02714 
02715 /* Constant strings for known chunk types.  If you need to add a chunk,
02716  * define the name here, and add an invocation of the macro in png.c and
02717  * wherever it's needed.
02718  */
02719 #define PNG_IHDR const png_byte png_IHDR[5] = { 73,  72,  68,  82, '\0'}
02720 #define PNG_IDAT const png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'}
02721 #define PNG_IEND const png_byte png_IEND[5] = { 73,  69,  78,  68, '\0'}
02722 #define PNG_PLTE const png_byte png_PLTE[5] = { 80,  76,  84,  69, '\0'}
02723 #define PNG_bKGD const png_byte png_bKGD[5] = { 98,  75,  71,  68, '\0'}
02724 #define PNG_cHRM const png_byte png_cHRM[5] = { 99,  72,  82,  77, '\0'}
02725 #define PNG_gAMA const png_byte png_gAMA[5] = {103,  65,  77,  65, '\0'}
02726 #define PNG_hIST const png_byte png_hIST[5] = {104,  73,  83,  84, '\0'}
02727 #define PNG_iCCP const png_byte png_iCCP[5] = {105,  67,  67,  80, '\0'}
02728 #define PNG_iTXt const png_byte png_iTXt[5] = {105,  84,  88, 116, '\0'}
02729 #define PNG_oFFs const png_byte png_oFFs[5] = {111,  70,  70, 115, '\0'}
02730 #define PNG_pCAL const png_byte png_pCAL[5] = {112,  67,  65,  76, '\0'}
02731 #define PNG_sCAL const png_byte png_sCAL[5] = {115,  67,  65,  76, '\0'}
02732 #define PNG_pHYs const png_byte png_pHYs[5] = {112,  72,  89, 115, '\0'}
02733 #define PNG_sBIT const png_byte png_sBIT[5] = {115,  66,  73,  84, '\0'}
02734 #define PNG_sPLT const png_byte png_sPLT[5] = {115,  80,  76,  84, '\0'}
02735 #define PNG_sRGB const png_byte png_sRGB[5] = {115,  82,  71,  66, '\0'}
02736 #define PNG_tEXt const png_byte png_tEXt[5] = {116,  69,  88, 116, '\0'}
02737 #define PNG_tIME const png_byte png_tIME[5] = {116,  73,  77,  69, '\0'}
02738 #define PNG_tRNS const png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'}
02739 #define PNG_zTXt const png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'}
02740 
02741 #ifdef PNG_USE_GLOBAL_ARRAYS
02742 PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5];
02743 PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5];
02744 PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5];
02745 PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5];
02746 PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5];
02747 PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5];
02748 PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5];
02749 PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5];
02750 PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5];
02751 PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5];
02752 PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5];
02753 PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5];
02754 PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5];
02755 PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5];
02756 PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5];
02757 PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5];
02758 PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5];
02759 PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5];
02760 PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5];
02761 PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5];
02762 PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
02763 #endif /* PNG_USE_GLOBAL_ARRAYS */
02764 
02765 
02766 /* Inline macros to do direct reads of bytes from the input buffer.  These
02767  * require that you are using an architecture that uses PNG byte ordering
02768  * (MSB first) and supports unaligned data storage.  I think that PowerPC
02769  * in big-endian mode and 680x0 are the only ones that will support this.
02770  * The x86 line of processors definitely do not.  The png_get_int_32()
02771  * routine also assumes we are using two's complement format for negative
02772  * values, which is almost certainly true.
02773  */
02774 #if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
02775 #  if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
02776 #    define png_get_int_32(buf) ( *((png_int_32p) (buf)))
02777 #  endif
02778 #  define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
02779 #  define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
02780 #else
02781 #  if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
02782 PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
02783 #  endif
02784 PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
02785 PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
02786 #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
02787 PNG_EXTERN png_uint_32 png_get_uint_31 PNGARG((png_structp png_ptr,
02788   png_bytep buf));
02789 
02790 /* Initialize png_ptr struct for reading, and allocate any other memory.
02791  * (old interface - DEPRECATED - use png_create_read_struct instead).
02792  */
02793 extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr));
02794 #undef png_read_init
02795 #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
02796     PNG_LIBPNG_VER_STRING,  png_sizeof(png_struct));
02797 extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
02798     png_const_charp user_png_ver, png_size_t png_struct_size));
02799 extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
02800     png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
02801     png_info_size));
02802 
02803 /* Initialize png_ptr struct for writing, and allocate any other memory.
02804  * (old interface - DEPRECATED - use png_create_write_struct instead).
02805  */
02806 extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr));
02807 #undef png_write_init
02808 #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
02809     PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
02810 extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
02811     png_const_charp user_png_ver, png_size_t png_struct_size));
02812 extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr,
02813     png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
02814     png_info_size));
02815 
02816 /* Allocate memory for an internal libpng struct */
02817 PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
02818 
02819 /* Free memory from internal libpng struct */
02820 PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
02821 
02822 PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
02823   malloc_fn, png_voidp mem_ptr));
02824 PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
02825    png_free_ptr free_fn, png_voidp mem_ptr));
02826 
02827 /* Free any memory that info_ptr points to and reset struct. */
02828 PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
02829    png_infop info_ptr));
02830 
02831 #ifndef PNG_1_0_X
02832 /* Function to allocate memory for zlib. */
02833 PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
02834 
02835 /* Function to free memory for zlib */
02836 PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
02837 
02838 #ifdef PNG_SIZE_T
02839 /* Function to convert a sizeof an item to png_sizeof item */
02840    PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
02841 #endif
02842 
02843 /* Next four functions are used internally as callbacks.  PNGAPI is required
02844  * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3. */
02845 
02846 PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
02847    png_bytep data, png_size_t length));
02848 
02849 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
02850 PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
02851    png_bytep buffer, png_size_t length));
02852 #endif
02853 
02854 PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
02855    png_bytep data, png_size_t length));
02856 
02857 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
02858 #if !defined(PNG_NO_STDIO)
02859 PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr));
02860 #endif
02861 #endif
02862 #else /* PNG_1_0_X */
02863 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
02864 PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
02865    png_bytep buffer, png_size_t length));
02866 #endif
02867 #endif /* PNG_1_0_X */
02868 
02869 /* Reset the CRC variable */
02870 PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
02871 
02872 /* Write the "data" buffer to whatever output you are using. */
02873 PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
02874    png_size_t length));
02875 
02876 /* Read data from whatever input you are using into the "data" buffer */
02877 PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
02878    png_size_t length));
02879 
02880 /* Read bytes into buf, and update png_ptr->crc */
02881 PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
02882    png_size_t length));
02883 
02884 /* Decompress data in a chunk that uses compression */
02885 #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
02886     defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
02887 PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr,
02888    int comp_type, png_charp chunkdata, png_size_t chunklength,
02889    png_size_t prefix_length, png_size_t *data_length));
02890 #endif
02891 
02892 /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
02893 PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
02894 
02895 /* Read the CRC from the file and compare it to the libpng calculated CRC */
02896 PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
02897 
02898 /* Calculate the CRC over a section of data.  Note that we are only
02899  * passing a maximum of 64K on systems that have this as a memory limit,
02900  * since this is the maximum buffer size we can specify.
02901  */
02902 PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
02903    png_size_t length));
02904 
02905 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
02906 PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
02907 #endif
02908 
02909 
02910 /* Place a 32-bit number into a buffer in PNG byte order (big-endian).
02911  * The only currently known PNG chunks that use signed numbers are
02912  * the ancillary extension chunks, oFFs and pCAL.
02913  */
02914 PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
02915 
02916 #if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
02917 PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
02918 #endif
02919 
02920 /* Place a 16-bit number into a buffer in PNG byte order.
02921  * The parameter is declared unsigned int, not png_uint_16,
02922  * just to avoid potential problems on pre-ANSI C compilers.
02923  */
02924 PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
02925 
02926 /* simple function to write the signature */
02927 PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
02928 
02929 /* write various chunks */
02930 
02931 /* Write the IHDR chunk, and update the png_struct with the necessary
02932  * information.
02933  */
02934 PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
02935    png_uint_32 height,
02936    int bit_depth, int color_type, int compression_method, int filter_method,
02937    int interlace_method));
02938 
02939 PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
02940    png_uint_32 num_pal));
02941 
02942 PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
02943    png_size_t length));
02944 
02945 PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
02946 
02947 #if defined(PNG_WRITE_gAMA_SUPPORTED)
02948 #ifdef PNG_FLOATING_POINT_SUPPORTED
02949 PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
02950 #endif
02951 #ifdef PNG_FIXED_POINT_SUPPORTED
02952 PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point
02953     file_gamma));
02954 #endif
02955 #endif
02956 
02957 #if defined(PNG_WRITE_sBIT_SUPPORTED)
02958 PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
02959    int color_type));
02960 #endif
02961 
02962 #if defined(PNG_WRITE_cHRM_SUPPORTED)
02963 #ifdef PNG_FLOATING_POINT_SUPPORTED
02964 PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
02965    double white_x, double white_y,
02966    double red_x, double red_y, double green_x, double green_y,
02967    double blue_x, double blue_y));
02968 #endif
02969 #ifdef PNG_FIXED_POINT_SUPPORTED
02970 PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
02971    png_fixed_point int_white_x, png_fixed_point int_white_y,
02972    png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
02973    int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
02974    png_fixed_point int_blue_y));
02975 #endif
02976 #endif
02977 
02978 #if defined(PNG_WRITE_sRGB_SUPPORTED)
02979 PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
02980    int intent));
02981 #endif
02982 
02983 #if defined(PNG_WRITE_iCCP_SUPPORTED)
02984 PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
02985    png_charp name, int compression_type,
02986    png_charp profile, int proflen));
02987    /* Note to maintainer: profile should be png_bytep */
02988 #endif
02989 
02990 #if defined(PNG_WRITE_sPLT_SUPPORTED)
02991 PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
02992    png_sPLT_tp palette));
02993 #endif
02994 
02995 #if defined(PNG_WRITE_tRNS_SUPPORTED)
02996 PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
02997    png_color_16p values, int number, int color_type));
02998 #endif
02999 
03000 #if defined(PNG_WRITE_bKGD_SUPPORTED)
03001 PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
03002    png_color_16p values, int color_type));
03003 #endif
03004 
03005 #if defined(PNG_WRITE_hIST_SUPPORTED)
03006 PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
03007    int num_hist));
03008 #endif
03009 
03010 #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
03011     defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
03012 PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
03013    png_charp key, png_charpp new_key));
03014 #endif
03015 
03016 #if defined(PNG_WRITE_tEXt_SUPPORTED)
03017 PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
03018    png_charp text, png_size_t text_len));
03019 #endif
03020 
03021 #if defined(PNG_WRITE_zTXt_SUPPORTED)
03022 PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
03023    png_charp text, png_size_t text_len, int compression));
03024 #endif
03025 
03026 #if defined(PNG_WRITE_iTXt_SUPPORTED)
03027 PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
03028    int compression, png_charp key, png_charp lang, png_charp lang_key,
03029    png_charp text));
03030 #endif
03031 
03032 #if defined(PNG_TEXT_SUPPORTED)  /* Added at version 1.0.14 and 1.2.4 */
03033 PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
03034    png_infop info_ptr, png_textp text_ptr, int num_text));
03035 #endif
03036 
03037 #if defined(PNG_WRITE_oFFs_SUPPORTED)
03038 PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
03039    png_int_32 x_offset, png_int_32 y_offset, int unit_type));
03040 #endif
03041 
03042 #if defined(PNG_WRITE_pCAL_SUPPORTED)
03043 PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
03044    png_int_32 X0, png_int_32 X1, int type, int nparams,
03045    png_charp units, png_charpp params));
03046 #endif
03047 
03048 #if defined(PNG_WRITE_pHYs_SUPPORTED)
03049 PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
03050    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
03051    int unit_type));
03052 #endif
03053 
03054 #if defined(PNG_WRITE_tIME_SUPPORTED)
03055 PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
03056    png_timep mod_time));
03057 #endif
03058 
03059 #if defined(PNG_WRITE_sCAL_SUPPORTED)
03060 #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
03061 PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
03062    int unit, double width, double height));
03063 #else
03064 #ifdef PNG_FIXED_POINT_SUPPORTED
03065 PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
03066    int unit, png_charp width, png_charp height));
03067 #endif
03068 #endif
03069 #endif
03070 
03071 /* Called when finished processing a row of data */
03072 PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
03073 
03074 /* Internal use only.   Called before first row of data */
03075 PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
03076 
03077 #if defined(PNG_READ_GAMMA_SUPPORTED)
03078 PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
03079 #endif
03080 
03081 /* combine a row of data, dealing with alpha, etc. if requested */
03082 PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
03083    int mask));
03084 
03085 #if defined(PNG_READ_INTERLACING_SUPPORTED)
03086 /* expand an interlaced row */
03087 /* OLD pre-1.0.9 interface:
03088 PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
03089    png_bytep row, int pass, png_uint_32 transformations));
03090  */
03091 PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr));
03092 #endif
03093 
03094 /* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */
03095 
03096 #if defined(PNG_WRITE_INTERLACING_SUPPORTED)
03097 /* grab pixels out of a row for an interlaced pass */
03098 PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
03099    png_bytep row, int pass));
03100 #endif
03101 
03102 /* unfilter a row */
03103 PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
03104    png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
03105 
03106 /* Choose the best filter to use and filter the row data */
03107 PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
03108    png_row_infop row_info));
03109 
03110 /* Write out the filtered row. */
03111 PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
03112    png_bytep filtered_row));
03113 /* finish a row while reading, dealing with interlacing passes, etc. */
03114 PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
03115 
03116 /* initialize the row buffers, etc. */
03117 PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
03118 /* optional call to update the users info structure */
03119 PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
03120    png_infop info_ptr));
03121 
03122 /* these are the functions that do the transformations */
03123 #if defined(PNG_READ_FILLER_SUPPORTED)
03124 PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
03125    png_bytep row, png_uint_32 filler, png_uint_32 flags));
03126 #endif
03127 
03128 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
03129 PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
03130    png_bytep row));
03131 #endif
03132 
03133 #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
03134 PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
03135    png_bytep row));
03136 #endif
03137 
03138 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
03139 PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
03140    png_bytep row));
03141 #endif
03142 
03143 #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
03144 PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
03145    png_bytep row));
03146 #endif
03147 
03148 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
03149     defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
03150 PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
03151    png_bytep row, png_uint_32 flags));
03152 #endif
03153 
03154 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
03155 PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
03156 #endif
03157 
03158 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
03159 PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
03160 #endif
03161 
03162 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
03163 PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
03164    row_info, png_bytep row));
03165 #endif
03166 
03167 #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
03168 PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
03169    png_bytep row));
03170 #endif
03171 
03172 #if defined(PNG_READ_PACK_SUPPORTED)
03173 PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
03174 #endif
03175 
03176 #if defined(PNG_READ_SHIFT_SUPPORTED)
03177 PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
03178    png_color_8p sig_bits));
03179 #endif
03180 
03181 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
03182 PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
03183 #endif
03184 
03185 #if defined(PNG_READ_16_TO_8_SUPPORTED)
03186 PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
03187 #endif
03188 
03189 #if defined(PNG_READ_DITHER_SUPPORTED)
03190 PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
03191    png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
03192 
03193 #  if defined(PNG_CORRECT_PALETTE_SUPPORTED)
03194 PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
03195    png_colorp palette, int num_palette));
03196 #  endif
03197 #endif
03198 
03199 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
03200 PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
03201 #endif
03202 
03203 #if defined(PNG_WRITE_PACK_SUPPORTED)
03204 PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
03205    png_bytep row, png_uint_32 bit_depth));
03206 #endif
03207 
03208 #if defined(PNG_WRITE_SHIFT_SUPPORTED)
03209 PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
03210    png_color_8p bit_depth));
03211 #endif
03212 
03213 #if defined(PNG_READ_BACKGROUND_SUPPORTED)
03214 #if defined(PNG_READ_GAMMA_SUPPORTED)
03215 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
03216    png_color_16p trans_values, png_color_16p background,
03217    png_color_16p background_1,
03218    png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
03219    png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
03220    png_uint_16pp gamma_16_to_1, int gamma_shift));
03221 #else
03222 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
03223    png_color_16p trans_values, png_color_16p background));
03224 #endif
03225 #endif
03226 
03227 #if defined(PNG_READ_GAMMA_SUPPORTED)
03228 PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
03229    png_bytep gamma_table, png_uint_16pp gamma_16_table,
03230    int gamma_shift));
03231 #endif
03232 
03233 #if defined(PNG_READ_EXPAND_SUPPORTED)
03234 PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
03235    png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
03236 PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
03237    png_bytep row, png_color_16p trans_value));
03238 #endif
03239 
03240 /* The following decodes the appropriate chunks, and does error correction,
03241  * then calls the appropriate callback for the chunk if it is valid.
03242  */
03243 
03244 /* decode the IHDR chunk */
03245 PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
03246    png_uint_32 length));
03247 PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
03248    png_uint_32 length));
03249 PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
03250    png_uint_32 length));
03251 
03252 #if defined(PNG_READ_bKGD_SUPPORTED)
03253 PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
03254    png_uint_32 length));
03255 #endif
03256 
03257 #if defined(PNG_READ_cHRM_SUPPORTED)
03258 PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
03259    png_uint_32 length));
03260 #endif
03261 
03262 #if defined(PNG_READ_gAMA_SUPPORTED)
03263 PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
03264    png_uint_32 length));
03265 #endif
03266 
03267 #if defined(PNG_READ_hIST_SUPPORTED)
03268 PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
03269    png_uint_32 length));
03270 #endif
03271 
03272 #if defined(PNG_READ_iCCP_SUPPORTED)
03273 extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
03274    png_uint_32 length));
03275 #endif /* PNG_READ_iCCP_SUPPORTED */
03276 
03277 #if defined(PNG_READ_iTXt_SUPPORTED)
03278 PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
03279    png_uint_32 length));
03280 #endif
03281 
03282 #if defined(PNG_READ_oFFs_SUPPORTED)
03283 PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
03284    png_uint_32 length));
03285 #endif
03286 
03287 #if defined(PNG_READ_pCAL_SUPPORTED)
03288 PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
03289    png_uint_32 length));
03290 #endif
03291 
03292 #if defined(PNG_READ_pHYs_SUPPORTED)
03293 PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
03294    png_uint_32 length));
03295 #endif
03296 
03297 #if defined(PNG_READ_sBIT_SUPPORTED)
03298 PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
03299    png_uint_32 length));
03300 #endif
03301 
03302 #if defined(PNG_READ_sCAL_SUPPORTED)
03303 PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
03304    png_uint_32 length));
03305 #endif
03306 
03307 #if defined(PNG_READ_sPLT_SUPPORTED)
03308 extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
03309    png_uint_32 length));
03310 #endif /* PNG_READ_sPLT_SUPPORTED */
03311 
03312 #if defined(PNG_READ_sRGB_SUPPORTED)
03313 PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
03314    png_uint_32 length));
03315 #endif
03316 
03317 #if defined(PNG_READ_tEXt_SUPPORTED)
03318 PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
03319    png_uint_32 length));
03320 #endif
03321 
03322 #if defined(PNG_READ_tIME_SUPPORTED)
03323 PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
03324    png_uint_32 length));
03325 #endif
03326 
03327 #if defined(PNG_READ_tRNS_SUPPORTED)
03328 PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
03329    png_uint_32 length));
03330 #endif
03331 
03332 #if defined(PNG_READ_zTXt_SUPPORTED)
03333 PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
03334    png_uint_32 length));
03335 #endif
03336 
03337 PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
03338    png_infop info_ptr, png_uint_32 length));
03339 
03340 PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
03341    png_bytep chunk_name));
03342 
03343 /* handle the transformations for reading and writing */
03344 PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
03345 PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
03346 
03347 PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
03348 
03349 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
03350 PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
03351    png_infop info_ptr));
03352 PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
03353    png_infop info_ptr));
03354 PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
03355 PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
03356    png_uint_32 length));
03357 PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
03358 PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
03359 PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
03360    png_bytep buffer, png_size_t buffer_length));
03361 PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
03362 PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
03363    png_bytep buffer, png_size_t buffer_length));
03364 PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
03365 PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
03366    png_infop info_ptr, png_uint_32 length));
03367 PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
03368    png_infop info_ptr));
03369 PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
03370    png_infop info_ptr));
03371 PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
03372 PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
03373    png_infop info_ptr));
03374 PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
03375    png_infop info_ptr));
03376 PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
03377 #if defined(PNG_READ_tEXt_SUPPORTED)
03378 PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
03379    png_infop info_ptr, png_uint_32 length));
03380 PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
03381    png_infop info_ptr));
03382 #endif
03383 #if defined(PNG_READ_zTXt_SUPPORTED)
03384 PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
03385    png_infop info_ptr, png_uint_32 length));
03386 PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
03387    png_infop info_ptr));
03388 #endif
03389 #if defined(PNG_READ_iTXt_SUPPORTED)
03390 PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
03391    png_infop info_ptr, png_uint_32 length));
03392 PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
03393    png_infop info_ptr));
03394 #endif
03395 
03396 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
03397 
03398 #ifdef PNG_MNG_FEATURES_SUPPORTED
03399 PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
03400    png_bytep row));
03401 PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
03402    png_bytep row));
03403 #endif
03404 
03405 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
03406 /* png.c */ /* PRIVATE */
03407 PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr));
03408 #endif
03409 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
03410 
03411 #endif /* PNG_INTERNAL */
03412 
03413 #ifdef __cplusplus
03414 }
03415 #endif
03416 
03417 #endif /* PNG_VERSION_INFO_ONLY */
03418 /* do not put anything past this line */
03419 #endif /* PNG_H */