Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# png.h

Go to the documentation of this file.

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