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 #if 1
01682 extern PNG_EXPORT(void,png_read_destroy) PNGARG((png_structp png_ptr, png_infop info_ptr,
01683    png_infop end_info_ptr));
01684 #else
01685 extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
01686    png_infop end_info_ptr));
01687 #endif
01688 
01689 /* free any memory associated with the png_struct and the png_info_structs */
01690 extern PNG_EXPORT(void,png_destroy_write_struct)
01691    PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
01692 
01693 /* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
01694 #if 1
01695 extern PNG_EXPORT(void,png_write_destroy) PNGARG((png_structp png_ptr));
01696 #else
01697 extern void png_write_destroy PNGARG((png_structp png_ptr));
01698 #endif
01699 
01700 /* set the libpng method of handling chunk CRC errors */
01701 extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
01702    int crit_action, int ancil_action));
01703 
01704 /* Values for png_set_crc_action() to say how to handle CRC errors in
01705  * ancillary and critical chunks, and whether to use the data contained
01706  * therein.  Note that it is impossible to "discard" data in a critical
01707  * chunk.  For versions prior to 0.90, the action was always error/quit,
01708  * whereas in version 0.90 and later, the action for CRC errors in ancillary
01709  * chunks is warn/discard.  These values should NOT be changed.
01710  *
01711  *      value                       action:critical     action:ancillary
01712  */
01713 #define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */
01714 #define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */
01715 #define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */
01716 #define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */
01717 #define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */
01718 #define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */
01719 
01720 /* These functions give the user control over the scan-line filtering in
01721  * libpng and the compression methods used by zlib.  These functions are
01722  * mainly useful for testing, as the defaults should work with most users.
01723  * Those users who are tight on memory or want faster performance at the
01724  * expense of compression can modify them.  See the compression library
01725  * header file (zlib.h) for an explination of the compression functions.
01726  */
01727 
01728 /* set the filtering method(s) used by libpng.  Currently, the only valid
01729  * value for "method" is 0.
01730  */
01731 extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
01732    int filters));
01733 
01734 /* Flags for png_set_filter() to say which filters to use.  The flags
01735  * are chosen so that they don't conflict with real filter types
01736  * below, in case they are supplied instead of the #defined constants.
01737  * These values should NOT be changed.
01738  */
01739 #define PNG_NO_FILTERS     0x00
01740 #define PNG_FILTER_NONE    0x08
01741 #define PNG_FILTER_SUB     0x10
01742 #define PNG_FILTER_UP      0x20
01743 #define PNG_FILTER_AVG     0x40
01744 #define PNG_FILTER_PAETH   0x80
01745 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
01746                          PNG_FILTER_AVG | PNG_FILTER_PAETH)
01747 
01748 /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
01749  * These defines should NOT be changed.
01750  */
01751 #define PNG_FILTER_VALUE_NONE  0
01752 #define PNG_FILTER_VALUE_SUB   1
01753 #define PNG_FILTER_VALUE_UP    2
01754 #define PNG_FILTER_VALUE_AVG   3
01755 #define PNG_FILTER_VALUE_PAETH 4
01756 #define PNG_FILTER_VALUE_LAST  5
01757 
01758 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
01759 /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
01760  * defines, either the default (minimum-sum-of-absolute-differences), or
01761  * the experimental method (weighted-minimum-sum-of-absolute-differences).
01762  *
01763  * Weights are factors >= 1.0, indicating how important it is to keep the
01764  * filter type consistent between rows.  Larger numbers mean the current
01765  * filter is that many times as likely to be the same as the "num_weights"
01766  * previous filters.  This is cumulative for each previous row with a weight.
01767  * There needs to be "num_weights" values in "filter_weights", or it can be
01768  * NULL if the weights aren't being specified.  Weights have no influence on
01769  * the selection of the first row filter.  Well chosen weights can (in theory)
01770  * improve the compression for a given image.
01771  *
01772  * Costs are factors >= 1.0 indicating the relative decoding costs of a
01773  * filter type.  Higher costs indicate more decoding expense, and are
01774  * therefore less likely to be selected over a filter with lower computational
01775  * costs.  There needs to be a value in "filter_costs" for each valid filter
01776  * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
01777  * setting the costs.  Costs try to improve the speed of decompression without
01778  * unduly increasing the compressed image size.
01779  *
01780  * A negative weight or cost indicates the default value is to be used, and
01781  * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
01782  * The default values for both weights and costs are currently 1.0, but may
01783  * change if good general weighting/cost heuristics can be found.  If both
01784  * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
01785  * to the UNWEIGHTED method, but with added encoding time/computation.
01786  */
01787 #ifdef PNG_FLOATING_POINT_SUPPORTED
01788 extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
01789    int heuristic_method, int num_weights, png_doublep filter_weights,
01790    png_doublep filter_costs));
01791 #endif
01792 #endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
01793 
01794 /* Heuristic used for row filter selection.  These defines should NOT be
01795  * changed.
01796  */
01797 #define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently "UNWEIGHTED" */
01798 #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */
01799 #define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */
01800 #define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */
01801 
01802 /* Set the library compression level.  Currently, valid values range from
01803  * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
01804  * (0 - no compression, 9 - "maximal" compression).  Note that tests have
01805  * shown that zlib compression levels 3-6 usually perform as well as level 9
01806  * for PNG images, and do considerably fewer caclulations.  In the future,
01807  * these values may not correspond directly to the zlib compression levels.
01808  */
01809 extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
01810    int level));
01811 
01812 extern PNG_EXPORT(void,png_set_compression_mem_level)
01813    PNGARG((png_structp png_ptr, int mem_level));
01814 
01815 extern PNG_EXPORT(void,png_set_compression_strategy)
01816    PNGARG((png_structp png_ptr, int strategy));
01817 
01818 extern PNG_EXPORT(void,png_set_compression_window_bits)
01819    PNGARG((png_structp png_ptr, int window_bits));
01820 
01821 extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
01822    int method));
01823 
01824 /* These next functions are called for input/output, memory, and error
01825  * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,
01826  * and call standard C I/O routines such as fread(), fwrite(), and
01827  * fprintf().  These functions can be made to use other I/O routines
01828  * at run time for those applications that need to handle I/O in a
01829  * different manner by calling png_set_???_fn().  See libpng.txt for
01830  * more information.
01831  */
01832 
01833 #if !defined(PNG_NO_STDIO)
01834 /* Initialize the input/output for the PNG file to the default functions. */
01835 extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp));
01836 #endif
01837 
01838 /* Replace the (error and abort), and warning functions with user
01839  * supplied functions.  If no messages are to be printed you must still
01840  * write and use replacement functions. The replacement error_fn should
01841  * still do a longjmp to the last setjmp location if you are using this
01842  * method of error handling.  If error_fn or warning_fn is NULL, the
01843  * default function will be used.
01844  */
01845 
01846 extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
01847    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
01848 
01849 /* Return the user pointer associated with the error functions */
01850 extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
01851 
01852 /* Replace the default data output functions with a user supplied one(s).
01853  * If buffered output is not used, then output_flush_fn can be set to NULL.
01854  * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
01855  * output_flush_fn will be ignored (and thus can be NULL).
01856  */
01857 extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
01858    png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
01859 
01860 /* Replace the default data input function with a user supplied one. */
01861 extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
01862    png_voidp io_ptr, png_rw_ptr read_data_fn));
01863 
01864 /* Return the user pointer associated with the I/O functions */
01865 extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
01866 
01867 extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
01868    png_read_status_ptr read_row_fn));
01869 
01870 extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
01871    png_write_status_ptr write_row_fn));
01872 
01873 #ifdef PNG_USER_MEM_SUPPORTED
01874 /* Replace the default memory allocation functions with user supplied one(s). */
01875 extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
01876    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
01877 /* Return the user pointer associated with the memory functions */
01878 extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
01879 #endif
01880 
01881 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
01882     defined(PNG_LEGACY_SUPPORTED)
01883 extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
01884    png_ptr, png_user_transform_ptr read_user_transform_fn));
01885 #endif
01886 
01887 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
01888     defined(PNG_LEGACY_SUPPORTED)
01889 extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
01890    png_ptr, png_user_transform_ptr write_user_transform_fn));
01891 #endif
01892 
01893 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
01894     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
01895     defined(PNG_LEGACY_SUPPORTED)
01896 extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
01897    png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
01898    int user_transform_channels));
01899 /* Return the user pointer associated with the user transform functions */
01900 extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
01901    PNGARG((png_structp png_ptr));
01902 #endif
01903 
01904 #ifdef PNG_USER_CHUNKS_SUPPORTED
01905 extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr,
01906    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
01907 extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp
01908    png_ptr));
01909 #endif
01910 
01911 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
01912 /* Sets the function callbacks for the push reader, and a pointer to a
01913  * user-defined structure available to the callback functions.
01914  */
01915 extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
01916    png_voidp progressive_ptr,
01917    png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
01918    png_progressive_end_ptr end_fn));
01919 
01920 /* returns the user pointer associated with the push read functions */
01921 extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
01922    PNGARG((png_structp png_ptr));
01923 
01924 /* function to be called when data becomes available */
01925 extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
01926    png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
01927 
01928 /* function that combines rows.  Not very much different than the
01929  * png_combine_row() call.  Is this even used?????
01930  */
01931 extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
01932    png_bytep old_row, png_bytep new_row));
01933 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
01934 
01935 extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
01936    png_uint_32 size));
01937 
01938 #if defined(PNG_1_0_X)
01939 #  define png_malloc_warn png_malloc
01940 #else
01941 /* Added at libpng version 1.2.4 */
01942 extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr,
01943    png_uint_32 size));
01944 #endif
01945 
01946 /* frees a pointer allocated by png_malloc() */
01947 extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
01948 
01949 #if defined(PNG_1_0_X)
01950 /* Function to allocate memory for zlib. */
01951 extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items,
01952    uInt size));
01953 
01954 /* Function to free memory for zlib */
01955 extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr));
01956 #endif
01957 
01958 /* Free data that was allocated internally */
01959 extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
01960    png_infop info_ptr, png_uint_32 free_me, int num));
01961 #ifdef PNG_FREE_ME_SUPPORTED
01962 /* Reassign responsibility for freeing existing data, whether allocated
01963  * by libpng or by the application */
01964 extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr,
01965    png_infop info_ptr, int freer, png_uint_32 mask));
01966 #endif
01967 /* assignments for png_data_freer */
01968 #define PNG_DESTROY_WILL_FREE_DATA 1
01969 #define PNG_SET_WILL_FREE_DATA 1
01970 #define PNG_USER_WILL_FREE_DATA 2
01971 /* Flags for png_ptr->free_me and info_ptr->free_me */
01972 #define PNG_FREE_HIST 0x0008
01973 #define PNG_FREE_ICCP 0x0010
01974 #define PNG_FREE_SPLT 0x0020
01975 #define PNG_FREE_ROWS 0x0040
01976 #define PNG_FREE_PCAL 0x0080
01977 #define PNG_FREE_SCAL 0x0100
01978 #define PNG_FREE_UNKN 0x0200
01979 #define PNG_FREE_LIST 0x0400
01980 #define PNG_FREE_PLTE 0x1000
01981 #define PNG_FREE_TRNS 0x2000
01982 #define PNG_FREE_TEXT 0x4000
01983 #define PNG_FREE_ALL  0x7fff
01984 #define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
01985 
01986 #ifdef PNG_USER_MEM_SUPPORTED
01987 extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
01988    png_uint_32 size));
01989 extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
01990    png_voidp ptr));
01991 #endif
01992 
01993 extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
01994    png_voidp s1, png_voidp s2, png_uint_32 size));
01995 
01996 extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr,
01997    png_voidp s1, int value, png_uint_32 size));
01998 
01999 #if defined(USE_FAR_KEYWORD)  /* memory model conversion function */
02000 extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
02001    int check));
02002 #endif /* USE_FAR_KEYWORD */
02003 
02004 /* Fatal error in PNG image of libpng - can't continue */
02005 extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
02006    png_const_charp error_message));
02007 
02008 /* The same, but the chunk name is prepended to the error string. */
02009 extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
02010    png_const_charp error_message));
02011 
02012 /* Non-fatal error in libpng.  Can continue, but may have a problem. */
02013 extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
02014    png_const_charp warning_message));
02015 
02016 /* Non-fatal error in libpng, chunk name is prepended to message. */
02017 extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
02018    png_const_charp warning_message));
02019 
02020 /* The png_set_<chunk> functions are for storing values in the png_info_struct.
02021  * Similarly, the png_get_<chunk> calls are used to read values from the
02022  * png_info_struct, either storing the parameters in the passed variables, or
02023  * setting pointers into the png_info_struct where the data is stored.  The
02024  * png_get_<chunk> functions return a non-zero value if the data was available
02025  * in info_ptr, or return zero and do not change any of the parameters if the
02026  * data was not available.
02027  *
02028  * These functions should be used instead of directly accessing png_info
02029  * to avoid problems with future changes in the size and internal layout of
02030  * png_info_struct.
02031  */
02032 /* Returns "flag" if chunk data is valid in info_ptr. */
02033 extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
02034 png_infop info_ptr, png_uint_32 flag));
02035 
02036 /* Returns number of bytes needed to hold a transformed row. */
02037 extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
02038 png_infop info_ptr));
02039 
02040 #if defined(PNG_INFO_IMAGE_SUPPORTED)
02041 /* Returns row_pointers, which is an array of pointers to scanlines that was
02042 returned from png_read_png(). */
02043 extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr,
02044 png_infop info_ptr));
02045 /* Set row_pointers, which is an array of pointers to scanlines for use
02046 by png_write_png(). */
02047 extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr,
02048    png_infop info_ptr, png_bytepp row_pointers));
02049 #endif
02050 
02051 /* Returns number of color channels in image. */
02052 extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
02053 png_infop info_ptr));
02054 
02055 #ifdef PNG_EASY_ACCESS_SUPPORTED
02056 /* Returns image width in pixels. */
02057 extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
02058 png_ptr, png_infop info_ptr));
02059 
02060 /* Returns image height in pixels. */
02061 extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
02062 png_ptr, png_infop info_ptr));
02063 
02064 /* Returns image bit_depth. */
02065 extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
02066 png_ptr, png_infop info_ptr));
02067 
02068 /* Returns image color_type. */
02069 extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
02070 png_ptr, png_infop info_ptr));
02071 
02072 /* Returns image filter_type. */
02073 extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
02074 png_ptr, png_infop info_ptr));
02075 
02076 /* Returns image interlace_type. */
02077 extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
02078 png_ptr, png_infop info_ptr));
02079 
02080 /* Returns image compression_type. */
02081 extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
02082 png_ptr, png_infop info_ptr));
02083 
02084 /* Returns image resolution in pixels per meter, from pHYs chunk data. */
02085 extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
02086 png_ptr, png_infop info_ptr));
02087 extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
02088 png_ptr, png_infop info_ptr));
02089 extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
02090 png_ptr, png_infop info_ptr));
02091 
02092 /* Returns pixel aspect ratio, computed from pHYs chunk data.  */
02093 #ifdef PNG_FLOATING_POINT_SUPPORTED
02094 extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
02095 png_ptr, png_infop info_ptr));
02096 #endif
02097 
02098 /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
02099 extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp
02100 png_ptr, png_infop info_ptr));
02101 extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp
02102 png_ptr, png_infop info_ptr));
02103 extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp
02104 png_ptr, png_infop info_ptr));
02105 extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp
02106 png_ptr, png_infop info_ptr));
02107 
02108 #endif /* PNG_EASY_ACCESS_SUPPORTED */
02109 
02110 /* Returns pointer to signature string read from PNG header */
02111 extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
02112 png_infop info_ptr));
02113 
02114 #if defined(PNG_bKGD_SUPPORTED)
02115 extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
02116    png_infop info_ptr, png_color_16p *background));
02117 #endif
02118 
02119 #if defined(PNG_bKGD_SUPPORTED)
02120 extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
02121    png_infop info_ptr, png_color_16p background));
02122 #endif
02123 
02124 #if defined(PNG_cHRM_SUPPORTED)
02125 #ifdef PNG_FLOATING_POINT_SUPPORTED
02126 extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
02127    png_infop info_ptr, double *white_x, double *white_y, double *red_x,
02128    double *red_y, double *green_x, double *green_y, double *blue_x,
02129    double *blue_y));
02130 #endif
02131 #ifdef PNG_FIXED_POINT_SUPPORTED
02132 extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr,
02133    png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point
02134    *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y,
02135    png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point
02136    *int_blue_x, png_fixed_point *int_blue_y));
02137 #endif
02138 #endif
02139 
02140 #if defined(PNG_cHRM_SUPPORTED)
02141 #ifdef PNG_FLOATING_POINT_SUPPORTED
02142 extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
02143    png_infop info_ptr, double white_x, double white_y, double red_x,
02144    double red_y, double green_x, double green_y, double blue_x, double blue_y));
02145 #endif
02146 #ifdef PNG_FIXED_POINT_SUPPORTED
02147 extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr,
02148    png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y,
02149    png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
02150    int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
02151    png_fixed_point int_blue_y));
02152 #endif
02153 #endif
02154 
02155 #if defined(PNG_gAMA_SUPPORTED)
02156 #ifdef PNG_FLOATING_POINT_SUPPORTED
02157 extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
02158    png_infop info_ptr, double *file_gamma));
02159 #endif
02160 extern PNG_EXPORT(png_uint_32,png_get_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_gAMA_SUPPORTED)
02165 #ifdef PNG_FLOATING_POINT_SUPPORTED
02166 extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
02167    png_infop info_ptr, double file_gamma));
02168 #endif
02169 extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr,
02170    png_infop info_ptr, png_fixed_point int_file_gamma));
02171 #endif
02172 
02173 #if defined(PNG_hIST_SUPPORTED)
02174 extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
02175    png_infop info_ptr, png_uint_16p *hist));
02176 #endif
02177 
02178 #if defined(PNG_hIST_SUPPORTED)
02179 extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
02180    png_infop info_ptr, png_uint_16p hist));
02181 #endif
02182 
02183 extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
02184    png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
02185    int *bit_depth, int *color_type, int *interlace_method,
02186    int *compression_method, int *filter_method));
02187 
02188 extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
02189    png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
02190    int color_type, int interlace_method, int compression_method,
02191    int filter_method));
02192 
02193 #if defined(PNG_oFFs_SUPPORTED)
02194 extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
02195    png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
02196    int *unit_type));
02197 #endif
02198 
02199 #if defined(PNG_oFFs_SUPPORTED)
02200 extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
02201    png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y,
02202    int unit_type));
02203 #endif
02204 
02205 #if defined(PNG_pCAL_SUPPORTED)
02206 extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
02207    png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
02208    int *type, int *nparams, png_charp *units, png_charpp *params));
02209 #endif
02210 
02211 #if defined(PNG_pCAL_SUPPORTED)
02212 extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
02213    png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
02214    int type, int nparams, png_charp units, png_charpp params));
02215 #endif
02216 
02217 #if defined(PNG_pHYs_SUPPORTED)
02218 extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
02219    png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
02220 #endif
02221 
02222 #if defined(PNG_pHYs_SUPPORTED)
02223 extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
02224    png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
02225 #endif
02226 
02227 extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
02228    png_infop info_ptr, png_colorp *palette, int *num_palette));
02229 
02230 extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
02231    png_infop info_ptr, png_colorp palette, int num_palette));
02232 
02233 #if defined(PNG_sBIT_SUPPORTED)
02234 extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
02235    png_infop info_ptr, png_color_8p *sig_bit));
02236 #endif
02237 
02238 #if defined(PNG_sBIT_SUPPORTED)
02239 extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
02240    png_infop info_ptr, png_color_8p sig_bit));
02241 #endif
02242 
02243 #if defined(PNG_sRGB_SUPPORTED)
02244 extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
02245    png_infop info_ptr, int *intent));
02246 #endif
02247 
02248 #if defined(PNG_sRGB_SUPPORTED)
02249 extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
02250    png_infop info_ptr, int intent));
02251 extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
02252    png_infop info_ptr, int intent));
02253 #endif
02254 
02255 #if defined(PNG_iCCP_SUPPORTED)
02256 extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
02257    png_infop info_ptr, png_charpp name, int *compression_type,
02258    png_charpp profile, png_uint_32 *proflen));
02259    /* Note to maintainer: profile should be png_bytepp */
02260 #endif
02261 
02262 #if defined(PNG_iCCP_SUPPORTED)
02263 extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
02264    png_infop info_ptr, png_charp name, int compression_type,
02265    png_charp profile, png_uint_32 proflen));
02266    /* Note to maintainer: profile should be png_bytep */
02267 #endif
02268 
02269 #if defined(PNG_sPLT_SUPPORTED)
02270 extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr,
02271    png_infop info_ptr, png_sPLT_tpp entries));
02272 #endif
02273 
02274 #if defined(PNG_sPLT_SUPPORTED)
02275 extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr,
02276    png_infop info_ptr, png_sPLT_tp entries, int nentries));
02277 #endif
02278 
02279 #if defined(PNG_TEXT_SUPPORTED)
02280 /* png_get_text also returns the number of text chunks in *num_text */
02281 extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
02282    png_infop info_ptr, png_textp *text_ptr, int *num_text));
02283 #endif
02284 
02285 /*
02286  *  Note while png_set_text() will accept a structure whose text,
02287  *  language, and  translated keywords are NULL pointers, the structure
02288  *  returned by png_get_text will always contain regular
02289  *  zero-terminated C strings.  They might be empty strings but
02290  *  they will never be NULL pointers.
02291  */
02292 
02293 #if defined(PNG_TEXT_SUPPORTED)
02294 extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
02295    png_infop info_ptr, png_textp text_ptr, int num_text));
02296 #endif
02297 
02298 #if defined(PNG_tIME_SUPPORTED)
02299 extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
02300    png_infop info_ptr, png_timep *mod_time));
02301 #endif
02302 
02303 #if defined(PNG_tIME_SUPPORTED)
02304 extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
02305    png_infop info_ptr, png_timep mod_time));
02306 #endif
02307 
02308 #if defined(PNG_tRNS_SUPPORTED)
02309 extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
02310    png_infop info_ptr, png_bytep *trans, int *num_trans,
02311    png_color_16p *trans_values));
02312 #endif
02313 
02314 #if defined(PNG_tRNS_SUPPORTED)
02315 extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
02316    png_infop info_ptr, png_bytep trans, int num_trans,
02317    png_color_16p trans_values));
02318 #endif
02319 
02320 #if defined(PNG_tRNS_SUPPORTED)
02321 #endif
02322 
02323 #if defined(PNG_sCAL_SUPPORTED)
02324 #ifdef PNG_FLOATING_POINT_SUPPORTED
02325 extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr,
02326    png_infop info_ptr, int *unit, double *width, double *height));
02327 #else
02328 #ifdef PNG_FIXED_POINT_SUPPORTED
02329 extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr,
02330    png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
02331 #endif
02332 #endif
02333 #endif /* PNG_sCAL_SUPPORTED */
02334 
02335 #if defined(PNG_sCAL_SUPPORTED)
02336 #ifdef PNG_FLOATING_POINT_SUPPORTED
02337 extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
02338    png_infop info_ptr, int unit, double width, double height));
02339 #endif
02340 #ifdef PNG_FIXED_POINT_SUPPORTED
02341 extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
02342    png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
02343 #endif
02344 #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
02345 
02346 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
02347 /* provide a list of chunks and how they are to be handled, if the built-in
02348    handling or default unknown chunk handling is not desired.  Any chunks not
02349    listed will be handled in the default manner.  The IHDR and IEND chunks
02350    must not be listed.
02351       keep = 0: follow default behavour
02352            = 1: do not keep
02353            = 2: keep only if safe-to-copy
02354            = 3: keep even if unsafe-to-copy
02355 */
02356 extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
02357    png_ptr, int keep, png_bytep chunk_list, int num_chunks));
02358 extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
02359    png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
02360 extern PNG_EXPORT(void, png_set_unknown_chunk_location)
02361    PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location));
02362 extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
02363    png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
02364 #endif
02365 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
02366 PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
02367    chunk_name));
02368 #endif
02369 
02370 /* Png_free_data() will turn off the "valid" flag for anything it frees.
02371    If you need to turn it off for a chunk that your application has freed,
02372    you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */
02373 extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr,
02374    png_infop info_ptr, int mask));
02375 
02376 #if defined(PNG_INFO_IMAGE_SUPPORTED)
02377 /* The "params" pointer is currently not used and is for future expansion. */
02378 extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
02379                         png_infop info_ptr,
02380                         int transforms,
02381                         png_voidp params));
02382 extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
02383                         png_infop info_ptr,
02384                         int transforms,
02385                         png_voidp params));
02386 #endif
02387 
02388 /* Define PNG_DEBUG at compile time for debugging information.  Higher
02389  * numbers for PNG_DEBUG mean more debugging information.  This has
02390  * only been added since version 0.95 so it is not implemented throughout
02391  * libpng yet, but more support will be added as needed.
02392  */
02393 #ifdef PNG_DEBUG
02394 #if (PNG_DEBUG > 0)
02395 #if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
02396 #include <crtdbg.h>
02397 #if (PNG_DEBUG > 1)
02398 #define png_debug(l,m)  _RPT0(_CRT_WARN,m)
02399 #define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m,p1)
02400 #define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2)
02401 #endif
02402 #else /* PNG_DEBUG_FILE || !_MSC_VER */
02403 #ifndef PNG_DEBUG_FILE
02404 #define PNG_DEBUG_FILE stderr
02405 #endif /* PNG_DEBUG_FILE */
02406 #if (PNG_DEBUG > 1)
02407 #define png_debug(l,m) \
02408 { \
02409      int num_tabs=l; \
02410      fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
02411        (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
02412 }
02413 #define png_debug1(l,m,p1) \
02414 { \
02415      int num_tabs=l; \
02416      fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
02417        (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
02418 }
02419 #define png_debug2(l,m,p1,p2) \
02420 { \
02421      int num_tabs=l; \
02422      fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
02423        (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
02424 }
02425 #endif /* (PNG_DEBUG > 1) */
02426 #endif /* _MSC_VER */
02427 #endif /* (PNG_DEBUG > 0) */
02428 #endif /* PNG_DEBUG */
02429 #ifndef png_debug
02430 #define png_debug(l, m)
02431 #endif
02432 #ifndef png_debug1
02433 #define png_debug1(l, m, p1)
02434 #endif
02435 #ifndef png_debug2
02436 #define png_debug2(l, m, p1, p2)
02437 #endif
02438 
02439 extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
02440 
02441 extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
02442 extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
02443 extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
02444 extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
02445 
02446 #ifdef PNG_MNG_FEATURES_SUPPORTED
02447 extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
02448    png_ptr, png_uint_32 mng_features_permitted));
02449 #endif
02450 
02451 /* For use in png_set_keep_unknown, added to version 1.2.6 */
02452 #define PNG_HANDLE_CHUNK_AS_DEFAULT   0
02453 #define PNG_HANDLE_CHUNK_NEVER        1
02454 #define PNG_HANDLE_CHUNK_IF_SAFE      2
02455 #define PNG_HANDLE_CHUNK_ALWAYS       3
02456 
02457 /* Added to version 1.2.0 */
02458 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
02459 #define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED  0x01  /* not user-settable */
02460 #define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU    0x02  /* not user-settable */
02461 #define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  0x04
02462 #define PNG_ASM_FLAG_MMX_READ_INTERLACE    0x08
02463 #define PNG_ASM_FLAG_MMX_READ_FILTER_SUB   0x10
02464 #define PNG_ASM_FLAG_MMX_READ_FILTER_UP    0x20
02465 #define PNG_ASM_FLAG_MMX_READ_FILTER_AVG   0x40
02466 #define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80
02467 #define PNG_ASM_FLAGS_INITIALIZED          0x80000000  /* not user-settable */
02468 
02469 #define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  \
02470                            | PNG_ASM_FLAG_MMX_READ_INTERLACE    \
02471                            | PNG_ASM_FLAG_MMX_READ_FILTER_SUB   \
02472                            | PNG_ASM_FLAG_MMX_READ_FILTER_UP    \
02473                            | PNG_ASM_FLAG_MMX_READ_FILTER_AVG   \
02474                            | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH )
02475 #define PNG_MMX_WRITE_FLAGS ( 0 )
02476 
02477 #define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \
02478                       | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU   \
02479                       | PNG_MMX_READ_FLAGS                \
02480                       | PNG_MMX_WRITE_FLAGS )
02481 
02482 #define PNG_SELECT_READ   1
02483 #define PNG_SELECT_WRITE  2
02484 
02485 #if !defined(PNG_1_0_X)
02486 /* pngget.c */
02487 extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask)
02488    PNGARG((int flag_select, int *compilerID));
02489 
02490 /* pngget.c */
02491 extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask)
02492    PNGARG((int flag_select));
02493 
02494 /* pngget.c */
02495 extern PNG_EXPORT(png_uint_32,png_get_asm_flags)
02496    PNGARG((png_structp png_ptr));
02497 
02498 /* pngget.c */
02499 extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold)
02500    PNGARG((png_structp png_ptr));
02501 
02502 /* pngget.c */
02503 extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold)
02504    PNGARG((png_structp png_ptr));
02505 
02506 /* pngset.c */
02507 extern PNG_EXPORT(void,png_set_asm_flags)
02508    PNGARG((png_structp png_ptr, png_uint_32 asm_flags));
02509 
02510 /* pngset.c */
02511 extern PNG_EXPORT(void,png_set_mmx_thresholds)
02512    PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold,
02513    png_uint_32 mmx_rowbytes_threshold));
02514 
02515 #endif /* PNG_1_0_X */
02516 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
02517 
02518 #if !defined(PNG_1_0_X)
02519 /* png.c, pnggccrd.c, or pngvcrd.c */
02520 extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
02521 
02522 /* Strip the prepended error numbers ("#nnn ") from error and warning
02523  * messages before passing them to the error or warning handler. */
02524 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
02525 extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp
02526    png_ptr, png_uint_32 strip_mode));
02527 #endif
02528 
02529 #endif /* PNG_1_0_X */
02530 
02531 /* Added at libpng-1.2.6 */
02532 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
02533 extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp
02534    png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max));
02535 extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp
02536    png_ptr));
02537 extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp
02538    png_ptr));
02539 #endif
02540 
02541 /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
02542 
02543 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
02544 /* With these routines we avoid an integer divide, which will be slower on
02545  * most machines.  However, it does take more operations than the corresponding
02546  * divide method, so it may be slower on a few RISC systems.  There are two
02547  * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
02548  *
02549  * Note that the rounding factors are NOT supposed to be the same!  128 and
02550  * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
02551  * standard method.
02552  *
02553  * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
02554  */
02555 
02556  /* fg and bg should be in `gamma 1.0' space; alpha is the opacity          */
02557 
02558 #  define png_composite(composite, fg, alpha, bg)                            \
02559      { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \
02560                         +        (png_uint_16)(bg)*(png_uint_16)(255 -       \
02561                         (png_uint_16)(alpha)) + (png_uint_16)128);           \
02562        (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
02563 
02564 #  define png_composite_16(composite, fg, alpha, bg)                         \
02565      { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \
02566                         + (png_uint_32)(bg)*(png_uint_32)(65535L -           \
02567                         (png_uint_32)(alpha)) + (png_uint_32)32768L);        \
02568        (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
02569 
02570 #else  /* standard method using integer division */
02571 
02572 #  define png_composite(composite, fg, alpha, bg)                            \
02573      (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +    \
02574        (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \
02575        (png_uint_16)127) / 255)
02576 
02577 #  define png_composite_16(composite, fg, alpha, bg)                         \
02578      (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
02579        (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) +      \
02580        (png_uint_32)32767) / (png_uint_32)65535L)
02581 
02582 #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
02583 
02584 /* These next functions are used internally in the code.  They generally
02585  * shouldn't be used unless you are writing code to add or replace some
02586  * functionality in libpng.  More information about most functions can
02587  * be found in the files where the functions are located.
02588  */
02589 
02590 #if defined(PNG_INTERNAL)
02591 
02592 /* Various modes of operation.  Note that after an init, mode is set to
02593  * zero automatically when the structure is created.
02594  */
02595 #define PNG_HAVE_IHDR               0x01
02596 #define PNG_HAVE_PLTE               0x02
02597 #define PNG_HAVE_IDAT               0x04
02598 #define PNG_AFTER_IDAT              0x08
02599 #define PNG_HAVE_IEND               0x10
02600 #define PNG_HAVE_gAMA               0x20
02601 #define PNG_HAVE_cHRM               0x40
02602 #define PNG_HAVE_sRGB               0x80
02603 #define PNG_HAVE_CHUNK_HEADER      0x100
02604 #define PNG_WROTE_tIME             0x200
02605 #define PNG_WROTE_INFO_BEFORE_PLTE 0x400
02606 #define PNG_BACKGROUND_IS_GRAY     0x800
02607 #define PNG_HAVE_PNG_SIGNATURE    0x1000
02608 
02609 /* flags for the transformations the PNG library does on the image data */
02610 #define PNG_BGR                0x0001
02611 #define PNG_INTERLACE          0x0002
02612 #define PNG_PACK               0x0004
02613 #define PNG_SHIFT              0x0008
02614 #define PNG_SWAP_BYTES         0x0010
02615 #define PNG_INVERT_MONO        0x0020
02616 #define PNG_DITHER             0x0040
02617 #define PNG_BACKGROUND         0x0080
02618 #define PNG_BACKGROUND_EXPAND  0x0100
02619                           /*   0x0200 unused */
02620 #define PNG_16_TO_8            0x0400
02621 #define PNG_RGBA               0x0800
02622 #define PNG_EXPAND             0x1000
02623 #define PNG_GAMMA              0x2000
02624 #define PNG_GRAY_TO_RGB        0x4000
02625 #define PNG_FILLER             0x8000L
02626 #define PNG_PACKSWAP          0x10000L
02627 #define PNG_SWAP_ALPHA        0x20000L
02628 #define PNG_STRIP_ALPHA       0x40000L
02629 #define PNG_INVERT_ALPHA      0x80000L
02630 #define PNG_USER_TRANSFORM   0x100000L
02631 #define PNG_RGB_TO_GRAY_ERR  0x200000L
02632 #define PNG_RGB_TO_GRAY_WARN 0x400000L
02633 #define PNG_RGB_TO_GRAY      0x600000L  /* two bits, RGB_TO_GRAY_ERR|WARN */
02634                        /*    0x800000L     Unused */
02635 #define PNG_ADD_ALPHA       0x1000000L  /* Added to libpng-1.2.7 */
02636                        /*   0x2000000L  unused */
02637                        /*   0x4000000L  unused */
02638                        /*   0x8000000L  unused */
02639                        /*  0x10000000L  unused */
02640                        /*  0x20000000L  unused */
02641                        /*  0x40000000L  unused */
02642 
02643 /* flags for png_create_struct */
02644 #define PNG_STRUCT_PNG   0x0001
02645 #define PNG_STRUCT_INFO  0x0002
02646 
02647 /* Scaling factor for filter heuristic weighting calculations */
02648 #define PNG_WEIGHT_SHIFT 8
02649 #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
02650 #define PNG_COST_SHIFT 3
02651 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
02652 
02653 /* flags for the png_ptr->flags rather than declaring a byte for each one */
02654 #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001
02655 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL        0x0002
02656 #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL    0x0004
02657 #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS  0x0008
02658 #define PNG_FLAG_ZLIB_CUSTOM_METHOD       0x0010
02659 #define PNG_FLAG_ZLIB_FINISHED            0x0020
02660 #define PNG_FLAG_ROW_INIT                 0x0040
02661 #define PNG_FLAG_FILLER_AFTER             0x0080
02662 #define PNG_FLAG_CRC_ANCILLARY_USE        0x0100
02663 #define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200
02664 #define PNG_FLAG_CRC_CRITICAL_USE         0x0400
02665 #define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800
02666 #define PNG_FLAG_FREE_PLTE                0x1000
02667 #define PNG_FLAG_FREE_TRNS                0x2000
02668 #define PNG_FLAG_FREE_HIST                0x4000
02669 #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000L
02670 #define PNG_FLAG_KEEP_UNSAFE_CHUNKS       0x10000L
02671 #define PNG_FLAG_LIBRARY_MISMATCH         0x20000L
02672 #define PNG_FLAG_STRIP_ERROR_NUMBERS      0x40000L
02673 #define PNG_FLAG_STRIP_ERROR_TEXT         0x80000L
02674 #define PNG_FLAG_MALLOC_NULL_MEM_OK       0x100000L
02675 #define PNG_FLAG_ADD_ALPHA                0x200000L  /* Added to libpng-1.2.8 */
02676 #define PNG_FLAG_STRIP_ALPHA              0x400000L  /* Added to libpng-1.2.8 */
02677                                   /*      0x800000L  unused */
02678                                   /*     0x1000000L  unused */
02679                                   /*     0x2000000L  unused */
02680                                   /*     0x4000000L  unused */
02681                                   /*     0x8000000L  unused */
02682                                   /*    0x10000000L  unused */
02683                                   /*    0x20000000L  unused */
02684                                   /*    0x40000000L  unused */
02685 
02686 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
02687                                      PNG_FLAG_CRC_ANCILLARY_NOWARN)
02688 
02689 #define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \
02690                                      PNG_FLAG_CRC_CRITICAL_IGNORE)
02691 
02692 #define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \
02693                                      PNG_FLAG_CRC_CRITICAL_MASK)
02694 
02695 /* save typing and make code easier to understand */
02696 
02697 #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
02698    abs((int)((c1).green) - (int)((c2).green)) + \
02699    abs((int)((c1).blue) - (int)((c2).blue)))
02700 
02701 /* Added to libpng-1.2.6 JB */
02702 #define PNG_ROWBYTES(pixel_bits, width) \
02703     ((pixel_bits) >= 8 ? \
02704     ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \
02705     (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) )
02706 
02707 /* PNG_OUT_OF_RANGE returns true if value is outside the range
02708    ideal-delta..ideal+delta.  Each argument is evaluated twice.
02709    "ideal" and "delta" should be constants, normally simple
02710    integers, "value" a variable. Added to libpng-1.2.6 JB */
02711 #define PNG_OUT_OF_RANGE(value, ideal, delta) \
02712         ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
02713 
02714 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
02715 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
02716 /* place to hold the signature string for a PNG file. */
02717 #ifdef PNG_USE_GLOBAL_ARRAYS
02718    PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8];
02719 #else
02720 #define png_sig png_sig_bytes(NULL)
02721 #endif
02722 #endif /* PNG_NO_EXTERN */
02723 
02724 /* Constant strings for known chunk types.  If you need to add a chunk,
02725  * define the name here, and add an invocation of the macro in png.c and
02726  * wherever it's needed.
02727  */
02728 #define PNG_IHDR const png_byte png_IHDR[5] = { 73,  72,  68,  82, '\0'}
02729 #define PNG_IDAT const png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'}
02730 #define PNG_IEND const png_byte png_IEND[5] = { 73,  69,  78,  68, '\0'}
02731 #define PNG_PLTE const png_byte png_PLTE[5] = { 80,  76,  84,  69, '\0'}
02732 #define PNG_bKGD const png_byte png_bKGD[5] = { 98,  75,  71,  68, '\0'}
02733 #define PNG_cHRM const png_byte png_cHRM[5] = { 99,  72,  82,  77, '\0'}
02734 #define PNG_gAMA const png_byte png_gAMA[5] = {103,  65,  77,  65, '\0'}
02735 #define PNG_hIST const png_byte png_hIST[5] = {104,  73,  83,  84, '\0'}
02736 #define PNG_iCCP const png_byte png_iCCP[5] = {105,  67,  67,  80, '\0'}
02737 #define PNG_iTXt const png_byte png_iTXt[5] = {105,  84,  88, 116, '\0'}
02738 #define PNG_oFFs const png_byte png_oFFs[5] = {111,  70,  70, 115, '\0'}
02739 #define PNG_pCAL const png_byte png_pCAL[5] = {112,  67,  65,  76, '\0'}
02740 #define PNG_sCAL const png_byte png_sCAL[5] = {115,  67,  65,  76, '\0'}
02741 #define PNG_pHYs const png_byte png_pHYs[5] = {112,  72,  89, 115, '\0'}
02742 #define PNG_sBIT const png_byte png_sBIT[5] = {115,  66,  73,  84, '\0'}
02743 #define PNG_sPLT const png_byte png_sPLT[5] = {115,  80,  76,  84, '\0'}
02744 #define PNG_sRGB const png_byte png_sRGB[5] = {115,  82,  71,  66, '\0'}
02745 #define PNG_tEXt const png_byte png_tEXt[5] = {116,  69,  88, 116, '\0'}
02746 #define PNG_tIME const png_byte png_tIME[5] = {116,  73,  77,  69, '\0'}
02747 #define PNG_tRNS const png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'}
02748 #define PNG_zTXt const png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'}
02749 
02750 #ifdef PNG_USE_GLOBAL_ARRAYS
02751 PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5];
02752 PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5];
02753 PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5];
02754 PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5];
02755 PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5];
02756 PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5];
02757 PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5];
02758 PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5];
02759 PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5];
02760 PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5];
02761 PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5];
02762 PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5];
02763 PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5];
02764 PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5];
02765 PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5];
02766 PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5];
02767 PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5];
02768 PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5];
02769 PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5];
02770 PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5];
02771 PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
02772 #endif /* PNG_USE_GLOBAL_ARRAYS */
02773 
02774 
02775 /* Inline macros to do direct reads of bytes from the input buffer.  These
02776  * require that you are using an architecture that uses PNG byte ordering
02777  * (MSB first) and supports unaligned data storage.  I think that PowerPC
02778  * in big-endian mode and 680x0 are the only ones that will support this.
02779  * The x86 line of processors definitely do not.  The png_get_int_32()
02780  * routine also assumes we are using two's complement format for negative
02781  * values, which is almost certainly true.
02782  */
02783 #if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
02784 #  if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
02785 #    define png_get_int_32(buf) ( *((png_int_32p) (buf)))
02786 #  endif
02787 #  define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
02788 #  define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
02789 #else
02790 #  if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
02791 PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
02792 #  endif
02793 PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
02794 PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
02795 #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
02796 PNG_EXTERN png_uint_32 png_get_uint_31 PNGARG((png_structp png_ptr,
02797   png_bytep buf));
02798 
02799 /* Initialize png_ptr struct for reading, and allocate any other memory.
02800  * (old interface - DEPRECATED - use png_create_read_struct instead).
02801  */
02802 extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr));
02803 #undef png_read_init
02804 #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
02805     PNG_LIBPNG_VER_STRING,  png_sizeof(png_struct));
02806 extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
02807     png_const_charp user_png_ver, png_size_t png_struct_size));
02808 extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
02809     png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
02810     png_info_size));
02811 
02812 /* Initialize png_ptr struct for writing, and allocate any other memory.
02813  * (old interface - DEPRECATED - use png_create_write_struct instead).
02814  */
02815 extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr));
02816 #undef png_write_init
02817 #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
02818     PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
02819 extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
02820     png_const_charp user_png_ver, png_size_t png_struct_size));
02821 extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr,
02822     png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
02823     png_info_size));
02824 
02825 /* Allocate memory for an internal libpng struct */
02826 PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
02827 
02828 /* Free memory from internal libpng struct */
02829 PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
02830 
02831 PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
02832   malloc_fn, png_voidp mem_ptr));
02833 PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
02834    png_free_ptr free_fn, png_voidp mem_ptr));
02835 
02836 /* Free any memory that info_ptr points to and reset struct. */
02837 PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
02838    png_infop info_ptr));
02839 
02840 #ifndef PNG_1_0_X
02841 /* Function to allocate memory for zlib. */
02842 PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
02843 
02844 /* Function to free memory for zlib */
02845 PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
02846 
02847 #ifdef PNG_SIZE_T
02848 /* Function to convert a sizeof an item to png_sizeof item */
02849    PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
02850 #endif
02851 
02852 /* Next four functions are used internally as callbacks.  PNGAPI is required
02853  * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3. */
02854 
02855 PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
02856    png_bytep data, png_size_t length));
02857 
02858 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
02859 PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
02860    png_bytep buffer, png_size_t length));
02861 #endif
02862 
02863 PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
02864    png_bytep data, png_size_t length));
02865 
02866 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
02867 #if !defined(PNG_NO_STDIO)
02868 PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr));
02869 #endif
02870 #endif
02871 #else /* PNG_1_0_X */
02872 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
02873 PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
02874    png_bytep buffer, png_size_t length));
02875 #endif
02876 #endif /* PNG_1_0_X */
02877 
02878 /* Reset the CRC variable */
02879 PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
02880 
02881 /* Write the "data" buffer to whatever output you are using. */
02882 PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
02883    png_size_t length));
02884 
02885 /* Read data from whatever input you are using into the "data" buffer */
02886 PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
02887    png_size_t length));
02888 
02889 /* Read bytes into buf, and update png_ptr->crc */
02890 PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
02891    png_size_t length));
02892 
02893 /* Decompress data in a chunk that uses compression */
02894 #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
02895     defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
02896 PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr,
02897    int comp_type, png_charp chunkdata, png_size_t chunklength,
02898    png_size_t prefix_length, png_size_t *data_length));
02899 #endif
02900 
02901 /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
02902 PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
02903 
02904 /* Read the CRC from the file and compare it to the libpng calculated CRC */
02905 PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
02906 
02907 /* Calculate the CRC over a section of data.  Note that we are only
02908  * passing a maximum of 64K on systems that have this as a memory limit,
02909  * since this is the maximum buffer size we can specify.
02910  */
02911 PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
02912    png_size_t length));
02913 
02914 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
02915 PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
02916 #endif
02917 
02918 
02919 /* Place a 32-bit number into a buffer in PNG byte order (big-endian).
02920  * The only currently known PNG chunks that use signed numbers are
02921  * the ancillary extension chunks, oFFs and pCAL.
02922  */
02923 PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
02924 
02925 #if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
02926 PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
02927 #endif
02928 
02929 /* Place a 16-bit number into a buffer in PNG byte order.
02930  * The parameter is declared unsigned int, not png_uint_16,
02931  * just to avoid potential problems on pre-ANSI C compilers.
02932  */
02933 PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
02934 
02935 /* simple function to write the signature */
02936 PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
02937 
02938 /* write various chunks */
02939 
02940 /* Write the IHDR chunk, and update the png_struct with the necessary
02941  * information.
02942  */
02943 PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
02944    png_uint_32 height,
02945    int bit_depth, int color_type, int compression_method, int filter_method,
02946    int interlace_method));
02947 
02948 PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
02949    png_uint_32 num_pal));
02950 
02951 PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
02952    png_size_t length));
02953 
02954 PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
02955 
02956 #if defined(PNG_WRITE_gAMA_SUPPORTED)
02957 #ifdef PNG_FLOATING_POINT_SUPPORTED
02958 PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
02959 #endif
02960 #ifdef PNG_FIXED_POINT_SUPPORTED
02961 PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point
02962     file_gamma));
02963 #endif
02964 #endif
02965 
02966 #if defined(PNG_WRITE_sBIT_SUPPORTED)
02967 PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
02968    int color_type));
02969 #endif
02970 
02971 #if defined(PNG_WRITE_cHRM_SUPPORTED)
02972 #ifdef PNG_FLOATING_POINT_SUPPORTED
02973 PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
02974    double white_x, double white_y,
02975    double red_x, double red_y, double green_x, double green_y,
02976    double blue_x, double blue_y));
02977 #endif
02978 #ifdef PNG_FIXED_POINT_SUPPORTED
02979 PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
02980    png_fixed_point int_white_x, png_fixed_point int_white_y,
02981    png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
02982    int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
02983    png_fixed_point int_blue_y));
02984 #endif
02985 #endif
02986 
02987 #if defined(PNG_WRITE_sRGB_SUPPORTED)
02988 PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
02989    int intent));
02990 #endif
02991 
02992 #if defined(PNG_WRITE_iCCP_SUPPORTED)
02993 PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
02994    png_charp name, int compression_type,
02995    png_charp profile, int proflen));
02996    /* Note to maintainer: profile should be png_bytep */
02997 #endif
02998 
02999 #if defined(PNG_WRITE_sPLT_SUPPORTED)
03000 PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
03001    png_sPLT_tp palette));
03002 #endif
03003 
03004 #if defined(PNG_WRITE_tRNS_SUPPORTED)
03005 PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
03006    png_color_16p values, int number, int color_type));
03007 #endif
03008 
03009 #if defined(PNG_WRITE_bKGD_SUPPORTED)
03010 PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
03011    png_color_16p values, int color_type));
03012 #endif
03013 
03014 #if defined(PNG_WRITE_hIST_SUPPORTED)
03015 PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
03016    int num_hist));
03017 #endif
03018 
03019 #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
03020     defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
03021 PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
03022    png_charp key, png_charpp new_key));
03023 #endif
03024 
03025 #if defined(PNG_WRITE_tEXt_SUPPORTED)
03026 PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
03027    png_charp text, png_size_t text_len));
03028 #endif
03029 
03030 #if defined(PNG_WRITE_zTXt_SUPPORTED)
03031 PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
03032    png_charp text, png_size_t text_len, int compression));
03033 #endif
03034 
03035 #if defined(PNG_WRITE_iTXt_SUPPORTED)
03036 PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
03037    int compression, png_charp key, png_charp lang, png_charp lang_key,
03038    png_charp text));
03039 #endif
03040 
03041 #if defined(PNG_TEXT_SUPPORTED)  /* Added at version 1.0.14 and 1.2.4 */
03042 PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
03043    png_infop info_ptr, png_textp text_ptr, int num_text));
03044 #endif
03045 
03046 #if defined(PNG_WRITE_oFFs_SUPPORTED)
03047 PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
03048    png_int_32 x_offset, png_int_32 y_offset, int unit_type));
03049 #endif
03050 
03051 #if defined(PNG_WRITE_pCAL_SUPPORTED)
03052 PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
03053    png_int_32 X0, png_int_32 X1, int type, int nparams,
03054    png_charp units, png_charpp params));
03055 #endif
03056 
03057 #if defined(PNG_WRITE_pHYs_SUPPORTED)
03058 PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
03059    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
03060    int unit_type));
03061 #endif
03062 
03063 #if defined(PNG_WRITE_tIME_SUPPORTED)
03064 PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
03065    png_timep mod_time));
03066 #endif
03067 
03068 #if defined(PNG_WRITE_sCAL_SUPPORTED)
03069 #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
03070 PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
03071    int unit, double width, double height));
03072 #else
03073 #ifdef PNG_FIXED_POINT_SUPPORTED
03074 PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
03075    int unit, png_charp width, png_charp height));
03076 #endif
03077 #endif
03078 #endif
03079 
03080 /* Called when finished processing a row of data */
03081 PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
03082 
03083 /* Internal use only.   Called before first row of data */
03084 PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
03085 
03086 #if defined(PNG_READ_GAMMA_SUPPORTED)
03087 PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
03088 #endif
03089 
03090 /* combine a row of data, dealing with alpha, etc. if requested */
03091 PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
03092    int mask));
03093 
03094 #if defined(PNG_READ_INTERLACING_SUPPORTED)
03095 /* expand an interlaced row */
03096 /* OLD pre-1.0.9 interface:
03097 PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
03098    png_bytep row, int pass, png_uint_32 transformations));
03099  */
03100 PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr));
03101 #endif
03102 
03103 /* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */
03104 
03105 #if defined(PNG_WRITE_INTERLACING_SUPPORTED)
03106 /* grab pixels out of a row for an interlaced pass */
03107 PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
03108    png_bytep row, int pass));
03109 #endif
03110 
03111 /* unfilter a row */
03112 PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
03113    png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
03114 
03115 /* Choose the best filter to use and filter the row data */
03116 PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
03117    png_row_infop row_info));
03118 
03119 /* Write out the filtered row. */
03120 PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
03121    png_bytep filtered_row));
03122 /* finish a row while reading, dealing with interlacing passes, etc. */
03123 PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
03124 
03125 /* initialize the row buffers, etc. */
03126 PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
03127 /* optional call to update the users info structure */
03128 PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
03129    png_infop info_ptr));
03130 
03131 /* these are the functions that do the transformations */
03132 #if defined(PNG_READ_FILLER_SUPPORTED)
03133 PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
03134    png_bytep row, png_uint_32 filler, png_uint_32 flags));
03135 #endif
03136 
03137 #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
03138 PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
03139    png_bytep row));
03140 #endif
03141 
03142 #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
03143 PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
03144    png_bytep row));
03145 #endif
03146 
03147 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
03148 PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
03149    png_bytep row));
03150 #endif
03151 
03152 #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
03153 PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
03154    png_bytep row));
03155 #endif
03156 
03157 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
03158     defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
03159 PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
03160    png_bytep row, png_uint_32 flags));
03161 #endif
03162 
03163 #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
03164 PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
03165 #endif
03166 
03167 #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
03168 PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
03169 #endif
03170 
03171 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
03172 PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
03173    row_info, png_bytep row));
03174 #endif
03175 
03176 #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
03177 PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
03178    png_bytep row));
03179 #endif
03180 
03181 #if defined(PNG_READ_PACK_SUPPORTED)
03182 PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
03183 #endif
03184 
03185 #if defined(PNG_READ_SHIFT_SUPPORTED)
03186 PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
03187    png_color_8p sig_bits));
03188 #endif
03189 
03190 #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
03191 PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
03192 #endif
03193 
03194 #if defined(PNG_READ_16_TO_8_SUPPORTED)
03195 PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
03196 #endif
03197 
03198 #if defined(PNG_READ_DITHER_SUPPORTED)
03199 PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
03200    png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
03201 
03202 #  if defined(PNG_CORRECT_PALETTE_SUPPORTED)
03203 PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
03204    png_colorp palette, int num_palette));
03205 #  endif
03206 #endif
03207 
03208 #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
03209 PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
03210 #endif
03211 
03212 #if defined(PNG_WRITE_PACK_SUPPORTED)
03213 PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
03214    png_bytep row, png_uint_32 bit_depth));
03215 #endif
03216 
03217 #if defined(PNG_WRITE_SHIFT_SUPPORTED)
03218 PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
03219    png_color_8p bit_depth));
03220 #endif
03221 
03222 #if defined(PNG_READ_BACKGROUND_SUPPORTED)
03223 #if defined(PNG_READ_GAMMA_SUPPORTED)
03224 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
03225    png_color_16p trans_values, png_color_16p background,
03226    png_color_16p background_1,
03227    png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
03228    png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
03229    png_uint_16pp gamma_16_to_1, int gamma_shift));
03230 #else
03231 PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
03232    png_color_16p trans_values, png_color_16p background));
03233 #endif
03234 #endif
03235 
03236 #if defined(PNG_READ_GAMMA_SUPPORTED)
03237 PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
03238    png_bytep gamma_table, png_uint_16pp gamma_16_table,
03239    int gamma_shift));
03240 #endif
03241 
03242 #if defined(PNG_READ_EXPAND_SUPPORTED)
03243 PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
03244    png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
03245 PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
03246    png_bytep row, png_color_16p trans_value));
03247 #endif
03248 
03249 /* The following decodes the appropriate chunks, and does error correction,
03250  * then calls the appropriate callback for the chunk if it is valid.
03251  */
03252 
03253 /* decode the IHDR chunk */
03254 PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
03255    png_uint_32 length));
03256 PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
03257    png_uint_32 length));
03258 PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
03259    png_uint_32 length));
03260 
03261 #if defined(PNG_READ_bKGD_SUPPORTED)
03262 PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
03263    png_uint_32 length));
03264 #endif
03265 
03266 #if defined(PNG_READ_cHRM_SUPPORTED)
03267 PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
03268    png_uint_32 length));
03269 #endif
03270 
03271 #if defined(PNG_READ_gAMA_SUPPORTED)
03272 PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
03273    png_uint_32 length));
03274 #endif
03275 
03276 #if defined(PNG_READ_hIST_SUPPORTED)
03277 PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
03278    png_uint_32 length));
03279 #endif
03280 
03281 #if defined(PNG_READ_iCCP_SUPPORTED)
03282 extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
03283    png_uint_32 length));
03284 #endif /* PNG_READ_iCCP_SUPPORTED */
03285 
03286 #if defined(PNG_READ_iTXt_SUPPORTED)
03287 PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
03288    png_uint_32 length));
03289 #endif
03290 
03291 #if defined(PNG_READ_oFFs_SUPPORTED)
03292 PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
03293    png_uint_32 length));
03294 #endif
03295 
03296 #if defined(PNG_READ_pCAL_SUPPORTED)
03297 PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
03298    png_uint_32 length));
03299 #endif
03300 
03301 #if defined(PNG_READ_pHYs_SUPPORTED)
03302 PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
03303    png_uint_32 length));
03304 #endif
03305 
03306 #if defined(PNG_READ_sBIT_SUPPORTED)
03307 PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
03308    png_uint_32 length));
03309 #endif
03310 
03311 #if defined(PNG_READ_sCAL_SUPPORTED)
03312 PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
03313    png_uint_32 length));
03314 #endif
03315 
03316 #if defined(PNG_READ_sPLT_SUPPORTED)
03317 extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
03318    png_uint_32 length));
03319 #endif /* PNG_READ_sPLT_SUPPORTED */
03320 
03321 #if defined(PNG_READ_sRGB_SUPPORTED)
03322 PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
03323    png_uint_32 length));
03324 #endif
03325 
03326 #if defined(PNG_READ_tEXt_SUPPORTED)
03327 PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
03328    png_uint_32 length));
03329 #endif
03330 
03331 #if defined(PNG_READ_tIME_SUPPORTED)
03332 PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
03333    png_uint_32 length));
03334 #endif
03335 
03336 #if defined(PNG_READ_tRNS_SUPPORTED)
03337 PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
03338    png_uint_32 length));
03339 #endif
03340 
03341 #if defined(PNG_READ_zTXt_SUPPORTED)
03342 PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
03343    png_uint_32 length));
03344 #endif
03345 
03346 PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
03347    png_infop info_ptr, png_uint_32 length));
03348 
03349 PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
03350    png_bytep chunk_name));
03351 
03352 /* handle the transformations for reading and writing */
03353 PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
03354 PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
03355 
03356 PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
03357 
03358 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
03359 PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
03360    png_infop info_ptr));
03361 PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
03362    png_infop info_ptr));
03363 PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
03364 PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
03365    png_uint_32 length));
03366 PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
03367 PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
03368 PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
03369    png_bytep buffer, png_size_t buffer_length));
03370 PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
03371 PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
03372    png_bytep buffer, png_size_t buffer_length));
03373 PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
03374 PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
03375    png_infop info_ptr, png_uint_32 length));
03376 PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
03377    png_infop info_ptr));
03378 PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
03379    png_infop info_ptr));
03380 PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
03381 PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
03382    png_infop info_ptr));
03383 PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
03384    png_infop info_ptr));
03385 PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
03386 #if defined(PNG_READ_tEXt_SUPPORTED)
03387 PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
03388    png_infop info_ptr, png_uint_32 length));
03389 PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
03390    png_infop info_ptr));
03391 #endif
03392 #if defined(PNG_READ_zTXt_SUPPORTED)
03393 PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
03394    png_infop info_ptr, png_uint_32 length));
03395 PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
03396    png_infop info_ptr));
03397 #endif
03398 #if defined(PNG_READ_iTXt_SUPPORTED)
03399 PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
03400    png_infop info_ptr, png_uint_32 length));
03401 PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
03402    png_infop info_ptr));
03403 #endif
03404 
03405 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
03406 
03407 #ifdef PNG_MNG_FEATURES_SUPPORTED
03408 PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
03409    png_bytep row));
03410 PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
03411    png_bytep row));
03412 #endif
03413 
03414 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
03415 /* png.c */ /* PRIVATE */
03416 PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr));
03417 #endif
03418 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
03419 
03420 #endif /* PNG_INTERNAL */
03421 
03422 #ifdef __cplusplus
03423 }
03424 #endif
03425 
03426 #endif /* PNG_VERSION_INFO_ONLY */
03427 /* do not put anything past this line */
03428 #endif /* PNG_H */

Generated on Mon Sep 18 01:24:41 2006 for BRL-CAD by  doxygen 1.4.6