Subversion Repositories Kolibri OS

Rev

Rev 1897 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1897 Rev 3928
Line 1... Line 1...
1
/* png.h - header file for PNG reference library
1
/* png.h - header file for PNG reference library
2
 *
2
 *
3
 * libpng version 1.5.1 - February 3, 2011
3
 * libpng version 1.6.5 - September 14, 2013
4
 * Copyright (c) 1998-2011 Glenn Randers-Pehrson
4
 * Copyright (c) 1998-2013 Glenn Randers-Pehrson
5
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
5
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
6
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
6
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
7
 *
7
 *
8
 * This code is released under the libpng license (See LICENSE, below)
8
 * This code is released under the libpng license (See LICENSE, below)
9
 *
9
 *
10
 * Authors and maintainers:
10
 * Authors and maintainers:
11
 *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
11
 *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
12
 *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
12
 *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
13
 *   libpng versions 0.97, January 1998, through 1.5.1 - February 3, 2011: Glenn
13
 *   libpng versions 0.97, January 1998, through 1.6.5 - September 14, 2013: Glenn
14
 *   See also "Contributing Authors", below.
14
 *   See also "Contributing Authors", below.
15
 *
15
 *
16
 * Note about libpng version numbers:
16
 * Note about libpng version numbers:
17
 *
17
 *
18
 *   Due to various miscommunications, unforeseen code incompatibilities
18
 *   Due to various miscommunications, unforeseen code incompatibilities
Line 145... Line 145...
145
 *    1.5.0                   15    10500  15.so.15.0[.0]
145
 *    1.5.0                   15    10500  15.so.15.0[.0]
146
 *    1.5.1beta01-11          15    10501  15.so.15.1[.0]
146
 *    1.5.1beta01-11          15    10501  15.so.15.1[.0]
147
 *    1.5.1rc01-02            15    10501  15.so.15.1[.0]
147
 *    1.5.1rc01-02            15    10501  15.so.15.1[.0]
148
 *    1.5.1                   15    10501  15.so.15.1[.0]
148
 *    1.5.1                   15    10501  15.so.15.1[.0]
149
 *
149
 *    1.5.2beta01-03          15    10502  15.so.15.2[.0]
-
 
150
 *    1.5.2rc01-03            15    10502  15.so.15.2[.0]
-
 
151
 *    1.5.2                   15    10502  15.so.15.2[.0]
-
 
152
 *    1.5.3beta01-10          15    10503  15.so.15.3[.0]
-
 
153
 *    1.5.3rc01-02            15    10503  15.so.15.3[.0]
-
 
154
 *    1.5.3beta11             15    10503  15.so.15.3[.0]
-
 
155
 *    1.5.3 [omitted]
-
 
156
 *    1.5.4beta01-08          15    10504  15.so.15.4[.0]
-
 
157
 *    1.5.4rc01               15    10504  15.so.15.4[.0]
-
 
158
 *    1.5.4                   15    10504  15.so.15.4[.0]
-
 
159
 *    1.5.5beta01-08          15    10505  15.so.15.5[.0]
-
 
160
 *    1.5.5rc01               15    10505  15.so.15.5[.0]
-
 
161
 *    1.5.5                   15    10505  15.so.15.5[.0]
-
 
162
 *    1.5.6beta01-07          15    10506  15.so.15.6[.0]
-
 
163
 *    1.5.6rc01-03            15    10506  15.so.15.6[.0]
-
 
164
 *    1.5.6                   15    10506  15.so.15.6[.0]
-
 
165
 *    1.5.7beta01-05          15    10507  15.so.15.7[.0]
-
 
166
 *    1.5.7rc01-03            15    10507  15.so.15.7[.0]
-
 
167
 *    1.5.7                   15    10507  15.so.15.7[.0]
-
 
168
 *    1.6.0beta01-40          16    10600  16.so.16.0[.0]
-
 
169
 *    1.6.0rc01-08            16    10600  16.so.16.0[.0]
-
 
170
 *    1.6.0                   16    10600  16.so.16.0[.0]
-
 
171
 *    1.6.1beta01-09          16    10601  16.so.16.1[.0]
-
 
172
 *    1.6.1rc01               16    10601  16.so.16.1[.0]
-
 
173
 *    1.6.1                   16    10601  16.so.16.1[.0]
-
 
174
 *    1.6.2beta01             16    10602  16.so.16.2[.0]
-
 
175
 *    1.6.2rc01-06            16    10602  16.so.16.2[.0]
-
 
176
 *    1.6.2                   16    10602  16.so.16.2[.0]
-
 
177
 *    1.6.3beta01-11          16    10603  16.so.16.3[.0]
-
 
178
 *    1.6.3rc01               16    10603  16.so.16.3[.0]
-
 
179
 *    1.6.3                   16    10603  16.so.16.3[.0]
-
 
180
 *    1.6.4beta01-02          16    10604  16.so.16.4[.0]
-
 
181
 *    1.6.4rc01               16    10604  16.so.16.4[.0]
-
 
182
 *    1.6.4                   16    10604  16.so.16.4[.0]
-
 
183
 *    1.6.5                   16    10605  16.so.16.5[.0]
-
 
184
 *
150
 *   Henceforth the source version will match the shared-library major
185
 *   Henceforth the source version will match the shared-library major
151
 *   and minor numbers; the shared-library major version number will be
186
 *   and minor numbers; the shared-library major version number will be
152
 *   used for changes in backward compatibility, as it is intended.  The
187
 *   used for changes in backward compatibility, as it is intended.  The
153
 *   PNG_LIBPNG_VER macro, which is not used within libpng but is available
188
 *   PNG_LIBPNG_VER macro, which is not used within libpng but is available
154
 *   for applications, is an unsigned integer of the form xyyzz corresponding
189
 *   for applications, is an unsigned integer of the form xyyzz corresponding
155
 *   to the source version x.y.z (leading zeros in y and z).  Beta versions
190
 *   to the source version x.y.z (leading zeros in y and z).  Beta versions
156
 *   were given the previous public release number plus a letter, until
191
 *   were given the previous public release number plus a letter, until
157
 *   version 1.0.6j; from then on they were given the upcoming public
192
 *   version 1.0.6j; from then on they were given the upcoming public
158
 *   release number plus "betaNN" or "rcN".
193
 *   release number plus "betaNN" or "rcNN".
159
 *
194
 *
160
 *   Binary incompatibility exists only when applications make direct access
195
 *   Binary incompatibility exists only when applications make direct access
161
 *   to the info_ptr or png_ptr members through png.h, and the compiled
196
 *   to the info_ptr or png_ptr members through png.h, and the compiled
162
 *   application is loaded with a different version of the library.
197
 *   application is loaded with a different version of the library.
163
 *
198
 *
164
 *   DLLNUM will change each time there are forward or backward changes
199
 *   DLLNUM will change each time there are forward or backward changes
Line 176... Line 211...
176
 * this sentence.
211
 * this sentence.
177
 *
212
 *
178
 * This code is released under the libpng license.
213
 * This code is released under the libpng license.
179
 *
214
 *
180
 * libpng versions 1.2.6, August 15, 2004, through 1.5.1, February 3, 2011, are
215
 * libpng versions 1.2.6, August 15, 2004, through 1.6.5, September 14, 2013, are
181
 * Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
216
 * Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
182
 * distributed according to the same disclaimer and license as libpng-1.2.5
217
 * distributed according to the same disclaimer and license as libpng-1.2.5
183
 * with the following individual added to the list of Contributing Authors:
218
 * with the following individual added to the list of Contributing Authors:
184
 *
219
 *
185
 *    Cosmin Truta
220
 *    Cosmin Truta
186
 *
221
 *
187
 * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
222
 * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
Line 288... Line 323...
288
/*
323
/*
289
 * Y2K compliance in libpng:
324
 * Y2K compliance in libpng:
290
 * =========================
325
 * =========================
291
 *
326
 *
292
 *    February 3, 2011
327
 *    September 14, 2013
293
 *
328
 *
294
 *    Since the PNG Development group is an ad-hoc body, we can't make
329
 *    Since the PNG Development group is an ad-hoc body, we can't make
295
 *    an official declaration.
330
 *    an official declaration.
296
 *
331
 *
297
 *    This is your unofficial assurance that libpng from version 0.71 and
332
 *    This is your unofficial assurance that libpng from version 0.71 and
298
 *    upward through 1.5.1 are Y2K compliant.  It is my belief that
333
 *    upward through 1.6.5 are Y2K compliant.  It is my belief that
299
 *    earlier versions were also Y2K compliant.
334
 *    earlier versions were also Y2K compliant.
300
 *
335
 *
301
 *    Libpng only has three year fields.  One is a 2-byte unsigned integer
336
 *    Libpng only has two year fields.  One is a 2-byte unsigned integer
302
 *    that will hold years up to 65535.  The other two hold the date in text
337
 *    that will hold years up to 65535.  The other, which is deprecated,
303
 *    format, and will hold years up to 9999.
338
 *    holds the date in text format, and will hold years up to 9999.
304
 *
339
 *
305
 *    The integer is
340
 *    The integer is
306
 *        "png_uint_16 year" in png_time_struct.
341
 *        "png_uint_16 year" in png_time_struct.
307
 *
342
 *
308
 *    The strings are
343
 *    The string is
309
 *        "png_charp time_buffer" in png_struct and
344
 *        "char time_buffer[29]" in png_struct.  This is no longer used
310
 *        "near_time_buffer", which is a local character string in png.c.
345
 *    in libpng-1.6.x and will be removed from libpng-1.7.0.
311
 *
346
 *
312
 *    There are seven time-related functions:
347
 *    There are seven time-related functions:
313
 *        png.c: png_convert_to_rfc_1123() in png.c
348
 *        png.c: png_convert_to_rfc_1123_buffer() in png.c
314
 *          (formerly png_convert_to_rfc_1152() in error)
349
 *          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
-
 
350
 *          png_convert_to_rfc_1152() in error prior to libpng-0.98)
315
 *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
351
 *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
316
 *        png_convert_from_time_t() in pngwrite.c
352
 *        png_convert_from_time_t() in pngwrite.c
317
 *        png_get_tIME() in pngget.c
353
 *        png_get_tIME() in pngget.c
318
 *        png_handle_tIME() in pngrutil.c, called in pngread.c
354
 *        png_handle_tIME() in pngrutil.c, called in pngread.c
319
 *        png_set_tIME() in pngset.c
355
 *        png_set_tIME() in pngset.c
320
 *        png_write_tIME() in pngwutil.c, called in pngwrite.c
356
 *        png_write_tIME() in pngwutil.c, called in pngwrite.c
321
 *
357
 *
322
 *    All handle dates properly in a Y2K environment.  The
358
 *    All handle dates properly in a Y2K environment.  The
323
 *    png_convert_from_time_t() function calls gmtime() to convert from system
359
 *    png_convert_from_time_t() function calls gmtime() to convert from system
324
 *    clock time, which returns (year - 1900), which we properly convert to
360
 *    clock time, which returns (year - 1900), which we properly convert to
325
 *    the full 4-digit year.  There is a possibility that applications using
361
 *    the full 4-digit year.  There is a possibility that libpng applications
326
 *    libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
362
 *    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()
327
 *    function, or that they are incorrectly passing only a 2-digit year
363
 *    function, or that they are incorrectly passing only a 2-digit year
328
 *    instead of "year - 1900" into the png_convert_from_struct_tm() function, 
364
 *    instead of "year - 1900" into the png_convert_from_struct_tm() function,
329
 *    but this is not under our control.  The libpng documentation has always
365
 *    but this is not under our control.  The libpng documentation has always
330
 *    stated that it works with 4-digit years, and the APIs have been
366
 *    stated that it works with 4-digit years, and the APIs have been
331
 *    documented as such.
367
 *    documented as such.
Line 347... Line 383...
347
/* This is not the place to learn how to use libpng. The file libpng-manual.txt
383
/* This is not the place to learn how to use libpng. The file libpng-manual.txt
348
 * describes how to use libpng, and the file example.c summarizes it
384
 * describes how to use libpng, and the file example.c summarizes it
349
 * with some code on which to build.  This file is useful for looking
385
 * with some code on which to build.  This file is useful for looking
350
 * at the actual function definitions and structure components.
386
 * at the actual function definitions and structure components.
-
 
387
 *
-
 
388
 * If you just need to read a PNG file and don't want to read the documentation
-
 
389
 * skip to the end of this file and read the section entitled 'simplified API'.
351
 */
390
 */
Line 352... Line 391...
352
 
391
 
353
/* Version information for png.h - this should match the version in png.c */
392
/* Version information for png.h - this should match the version in png.c */
354
#define PNG_LIBPNG_VER_STRING "1.5.1"
393
#define PNG_LIBPNG_VER_STRING "1.6.5"
355
#define PNG_HEADER_VERSION_STRING \
394
#define PNG_HEADER_VERSION_STRING \
Line 356... Line 395...
356
     " libpng version 1.5.1 - February 3, 2011\n"
395
     " libpng version 1.6.5 - September 14, 2013\n"
357
 
396
 
Line 358... Line 397...
358
#define PNG_LIBPNG_VER_SONUM   15
397
#define PNG_LIBPNG_VER_SONUM   16
359
#define PNG_LIBPNG_VER_DLLNUM  15
398
#define PNG_LIBPNG_VER_DLLNUM  16
360
 
399
 
361
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
400
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
-
 
401
#define PNG_LIBPNG_VER_MAJOR   1
362
#define PNG_LIBPNG_VER_MAJOR   1
402
#define PNG_LIBPNG_VER_MINOR   6
363
#define PNG_LIBPNG_VER_MINOR   5
403
#define PNG_LIBPNG_VER_RELEASE 5
364
#define PNG_LIBPNG_VER_RELEASE 1
404
 
Line 365... Line 405...
365
/* This should match the numeric part of the final component of
405
/* This should match the numeric part of the final component of
Line 382... Line 422...
382
                                       PNG_LIBPNG_BUILD_SPECIAL */
422
                                       PNG_LIBPNG_BUILD_SPECIAL */
383
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
423
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
384
                                       PNG_LIBPNG_BUILD_PRIVATE */
424
                                       PNG_LIBPNG_BUILD_PRIVATE */
385
 
425
 
Line 386... Line 426...
386
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
426
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
Line 387... Line 427...
387
 
427
 
388
/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
428
/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
389
 * We must not include leading zeros.
429
 * We must not include leading zeros.
390
 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
430
 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
391
 * version 1.0.0 was mis-numbered 100 instead of 10000).  From
431
 * version 1.0.0 was mis-numbered 100 instead of 10000).  From
392
 * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
432
 * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
393
 */
433
 */
Line 394... Line 434...
394
#define PNG_LIBPNG_VER 10501 /* 1.5.1 */
434
#define PNG_LIBPNG_VER 10605 /* 1.6.5 */
395
 
435
 
396
/* Library configuration: these options cannot be changed after
436
/* Library configuration: these options cannot be changed after
397
 * the library has been built.
437
 * the library has been built.
Line 403... Line 443...
403
#   include "pnglibconf.h"
443
#   include "pnglibconf.h"
404
#endif
444
#endif
405
 
445
 
Line 406... Line 446...
406
#ifndef PNG_VERSION_INFO_ONLY
446
#ifndef PNG_VERSION_INFO_ONLY
407
/* Standard header files (not needed for the version info) */
-
 
408
#  ifdef PNG_SETJMP_SUPPORTED
-
 
409
#    include 
-
 
410
#  endif
-
 
411
 
-
 
412
/* Need the time information for converting tIME chunks, it
-
 
413
 * defines struct tm:
-
 
414
 */
-
 
415
#ifdef PNG_CONVERT_tIME_SUPPORTED
-
 
416
   /* "time.h" functions are not supported on all operating systems */
-
 
417
#  include 
-
 
418
#endif
-
 
419
 
-
 
420
/* Machine specific configuration. */
447
   /* Machine specific configuration. */
421
#  include "pngconf.h"
448
#  include "pngconf.h"
422
#endif
449
#endif
Line 423... Line 450...
423
 
450
 
Line 465... Line 492...
465
 *    code when it is built.  (Build time configuration is in pnglibconf.h)
492
 *    code when it is built.  (Build time configuration is in pnglibconf.h)
466
 * 2. Type definitions (base types are defined in pngconf.h), structure
493
 * 2. Type definitions (base types are defined in pngconf.h), structure
467
 *    definitions.
494
 *    definitions.
468
 * 3. Exported library functions.
495
 * 3. Exported library functions.
469
 *
496
 * 4. Simplified API.
-
 
497
 *
470
 * The library source code has additional files (principally pngpriv.h) that
498
 * The library source code has additional files (principally pngpriv.h) that
471
 * allow configuration of the library.
499
 * allow configuration of the library.
472
 */
500
 */
473
/* Section 1: run time configuration
501
/* Section 1: run time configuration
474
 * See pnglibconf.h for build time configuration
502
 * See pnglibconf.h for build time configuration
Line 507... Line 535...
507
 
535
 
Line 508... Line 536...
508
/* This triggers a compiler error in png.c, if png.c and png.h
536
/* This triggers a compiler error in png.c, if png.c and png.h
509
 * do not agree upon the version number.
537
 * do not agree upon the version number.
510
 */
538
 */
511
typedef char* png_libpng_version_1_5_1;
539
typedef char* png_libpng_version_1_6_5;
-
 
540
 
-
 
541
/* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
-
 
542
 *
-
 
543
 * png_struct is the cache of information used while reading or writing a single
-
 
544
 * PNG file.  One of these is always required, although the simplified API
-
 
545
 * (below) hides the creation and destruction of it.
-
 
546
 */
-
 
547
typedef struct png_struct_def png_struct;
-
 
548
typedef const png_struct * png_const_structp;
-
 
549
typedef png_struct * png_structp;
-
 
550
typedef png_struct * * png_structpp;
-
 
551
 
-
 
552
/* png_info contains information read from or to be written to a PNG file.  One
-
 
553
 * or more of these must exist while reading or creating a PNG file.  The
-
 
554
 * information is not used by libpng during read but is used to control what
-
 
555
 * gets written when a PNG file is created.  "png_get_" function calls read
-
 
556
 * information during read and "png_set_" functions calls write information
-
 
557
 * when creating a PNG.
-
 
558
 * been moved into a separate header file that is not accessible to
-
 
559
 * applications.  Read libpng-manual.txt or libpng.3 for more info.
-
 
560
 */
-
 
561
typedef struct png_info_def png_info;
-
 
562
typedef png_info * png_infop;
-
 
563
typedef const png_info * png_const_infop;
-
 
564
typedef png_info * * png_infopp;
-
 
565
 
-
 
566
/* Types with names ending 'p' are pointer types.  The corresponding types with
-
 
567
 * names ending 'rp' are identical pointer types except that the pointer is
-
 
568
 * marked 'restrict', which means that it is the only pointer to the object
-
 
569
 * passed to the function.  Applications should not use the 'restrict' types;
-
 
570
 * it is always valid to pass 'p' to a pointer with a function argument of the
-
 
571
 * corresponding 'rp' type.  Different compilers have different rules with
-
 
572
 * regard to type matching in the presence of 'restrict'.  For backward
-
 
573
 * compatibility libpng callbacks never have 'restrict' in their parameters and,
-
 
574
 * consequentially, writing portable application code is extremely difficult if
-
 
575
 * an attempt is made to use 'restrict'.
-
 
576
 */
-
 
577
typedef png_struct * PNG_RESTRICT png_structrp;
-
 
578
typedef const png_struct * PNG_RESTRICT png_const_structrp;
-
 
579
typedef png_info * PNG_RESTRICT png_inforp;
-
 
580
typedef const png_info * PNG_RESTRICT png_const_inforp;
Line 512... Line 581...
512
 
581
 
513
/* Three color definitions.  The order of the red, green, and blue, (and the
582
/* Three color definitions.  The order of the red, green, and blue, (and the
514
 * exact size) is not important, although the size of the fields need to
583
 * exact size) is not important, although the size of the fields need to
515
 * be png_byte or png_uint_16 (as defined below).
584
 * be png_byte or png_uint_16 (as defined below).
Line 519... Line 588...
519
   png_byte red;
588
   png_byte red;
520
   png_byte green;
589
   png_byte green;
521
   png_byte blue;
590
   png_byte blue;
522
} png_color;
591
} png_color;
523
typedef png_color FAR * png_colorp;
592
typedef png_color * png_colorp;
524
typedef PNG_CONST png_color FAR * png_const_colorp;
593
typedef const png_color * png_const_colorp;
525
typedef png_color FAR * FAR * png_colorpp;
594
typedef png_color * * png_colorpp;
526
 
595
 
Line 527... Line 596...
527
typedef struct png_color_16_struct
596
typedef struct png_color_16_struct
528
{
597
{
529
   png_byte index;    /* used for palette files */
598
   png_byte index;    /* used for palette files */
530
   png_uint_16 red;   /* for use in red green blue files */
599
   png_uint_16 red;   /* for use in red green blue files */
531
   png_uint_16 green;
600
   png_uint_16 green;
532
   png_uint_16 blue;
601
   png_uint_16 blue;
533
   png_uint_16 gray;  /* for use in grayscale files */
602
   png_uint_16 gray;  /* for use in grayscale files */
534
} png_color_16;
603
} png_color_16;
535
typedef png_color_16 FAR * png_color_16p;
604
typedef png_color_16 * png_color_16p;
536
typedef PNG_CONST png_color_16 FAR * png_const_color_16p;
605
typedef const png_color_16 * png_const_color_16p;
537
typedef png_color_16 FAR * FAR * png_color_16pp;
606
typedef png_color_16 * * png_color_16pp;
Line 538... Line 607...
538
 
607
 
539
typedef struct png_color_8_struct
608
typedef struct png_color_8_struct
540
{
609
{
541
   png_byte red;   /* for use in red green blue files */
610
   png_byte red;   /* for use in red green blue files */
542
   png_byte green;
611
   png_byte green;
543
   png_byte blue;
612
   png_byte blue;
544
   png_byte gray;  /* for use in grayscale files */
613
   png_byte gray;  /* for use in grayscale files */
545
   png_byte alpha; /* for alpha channel files */
614
   png_byte alpha; /* for alpha channel files */
546
} png_color_8;
615
} png_color_8;
547
typedef png_color_8 FAR * png_color_8p;
616
typedef png_color_8 * png_color_8p;
548
typedef PNG_CONST png_color_8 FAR * png_const_color_8p;
617
typedef const png_color_8 * png_const_color_8p;
Line 549... Line 618...
549
typedef png_color_8 FAR * FAR * png_color_8pp;
618
typedef png_color_8 * * png_color_8pp;
550
 
619
 
551
/*
620
/*
552
 * The following two structures are used for the in-core representation
621
 * The following two structures are used for the in-core representation
Line 559... Line 628...
559
   png_uint_16 blue;
628
   png_uint_16 blue;
560
   png_uint_16 alpha;
629
   png_uint_16 alpha;
561
   png_uint_16 frequency;
630
   png_uint_16 frequency;
562
} png_sPLT_entry;
631
} png_sPLT_entry;
563
typedef png_sPLT_entry FAR * png_sPLT_entryp;
632
typedef png_sPLT_entry * png_sPLT_entryp;
564
typedef PNG_CONST png_sPLT_entry FAR * png_const_sPLT_entryp;
633
typedef const png_sPLT_entry * png_const_sPLT_entryp;
565
typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
634
typedef png_sPLT_entry * * png_sPLT_entrypp;
566
 
635
 
Line 567... Line 636...
567
/*  When the depth of the sPLT palette is 8 bits, the color and alpha samples
636
/*  When the depth of the sPLT palette is 8 bits, the color and alpha samples
568
 *  occupy the LSB of their respective members, and the MSB of each member
637
 *  occupy the LSB of their respective members, and the MSB of each member
569
 *  is zero-filled.  The frequency member always occupies the full 16 bits.
638
 *  is zero-filled.  The frequency member always occupies the full 16 bits.
570
 */
639
 */
Line 575... Line 644...
575
   png_byte depth;           /* depth of palette samples */
644
   png_byte depth;           /* depth of palette samples */
576
   png_sPLT_entryp entries;  /* palette entries */
645
   png_sPLT_entryp entries;  /* palette entries */
577
   png_int_32 nentries;      /* number of palette entries */
646
   png_int_32 nentries;      /* number of palette entries */
578
} png_sPLT_t;
647
} png_sPLT_t;
579
typedef png_sPLT_t FAR * png_sPLT_tp;
648
typedef png_sPLT_t * png_sPLT_tp;
580
typedef PNG_CONST png_sPLT_t FAR * png_const_sPLT_tp;
649
typedef const png_sPLT_t * png_const_sPLT_tp;
581
typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
650
typedef png_sPLT_t * * png_sPLT_tpp;
582
 
651
 
Line 583... Line 652...
583
#ifdef PNG_TEXT_SUPPORTED
652
#ifdef PNG_TEXT_SUPPORTED
584
/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, 
653
/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
585
 * and whether that contents is compressed or not.  The "key" field
654
 * and whether that contents is compressed or not.  The "key" field
586
 * points to a regular zero-terminated C string.  The "text", "lang", and
655
 * points to a regular zero-terminated C string.  The "text" fields can be a
587
 * "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
656
 * regular C string, an empty string, or a NULL pointer.
588
 * However, the * structure returned by png_get_text() will always contain
657
 * However, the structure returned by png_get_text() will always contain
589
 * regular zero-terminated C strings (possibly empty), never NULL pointers, 
658
 * the "text" field as a regular zero-terminated C string (possibly
-
 
659
 * empty), never a NULL pointer, so it can be safely used in printf() and
590
 * so they can be safely used in printf() and other string-handling functions.
660
 * other string-handling functions.  Note that the "itxt_length", "lang", and
-
 
661
 * "lang_key" members of the structure only exist when the library is built
-
 
662
 * with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by
-
 
663
 * default without iTXt support. Also note that when iTXt *is* supported,
-
 
664
 * the "lang" and "lang_key" fields contain NULL pointers when the
-
 
665
 * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or
-
 
666
 * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the
-
 
667
 * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag"
-
 
668
 * which is always 0 or 1, or its "compression method" which is always 0.
591
 */
669
 */
592
typedef struct png_text_struct
670
typedef struct png_text_struct
593
{
671
{
594
   int  compression;       /* compression value:
672
   int  compression;       /* compression value:
595
                             -1: tEXt, none
673
                             -1: tEXt, none
Line 605... Line 683...
605
                              or a NULL pointer */
683
                              or a NULL pointer */
606
   png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more
684
   png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more
607
                              chars or a NULL pointer */
685
                              chars or a NULL pointer */
608
} png_text;
686
} png_text;
609
typedef png_text FAR * png_textp;
687
typedef png_text * png_textp;
610
typedef PNG_CONST png_text FAR * png_const_textp;
688
typedef const png_text * png_const_textp;
611
typedef png_text FAR * FAR * png_textpp;
689
typedef png_text * * png_textpp;
612
#endif
690
#endif
613
 
691
 
Line 614... Line 692...
614
/* Supported compression types for text in PNG files (tEXt, and zTXt).
692
/* Supported compression types for text in PNG files (tEXt, and zTXt).
615
 * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
693
 * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
616
#define PNG_TEXT_COMPRESSION_NONE_WR -3
694
#define PNG_TEXT_COMPRESSION_NONE_WR -3
Line 635... Line 713...
635
   png_byte hour;    /* hour of day, 0 - 23 */
713
   png_byte hour;    /* hour of day, 0 - 23 */
636
   png_byte minute;  /* minute of hour, 0 - 59 */
714
   png_byte minute;  /* minute of hour, 0 - 59 */
637
   png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */
715
   png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */
638
} png_time;
716
} png_time;
639
typedef png_time FAR * png_timep;
717
typedef png_time * png_timep;
640
typedef PNG_CONST png_time FAR * png_const_timep;
718
typedef const png_time * png_const_timep;
641
typedef png_time FAR * FAR * png_timepp;
719
typedef png_time * * png_timepp;
642
 
720
 
Line 643... Line 721...
643
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
721
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
644
    defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
-
 
645
/* png_unknown_chunk is a structure to hold queued chunks for which there is
722
/* png_unknown_chunk is a structure to hold queued chunks for which there is
646
 * no specific support.  The idea is that we can use this to queue
723
 * no specific support.  The idea is that we can use this to queue
647
 * up private chunks for output even though the library doesn't actually
724
 * up private chunks for output even though the library doesn't actually
648
 * know about their semantics.
725
 * know about their semantics.
-
 
726
 *
-
 
727
 * The data in the structure is set by libpng on read and used on write.
649
 */
728
 */
650
typedef struct png_unknown_chunk_t
729
typedef struct png_unknown_chunk_t
651
{
730
{
652
    png_byte name[5];
731
    png_byte name[5]; /* Textual chunk name with '\0' terminator */
653
    png_byte *data;
732
    png_byte *data;   /* Data, should not be modified on read! */
654
    png_size_t size;
733
    png_size_t size;
Line 655... Line 734...
655
 
734
 
-
 
735
    /* On write 'location' must be set using the flag values listed below.
-
 
736
     * Notice that on read it is set by libpng however the values stored have
-
 
737
     * more bits set than are listed below.  Always treat the value as a
-
 
738
     * bitmask.  On write set only one bit - setting multiple bits may cause the
-
 
739
     * chunk to be written in multiple places.
656
    /* libpng-using applications should NOT directly modify this byte. */
740
     */
657
    png_byte location; /* mode of operation at read time */
741
    png_byte location; /* mode of operation at read time */
658
}
742
}
-
 
743
png_unknown_chunk;
659
png_unknown_chunk;
744
 
660
typedef png_unknown_chunk FAR * png_unknown_chunkp;
745
typedef png_unknown_chunk * png_unknown_chunkp;
661
typedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp;
746
typedef const png_unknown_chunk * png_const_unknown_chunkp;
662
typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
747
typedef png_unknown_chunk * * png_unknown_chunkpp;
Line 663... Line 748...
663
#endif
748
#endif
664
 
749
 
665
typedef struct png_info_def png_info;
750
/* Flag values for the unknown chunk location byte. */
666
typedef png_info FAR * png_infop;
751
#define PNG_HAVE_IHDR  0x01
Line 667... Line 752...
667
typedef PNG_CONST png_info FAR * png_const_infop;
752
#define PNG_HAVE_PLTE  0x02
668
typedef png_info FAR * FAR * png_infopp;
753
#define PNG_AFTER_IDAT 0x08
669
 
754
 
670
/* Maximum positive integer used in PNG is (2^31)-1 */
755
/* Maximum positive integer used in PNG is (2^31)-1 */
Line 676... Line 761...
676
 * PNG specification manner (x100000)
761
 * PNG specification manner (x100000)
677
 */
762
 */
678
#define PNG_FP_1    100000
763
#define PNG_FP_1    100000
679
#define PNG_FP_HALF  50000
764
#define PNG_FP_HALF  50000
680
 
765
#define PNG_FP_MAX  ((png_fixed_point)0x7fffffffL)
-
 
766
#define PNG_FP_MIN  (-PNG_FP_MAX)
-
 
767
 
Line 681... Line 768...
681
/* These describe the color_type field in png_info. */
768
/* These describe the color_type field in png_info. */
682
/* color type masks */
769
/* color type masks */
683
#define PNG_COLOR_MASK_PALETTE    1
770
#define PNG_COLOR_MASK_PALETTE    1
684
#define PNG_COLOR_MASK_COLOR      2
771
#define PNG_COLOR_MASK_COLOR      2
Line 763... Line 850...
763
#define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */
850
#define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */
764
#define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */
851
#define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */
765
#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
852
#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
766
#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
853
#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
767
#define PNG_INFO_IDAT 0x8000L  /* ESR, 1.0.6 */
854
#define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */
768
 
855
 
Line 769... Line 856...
769
/* This is used for the transformation routines, as some of them
856
/* This is used for the transformation routines, as some of them
770
 * change these values for the row.  It also should enable using
857
 * change these values for the row.  It also should enable using
771
 * the routines for other purposes.
858
 * the routines for other purposes.
772
 */
859
 */
Line 779... Line 866...
779
   png_byte channels;    /* number of channels (1, 2, 3, or 4) */
866
   png_byte channels;    /* number of channels (1, 2, 3, or 4) */
780
   png_byte pixel_depth; /* bits per pixel (depth * channels) */
867
   png_byte pixel_depth; /* bits per pixel (depth * channels) */
781
} png_row_info;
868
} png_row_info;
782
 
869
 
Line 783... Line 870...
783
typedef png_row_info FAR * png_row_infop;
870
typedef png_row_info * png_row_infop;
784
typedef png_row_info FAR * FAR * png_row_infopp;
871
typedef png_row_info * * png_row_infopp;
Line 785... Line 872...
785
 
872
 
786
/* These are the function types for the I/O functions and for the functions
873
/* These are the function types for the I/O functions and for the functions
787
 * that allow the user to override the default I/O functions with his or her
874
 * that allow the user to override the default I/O functions with his or her
788
 * own.  The png_error_ptr type should match that of user-supplied warning
875
 * own.  The png_error_ptr type should match that of user-supplied warning
789
 * and error functions, while the png_rw_ptr type should match that of the
876
 * and error functions, while the png_rw_ptr type should match that of the
790
 * user read/write data functions.  Note that the 'write' function must not
877
 * user read/write data functions.  Note that the 'write' function must not
791
 * modify the buffer it is passed. The 'read' function, on the other hand, is
878
 * modify the buffer it is passed. The 'read' function, on the other hand, is
792
 * expected to return the read data in the buffer.
879
 * expected to return the read data in the buffer.
793
 */
-
 
794
typedef struct png_struct_def png_struct;
-
 
795
typedef PNG_CONST png_struct FAR * png_const_structp;
-
 
796
typedef png_struct FAR * png_structp;
-
 
797
 
880
 */
798
typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp), );
881
typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));
799
typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t), );
882
typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));
800
typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp), );
883
typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));
801
typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, 
884
typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,
802
    int), );
885
    int));
803
typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, 
886
typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,
Line 804... Line 887...
804
    int), );
887
    int));
805
 
888
 
806
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
889
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-
 
890
typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
-
 
891
typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
807
typedef PNG_CALLBACK(void, *png_progressive_info_ptr, 
892
 
-
 
893
/* The following callback receives png_uint_32 row_number, int pass for the
-
 
894
 * png_bytep data of the row.  When transforming an interlaced image the
808
    (png_structp, png_infop), );
895
 * row number is the row number within the sub-image of the interlace pass, so
-
 
896
 * the value will increase to the height of the sub-image (not the full image)
-
 
897
 * then reset to 0 for the next pass.
-
 
898
 *
-
 
899
 * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
-
 
900
 * find the output pixel (x,y) given an interlaced sub-image pixel
809
typedef PNG_CALLBACK(void, *png_progressive_end_ptr,
901
 * (row,col,pass).  (See below for these macros.)
810
    (png_structp, png_infop), );
902
 */
811
typedef PNG_CALLBACK(void, *png_progressive_row_ptr,
903
typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,
Line 812... Line 904...
812
    (png_structp, png_bytep, png_uint_32, int), );
904
    png_uint_32, int));
813
#endif
905
#endif
814
 
906
 
815
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
907
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
816
    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
908
    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
Line 817... Line 909...
817
typedef PNG_CALLBACK(void, *png_user_transform_ptr,
909
typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,
818
    (png_structp, png_row_infop, png_bytep), );
910
    png_bytep));
819
#endif
911
#endif
820
 
912
 
821
#ifdef PNG_USER_CHUNKS_SUPPORTED
913
#ifdef PNG_USER_CHUNKS_SUPPORTED
-
 
914
typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,
822
typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, 
915
    png_unknown_chunkp));
823
    png_unknown_chunkp), );
916
#endif
Line 824... Line 917...
824
#endif
917
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
825
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
918
/* not used anywhere */
826
typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp), );
919
/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */
827
#endif
920
#endif
828
 
-
 
829
#ifdef PNG_SETJMP_SUPPORTED
-
 
830
/* This must match the function definition in , and the
-
 
831
 * application must include this before png.h to obtain the definition
-
 
832
 * of jmp_buf.  The function is required to be PNG_NORETURN.  (Note that
-
 
833
 * PNG_PTR_NORETURN is used here because current versions of the Microsoft
921
 
834
 * C compiler do not support the PNG_NORETURN attribute on a pointer.)
-
 
835
 *
922
#ifdef PNG_SETJMP_SUPPORTED
836
 * If you get a type warning from the compiler when linking against this line
923
/* This must match the function definition in , and the application
837
 * then your compiler has 'longjmp' that does not match the requirements of the
924
 * must include this before png.h to obtain the definition of jmp_buf.  The
838
 * compiler that built libpng.  You will have to write a wrapper function for
925
 * function is required to be PNG_NORETURN, but this is not checked.  If the
839
 * your compiler's longjmp and call png_set_longjmp_fn directly (not via the
926
 * function does return the application will crash via an abort() or similar
840
 * png_jmpbuf macro.)
927
 * system level call.
841
 *
928
 *
842
 * If you get a warning here while building the library you will need to make
929
 * If you get a warning here while building the library you may need to make
843
 * changes to ensure that pnglibconf.h records the calling convention used by
-
 
844
 * your compiler.  This may be very difficult - try using a different compiler
930
 * changes to ensure that pnglibconf.h records the calling convention used by
Line 845... Line 931...
845
 * to build the library!
931
 * your compiler.  This may be very difficult - try using a different compiler
846
 */
932
 * to build the library!
847
typedef PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), 
933
 */
Line 866... Line 952...
866
#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER
952
#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER
867
#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
953
#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
868
/* Added to libpng-1.4.0 */
954
/* Added to libpng-1.4.0 */
869
#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */
955
#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */
870
 
956
/* Added to libpng-1.5.4 */
-
 
957
#define PNG_TRANSFORM_EXPAND_16     0x4000      /* read only */
-
 
958
#define PNG_TRANSFORM_SCALE_16      0x8000      /* read only */
-
 
959
 
Line 871... Line 960...
871
/* Flags for MNG supported features */
960
/* Flags for MNG supported features */
872
#define PNG_FLAG_MNG_EMPTY_PLTE     0x01
961
#define PNG_FLAG_MNG_EMPTY_PLTE     0x01
873
#define PNG_FLAG_MNG_FILTER_64      0x04
962
#define PNG_FLAG_MNG_FILTER_64      0x04
874
#define PNG_ALL_MNG_FEATURES        0x05
963
#define PNG_ALL_MNG_FEATURES        0x05
Line 879... Line 968...
879
 * ignores the first argument) should be completely compatible with the
968
 * ignores the first argument) should be completely compatible with the
880
 * following.
969
 * following.
881
 */
970
 */
882
typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, 
971
typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
883
    png_alloc_size_t), );
972
    png_alloc_size_t));
884
typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp), );
973
typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
885
 
974
 
886
typedef png_struct FAR * FAR * png_structpp;
-
 
887
 
-
 
Line 888... Line 975...
888
/* Section 3: exported functions
975
/* Section 3: exported functions
889
 * Here are the function definitions most commonly used.  This is not
976
 * Here are the function definitions most commonly used.  This is not
890
 * the place to find out how to use libpng.  See libpng-manual.txt for the
977
 * the place to find out how to use libpng.  See libpng-manual.txt for the
891
 * full explanation, see example.c for the summary.  This just provides
978
 * full explanation, see example.c for the summary.  This just provides
Line 919... Line 1006...
919
 
1006
 
Line 920... Line 1007...
920
/* Tell lib we have already handled the first  magic bytes.
1007
/* Tell lib we have already handled the first  magic bytes.
921
 * Handling more than 8 bytes from the beginning of the file is an error.
1008
 * Handling more than 8 bytes from the beginning of the file is an error.
922
 */
1009
 */
923
PNG_EXPORT(2, void, png_set_sig_bytes, (png_structp png_ptr, int num_bytes));
1010
PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
Line 924... Line 1011...
924
 
1011
 
925
/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
1012
/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
926
 * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG
1013
 * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG
927
 * signature, and non-zero otherwise.  Having num_to_check == 0 or
1014
 * signature, and non-zero otherwise.  Having num_to_check == 0 or
Line 947... Line 1034...
947
    png_error_ptr warn_fn), 
1034
    png_error_ptr warn_fn),
948
    PNG_ALLOCATED);
1035
    PNG_ALLOCATED);
949
 
1036
 
Line 950... Line 1037...
950
PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,
1037
PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,
951
    (png_const_structp png_ptr));
1038
    (png_const_structrp png_ptr));
Line 952... Line 1039...
952
 
1039
 
953
PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structp png_ptr, 
1040
PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,
Line 954... Line 1041...
954
    png_size_t size));
1041
    png_size_t size));
955
 
1042
 
956
/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
1043
/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
Line 963... Line 1050...
963
 * acceptable.  The size of the jmp_buf is checked against the actual size
1050
 * acceptable.  The size of the jmp_buf is checked against the actual size
964
 * allocated by the library - the call will return NULL on a mismatch
1051
 * allocated by the library - the call will return NULL on a mismatch
965
 * indicating an ABI mismatch.
1052
 * indicating an ABI mismatch.
966
 */
1053
 */
967
PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structp png_ptr, 
1054
PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,
968
    png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));
1055
    png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));
969
#  define png_jmpbuf(png_ptr) \
1056
#  define png_jmpbuf(png_ptr) \
970
      (*png_set_longjmp_fn((png_ptr), longjmp, sizeof (jmp_buf)))
1057
      (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))
971
#else
1058
#else
972
#  define png_jmpbuf(png_ptr) \
1059
#  define png_jmpbuf(png_ptr) \
973
      (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
1060
      (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
974
#endif
1061
#endif
975
/* This function should be used by libpng applications in place of
1062
/* This function should be used by libpng applications in place of
976
 * longjmp(png_ptr->jmpbuf, val).  If longjmp_fn() has been set, it
1063
 * longjmp(png_ptr->jmpbuf, val).  If longjmp_fn() has been set, it
977
 * will use it; otherwise it will call PNG_ABORT().  This function was
1064
 * will use it; otherwise it will call PNG_ABORT().  This function was
978
 * added in libpng-1.5.0.
1065
 * added in libpng-1.5.0.
979
 */
1066
 */
980
PNG_EXPORTA(9, void, png_longjmp, (png_structp png_ptr, int val),
1067
PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),
981
    PNG_NORETURN);
1068
    PNG_NORETURN);
982
 
1069
 
Line 983... Line 1070...
983
#ifdef PNG_READ_SUPPORTED
1070
#ifdef PNG_READ_SUPPORTED
984
/* Reset the compression stream */
1071
/* Reset the compression stream */
985
PNG_EXPORT(10, int, png_reset_zstream, (png_structp png_ptr));
1072
PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);
986
#endif
1073
#endif
Line 987... Line 1074...
987
 
1074
 
988
/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
1075
/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
989
#ifdef PNG_USER_MEM_SUPPORTED
1076
#ifdef PNG_USER_MEM_SUPPORTED
Line 999... Line 1086...
999
    PNG_ALLOCATED);
1086
    PNG_ALLOCATED);
1000
#endif
1087
#endif
1001
 
1088
 
Line 1002... Line 1089...
1002
/* Write the PNG file signature. */
1089
/* Write the PNG file signature. */
1003
PNG_EXPORT(13, void, png_write_sig, (png_structp png_ptr));
1090
PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));
Line 1004... Line 1091...
1004
 
1091
 
1005
/* Write a PNG chunk - size, type, (optional) data, CRC. */
1092
/* Write a PNG chunk - size, type, (optional) data, CRC. */
1006
PNG_EXPORT(14, void, png_write_chunk, (png_structp png_ptr, png_const_bytep
1093
PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep
Line 1007... Line 1094...
1007
    chunk_name, png_const_bytep data, png_size_t length));
1094
    chunk_name, png_const_bytep data, png_size_t length));
1008
 
1095
 
1009
/* Write the start of a PNG chunk - length and chunk name. */
1096
/* Write the start of a PNG chunk - length and chunk name. */
Line 1010... Line 1097...
1010
PNG_EXPORT(15, void, png_write_chunk_start, (png_structp png_ptr, 
1097
PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,
1011
    png_const_bytep chunk_name, png_uint_32 length));
1098
    png_const_bytep chunk_name, png_uint_32 length));
1012
 
1099
 
Line 1013... Line 1100...
1013
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
1100
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
1014
PNG_EXPORT(16, void, png_write_chunk_data, (png_structp png_ptr,
1101
PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,
Line 1015... Line 1102...
1015
    png_const_bytep data, png_size_t length));
1102
    png_const_bytep data, png_size_t length));
1016
 
1103
 
1017
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
1104
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
Line -... Line 1105...
-
 
1105
PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));
-
 
1106
 
-
 
1107
/* Allocate and initialize the info structure */
-
 
1108
PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),
1018
PNG_EXPORT(17, void, png_write_chunk_end, (png_structp png_ptr));
1109
    PNG_ALLOCATED);
1019
 
1110
 
Line 1020... Line 1111...
1020
/* Allocate and initialize the info structure */
1111
/* DEPRECATED: this function allowed init structures to be created using the
1021
PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_structp png_ptr), 
1112
 * default allocation method (typically malloc).  Use is deprecated in 1.6.0 and
1022
    PNG_ALLOCATED);
1113
 * the API will be removed in the future.
1023
 
1114
 */
1024
PNG_EXPORT(19, void, png_info_init_3, (png_infopp info_ptr, 
1115
PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,
Line 1025... Line 1116...
1025
    png_size_t png_info_struct_size));
1116
    png_size_t png_info_struct_size), PNG_DEPRECATED);
1026
 
1117
 
1027
/* Writes all the PNG information before the image. */
1118
/* Writes all the PNG information before the image. */
1028
PNG_EXPORT(20, void, png_write_info_before_PLTE,
1119
PNG_EXPORT(20, void, png_write_info_before_PLTE,
1029
    (png_structp png_ptr, png_infop info_ptr));
1120
    (png_structrp png_ptr, png_const_inforp info_ptr));
Line 1030... Line 1121...
1030
PNG_EXPORT(21, void, png_write_info,
1121
PNG_EXPORT(21, void, png_write_info,
-
 
1122
    (png_structrp png_ptr, png_const_inforp info_ptr));
-
 
1123
 
-
 
1124
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-
 
1125
/* Read the information before the actual image data. */
-
 
1126
PNG_EXPORT(22, void, png_read_info,
-
 
1127
    (png_structrp png_ptr, png_inforp info_ptr));
1031
    (png_structp png_ptr, png_infop info_ptr));
1128
#endif
1032
 
1129
 
-
 
1130
#ifdef PNG_TIME_RFC1123_SUPPORTED
-
 
1131
   /* Convert to a US string format: there is no localization support in this
1033
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1132
    * routine.  The original implementation used a 29 character buffer in
1034
/* Read the information before the actual image data. */
1133
    * png_struct, this will be removed in future versions.
Line 1035... Line 1134...
1035
PNG_EXPORT(22, void, png_read_info,
1134
    */
1036
    (png_structp png_ptr, png_infop info_ptr));
1135
#if PNG_LIBPNG_VER < 10700
1037
#endif
1136
/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */
1038
 
1137
PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
Line 1039... Line 1138...
1039
#ifdef PNG_TIME_RFC1123_SUPPORTED
1138
    png_const_timep ptime),PNG_DEPRECATED);
1040
PNG_EXPORT(23, png_const_charp, png_convert_to_rfc1123,
1139
#endif
1041
    (png_structp png_ptr, 
-
 
1042
    png_const_timep ptime));
1140
PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],
Line 1043... Line 1141...
1043
#endif
1141
    png_const_timep ptime));
1044
 
1142
#endif
1045
#ifdef PNG_CONVERT_tIME_SUPPORTED
1143
 
1046
/* Convert from a struct tm to png_time */
1144
#ifdef PNG_CONVERT_tIME_SUPPORTED
1047
PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, 
1145
/* Convert from a struct tm to png_time */
1048
    PNG_CONST struct tm FAR * ttime));
1146
PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,
-
 
1147
    const struct tm * ttime));
-
 
1148
 
-
 
1149
/* Convert from time_t to png_time.  Uses gmtime() */
-
 
1150
PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));
-
 
1151
#endif /* PNG_CONVERT_tIME_SUPPORTED */
-
 
1152
 
-
 
1153
#ifdef PNG_READ_EXPAND_SUPPORTED
1049
 
1154
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
Line 1050... Line 1155...
1050
/* Convert from time_t to png_time.  Uses gmtime() */
1155
PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr));
1051
PNG_EXPORT(25, void, png_convert_from_time_t,
1156
PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr));
1052
    (png_timep ptime, time_t ttime));
1157
PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr));
1053
#endif /* PNG_CONVERT_tIME_SUPPORTED */
1158
PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr));
Line 1054... Line 1159...
1054
 
1159
#endif
1055
#ifdef PNG_READ_EXPAND_SUPPORTED
1160
 
1056
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
1161
#ifdef PNG_READ_EXPAND_16_SUPPORTED
1057
PNG_EXPORT(26, void, png_set_expand, (png_structp png_ptr));
1162
/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion
Line 1058... Line 1163...
1058
PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structp png_ptr));
1163
 * of a tRNS chunk if present.
1059
PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structp png_ptr));
1164
 */
-
 
1165
PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr));
-
 
1166
#endif
-
 
1167
 
-
 
1168
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-
 
1169
/* Use blue, green, red order for pixels. */
1060
PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structp png_ptr));
1170
PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr));
1061
#endif
1171
#endif
1062
 
1172
 
1063
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
1173
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
Line 1064... Line 1174...
1064
/* Use blue, green, red order for pixels. */
1174
/* Expand the grayscale to 24-bit RGB if necessary. */
1065
PNG_EXPORT(30, void, png_set_bgr, (png_structp png_ptr));
1175
PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr));
1066
#endif
1176
#endif
Line -... Line 1177...
-
 
1177
 
1067
 
1178
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1068
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
1179
/* Reduce RGB to grayscale. */
-
 
1180
#define PNG_ERROR_ACTION_NONE  1
-
 
1181
#define PNG_ERROR_ACTION_WARN  2
-
 
1182
#define PNG_ERROR_ACTION_ERROR 3
-
 
1183
#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/
-
 
1184
 
-
 
1185
PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr,
-
 
1186
    int error_action, double red, double green))
-
 
1187
PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr,
-
 
1188
    int error_action, png_fixed_point red, png_fixed_point green))
-
 
1189
 
-
 
1190
PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp
-
 
1191
    png_ptr));
-
 
1192
#endif
-
 
1193
 
-
 
1194
#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
-
 
1195
PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
-
 
1196
    png_colorp palette));
-
 
1197
#endif
-
 
1198
 
-
 
1199
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
-
 
1200
/* How the alpha channel is interpreted - this affects how the color channels of
-
 
1201
 * a PNG file are returned when an alpha channel, or tRNS chunk in a palette
-
 
1202
 * file, is present.
-
 
1203
 *
-
 
1204
 * This has no effect on the way pixels are written into a PNG output
-
 
1205
 * datastream. The color samples in a PNG datastream are never premultiplied
-
 
1206
 * with the alpha samples.
-
 
1207
 *
-
 
1208
 * The default is to return data according to the PNG specification: the alpha
-
 
1209
 * channel is a linear measure of the contribution of the pixel to the
-
 
1210
 * corresponding composited pixel.  The gamma encoded color channels must be
-
 
1211
 * scaled according to the contribution and to do this it is necessary to undo
-
 
1212
 * the encoding, scale the color values, perform the composition and reencode
-
 
1213
 * the values.  This is the 'PNG' mode.
-
 
1214
 *
-
 
1215
 * The alternative is to 'associate' the alpha with the color information by
-
 
1216
 * storing color channel values that have been scaled by the alpha.  The
-
 
1217
 * advantage is that the color channels can be resampled (the image can be
-
 
1218
 * scaled) in this form.  The disadvantage is that normal practice is to store
-
 
1219
 * linear, not (gamma) encoded, values and this requires 16-bit channels for
-
 
1220
 * still images rather than the 8-bit channels that are just about sufficient if
-
 
1221
 * gamma encoding is used.  In addition all non-transparent pixel values,
-
 
1222
 * including completely opaque ones, must be gamma encoded to produce the final
-
 
1223
 * image.  This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the
-
 
1224
 * latter being the two common names for associated alpha color channels.)
-
 
1225
 *
-
 
1226
 * Since it is not necessary to perform arithmetic on opaque color values so
-
 
1227
 * long as they are not to be resampled and are in the final color space it is
-
 
1228
 * possible to optimize the handling of alpha by storing the opaque pixels in
-
 
1229
 * the PNG format (adjusted for the output color space) while storing partially
-
 
1230
 * opaque pixels in the standard, linear, format.  The accuracy required for
-
 
1231
 * standard alpha composition is relatively low, because the pixels are
-
 
1232
 * isolated, therefore typically the accuracy loss in storing 8-bit linear
-
 
1233
 * values is acceptable.  (This is not true if the alpha channel is used to
-
 
1234
 * simulate transparency over large areas - use 16 bits or the PNG mode in
-
 
1235
 * this case!)  This is the 'OPTIMIZED' mode.  For this mode a pixel is
-
 
1236
 * treated as opaque only if the alpha value is equal to the maximum value.
-
 
1237
 *
-
 
1238
 * The final choice is to gamma encode the alpha channel as well.  This is
-
 
1239
 * broken because, in practice, no implementation that uses this choice
-
 
1240
 * correctly undoes the encoding before handling alpha composition.  Use this
-
 
1241
 * choice only if other serious errors in the software or hardware you use
-
 
1242
 * mandate it; the typical serious error is for dark halos to appear around
-
 
1243
 * opaque areas of the composited PNG image because of arithmetic overflow.
-
 
1244
 *
-
 
1245
 * The API function png_set_alpha_mode specifies which of these choices to use
-
 
1246
 * with an enumerated 'mode' value and the gamma of the required output:
-
 
1247
 */
-
 
1248
#define PNG_ALPHA_PNG           0 /* according to the PNG standard */
-
 
1249
#define PNG_ALPHA_STANDARD      1 /* according to Porter/Duff */
-
 
1250
#define PNG_ALPHA_ASSOCIATED    1 /* as above; this is the normal practice */
-
 
1251
#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */
-
 
1252
#define PNG_ALPHA_OPTIMIZED     2 /* 'PNG' for opaque pixels, else 'STANDARD' */
-
 
1253
#define PNG_ALPHA_BROKEN        3 /* the alpha channel is gamma encoded */
-
 
1254
 
-
 
1255
PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode,
-
 
1256
    double output_gamma))
-
 
1257
PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,
-
 
1258
    int mode, png_fixed_point output_gamma))
-
 
1259
#endif
-
 
1260
 
-
 
1261
#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
-
 
1262
/* The output_gamma value is a screen gamma in libpng terminology: it expresses
-
 
1263
 * how to decode the output values, not how they are encoded.  The values used
-
 
1264
 * correspond to the normal numbers used to describe the overall gamma of a
-
 
1265
 * computer display system; for example 2.2 for an sRGB conformant system.  The
-
 
1266
 * values are scaled by 100000 in the _fixed version of the API (so 220000 for
-
 
1267
 * sRGB.)
-
 
1268
 *
-
 
1269
 * The inverse of the value is always used to provide a default for the PNG file
-
 
1270
 * encoding if it has no gAMA chunk and if png_set_gamma() has not been called
-
 
1271
 * to override the PNG gamma information.
-
 
1272
 *
-
 
1273
 * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode
-
 
1274
 * opaque pixels however pixels with lower alpha values are not encoded,
-
 
1275
 * regardless of the output gamma setting.
-
 
1276
 *
-
 
1277
 * When the standard Porter Duff handling is requested with mode 1 the output
-
 
1278
 * encoding is set to be linear and the output_gamma value is only relevant
-
 
1279
 * as a default for input data that has no gamma information.  The linear output
-
 
1280
 * encoding will be overridden if png_set_gamma() is called - the results may be
-
 
1281
 * highly unexpected!
-
 
1282
 *
-
 
1283
 * The following numbers are derived from the sRGB standard and the research
-
 
1284
 * behind it.  sRGB is defined to be approximated by a PNG gAMA chunk value of
-
 
1285
 * 0.45455 (1/2.2) for PNG.  The value implicitly includes any viewing
-
 
1286
 * correction required to take account of any differences in the color
-
 
1287
 * environment of the original scene and the intended display environment; the
-
 
1288
 * value expresses how to *decode* the image for display, not how the original
-
 
1289
 * data was *encoded*.
-
 
1290
 *
-
 
1291
 * sRGB provides a peg for the PNG standard by defining a viewing environment.
-
 
1292
 * sRGB itself, and earlier TV standards, actually use a more complex transform
-
 
1293
 * (a linear portion then a gamma 2.4 power law) than PNG can express.  (PNG is
-
 
1294
 * limited to simple power laws.)  By saying that an image for direct display on
-
 
1295
 * an sRGB conformant system should be stored with a gAMA chunk value of 45455
-
 
1296
 * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification
-
 
1297
 * makes it possible to derive values for other display systems and
-
 
1298
 * environments.
-
 
1299
 *
-
 
1300
 * The Mac value is deduced from the sRGB based on an assumption that the actual
-
 
1301
 * extra viewing correction used in early Mac display systems was implemented as
-
 
1302
 * a power 1.45 lookup table.
-
 
1303
 *
-
 
1304
 * Any system where a programmable lookup table is used or where the behavior of
-
 
1305
 * the final display device characteristics can be changed requires system
-
 
1306
 * specific code to obtain the current characteristic.  However this can be
-
 
1307
 * difficult and most PNG gamma correction only requires an approximate value.
-
 
1308
 *
-
 
1309
 * By default, if png_set_alpha_mode() is not called, libpng assumes that all
-
 
1310
 * values are unencoded, linear, values and that the output device also has a
-
 
1311
 * linear characteristic.  This is only very rarely correct - it is invariably
-
 
1312
 * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the
-
 
1313
 * default if you don't know what the right answer is!
-
 
1314
 *
-
 
1315
 * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS
-
 
1316
 * 10.6) which used a correction table to implement a somewhat lower gamma on an
-
 
1317
 * otherwise sRGB system.
-
 
1318
 *
-
 
1319
 * Both these values are reserved (not simple gamma values) in order to allow
-
 
1320
 * more precise correction internally in the future.
-
 
1321
 *
-
 
1322
 * NOTE: the following values can be passed to either the fixed or floating
-
 
1323
 * point APIs, but the floating point API will also accept floating point
-
 
1324
 * values.
-
 
1325
 */
-
 
1326
#define PNG_DEFAULT_sRGB -1       /* sRGB gamma and color space */
-
 
1327
#define PNG_GAMMA_MAC_18 -2       /* Old Mac '1.8' gamma and color space */
-
 
1328
#define PNG_GAMMA_sRGB   220000   /* Television standards--matches sRGB gamma */
-
 
1329
#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */
-
 
1330
#endif
-
 
1331
 
-
 
1332
/* The following are examples of calls to png_set_alpha_mode to achieve the
-
 
1333
 * required overall gamma correction and, where necessary, alpha
-
 
1334
 * premultiplication.
-
 
1335
 *
-
 
1336
 * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
-
 
1337
 *    This is the default libpng handling of the alpha channel - it is not
-
 
1338
 *    pre-multiplied into the color components.  In addition the call states
-
 
1339
 *    that the output is for a sRGB system and causes all PNG files without gAMA
-
 
1340
 *    chunks to be assumed to be encoded using sRGB.
-
 
1341
 *
-
 
1342
 * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
-
 
1343
 *    In this case the output is assumed to be something like an sRGB conformant
-
 
1344
 *    display preceeded by a power-law lookup table of power 1.45.  This is how
-
 
1345
 *    early Mac systems behaved.
-
 
1346
 *
-
 
1347
 * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);
-
 
1348
 *    This is the classic Jim Blinn approach and will work in academic
-
 
1349
 *    environments where everything is done by the book.  It has the shortcoming
-
 
1350
 *    of assuming that input PNG data with no gamma information is linear - this
-
 
1351
 *    is unlikely to be correct unless the PNG files where generated locally.
-
 
1352
 *    Most of the time the output precision will be so low as to show
-
 
1353
 *    significant banding in dark areas of the image.
-
 
1354
 *
-
 
1355
 * png_set_expand_16(pp);
-
 
1356
 * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);
-
 
1357
 *    This is a somewhat more realistic Jim Blinn inspired approach.  PNG files
-
 
1358
 *    are assumed to have the sRGB encoding if not marked with a gamma value and
-
 
1359
 *    the output is always 16 bits per component.  This permits accurate scaling
-
 
1360
 *    and processing of the data.  If you know that your input PNG files were
-
 
1361
 *    generated locally you might need to replace PNG_DEFAULT_sRGB with the
-
 
1362
 *    correct value for your system.
-
 
1363
 *
-
 
1364
 * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);
-
 
1365
 *    If you just need to composite the PNG image onto an existing background
-
 
1366
 *    and if you control the code that does this you can use the optimization
-
 
1367
 *    setting.  In this case you just copy completely opaque pixels to the
-
 
1368
 *    output.  For pixels that are not completely transparent (you just skip
-
 
1369
 *    those) you do the composition math using png_composite or png_composite_16
-
 
1370
 *    below then encode the resultant 8-bit or 16-bit values to match the output
-
 
1371
 *    encoding.
-
 
1372
 *
-
 
1373
 * Other cases
-
 
1374
 *    If neither the PNG nor the standard linear encoding work for you because
-
 
1375
 *    of the software or hardware you use then you have a big problem.  The PNG
-
 
1376
 *    case will probably result in halos around the image.  The linear encoding
-
 
1377
 *    will probably result in a washed out, too bright, image (it's actually too
-
 
1378
 *    contrasty.)  Try the ALPHA_OPTIMIZED mode above - this will probably
-
 
1379
 *    substantially reduce the halos.  Alternatively try:
-
 
1380
 *
-
 
1381
 * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);
-
 
1382
 *    This option will also reduce the halos, but there will be slight dark
-
 
1383
 *    halos round the opaque parts of the image where the background is light.
-
 
1384
 *    In the OPTIMIZED mode the halos will be light halos where the background
-
 
1385
 *    is dark.  Take your pick - the halos are unavoidable unless you can get
-
 
1386
 *    your hardware/software fixed!  (The OPTIMIZED approach is slightly
-
 
1387
 *    faster.)
-
 
1388
 *
-
 
1389
 * When the default gamma of PNG files doesn't match the output gamma.
Line 1069... Line 1390...
1069
/* Expand the grayscale to 24-bit RGB if necessary. */
1390
 *    If you have PNG files with no gamma information png_set_alpha_mode allows
1070
PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr));
1391
 *    you to provide a default gamma, but it also sets the ouput gamma to the
1071
#endif
1392
 *    matching value.  If you know your PNG files have a gamma that doesn't
Line 1072... Line 1393...
1072
 
1393
 *    match the output you can take advantage of the fact that
1073
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1394
 *    png_set_alpha_mode always sets the output gamma but only sets the PNG
1074
/* Reduce RGB to grayscale. */
1395
 *    default if it is not already set:
1075
PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr,
1396
 *
Line 1076... Line 1397...
1076
    int error_action, double red, double green));
1397
 * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
1077
PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structp png_ptr, 
1398
 * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
1078
    int error_action, png_fixed_point red, png_fixed_point green));
1399
 *    The first call sets both the default and the output gamma values, the
1079
 
1400
 *    second call overrides the output gamma without changing the default.  This
Line 1080... Line 1401...
1080
PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp
1401
 *    is easier than achieving the same effect with png_set_gamma.  You must use
1081
    png_ptr));
1402
 *    PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will
1082
#endif
1403
 *    fire if more than one call to png_set_alpha_mode and png_set_background is
1083
 
1404
 *    made in the same read operation, however multiple calls with PNG_ALPHA_PNG
1084
PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, 
1405
 *    are ignored.
1085
    png_colorp palette));
1406
 */
1086
 
1407
 
1087
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
1408
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
1088
PNG_EXPORT(36, void, png_set_strip_alpha, (png_structp png_ptr));
1409
PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr));
1089
#endif
1410
#endif
1090
 
-
 
1091
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
1411
 
Line 1092... Line 1412...
1092
    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
1412
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
1093
PNG_EXPORT(37, void, png_set_swap_alpha, (png_structp png_ptr));
1413
    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
1094
#endif
1414
PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr));
1095
 
1415
#endif
Line 1096... Line 1416...
1096
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
1416
 
1097
    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
1417
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
1098
PNG_EXPORT(38, void, png_set_invert_alpha, (png_structp png_ptr));
1418
    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
1099
#endif
1419
PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));
Line 1100... Line 1420...
1100
 
1420
#endif
1101
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
1421
 
1102
/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
1422
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
1103
PNG_EXPORT(39, void, png_set_filler, (png_structp png_ptr, png_uint_32 filler, 
1423
/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
1104
    int flags));
1424
PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,
Line 1105... Line 1425...
1105
/* The values of the PNG_FILLER_ defines should NOT be changed */
1425
    int flags));
1106
#  define PNG_FILLER_BEFORE 0
1426
/* The values of the PNG_FILLER_ defines should NOT be changed */
1107
#  define PNG_FILLER_AFTER 1
1427
#  define PNG_FILLER_BEFORE 0
1108
/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
1428
#  define PNG_FILLER_AFTER 1
1109
PNG_EXPORT(40, void, png_set_add_alpha,
1429
/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
Line 1110... Line 1430...
1110
    (png_structp png_ptr, png_uint_32 filler, 
1430
PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,
1111
    int flags));
1431
    png_uint_32 filler, int flags));
Line 1140... Line 1460...
1140
 * otherwise it will not have the desired effect.  Note that it is still
1460
 * otherwise it will not have the desired effect.  Note that it is still
1141
 * necessary to call png_read_row or png_read_rows png_get_image_height
1461
 * necessary to call png_read_row or png_read_rows png_get_image_height
1142
 * times for each pass.
1462
 * times for each pass.
1143
*/
1463
*/
1144
PNG_EXPORT(45, int, png_set_interlace_handling, (png_structp png_ptr));
1464
PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr));
1145
#endif
1465
#endif
1146
 
1466
 
Line 1147... Line 1467...
1147
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
1467
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
1148
/* Invert monochrome files */
1468
/* Invert monochrome files */
1149
PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr));
1469
PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr));
1150
#endif
1470
#endif
Line 1151... Line 1471...
1151
 
1471
 
1152
#ifdef PNG_READ_BACKGROUND_SUPPORTED
1472
#ifdef PNG_READ_BACKGROUND_SUPPORTED
-
 
1473
/* Handle alpha and tRNS by replacing with a background color.  Prior to
-
 
1474
 * libpng-1.5.4 this API must not be called before the PNG file header has been
-
 
1475
 * read.  Doing so will result in unexpected behavior and possible warnings or
-
 
1476
 * errors if the PNG file contains a bKGD chunk.
1153
/* Handle alpha and tRNS by replacing with a background color. */
1477
 */
1154
PNG_FP_EXPORT(47, void, png_set_background, (png_structp png_ptr, 
1478
PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,
1155
    png_const_color_16p background_color, int background_gamma_code, 
1479
    png_const_color_16p background_color, int background_gamma_code,
1156
    int need_expand, double background_gamma));
1480
    int need_expand, double background_gamma))
1157
PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr,
1481
PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,
1158
    png_const_color_16p background_color, int background_gamma_code, 
1482
    png_const_color_16p background_color, int background_gamma_code,
1159
    int need_expand, png_fixed_point background_gamma));
1483
    int need_expand, png_fixed_point background_gamma))
1160
#endif
1484
#endif
1161
#ifdef PNG_READ_BACKGROUND_SUPPORTED
1485
#ifdef PNG_READ_BACKGROUND_SUPPORTED
1162
#  define PNG_BACKGROUND_GAMMA_UNKNOWN 0
1486
#  define PNG_BACKGROUND_GAMMA_UNKNOWN 0
1163
#  define PNG_BACKGROUND_GAMMA_SCREEN  1
1487
#  define PNG_BACKGROUND_GAMMA_SCREEN  1
1164
#  define PNG_BACKGROUND_GAMMA_FILE    2
1488
#  define PNG_BACKGROUND_GAMMA_FILE    2
1165
#  define PNG_BACKGROUND_GAMMA_UNIQUE  3
1489
#  define PNG_BACKGROUND_GAMMA_UNIQUE  3
Line 1166... Line 1490...
1166
#endif
1490
#endif
-
 
1491
 
-
 
1492
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
-
 
1493
/* Scale a 16-bit depth file down to 8-bit, accurately. */
-
 
1494
PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));
-
 
1495
#endif
-
 
1496
 
1167
 
1497
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
1168
#ifdef PNG_READ_16_TO_8_SUPPORTED
1498
#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
1169
/* Strip the second byte of information from a 16-bit depth file. */
1499
/* Strip the second byte of information from a 16-bit depth file. */
Line 1170... Line 1500...
1170
PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr));
1500
PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
1171
#endif
1501
#endif
1172
 
1502
 
1173
#ifdef PNG_READ_QUANTIZE_SUPPORTED
1503
#ifdef PNG_READ_QUANTIZE_SUPPORTED
1174
/* Turn on quantizing, and reduce the palette to the number of colors
1504
/* Turn on quantizing, and reduce the palette to the number of colors
1175
 * available.
-
 
1176
 */
1505
 * available.
1177
PNG_EXPORT(49, void, png_set_quantize,
1506
 */
1178
    (png_structp png_ptr, png_colorp palette, 
1507
PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,
Line 1179... Line 1508...
1179
    int num_palette, int maximum_colors, png_const_uint_16p histogram, 
1508
    png_colorp palette, int num_palette, int maximum_colors,
1180
    int full_quantize));
1509
    png_const_uint_16p histogram, int full_quantize));
1181
#endif
1510
#endif
1182
 
1511
 
1183
#ifdef PNG_READ_GAMMA_SUPPORTED
1512
#ifdef PNG_READ_GAMMA_SUPPORTED
Line 1184... Line 1513...
1184
/* The threshold on gamma processing is configurable but hard-wired into the
1513
/* The threshold on gamma processing is configurable but hard-wired into the
-
 
1514
 * library.  The following is the floating point variant.
-
 
1515
 */
-
 
1516
#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)
-
 
1517
 
-
 
1518
/* Handle gamma correction. Screen_gamma=(display_exponent).
-
 
1519
 * NOTE: this API simply sets the screen and file gamma values. It will
-
 
1520
 * therefore override the value for gamma in a PNG file if it is called after
-
 
1521
 * the file header has been read - use with care  - call before reading the PNG
1185
 * library.  The following is the floating point variant.
1522
 * file for best results!
-
 
1523
 *
1186
 */
1524
 * These routines accept the same gamma values as png_set_alpha_mode (described
1187
#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)
1525
 * above).  The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either
1188
 
1526
 * API (floating point or fixed.)  Notice, however, that the 'file_gamma' value
1189
/* Handle gamma correction. Screen_gamma=(display_exponent) */
1527
 * is the inverse of a 'screen gamma' value.
1190
PNG_FP_EXPORT(50, void, png_set_gamma,
1528
 */
Line 1191... Line 1529...
1191
    (png_structp png_ptr, double screen_gamma, 
1529
PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr,
1192
    double default_file_gamma));
1530
    double screen_gamma, double override_file_gamma))
1193
PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structp png_ptr, 
1531
PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr,
1194
    png_fixed_point screen_gamma, png_fixed_point default_file_gamma));
1532
    png_fixed_point screen_gamma, png_fixed_point override_file_gamma))
1195
#endif
1533
#endif
1196
 
1534
 
Line 1197... Line 1535...
1197
#ifdef PNG_WRITE_FLUSH_SUPPORTED
1535
#ifdef PNG_WRITE_FLUSH_SUPPORTED
1198
/* Set how many lines between output flushes - 0 for no flushing */
1536
/* Set how many lines between output flushes - 0 for no flushing */
Line 1199... Line 1537...
1199
PNG_EXPORT(51, void, png_set_flush, (png_structp png_ptr, int nrows));
1537
PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows));
1200
/* Flush the current PNG output buffer */
1538
/* Flush the current PNG output buffer */
1201
PNG_EXPORT(52, void, png_write_flush, (png_structp png_ptr));
1539
PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr));
Line 1202... Line 1540...
1202
#endif
1540
#endif
1203
 
1541
 
1204
/* Optional update palette with requested transformations */
1542
/* Optional update palette with requested transformations */
1205
PNG_EXPORT(53, void, png_start_read_image, (png_structp png_ptr));
1543
PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr));
1206
 
1544
 
Line 1207... Line 1545...
1207
/* Optional call to update the users info structure */
1545
/* Optional call to update the users info structure */
1208
PNG_EXPORT(54, void, png_read_update_info,
1546
PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr,
1209
    (png_structp png_ptr, png_infop info_ptr));
1547
    png_inforp info_ptr));
1210
 
1548
 
1211
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1549
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
Line 1212... Line 1550...
1212
/* Read one or more rows of image data. */
1550
/* Read one or more rows of image data. */
1213
PNG_EXPORT(55, void, png_read_rows, (png_structp png_ptr, png_bytepp row, 
1551
PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row,
1214
    png_bytepp display_row, png_uint_32 num_rows));
1552
    png_bytepp display_row, png_uint_32 num_rows));
1215
#endif
1553
#endif
Line 1216... Line 1554...
1216
 
1554
 
1217
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1555
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1218
/* Read a row of data. */
1556
/* Read a row of data. */
Line 1219... Line 1557...
1219
PNG_EXPORT(56, void, png_read_row, (png_structp png_ptr, png_bytep row, 
1557
PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row,
1220
    png_bytep display_row));
1558
    png_bytep display_row));
1221
#endif
1559
#endif
1222
 
1560
 
1223
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1561
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
1224
/* Read the whole image into memory at once. */
1562
/* Read the whole image into memory at once. */
1225
PNG_EXPORT(57, void, png_read_image, (png_structp png_ptr, png_bytepp image));
1563
PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image));
Line 1226... Line 1564...
1226
#endif
1564
#endif
1227
 
-
 
1228
/* Write a row of image data */
1565
 
Line 1229... Line 1566...
1229
PNG_EXPORT(58, void, png_write_row,
1566
/* Write a row of image data */
1230
    (png_structp png_ptr, png_const_bytep row));
1567
PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr,
1231
 
1568
    png_const_bytep row));
Line 1232... Line 1569...
1232
/* Write a few rows of image data: (*row) is not written; however, the type
1569
 
1233
 * is declared as writeable to maintain compatibility with previous versions
1570
/* Write a few rows of image data: (*row) is not written; however, the type
1234
 * of libpng and to allow the 'display_row' array from read_rows to be passed
1571
 * is declared as writeable to maintain compatibility with previous versions
1235
 * unchanged to write_rows.
1572
 * of libpng and to allow the 'display_row' array from read_rows to be passed
Line 1236... Line 1573...
1236
 */
1573
 * unchanged to write_rows.
1237
PNG_EXPORT(59, void, png_write_rows, (png_structp png_ptr, png_bytepp row, 
1574
 */
1238
    png_uint_32 num_rows));
1575
PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row,
Line 1239... Line 1576...
1239
 
1576
    png_uint_32 num_rows));
1240
/* Write the image data */
1577
 
1241
PNG_EXPORT(60, void, png_write_image,
1578
/* Write the image data */
Line 1262... Line 1599...
1262
PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, 
1599
PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,
1263
    png_infopp info_ptr_ptr));
1600
    png_infopp info_ptr_ptr));
1264
 
1601
 
Line 1265... Line 1602...
1265
/* Set the libpng method of handling chunk CRC errors */
1602
/* Set the libpng method of handling chunk CRC errors */
1266
PNG_EXPORT(66, void, png_set_crc_action,
1603
PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
1267
    (png_structp png_ptr, int crit_action, int ancil_action));
1604
    int ancil_action));
Line 1268... Line 1605...
1268
 
1605
 
1269
/* Values for png_set_crc_action() say how to handle CRC errors in
1606
/* Values for png_set_crc_action() say how to handle CRC errors in
1270
 * ancillary and critical chunks, and whether to use the data contained
1607
 * ancillary and critical chunks, and whether to use the data contained
1271
 * therein.  Note that it is impossible to "discard" data in a critical
1608
 * therein.  Note that it is impossible to "discard" data in a critical
Line 1292... Line 1629...
1292
 
1629
 
Line 1293... Line 1630...
1293
/* Set the filtering method(s) used by libpng.  Currently, the only valid
1630
/* Set the filtering method(s) used by libpng.  Currently, the only valid
1294
 * value for "method" is 0.
1631
 * value for "method" is 0.
1295
 */
1632
 */
1296
PNG_EXPORT(67, void, png_set_filter,
1633
PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
1297
    (png_structp png_ptr, int method, int filters));
1634
    int filters));
Line 1298... Line 1635...
1298
 
1635
 
1299
/* Flags for png_set_filter() to say which filters to use.  The flags
1636
/* Flags for png_set_filter() to say which filters to use.  The flags
1300
 * are chosen so that they don't conflict with real filter types
1637
 * are chosen so that they don't conflict with real filter types
1301
 * below, in case they are supplied instead of the #defined constants.
1638
 * below, in case they are supplied instead of the #defined constants.
Line 1348... Line 1685...
1348
 * change if good general weighting/cost heuristics can be found.  If both
1685
 * change if good general weighting/cost heuristics can be found.  If both
1349
 * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
1686
 * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
1350
 * to the UNWEIGHTED method, but with added encoding time/computation.
1687
 * to the UNWEIGHTED method, but with added encoding time/computation.
1351
 */
1688
 */
1352
PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structp png_ptr, 
1689
PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
1353
    int heuristic_method, int num_weights, png_const_doublep filter_weights, 
1690
    int heuristic_method, int num_weights, png_const_doublep filter_weights,
1354
    png_const_doublep filter_costs));
1691
    png_const_doublep filter_costs))
1355
PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
1692
PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
1356
    (png_structp png_ptr, 
1693
    (png_structrp png_ptr, int heuristic_method, int num_weights,
1357
    int heuristic_method, int num_weights, png_const_fixed_point_p
1694
    png_const_fixed_point_p filter_weights,
1358
    filter_weights, png_const_fixed_point_p filter_costs));
1695
    png_const_fixed_point_p filter_costs))
1359
#endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
1696
#endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
1360
 
1697
 
Line 1361... Line 1698...
1361
/* Heuristic used for row filter selection.  These defines should NOT be
1698
/* Heuristic used for row filter selection.  These defines should NOT be
1362
 * changed.
1699
 * changed.
1363
 */
1700
 */
1364
#define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently "UNWEIGHTED" */
1701
#define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently "UNWEIGHTED" */
1365
#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */
1702
#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */
1366
#define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */
1703
#define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */
1367
#define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */
1704
#define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */
Line -... Line 1705...
-
 
1705
 
1368
 
1706
#ifdef PNG_WRITE_SUPPORTED
1369
/* Set the library compression level.  Currently, valid values range from
1707
/* Set the library compression level.  Currently, valid values range from
1370
 * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
1708
 * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
1371
 * (0 - no compression, 9 - "maximal" compression).  Note that tests have
1709
 * (0 - no compression, 9 - "maximal" compression).  Note that tests have
1372
 * shown that zlib compression levels 3-6 usually perform as well as level 9
1710
 * shown that zlib compression levels 3-6 usually perform as well as level 9
1373
 * for PNG images, and do considerably fewer caclulations.  In the future, 
1711
 * for PNG images, and do considerably fewer caclulations.  In the future,
1374
 * these values may not correspond directly to the zlib compression levels.
1712
 * these values may not correspond directly to the zlib compression levels.
1375
 */
1713
 */
1376
PNG_EXPORT(69, void, png_set_compression_level,
1714
PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,
Line 1377... Line 1715...
1377
    (png_structp png_ptr, int level));
1715
    int level));
1378
 
1716
 
Line 1379... Line 1717...
1379
PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structp png_ptr, 
1717
PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr,
1380
    int mem_level));
1718
    int mem_level));
Line -... Line 1719...
-
 
1719
 
-
 
1720
PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr,
-
 
1721
    int strategy));
1381
 
1722
 
1382
PNG_EXPORT(71, void, png_set_compression_strategy, (png_structp png_ptr, 
1723
/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
Line 1383... Line 1724...
1383
    int strategy));
1724
 * smaller value of window_bits if it can do so safely.
-
 
1725
 */
-
 
1726
PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,
-
 
1727
    int window_bits));
-
 
1728
 
-
 
1729
PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,
-
 
1730
    int method));
-
 
1731
#endif
-
 
1732
 
-
 
1733
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
-
 
1734
/* Also set zlib parameters for compressing non-IDAT chunks */
-
 
1735
PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr,
-
 
1736
    int level));
-
 
1737
 
-
 
1738
PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr,
-
 
1739
    int mem_level));
-
 
1740
 
-
 
1741
PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr,
-
 
1742
    int strategy));
-
 
1743
 
-
 
1744
/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
-
 
1745
 * smaller value of window_bits if it can do so safely.
1384
 
1746
 */
-
 
1747
PNG_EXPORT(225, void, png_set_text_compression_window_bits,
Line 1385... Line 1748...
1385
PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structp png_ptr, 
1748
    (png_structrp png_ptr, int window_bits));
1386
    int window_bits));
1749
 
1387
 
1750
PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
1388
PNG_EXPORT(73, void, png_set_compression_method, (png_structp png_ptr,
1751
    int method));
Line 1398... Line 1761...
1398
 */
1761
 */
1399
 
1762
 
Line 1400... Line 1763...
1400
#ifdef PNG_STDIO_SUPPORTED
1763
#ifdef PNG_STDIO_SUPPORTED
1401
/* Initialize the input/output for the PNG file to the default functions. */
1764
/* Initialize the input/output for the PNG file to the default functions. */
1402
PNG_EXPORT(74, void, png_init_io, (png_structp png_ptr, png_FILE_p fp));
1765
PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));
1403
#endif
1766
#endif
Line 1404... Line 1767...
1404
 
1767
 
1405
/* Replace the (error and abort), and warning functions with user
1768
/* Replace the (error and abort), and warning functions with user
1406
 * supplied functions.  If no messages are to be printed you must still
1769
 * supplied functions.  If no messages are to be printed you must still
1407
 * write and use replacement functions. The replacement error_fn should
1770
 * write and use replacement functions. The replacement error_fn should
1408
 * still do a longjmp to the last setjmp location if you are using this
1771
 * still do a longjmp to the last setjmp location if you are using this
1409
 * method of error handling.  If error_fn or warning_fn is NULL, the
1772
 * method of error handling.  If error_fn or warning_fn is NULL, the
1410
 * default function will be used.
1773
 * default function will be used.
Line 1411... Line 1774...
1411
 */
1774
 */
1412
 
-
 
1413
PNG_EXPORT(75, void, png_set_error_fn,
1775
 
Line 1414... Line 1776...
1414
    (png_structp png_ptr, png_voidp error_ptr, 
1776
PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr,
1415
    png_error_ptr error_fn, png_error_ptr warning_fn));
1777
    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
Line 1416... Line 1778...
1416
 
1778
 
1417
/* Return the user pointer associated with the error functions */
1779
/* Return the user pointer associated with the error functions */
1418
PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structp png_ptr));
1780
PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr));
1419
 
1781
 
Line 1426... Line 1788...
1426
 * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
1788
 * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
1427
 * default flush function, which uses the standard *FILE structure, will
1789
 * default flush function, which uses the standard *FILE structure, will
1428
 * be used.
1790
 * be used.
1429
 */
1791
 */
1430
PNG_EXPORT(77, void, png_set_write_fn, (png_structp png_ptr, png_voidp io_ptr, 
1792
PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr,
1431
    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
1793
    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
1432
 
1794
 
Line 1433... Line 1795...
1433
/* Replace the default data input function with a user supplied one. */
1795
/* Replace the default data input function with a user supplied one. */
1434
PNG_EXPORT(78, void, png_set_read_fn, (png_structp png_ptr, png_voidp io_ptr, 
1796
PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr,
1435
    png_rw_ptr read_data_fn));
1797
    png_rw_ptr read_data_fn));
Line 1436... Line 1798...
1436
 
1798
 
1437
/* Return the user pointer associated with the I/O functions */
1799
/* Return the user pointer associated with the I/O functions */
Line 1438... Line 1800...
1438
PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_structp png_ptr));
1800
PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr));
1439
 
1801
 
Line 1440... Line 1802...
1440
PNG_EXPORT(80, void, png_set_read_status_fn, (png_structp png_ptr, 
1802
PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr,
1441
    png_read_status_ptr read_row_fn));
1803
    png_read_status_ptr read_row_fn));
Line 1442... Line 1804...
1442
 
1804
 
1443
PNG_EXPORT(81, void, png_set_write_status_fn, (png_structp png_ptr, 
1805
PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr,
1444
    png_write_status_ptr write_row_fn));
1806
    png_write_status_ptr write_row_fn));
1445
 
1807
 
1446
#ifdef PNG_USER_MEM_SUPPORTED
1808
#ifdef PNG_USER_MEM_SUPPORTED
1447
/* Replace the default memory allocation functions with user supplied one(s). */
1809
/* Replace the default memory allocation functions with user supplied one(s). */
1448
PNG_EXPORT(82, void, png_set_mem_fn, (png_structp png_ptr, png_voidp mem_ptr, 
1810
PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr,
Line 1449... Line 1811...
1449
    png_malloc_ptr malloc_fn, png_free_ptr free_fn));
1811
    png_malloc_ptr malloc_fn, png_free_ptr free_fn));
1450
/* Return the user pointer associated with the memory functions */
1812
/* Return the user pointer associated with the memory functions */
1451
PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structp png_ptr));
1813
PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr));
1452
#endif
1814
#endif
Line 1453... Line 1815...
1453
 
1815
 
1454
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
1816
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
1455
PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structp png_ptr, 
1817
PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr,
1456
    png_user_transform_ptr read_user_transform_fn));
1818
    png_user_transform_ptr read_user_transform_fn));
Line 1457... Line 1819...
1457
#endif
1819
#endif
1458
 
1820
 
1459
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
1821
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
1460
PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structp png_ptr, 
1822
PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr,
1461
    png_user_transform_ptr write_user_transform_fn));
1823
    png_user_transform_ptr write_user_transform_fn));
1462
#endif
1824
#endif
1463
 
1825
 
1464
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
1826
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
Line 1465... Line 1827...
1465
PNG_EXPORT(86, void, png_set_user_transform_info, (png_structp png_ptr, 
1827
PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr,
1466
    png_voidp user_transform_ptr, int user_transform_depth, 
1828
    png_voidp user_transform_ptr, int user_transform_depth,
1467
    int user_transform_channels));
1829
    int user_transform_channels));
1468
/* Return the user pointer associated with the user transform functions */
1830
/* Return the user pointer associated with the user transform functions */
1469
PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
1831
PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
1470
    (png_const_structp png_ptr));
1832
    (png_const_structrp png_ptr));
1471
#endif
1833
#endif
-
 
1834
 
-
 
1835
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
-
 
1836
/* Return information about the row currently being processed.  Note that these
-
 
1837
 * APIs do not fail but will return unexpected results if called outside a user
1472
 
1838
 * transform callback.  Also note that when transforming an interlaced image the
1473
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
1839
 * row number is the row number within the sub-image of the interlace pass, so
1474
/* Return information about the row currently being processed.  Note that these
1840
 * the value will increase to the height of the sub-image (not the full image)
1475
 * APIs do not fail but will return unexpected results if called outside a user
1841
 * then reset to 0 for the next pass.
Line 1476... Line 1842...
1476
 * transform callback.  Also note that when transforming an interlaced image the
1842
 *
-
 
1843
 * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
-
 
1844
 * find the output pixel (x,y) given an interlaced sub-image pixel
-
 
1845
 * (row,col,pass).  (See below for these macros.)
-
 
1846
 */
-
 
1847
PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp));
-
 
1848
PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
-
 
1849
#endif
-
 
1850
 
-
 
1851
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
-
 
1852
/* This callback is called only for *unknown* chunks.  If
-
 
1853
 * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known
-
 
1854
 * chunks to be treated as unknown, however in this case the callback must do
-
 
1855
 * any processing required by the chunk (e.g. by calling the appropriate
-
 
1856
 * png_set_ APIs.)
-
 
1857
 *
-
 
1858
 * There is no write support - on write, by default, all the chunks in the
-
 
1859
 * 'unknown' list are written in the specified position.
-
 
1860
 *
-
 
1861
 * The integer return from the callback function is interpreted thus:
1477
 * row number is still the row in the final, de-interlaced, image but the row
1862
 *
1478
 * only contains the data of the current pass - consult png_row_info for the
1863
 * negative: An error occured, png_chunk_error will be called.
-
 
1864
 *     zero: The chunk was not handled, the chunk will be saved. A critical
-
 
1865
 *           chunk will cause an error at this point unless it is to be saved.
-
 
1866
 * positive: The chunk was handled, libpng will ignore/discard it.
1479
 * actual width of the row!
1867
 *
1480
 */
1868
 * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about
Line 1481... Line 1869...
1481
PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structp));
1869
 * how this behavior will change in libpng 1.7
1482
PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structp));
1870
 */
1483
#endif
1871
PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,
1484
 
1872
    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
1485
#ifdef PNG_USER_CHUNKS_SUPPORTED
1873
#endif
1486
PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structp png_ptr, 
1874
 
1487
    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
1875
#ifdef PNG_USER_CHUNKS_SUPPORTED
Line 1488... Line 1876...
1488
PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structp png_ptr));
1876
PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr));
1489
#endif
1877
#endif
-
 
1878
 
Line 1490... Line 1879...
1490
 
1879
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
1491
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
1880
/* Sets the function callbacks for the push reader, and a pointer to a
1492
/* Sets the function callbacks for the push reader, and a pointer to a
-
 
1493
 * user-defined structure available to the callback functions.
1881
 * user-defined structure available to the callback functions.
Line 1494... Line 1882...
1494
 */
1882
 */
1495
PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structp png_ptr, 
1883
PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr,
1496
    png_voidp progressive_ptr, png_progressive_info_ptr info_fn, 
1884
    png_voidp progressive_ptr, png_progressive_info_ptr info_fn,
1497
    png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));
1885
    png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));
1498
 
1886
 
1499
/* Returns the user pointer associated with the push read functions */
1887
/* Returns the user pointer associated with the push read functions */
1500
PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structp png_ptr));
1888
PNG_EXPORT(91, png_voidp, png_get_progressive_ptr,
1501
 
1889
    (png_const_structrp png_ptr));
Line 1502... Line 1890...
1502
/* Function to be called when data becomes available */
1890
 
1503
PNG_EXPORT(92, void, png_process_data,
1891
/* Function to be called when data becomes available */
1504
    (png_structp png_ptr, png_infop info_ptr, 
1892
PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,
1505
    png_bytep buffer, png_size_t buffer_size));
1893
    png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size));
1506
 
1894
 
1507
/* A function which may be called *only* within png_process_data to stop the
1895
/* A function which may be called *only* within png_process_data to stop the
1508
 * processing of any more data.  The function returns the number of bytes
1896
 * processing of any more data.  The function returns the number of bytes
Line -... Line 1897...
-
 
1897
 * remaining, excluding any that libpng has cached internally.  A subsequent
1509
 * remaining, excluding any that libpng has cached internally.  A subsequent
1898
 * call to png_process_data must supply these bytes again.  If the argument
1510
 * call to png_process_data must supply these bytes again.  If the argument
1899
 * 'save' is set to true the routine will first save all the pending data and
1511
 * 'save' is set to true the routine will first save all the pending data and
1900
 * will always return 0.
1512
 * will always return 0.
1901
 */
1513
 */
1902
PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save));
1514
PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save));
1903
 
1515
 
1904
/* A function which may be called *only* outside (after) a call to
-
 
1905
 * png_process_data.  It returns the number of bytes of data to skip in the
1516
/* A function which may be called *only* outside (after) a call to
1906
 * input.  Normally it will return 0, but if it returns a non-zero value the
Line 1517... Line 1907...
1517
 * png_process_data.  It returns the number of bytes of data to skip in the
1907
 * application must skip than number of bytes of input data and pass the
1518
 * input.  Normally it will return 0, but if it returns a non-zero value the
-
 
1519
 * application must skip than number of bytes of input data and pass the
1908
 * following data to the next call to png_process_data.
1520
 * following data to the next call to png_process_data.
1909
 */
1521
 */
1910
PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));
1522
PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp));
-
 
1523
 
1911
 
Line 1524... Line 1912...
1524
/* Function that combines rows.  'new_row' is a flag that should come from
1912
#ifdef PNG_READ_INTERLACING_SUPPORTED
1525
 * the callback and be non-NULL if anything needs to be done; the library
1913
/* Function that combines rows.  'new_row' is a flag that should come from
1526
 * stores its own version of the new data internally and ignores the passed
1914
 * the callback and be non-NULL if anything needs to be done; the library
Line 1527... Line 1915...
1527
 * in value.
1915
 * stores its own version of the new data internally and ignores the passed
1528
 */
1916
 * in value.
Line 1529... Line 1917...
1529
PNG_EXPORT(93, void, png_progressive_combine_row, (png_structp png_ptr, 
1917
 */
1530
    png_bytep old_row, png_const_bytep new_row));
1918
PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,
1531
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
1919
    png_bytep old_row, png_const_bytep new_row));
Line 1532... Line 1920...
1532
 
1920
#endif /* PNG_READ_INTERLACING_SUPPORTED */
1533
PNG_EXPORTA(94, png_voidp, png_malloc,
1921
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
-
 
1922
 
-
 
1923
PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,
-
 
1924
    png_alloc_size_t size), PNG_ALLOCATED);
-
 
1925
/* Added at libpng version 1.4.0 */
-
 
1926
PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr,
1534
    (png_structp png_ptr, png_alloc_size_t size), 
1927
    png_alloc_size_t size), PNG_ALLOCATED);
1535
    PNG_ALLOCATED);
1928
 
Line 1536... Line 1929...
1536
/* Added at libpng version 1.4.0 */
1929
/* Added at libpng version 1.2.4 */
1537
PNG_EXPORTA(95, png_voidp, png_calloc,
1930
PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr,
1538
    (png_structp png_ptr, png_alloc_size_t size), 
1931
    png_alloc_size_t size), PNG_ALLOCATED);
1539
    PNG_ALLOCATED);
1932
 
Line 1564... Line 1957...
1564
#define PNG_FREE_SPLT 0x0020
1957
#define PNG_FREE_SPLT 0x0020
1565
#define PNG_FREE_ROWS 0x0040
1958
#define PNG_FREE_ROWS 0x0040
1566
#define PNG_FREE_PCAL 0x0080
1959
#define PNG_FREE_PCAL 0x0080
1567
#define PNG_FREE_SCAL 0x0100
1960
#define PNG_FREE_SCAL 0x0100
1568
#define PNG_FREE_UNKN 0x0200
1961
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-
 
1962
#  define PNG_FREE_UNKN 0x0200
1569
#define PNG_FREE_LIST 0x0400
1963
#endif
-
 
1964
/*      PNG_FREE_LIST 0x0400    removed in 1.6.0 because it is ignored */
1570
#define PNG_FREE_PLTE 0x1000
1965
#define PNG_FREE_PLTE 0x1000
1571
#define PNG_FREE_TRNS 0x2000
1966
#define PNG_FREE_TRNS 0x2000
1572
#define PNG_FREE_TEXT 0x4000
1967
#define PNG_FREE_TEXT 0x4000
1573
#define PNG_FREE_ALL  0x7fff
1968
#define PNG_FREE_ALL  0x7fff
1574
#define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
1969
#define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
1575
 
1970
 
Line 1576... Line 1971...
1576
#ifdef PNG_USER_MEM_SUPPORTED
1971
#ifdef PNG_USER_MEM_SUPPORTED
1577
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_structp png_ptr, 
1972
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
1578
    png_alloc_size_t size), PNG_ALLOCATED);
1973
    png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);
1579
PNG_EXPORT(101, void, png_free_default, (png_structp png_ptr, png_voidp ptr));
1974
PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,
-
 
1975
    png_voidp ptr), PNG_DEPRECATED);
1580
#endif
1976
#endif
Line 1581... Line 1977...
1581
 
1977
 
1582
#ifdef PNG_ERROR_TEXT_SUPPORTED
1978
#ifdef PNG_ERROR_TEXT_SUPPORTED
1583
/* Fatal error in PNG image of libpng - can't continue */
1979
/* Fatal error in PNG image of libpng - can't continue */
1584
PNG_EXPORTA(102, void, png_error,
1980
PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,
1585
    (png_structp png_ptr, png_const_charp error_message), 
-
 
Line 1586... Line 1981...
1586
    PNG_NORETURN);
1981
    png_const_charp error_message), PNG_NORETURN);
1587
 
1982
 
1588
/* The same, but the chunk name is prepended to the error string. */
1983
/* The same, but the chunk name is prepended to the error string. */
Line 1589... Line 1984...
1589
PNG_EXPORTA(103, void, png_chunk_error, (png_structp png_ptr, 
1984
PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,
1590
    png_const_charp error_message), PNG_NORETURN);
1985
    png_const_charp error_message), PNG_NORETURN);
1591
 
1986
 
1592
#else
1987
#else
Line -... Line 1988...
-
 
1988
/* Fatal error in PNG image of libpng - can't continue */
1593
/* Fatal error in PNG image of libpng - can't continue */
1989
PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);
1594
PNG_EXPORTA(104, void, png_err, (png_structp png_ptr), PNG_NORETURN);
1990
#endif
1595
#endif
1991
 
Line 1596... Line 1992...
1596
 
1992
#ifdef PNG_WARNINGS_SUPPORTED
1597
/* Non-fatal error in libpng.  Can continue, but may have a problem. */
1993
/* Non-fatal error in libpng.  Can continue, but may have a problem. */
1598
PNG_EXPORT(105, void, png_warning, (png_structp png_ptr, 
1994
PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,
-
 
1995
    png_const_charp warning_message));
Line 1599... Line 1996...
1599
    png_const_charp warning_message));
1996
 
1600
 
1997
/* Non-fatal error in libpng, chunk name is prepended to message. */
1601
/* Non-fatal error in libpng, chunk name is prepended to message. */
1998
PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,
1602
PNG_EXPORT(106, void, png_chunk_warning, (png_structp png_ptr, 
-
 
1603
    png_const_charp warning_message));
1999
    png_const_charp warning_message));
1604
 
2000
#endif
Line -... Line 2001...
-
 
2001
 
1605
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
2002
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
1606
/* Benign error in libpng.  Can continue, but may have a problem.
-
 
1607
 * User can choose whether to handle as a fatal error or as a warning. */
2003
/* Benign error in libpng.  Can continue, but may have a problem.
1608
#  undef png_benign_error
2004
 * User can choose whether to handle as a fatal error or as a warning. */
-
 
2005
PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr,
Line 1609... Line 2006...
1609
PNG_EXPORT(107, void, png_benign_error, (png_structp png_ptr, 
2006
    png_const_charp warning_message));
1610
    png_const_charp warning_message));
2007
 
1611
 
2008
#ifdef PNG_READ_SUPPORTED
1612
/* Same, chunk name is prepended to message. */
2009
/* Same, chunk name is prepended to message (only during read) */
1613
#  undef png_chunk_benign_error
2010
PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr,
1614
PNG_EXPORT(108, void, png_chunk_benign_error, (png_structp png_ptr, 
2011
    png_const_charp warning_message));
1615
    png_const_charp warning_message));
2012
#endif
Line 1638... Line 2035...
1638
 * to avoid problems with future changes in the size and internal layout of
2035
 * to avoid problems with future changes in the size and internal layout of
1639
 * png_info_struct.
2036
 * png_info_struct.
1640
 */
2037
 */
1641
/* Returns "flag" if chunk data is valid in info_ptr. */
2038
/* Returns "flag" if chunk data is valid in info_ptr. */
1642
PNG_EXPORT(110, png_uint_32, png_get_valid,
2039
PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,
1643
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2040
    png_const_inforp info_ptr, png_uint_32 flag));
1644
    png_uint_32 flag));
2041
 
1645
 
-
 
Line 1646... Line 2042...
1646
/* Returns number of bytes needed to hold a transformed row. */
2042
/* Returns number of bytes needed to hold a transformed row. */
1647
PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structp png_ptr, 
2043
PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr,
1648
    png_const_infop info_ptr));
2044
    png_const_inforp info_ptr));
Line 1649... Line 2045...
1649
 
2045
 
1650
#ifdef PNG_INFO_IMAGE_SUPPORTED
2046
#ifdef PNG_INFO_IMAGE_SUPPORTED
1651
/* Returns row_pointers, which is an array of pointers to scanlines that was
2047
/* Returns row_pointers, which is an array of pointers to scanlines that was
1652
 * returned from png_read_png().
2048
 * returned from png_read_png().
1653
 */
2049
 */
1654
PNG_EXPORT(112, png_bytepp, png_get_rows,
2050
PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr,
-
 
2051
    png_const_inforp info_ptr));
1655
    (png_const_structp png_ptr, png_const_infop info_ptr));
2052
 
1656
/* Set row_pointers, which is an array of pointers to scanlines for use
2053
/* Set row_pointers, which is an array of pointers to scanlines for use
1657
 * by png_write_png().
2054
 * by png_write_png().
1658
 */
2055
 */
1659
PNG_EXPORT(113, void, png_set_rows, (png_structp png_ptr,
2056
PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr,
1660
    png_infop info_ptr, png_bytepp row_pointers));
2057
    png_inforp info_ptr, png_bytepp row_pointers));
Line 1661... Line 2058...
1661
#endif
2058
#endif
1662
 
2059
 
1663
/* Returns number of color channels in image. */
2060
/* Returns number of color channels in image. */
Line 1664... Line 2061...
1664
PNG_EXPORT(114, png_byte, png_get_channels,
2061
PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr,
1665
    (png_const_structp png_ptr, png_const_infop info_ptr));
2062
    png_const_inforp info_ptr));
1666
 
2063
 
1667
#ifdef PNG_EASY_ACCESS_SUPPORTED
2064
#ifdef PNG_EASY_ACCESS_SUPPORTED
Line 1668... Line 2065...
1668
/* Returns image width in pixels. */
2065
/* Returns image width in pixels. */
1669
PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structp png_ptr, 
2066
PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr,
1670
    png_const_infop info_ptr));
2067
    png_const_inforp info_ptr));
Line 1671... Line 2068...
1671
 
2068
 
1672
/* Returns image height in pixels. */
2069
/* Returns image height in pixels. */
1673
PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structp png_ptr, 
2070
PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr,
Line 1674... Line 2071...
1674
    png_const_infop info_ptr));
2071
    png_const_inforp info_ptr));
1675
 
2072
 
1676
/* Returns image bit_depth. */
2073
/* Returns image bit_depth. */
Line 1677... Line 2074...
1677
PNG_EXPORT(117, png_byte, png_get_bit_depth,
2074
PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr,
1678
    (png_const_structp png_ptr, png_const_infop info_ptr));
2075
    png_const_inforp info_ptr));
1679
 
2076
 
Line 1680... Line 2077...
1680
/* Returns image color_type. */
2077
/* Returns image color_type. */
1681
PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structp png_ptr, 
2078
PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr,
1682
    png_const_infop info_ptr));
2079
    png_const_inforp info_ptr));
Line 1683... Line 2080...
1683
 
2080
 
1684
/* Returns image filter_type. */
2081
/* Returns image filter_type. */
1685
PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structp png_ptr, 
2082
PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr,
Line 1686... Line 2083...
1686
    png_const_infop info_ptr));
2083
    png_const_inforp info_ptr));
1687
 
2084
 
1688
/* Returns image interlace_type. */
2085
/* Returns image interlace_type. */
1689
PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structp png_ptr, 
2086
PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr,
1690
    png_const_infop info_ptr));
2087
    png_const_inforp info_ptr));
1691
 
2088
 
1692
/* Returns image compression_type. */
2089
/* Returns image compression_type. */
Line 1693... Line 2090...
1693
PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structp png_ptr, 
2090
PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr,
1694
    png_const_infop info_ptr));
2091
    png_const_inforp info_ptr));
1695
 
2092
 
1696
/* Returns image resolution in pixels per meter, from pHYs chunk data. */
2093
/* Returns image resolution in pixels per meter, from pHYs chunk data. */
1697
PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,
2094
PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,
Line 1698... Line 2095...
1698
    (png_const_structp png_ptr, png_const_infop info_ptr));
2095
    (png_const_structrp png_ptr, png_const_inforp info_ptr));
1699
PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,
2096
PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,
1700
    (png_const_structp png_ptr, png_const_infop info_ptr));
2097
    (png_const_structrp png_ptr, png_const_inforp info_ptr));
1701
PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,
2098
PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,
1702
    (png_const_structp png_ptr, png_const_infop info_ptr));
2099
    (png_const_structrp png_ptr, png_const_inforp info_ptr));
1703
 
2100
 
1704
/* Returns pixel aspect ratio, computed from pHYs chunk data.  */
2101
/* Returns pixel aspect ratio, computed from pHYs chunk data.  */
1705
PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,
2102
PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,
1706
    (png_const_structp png_ptr, png_const_infop info_ptr));
2103
    (png_const_structrp png_ptr, png_const_inforp info_ptr))
Line 1707... Line 2104...
1707
PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, 
2104
PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,
Line -... Line 2105...
-
 
2105
    (png_const_structrp png_ptr, png_const_inforp info_ptr))
1708
    (png_const_structp png_ptr, png_const_infop info_ptr));
2106
 
1709
 
2107
/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
1710
/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
2108
PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,
-
 
2109
    (png_const_structrp png_ptr, png_const_inforp info_ptr));
Line 1711... Line 2110...
1711
PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,
2110
PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,
1712
    (png_const_structp png_ptr, png_const_infop info_ptr));
2111
    (png_const_structrp png_ptr, png_const_inforp info_ptr));
1713
PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,
-
 
1714
    (png_const_structp png_ptr, png_const_infop info_ptr));
2112
PNG_EXPORT(128, png_int_32, png_get_x_offset_microns,
1715
PNG_EXPORT(128, png_int_32, png_get_x_offset_microns,
2113
    (png_const_structrp png_ptr, png_const_inforp info_ptr));
Line 1716... Line 2114...
1716
    (png_const_structp png_ptr, png_const_infop info_ptr));
2114
PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
1717
PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
2115
    (png_const_structrp png_ptr, png_const_inforp info_ptr));
1718
    (png_const_structp png_ptr, png_const_infop info_ptr));
2116
 
1719
 
2117
#endif /* PNG_EASY_ACCESS_SUPPORTED */
Line 1720... Line 2118...
1720
#endif /* PNG_EASY_ACCESS_SUPPORTED */
2118
 
1721
 
2119
#ifdef PNG_READ_SUPPORTED
1722
/* Returns pointer to signature string read from PNG header */
2120
/* Returns pointer to signature string read from PNG header */
1723
PNG_EXPORT(130, png_const_bytep, png_get_signature,
2121
PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr,
1724
    (png_const_structp png_ptr, png_infop info_ptr));
2122
    png_const_inforp info_ptr));
-
 
2123
#endif
-
 
2124
 
1725
 
2125
#ifdef PNG_bKGD_SUPPORTED
-
 
2126
PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr,
1726
#ifdef PNG_bKGD_SUPPORTED
2127
    png_inforp info_ptr, png_color_16p *background));
1727
PNG_EXPORT(131, png_uint_32, png_get_bKGD,
2128
#endif
1728
    (png_const_structp png_ptr, png_infop info_ptr, 
2129
 
1729
    png_color_16p *background));
2130
#ifdef PNG_bKGD_SUPPORTED
-
 
2131
PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr,
-
 
2132
    png_inforp info_ptr, png_const_color_16p background));
-
 
2133
#endif
-
 
2134
 
-
 
2135
#ifdef PNG_cHRM_SUPPORTED
1730
#endif
2136
PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr,
1731
 
2137
    png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x,
-
 
2138
    double *red_y, double *green_x, double *green_y, double *blue_x,
1732
#ifdef PNG_bKGD_SUPPORTED
2139
    double *blue_y))
1733
PNG_EXPORT(132, void, png_set_bKGD, (png_structp png_ptr, png_infop info_ptr, 
-
 
1734
    png_const_color_16p background));
2140
PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr,
Line 1735... Line 2141...
1735
#endif
2141
    png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z,
1736
 
2142
    double *green_X, double *green_Y, double *green_Z, double *blue_X,
1737
#ifdef PNG_cHRM_SUPPORTED
2143
    double *blue_Y, double *blue_Z))
1738
PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr, 
2144
PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
1739
   png_const_infop info_ptr, double *white_x, double *white_y, double *red_x, 
2145
    (png_const_structrp png_ptr, png_const_inforp info_ptr,
-
 
2146
    png_fixed_point *int_white_x, png_fixed_point *int_white_y,
-
 
2147
    png_fixed_point *int_red_x, png_fixed_point *int_red_y,
-
 
2148
    png_fixed_point *int_green_x, png_fixed_point *int_green_y,
-
 
2149
    png_fixed_point *int_blue_x, png_fixed_point *int_blue_y))
1740
    double *red_y, double *green_x, double *green_y, double *blue_x, 
2150
PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,
1741
    double *blue_y));
2151
    (png_const_structrp png_ptr, png_const_inforp info_ptr,
1742
#ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */
2152
    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
1743
PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
2153
    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
1744
    (png_const_structp png_ptr, 
2154
    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
1745
    png_const_infop info_ptr, png_fixed_point *int_white_x, 
2155
    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
-
 
2156
    png_fixed_point *int_blue_Z))
-
 
2157
#endif
-
 
2158
 
-
 
2159
#ifdef PNG_cHRM_SUPPORTED
-
 
2160
PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr,
-
 
2161
    png_inforp info_ptr,
1746
    png_fixed_point *int_white_y, png_fixed_point *int_red_x, 
2162
    double white_x, double white_y, double red_x, double red_y, double green_x,
Line 1747... Line 2163...
1747
    png_fixed_point *int_red_y, png_fixed_point *int_green_x, 
2163
    double green_y, double blue_x, double blue_y))
1748
    png_fixed_point *int_green_y, png_fixed_point *int_blue_x, 
2164
PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr,
1749
    png_fixed_point *int_blue_y));
2165
    png_inforp info_ptr, double red_X, double red_Y, double red_Z,
1750
#endif
-
 
1751
#endif
2166
    double green_X, double green_Y, double green_Z, double blue_X,
1752
 
2167
    double blue_Y, double blue_Z))
1753
#ifdef PNG_cHRM_SUPPORTED
2168
PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,
1754
PNG_FP_EXPORT(135, void, png_set_cHRM,
2169
    png_inforp info_ptr, png_fixed_point int_white_x,
Line 1755... Line 2170...
1755
    (png_structp png_ptr, png_infop info_ptr, 
2170
    png_fixed_point int_white_y, png_fixed_point int_red_x,
1756
    double white_x, double white_y, double red_x, double red_y, double green_x, 
2171
    png_fixed_point int_red_y, png_fixed_point int_green_x,
1757
    double green_y, double blue_x, double blue_y));
2172
    png_fixed_point int_green_y, png_fixed_point int_blue_x,
1758
PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structp png_ptr, 
2173
    png_fixed_point int_blue_y))
1759
    png_infop info_ptr, png_fixed_point int_white_x, 
2174
PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
1760
    png_fixed_point int_white_y, png_fixed_point int_red_x, 
2175
    png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,
Line 1761... Line 2176...
1761
    png_fixed_point int_red_y, png_fixed_point int_green_x, 
2176
    png_fixed_point int_red_Z, png_fixed_point int_green_X,
1762
    png_fixed_point int_green_y, png_fixed_point int_blue_x, 
2177
    png_fixed_point int_green_Y, png_fixed_point int_green_Z,
1763
    png_fixed_point int_blue_y));
-
 
1764
#endif
2178
    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
1765
 
2179
    png_fixed_point int_blue_Z))
Line 1766... Line 2180...
1766
#ifdef PNG_gAMA_SUPPORTED
2180
#endif
1767
PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA,
2181
 
1768
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2182
#ifdef PNG_gAMA_SUPPORTED
1769
    double *file_gamma));
2183
PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,
Line 1770... Line 2184...
1770
PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,
2184
    png_const_inforp info_ptr, double *file_gamma))
1771
    (png_const_structp png_ptr, png_const_infop info_ptr,
2185
PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,
1772
    png_fixed_point *int_file_gamma));
2186
    (png_const_structrp png_ptr, png_const_inforp info_ptr,
1773
#endif
2187
    png_fixed_point *int_file_gamma))
1774
 
2188
#endif
1775
#ifdef PNG_gAMA_SUPPORTED
2189
 
1776
PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr,
2190
#ifdef PNG_gAMA_SUPPORTED
1777
    png_infop info_ptr, double file_gamma));
2191
PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,
1778
PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_structp png_ptr, 
2192
    png_inforp info_ptr, double file_gamma))
Line 1779... Line 2193...
1779
    png_infop info_ptr, png_fixed_point int_file_gamma));
2193
PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,
1780
#endif
2194
    png_inforp info_ptr, png_fixed_point int_file_gamma))
1781
 
2195
#endif
1782
#ifdef PNG_hIST_SUPPORTED
2196
 
1783
PNG_EXPORT(141, png_uint_32, png_get_hIST,
2197
#ifdef PNG_hIST_SUPPORTED
Line 1784... Line 2198...
1784
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2198
PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
1785
    png_uint_16p *hist));
2199
    png_inforp info_ptr, png_uint_16p *hist));
1786
#endif
2200
#endif
1787
 
2201
 
1788
#ifdef PNG_hIST_SUPPORTED
2202
#ifdef PNG_hIST_SUPPORTED
Line 1789... Line 2203...
1789
PNG_EXPORT(142, void, png_set_hIST, (png_structp png_ptr,
2203
PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,
1790
    png_infop info_ptr, png_const_uint_16p hist));
2204
    png_inforp info_ptr, png_const_uint_16p hist));
1791
#endif
2205
#endif
1792
 
2206
 
1793
PNG_EXPORT(143, png_uint_32, png_get_IHDR,
-
 
1794
    (png_structp png_ptr, png_infop info_ptr, 
2207
PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr,
1795
    png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, 
2208
    png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height,
Line 1796... Line 2209...
1796
    int *interlace_method, int *compression_method, int *filter_method));
2209
    int *bit_depth, int *color_type, int *interlace_method,
1797
 
2210
    int *compression_method, int *filter_method));
1798
PNG_EXPORT(144, void, png_set_IHDR,
-
 
1799
    (png_structp png_ptr, png_infop info_ptr, 
2211
 
1800
    png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, 
2212
PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr,
1801
    int interlace_method, int compression_method, int filter_method));
2213
    png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
Line 1802... Line 2214...
1802
 
2214
    int color_type, int interlace_method, int compression_method,
1803
#ifdef PNG_oFFs_SUPPORTED
2215
    int filter_method));
1804
PNG_EXPORT(145, png_uint_32, png_get_oFFs,
2216
 
1805
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2217
#ifdef PNG_oFFs_SUPPORTED
1806
    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type));
2218
PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr,
Line 1807... Line 2219...
1807
#endif
2219
   png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
1808
 
2220
   int *unit_type));
1809
#ifdef PNG_oFFs_SUPPORTED
-
 
1810
PNG_EXPORT(146, void, png_set_oFFs,
2221
#endif
1811
    (png_structp png_ptr, png_infop info_ptr, 
2222
 
Line 1812... Line 2223...
1812
    png_int_32 offset_x, png_int_32 offset_y, int unit_type));
2223
#ifdef PNG_oFFs_SUPPORTED
1813
#endif
-
 
1814
 
2224
PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,
1815
#ifdef PNG_pCAL_SUPPORTED
2225
    png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y,
1816
PNG_EXPORT(147, png_uint_32, png_get_pCAL,
2226
    int unit_type));
1817
    (png_const_structp png_ptr, png_const_infop info_ptr, 
-
 
1818
    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type,
2227
#endif
Line 1819... Line 2228...
1819
    int *nparams, 
2228
 
1820
    png_charp *units, png_charpp *params));
2229
#ifdef PNG_pCAL_SUPPORTED
1821
#endif
-
 
1822
 
2230
PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,
1823
#ifdef PNG_pCAL_SUPPORTED
2231
    png_inforp info_ptr, png_charp *purpose, png_int_32 *X0,
Line 1824... Line 2232...
1824
PNG_EXPORT(148, void, png_set_pCAL, (png_structp png_ptr,
2232
    png_int_32 *X1, int *type, int *nparams, png_charp *units,
1825
    png_infop info_ptr, 
2233
    png_charpp *params));
1826
    png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, 
2234
#endif
1827
    int nparams, png_const_charp units, png_charpp params));
2235
 
Line 1828... Line 2236...
1828
#endif
2236
#ifdef PNG_pCAL_SUPPORTED
1829
 
2237
PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr,
1830
#ifdef PNG_pHYs_SUPPORTED
2238
    png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1,
1831
PNG_EXPORT(149, png_uint_32, png_get_pHYs,
2239
    int type, int nparams, png_const_charp units, png_charpp params));
Line 1832... Line 2240...
1832
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2240
#endif
1833
    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
2241
 
1834
#endif
2242
#ifdef PNG_pHYs_SUPPORTED
1835
 
2243
PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr,
1836
#ifdef PNG_pHYs_SUPPORTED
2244
    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
1837
PNG_EXPORT(150, void, png_set_pHYs,
2245
    int *unit_type));
Line 1838... Line 2246...
1838
    (png_structp png_ptr, png_infop info_ptr, 
2246
#endif
1839
    png_uint_32 res_x, png_uint_32 res_y, int unit_type));
2247
 
1840
#endif
-
 
1841
 
2248
#ifdef PNG_pHYs_SUPPORTED
1842
PNG_EXPORT(151, png_uint_32, png_get_PLTE,
2249
PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,
1843
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2250
    png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
Line 1844... Line 2251...
1844
    png_colorp *palette, int *num_palette));
2251
#endif
1845
 
2252
 
1846
PNG_EXPORT(152, void, png_set_PLTE,
-
 
1847
    (png_structp png_ptr, png_infop info_ptr, 
2253
PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,
1848
    png_const_colorp palette, int num_palette));
2254
   png_inforp info_ptr, png_colorp *palette, int *num_palette));
1849
 
2255
 
Line 1850... Line 2256...
1850
#ifdef PNG_sBIT_SUPPORTED
2256
PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,
1851
PNG_EXPORT(153, png_uint_32, png_get_sBIT,
2257
    png_inforp info_ptr, png_const_colorp palette, int num_palette));
1852
    (png_const_structp png_ptr, png_infop info_ptr, 
-
 
1853
    png_color_8p *sig_bit));
2258
 
1854
#endif
2259
#ifdef PNG_sBIT_SUPPORTED
Line 1855... Line 2260...
1855
 
2260
PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr,
1856
#ifdef PNG_sBIT_SUPPORTED
2261
    png_inforp info_ptr, png_color_8p *sig_bit));
1857
PNG_EXPORT(154, void, png_set_sBIT,
-
 
1858
    (png_structp png_ptr, png_infop info_ptr, png_const_color_8p sig_bit));
2262
#endif
1859
#endif
2263
 
Line 1860... Line 2264...
1860
 
2264
#ifdef PNG_sBIT_SUPPORTED
1861
#ifdef PNG_sRGB_SUPPORTED
2265
PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr,
1862
PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structp png_ptr,
2266
    png_inforp info_ptr, png_const_color_8p sig_bit));
1863
    png_const_infop info_ptr, int *file_srgb_intent));
-
 
1864
#endif
2267
#endif
1865
 
2268
 
Line 1866... Line 2269...
1866
#ifdef PNG_sRGB_SUPPORTED
2269
#ifdef PNG_sRGB_SUPPORTED
1867
PNG_EXPORT(156, void, png_set_sRGB,
2270
PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr,
1868
    (png_structp png_ptr, png_infop info_ptr, int srgb_intent));
2271
    png_const_inforp info_ptr, int *file_srgb_intent));
1869
PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_structp png_ptr, 
2272
#endif
1870
    png_infop info_ptr, int srgb_intent));
2273
 
1871
#endif
2274
#ifdef PNG_sRGB_SUPPORTED
Line 1872... Line 2275...
1872
 
2275
PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr,
1873
#ifdef PNG_iCCP_SUPPORTED
2276
    png_inforp info_ptr, int srgb_intent));
1874
PNG_EXPORT(158, png_uint_32, png_get_iCCP,
-
 
1875
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2277
PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,
1876
    png_charpp name, int *compression_type, png_bytepp profile, 
2278
    png_inforp info_ptr, int srgb_intent));
Line 1877... Line 2279...
1877
    png_uint_32 *proflen));
2279
#endif
1878
#endif
2280
 
1879
 
2281
#ifdef PNG_iCCP_SUPPORTED
1880
#ifdef PNG_iCCP_SUPPORTED
2282
PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,
Line 1881... Line 2283...
1881
PNG_EXPORT(159, void, png_set_iCCP,
2283
    png_inforp info_ptr, png_charpp name, int *compression_type,
1882
    (png_structp png_ptr, png_infop info_ptr, 
2284
    png_bytepp profile, png_uint_32 *proflen));
1883
    png_const_charp name, int compression_type, png_const_bytep profile, 
2285
#endif
1884
    png_uint_32 proflen));
2286
 
Line 1885... Line 2287...
1885
#endif
2287
#ifdef PNG_iCCP_SUPPORTED
1886
 
2288
PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,
1887
#ifdef PNG_sPLT_SUPPORTED
2289
    png_inforp info_ptr, png_const_charp name, int compression_type,
1888
PNG_EXPORT(160, png_uint_32, png_get_sPLT,
2290
    png_const_bytep profile, png_uint_32 proflen));
1889
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2291
#endif
Line 1890... Line 2292...
1890
    png_sPLT_tpp entries));
2292
 
1891
#endif
2293
#ifdef PNG_sPLT_SUPPORTED
1892
 
-
 
1893
#ifdef PNG_sPLT_SUPPORTED
2294
PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,
1894
PNG_EXPORT(161, void, png_set_sPLT,
2295
    png_inforp info_ptr, png_sPLT_tpp entries));
1895
    (png_structp png_ptr, png_infop info_ptr, 
2296
#endif
Line 1896... Line 2297...
1896
    png_const_sPLT_tp entries, int nentries));
2297
 
1897
#endif
2298
#ifdef PNG_sPLT_SUPPORTED
1898
 
2299
PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,
1899
#ifdef PNG_TEXT_SUPPORTED
2300
    png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));
1900
/* png_get_text also returns the number of text chunks in *num_text */
2301
#endif
1901
PNG_EXPORT(162, png_uint_32, png_get_text,
2302
 
1902
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2303
#ifdef PNG_TEXT_SUPPORTED
1903
    png_textp *text_ptr, int *num_text));
2304
/* png_get_text also returns the number of text chunks in *num_text */
1904
#endif
2305
PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,
1905
 
2306
    png_inforp info_ptr, png_textp *text_ptr, int *num_text));
1906
/* Note while png_set_text() will accept a structure whose text, 
2307
#endif
1907
 * language, and  translated keywords are NULL pointers, the structure
2308
 
1908
 * returned by png_get_text will always contain regular
-
 
1909
 * zero-terminated C strings.  They might be empty strings but
2309
/* Note while png_set_text() will accept a structure whose text,
1910
 * they will never be NULL pointers.
2310
 * language, and  translated keywords are NULL pointers, the structure
1911
 */
2311
 * returned by png_get_text will always contain regular
1912
 
2312
 * zero-terminated C strings.  They might be empty strings but
1913
#ifdef PNG_TEXT_SUPPORTED
2313
 * they will never be NULL pointers.
Line 1914... Line 2314...
1914
PNG_EXPORT(163, void, png_set_text,
2314
 */
1915
    (png_structp png_ptr, png_infop info_ptr, 
-
 
1916
    png_const_textp text_ptr, int num_text));
2315
 
1917
#endif
2316
#ifdef PNG_TEXT_SUPPORTED
1918
 
2317
PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,
1919
#ifdef PNG_tIME_SUPPORTED
2318
    png_inforp info_ptr, png_const_textp text_ptr, int num_text));
1920
PNG_EXPORT(164, png_uint_32, png_get_tIME,
2319
#endif
1921
    (png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time));
2320
 
1922
#endif
2321
#ifdef PNG_tIME_SUPPORTED
1923
 
2322
PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr,
Line -... Line 2323...
-
 
2323
    png_inforp info_ptr, png_timep *mod_time));
-
 
2324
#endif
-
 
2325
 
-
 
2326
#ifdef PNG_tIME_SUPPORTED
-
 
2327
PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr,
-
 
2328
    png_inforp info_ptr, png_const_timep mod_time));
-
 
2329
#endif
-
 
2330
 
-
 
2331
#ifdef PNG_tRNS_SUPPORTED
-
 
2332
PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr,
-
 
2333
    png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans,
-
 
2334
    png_color_16p *trans_color));
-
 
2335
#endif
-
 
2336
 
-
 
2337
#ifdef PNG_tRNS_SUPPORTED
-
 
2338
PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,
-
 
2339
    png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans,
-
 
2340
    png_const_color_16p trans_color));
-
 
2341
#endif
-
 
2342
 
-
 
2343
#ifdef PNG_sCAL_SUPPORTED
-
 
2344
PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,
-
 
2345
    png_const_inforp info_ptr, int *unit, double *width, double *height))
-
 
2346
#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
-
 
2347
   defined(PNG_FLOATING_POINT_SUPPORTED)
-
 
2348
/* NOTE: this API is currently implemented using floating point arithmetic,
-
 
2349
 * consequently it can only be used on systems with floating point support.
-
 
2350
 * In any case the range of values supported by png_fixed_point is small and it
-
 
2351
 * is highly recommended that png_get_sCAL_s be used instead.
-
 
2352
 */
-
 
2353
PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,
-
 
2354
    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
-
 
2355
    png_fixed_point *width, png_fixed_point *height))
-
 
2356
#endif
-
 
2357
PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
-
 
2358
    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
-
 
2359
    png_charpp swidth, png_charpp sheight));
-
 
2360
 
-
 
2361
PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,
-
 
2362
    png_inforp info_ptr, int unit, double width, double height))
-
 
2363
PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,
-
 
2364
   png_inforp info_ptr, int unit, png_fixed_point width,
-
 
2365
   png_fixed_point height))
-
 
2366
PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
-
 
2367
    png_inforp info_ptr, int unit,
-
 
2368
    png_const_charp swidth, png_const_charp sheight));
-
 
2369
#endif /* PNG_sCAL_SUPPORTED */
1924
#ifdef PNG_tIME_SUPPORTED
2370
 
1925
PNG_EXPORT(165, void, png_set_tIME,
2371
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
1926
    (png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time));
2372
/* Provide the default handling for all unknown chunks or, optionally, for
-
 
2373
 * specific unknown chunks.
1927
#endif
2374
 *
-
 
2375
 * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was
1928
 
2376
 * ignored and the default was used, the per-chunk setting only had an effect on
-
 
2377
 * write.  If you wish to have chunk-specific handling on read in code that must
-
 
2378
 * work on earlier versions you must use a user chunk callback to specify the
-
 
2379
 * desired handling (keep or discard.)
-
 
2380
 *
-
 
2381
 * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below.  The
-
 
2382
 * parameter is interpreted as follows:
-
 
2383
 *
-
 
2384
 * READ:
-
 
2385
 *    PNG_HANDLE_CHUNK_AS_DEFAULT:
-
 
2386
 *       Known chunks: do normal libpng processing, do not keep the chunk (but
-
 
2387
 *          see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
-
 
2388
 *       Unknown chunks: for a specific chunk use the global default, when used
-
 
2389
 *          as the default discard the chunk data.
-
 
2390
 *    PNG_HANDLE_CHUNK_NEVER:
-
 
2391
 *       Discard the chunk data.
-
 
2392
 *    PNG_HANDLE_CHUNK_IF_SAFE:
-
 
2393
 *       Keep the chunk data if the chunk is not critical else raise a chunk
-
 
2394
 *       error.
-
 
2395
 *    PNG_HANDLE_CHUNK_ALWAYS:
1929
#ifdef PNG_tRNS_SUPPORTED
2396
 *       Keep the chunk data.
-
 
2397
 *
-
 
2398
 * If the chunk data is saved it can be retrieved using png_get_unknown_chunks,
-
 
2399
 * below.  Notice that specifying "AS_DEFAULT" as a global default is equivalent
1930
PNG_EXPORT(166, png_uint_32, png_get_tRNS,
2400
 * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks
-
 
2401
 * it simply resets the behavior to the libpng default.
-
 
2402
 *
-
 
2403
 * INTERACTION WTIH USER CHUNK CALLBACKS:
-
 
2404
 * The per-chunk handling is always used when there is a png_user_chunk_ptr
-
 
2405
 * callback and the callback returns 0; the chunk is then always stored *unless*
-
 
2406
 * it is critical and the per-chunk setting is other than ALWAYS.  Notice that
-
 
2407
 * the global default is *not* used in this case.  (In effect the per-chunk
-
 
2408
 * value is incremented to at least IF_SAFE.)
-
 
2409
 *
-
 
2410
 * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and
-
 
2411
 * per-chunk defaults will be honored.  If you want to preserve the current
1931
    (png_const_structp png_ptr, png_infop info_ptr, 
2412
 * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE
-
 
2413
 * as the default - if you don't do this libpng 1.6 will issue a warning.
-
 
2414
 *
1932
    png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color));
2415
 * If you want unhandled unknown chunks to be discarded in libpng 1.6 and
-
 
2416
 * earlier simply return '1' (handled).
-
 
2417
 *
-
 
2418
 * PNG_HANDLE_AS_UNKNOWN_SUPPORTED:
-
 
2419
 *    If this is *not* set known chunks will always be handled by libpng and
-
 
2420
 *    will never be stored in the unknown chunk list.  Known chunks listed to
1933
#endif
2421
 *    png_set_keep_unknown_chunks will have no effect.  If it is set then known
1934
 
2422
 *    chunks listed with a keep other than AS_DEFAULT will *never* be processed
1935
#ifdef PNG_tRNS_SUPPORTED
2423
 *    by libpng, in addition critical chunks must either be processed by the
-
 
2424
 *    callback or saved.
-
 
2425
 *
-
 
2426
 *    The IHDR and IEND chunks must not be listed.  Because this turns off the
1936
PNG_EXPORT(167, void, png_set_tRNS,
2427
 *    default handling for chunks that would otherwise be recognized the
-
 
2428
 *    behavior of libpng transformations may well become incorrect!
1937
    (png_structp png_ptr, png_infop info_ptr, 
2429
 *
1938
    png_const_bytep trans_alpha, int num_trans, 
2430
 * WRITE:
1939
    png_const_color_16p trans_color));
2431
 *    When writing chunks the options only apply to the chunks specified by
-
 
2432
 *    png_set_unknown_chunks (below), libpng will *always* write known chunks
1940
#endif
2433
 *    required by png_set_ calls and will always write the core critical chunks
1941
 
2434
 *    (as required for PLTE).
1942
#ifdef PNG_sCAL_SUPPORTED
2435
 *
1943
PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL,
2436
 *    Each chunk in the png_set_unknown_chunks list is looked up in the
-
 
2437
 *    png_set_keep_unknown_chunks list to find the keep setting, this is then
-
 
2438
 *    interpreted as follows:
-
 
2439
 *
-
 
2440
 *    PNG_HANDLE_CHUNK_AS_DEFAULT:
-
 
2441
 *       Write safe-to-copy chunks and write other chunks if the global
-
 
2442
 *       default is set to _ALWAYS, otherwise don't write this chunk.
-
 
2443
 *    PNG_HANDLE_CHUNK_NEVER:
-
 
2444
 *       Do not write the chunk.
-
 
2445
 *    PNG_HANDLE_CHUNK_IF_SAFE:
1944
    (png_const_structp png_ptr, png_const_infop info_ptr, 
2446
 *       Write the chunk if it is safe-to-copy, otherwise do not write it.
1945
    int *unit, double *width, double *height));
2447
 *    PNG_HANDLE_CHUNK_ALWAYS:
-
 
2448
 *       Write the chunk.
1946
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
2449
 *
1947
/* NOTE: this API is currently implemented using floating point arithmetic, 
2450
 * Note that the default behavior is effectively the opposite of the read case -
1948
 * consequently it can only be used on systems with floating point support.
2451
 * in read unknown chunks are not stored by default, in write they are written
Line 1949... Line 2452...
1949
 * In any case the range of values supported by png_fixed_point is small and it
2452
 * by default.  Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different
1950
 * is highly recommended that png_get_sCAL_s be used instead.
2453
 * - on write the safe-to-copy bit is checked, on read the critical bit is
1951
 */
2454
 * checked and on read if the chunk is critical an error will be raised.
1952
PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,
2455
 *
1953
    (png_structp png_ptr, png_const_infop info_ptr, int *unit,
2456
 * num_chunks:
1954
    png_fixed_point *width, 
2457
 * ===========
Line 1955... Line 2458...
1955
    png_fixed_point *height));
2458
 *    If num_chunks is positive, then the "keep" parameter specifies the manner
1956
#endif
2459
 *    for handling only those chunks appearing in the chunk_list array,
1957
PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
2460
 *    otherwise the chunk list array is ignored.
1958
    (png_const_structp png_ptr, png_const_infop info_ptr,
2461
 *
1959
    int *unit, png_charpp swidth, png_charpp sheight));
2462
 *    If num_chunks is 0 the "keep" parameter specifies the default behavior for
1960
 
2463
 *    unknown chunks, as described above.
1961
PNG_FP_EXPORT(170, void, png_set_sCAL,
2464
 *
Line 1962... Line 2465...
1962
    (png_structp png_ptr, png_infop info_ptr, 
2465
 *    If num_chunks is negative, then the "keep" parameter specifies the manner
1963
    int unit, double width, double height));
2466
 *    for handling all unknown chunks plus all chunks recognized by libpng
1964
PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_structp png_ptr, 
2467
 *    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
1965
   png_infop info_ptr, int unit, png_fixed_point width, 
2468
 *    be processed by libpng.
1966
   png_fixed_point height));
2469
 */
1967
PNG_EXPORT(171, void, png_set_sCAL_s,
2470
PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
1968
    (png_structp png_ptr, png_infop info_ptr, 
2471
    int keep, png_const_bytep chunk_list, int num_chunks));
1969
    int unit, png_const_charp swidth, png_const_charp sheight));
2472
 
Line 1970... Line 2473...
1970
#endif /* PNG_sCAL_SUPPORTED */
2473
/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
1971
 
2474
 * the result is therefore true (non-zero) if special handling is required,
1972
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
2475
 * false for the default handling.
1973
/* Provide a list of chunks and how they are to be handled, if the built-in
2476
 */
Line 1974... Line 2477...
1974
   handling or default unknown chunk handling is not desired.  Any chunks not
2477
PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
1975
   listed will be handled in the default manner.  The IHDR and IEND chunks
2478
    png_const_bytep chunk_name));
1976
   must not be listed.
2479
#endif
1977
      keep = 0: follow default behaviour
2480
 
1978
           = 1: do not keep
2481
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-
 
2482
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
Line 1979... Line 2483...
1979
           = 2: keep only if safe-to-copy
2483
    png_inforp info_ptr, png_const_unknown_chunkp unknowns,
1980
           = 3: keep even if unsafe-to-copy
2484
    int num_unknowns));
1981
*/
2485
   /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added
1982
PNG_EXPORT(172, void, png_set_keep_unknown_chunks,
2486
    * unknowns to the location currently stored in the png_struct.  This is
1983
    (png_structp png_ptr, int keep, 
2487
    * invariably the wrong value on write.  To fix this call the following API
1984
    png_const_bytep chunk_list, int num_chunks));
-
 
1985
PNG_EXPORT(173, int, png_handle_as_unknown, (png_structp png_ptr, 
2488
    * for each chunk in the list with the correct location.  If you know your
1986
    png_const_bytep chunk_name));
2489
    * code won't be compiled on earlier versions you can rely on
Line 1987... Line 2490...
1987
#endif
2490
    * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing
1988
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
2491
    * the correct thing.
1989
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_structp png_ptr, 
2492
    */
1990
    png_infop info_ptr, png_const_unknown_chunkp unknowns,
2493
 
1991
    int num_unknowns));
2494
PNG_EXPORT(175, void, png_set_unknown_chunk_location,
1992
PNG_EXPORT(175, void, png_set_unknown_chunk_location,
2495
    (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));
1993
    (png_structp png_ptr, png_infop info_ptr, int chunk, int location));
2496
 
1994
PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structp png_ptr, 
2497
PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,
1995
    png_const_infop info_ptr, png_unknown_chunkpp entries));
2498
    png_inforp info_ptr, png_unknown_chunkpp entries));
1996
#endif
2499
#endif
1997
 
2500
 
1998
/* Png_free_data() will turn off the "valid" flag for anything it frees.
2501
/* Png_free_data() will turn off the "valid" flag for anything it frees.
1999
 * If you need to turn it off for a chunk that your application has freed, 
2502
 * If you need to turn it off for a chunk that your application has freed,
2000
 * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);
2503
 * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);
2001
 */
2504
 */
2002
PNG_EXPORT(177, void, png_set_invalid,
2505
PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,
2003
    (png_structp png_ptr, png_infop info_ptr, int mask));
2506
    png_inforp info_ptr, int mask));
2004
 
2507
 
2005
#ifdef PNG_INFO_IMAGE_SUPPORTED
2508
#ifdef PNG_INFO_IMAGE_SUPPORTED
Line 2006... Line 2509...
2006
/* The "params" pointer is currently not used and is for future expansion. */
2509
/* The "params" pointer is currently not used and is for future expansion. */
2007
PNG_EXPORT(178, void, png_read_png, (png_structp png_ptr, png_infop info_ptr, 
2510
PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,
2008
    int transforms, png_voidp params));
2511
    int transforms, png_voidp params));
Line 2009... Line 2512...
2009
PNG_EXPORT(179, void, png_write_png, (png_structp png_ptr, png_infop info_ptr, 
2512
PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,
2010
    int transforms, png_voidp params));
2513
    int transforms, png_voidp params));
Line 2011... Line 2514...
2011
#endif
2514
#endif
2012
 
2515
 
Line 2013... Line 2516...
2013
PNG_EXPORT(180, png_const_charp, png_get_copyright,
2516
PNG_EXPORT(180, png_const_charp, png_get_copyright,
2014
    (png_const_structp png_ptr));
2517
    (png_const_structrp png_ptr));
2015
PNG_EXPORT(181, png_const_charp, png_get_header_ver,
2518
PNG_EXPORT(181, png_const_charp, png_get_header_ver,
2016
    (png_const_structp png_ptr));
2519
    (png_const_structrp png_ptr));
2017
PNG_EXPORT(182, png_const_charp, png_get_header_version,
2520
PNG_EXPORT(182, png_const_charp, png_get_header_version,
2018
    (png_const_structp png_ptr));
2521
    (png_const_structrp png_ptr));
Line 2019... Line 2522...
2019
PNG_EXPORT(183, png_const_charp, png_get_libpng_ver,
2522
PNG_EXPORT(183, png_const_charp, png_get_libpng_ver,
2020
    (png_const_structp png_ptr));
2523
    (png_const_structrp png_ptr));
2021
 
2524
 
2022
#ifdef PNG_MNG_FEATURES_SUPPORTED
2525
#ifdef PNG_MNG_FEATURES_SUPPORTED
2023
PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structp png_ptr, 
2526
PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,
2024
    png_uint_32 mng_features_permitted));
2527
    png_uint_32 mng_features_permitted));
Line 2025... Line 2528...
2025
#endif
2528
#endif
2026
 
2529
 
2027
/* For use in png_set_keep_unknown, added to version 1.2.6 */
2530
/* For use in png_set_keep_unknown, added to version 1.2.6 */
2028
#define PNG_HANDLE_CHUNK_AS_DEFAULT   0
2531
#define PNG_HANDLE_CHUNK_AS_DEFAULT   0
2029
#define PNG_HANDLE_CHUNK_NEVER        1
2532
#define PNG_HANDLE_CHUNK_NEVER        1
2030
#define PNG_HANDLE_CHUNK_IF_SAFE      2
2533
#define PNG_HANDLE_CHUNK_IF_SAFE      2
Line 2031... Line 2534...
2031
#define PNG_HANDLE_CHUNK_ALWAYS       3
2534
#define PNG_HANDLE_CHUNK_ALWAYS       3
2032
 
2535
#define PNG_HANDLE_CHUNK_LAST         4
2033
/* Strip the prepended error numbers ("#nnn ") from error and warning
2536
 
-
 
2537
/* Strip the prepended error numbers ("#nnn ") from error and warning
-
 
2538
 * messages before passing them to the error or warning handler.
-
 
2539
 */
-
 
2540
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
Line 2034... Line -...
2034
 * messages before passing them to the error or warning handler.
-
 
2035
 */
-
 
2036
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
2541
PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr,
2037
PNG_EXPORT(185, void, png_set_strip_error_numbers,
2542
    png_uint_32 strip_mode));
Line 2038... Line 2543...
2038
    (png_structp png_ptr, 
2543
#endif
2039
    png_uint_32 strip_mode));
2544
 
2040
#endif
2545
/* Added in libpng-1.2.6 */
2041
 
2546
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
Line 2120... Line 2625...
2120
/* Two macros to return the first row and first column of the original,
2625
/* Two macros to return the first row and first column of the original,
2121
 * full, image which appears in a given pass.  'pass' is in the range 0
2626
 * full, image which appears in a given pass.  'pass' is in the range 0
2122
 * to 6 and the result is in the range 0 to 7.
2627
 * to 6 and the result is in the range 0 to 7.
2123
 */
2628
 */
2124
#define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7)
2629
#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)
2125
#define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7)
2630
#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)
-
 
2631
 
-
 
2632
/* A macro to return the offset between pixels in the output row for a pair of
-
 
2633
 * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that
-
 
2634
 * follows.  Note that ROW_OFFSET is the offset from one row to the next whereas
-
 
2635
 * COL_OFFSET is from one column to the next, within a row.
-
 
2636
 */
-
 
2637
#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)
-
 
2638
#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))
Line 2126... Line 2639...
2126
 
2639
 
2127
/* Two macros to help evaluate the number of rows or columns in each
2640
/* Two macros to help evaluate the number of rows or columns in each
2128
 * pass.  This is expressed as a shift - effectively log2 of the number or
2641
 * pass.  This is expressed as a shift - effectively log2 of the number or
2129
 * rows or columns in each 8x8 tile of the original image.
2642
 * rows or columns in each 8x8 tile of the original image.
Line 2140... Line 2653...
2140
   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))
2653
   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))
2141
#define PNG_PASS_COLS(width, pass) (((width)+(((1<
2654
#define PNG_PASS_COLS(width, pass) (((width)+(((1<
2142
   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))
2655
   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))
2143
 
2656
 
Line 2144... Line 2657...
2144
/* For the progressive reader it is necessary to find the row in the output
2657
/* For the reader row callbacks (both progressive and sequential) it is
2145
 * image given a row in an interlaced image, so two more macros:
2658
 * necessary to find the row in the output image given a row in an interlaced
-
 
2659
 * image, so two more macros:
2146
 */
2660
 */
2147
#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \
2661
#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \
2148
   (((yIn)<
2662
   (((y_in)<
2149
#define PNG_COL_FROM_PASS_COL(xIn, pass) \
2663
#define PNG_COL_FROM_PASS_COL(x_in, pass) \
2150
   (((xIn)<
2664
   (((x_in)<
Line 2151... Line 2665...
2151
 
2665
 
2152
/* Two macros which return a boolean (0 or 1) saying whether the given row
2666
/* Two macros which return a boolean (0 or 1) saying whether the given row
2153
 * or column is in a particular pass.  These use a common utility macro that
2667
 * or column is in a particular pass.  These use a common utility macro that
2154
 * returns a mask for a given pass - the offset 'off' selects the row or
2668
 * returns a mask for a given pass - the offset 'off' selects the row or
2155
 * column version.  The mask has the appropriate bit set for each column in
2669
 * column version.  The mask has the appropriate bit set for each column in
2156
 * the tile.
2670
 * the tile.
2157
 */
2671
 */
2158
#define PNG_PASS_MASK(pass,off) ( \
2672
#define PNG_PASS_MASK(pass,off) ( \
2159
   ((0x110145AFU>>(((7-(off))-(pass))<<2)) & 0xFU) | \
2673
   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \
Line 2160... Line 2674...
2160
   ((0x01145AF0U>>(((7-(off))-(pass))<<2)) & 0xF0U))
2674
   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))
2161
 
2675
 
2162
#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
2676
#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
2163
   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
2677
   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
Line 2182... Line 2696...
2182
#  define png_composite(composite, fg, alpha, bg)         \
2696
#  define png_composite(composite, fg, alpha, bg)         \
2183
     { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
2697
     { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
2184
           * (png_uint_16)(alpha)                         \
2698
           * (png_uint_16)(alpha)                         \
2185
           + (png_uint_16)(bg)*(png_uint_16)(255          \
2699
           + (png_uint_16)(bg)*(png_uint_16)(255          \
2186
           - (png_uint_16)(alpha)) + (png_uint_16)128);   \
2700
           - (png_uint_16)(alpha)) + 128);                \
2187
       (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
2701
       (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
Line 2188... Line 2702...
2188
 
2702
 
2189
#  define png_composite_16(composite, fg, alpha, bg)       \
2703
#  define png_composite_16(composite, fg, alpha, bg)       \
2190
     { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \
2704
     { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \
2191
           * (png_uint_32)(alpha)                          \
2705
           * (png_uint_32)(alpha)                          \
2192
           + (png_uint_32)(bg)*(png_uint_32)(65535L        \
2706
           + (png_uint_32)(bg)*(65535                      \
2193
           - (png_uint_32)(alpha)) + (png_uint_32)32768L); \
2707
           - (png_uint_32)(alpha)) + 32768);               \
Line 2194... Line 2708...
2194
       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
2708
       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
Line 2195... Line 2709...
2195
 
2709
 
2196
#else  /* Standard method using integer division */
2710
#else  /* Standard method using integer division */
2197
 
2711
 
2198
#  define png_composite(composite, fg, alpha, bg)                          \
2712
#  define png_composite(composite, fg, alpha, bg)                          \
Line 2199... Line 2713...
2199
     (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \
2713
     (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \
2200
     (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \
2714
     (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \
2201
     (png_uint_16)127) / 255)
2715
     127) / 255)
2202
 
2716
 
2203
#  define png_composite_16(composite, fg, alpha, bg)                         \
2717
#  define png_composite_16(composite, fg, alpha, bg)                         \
Line 2204... Line 2718...
2204
     (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
2718
     (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
2205
     (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) +        \
2719
     (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +         \
2206
     (png_uint_32)32767) / (png_uint_32)65535L)
2720
     32767) / 65535)
2207
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
2721
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
2208
 
2722
 
Line 2209... Line 2723...
2209
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
2723
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
2210
PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
2724
PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
2211
PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
2725
PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
Line 2212... Line 2726...
2212
PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));
2726
PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));
2213
#endif
2727
#endif
Line 2237... Line 2751...
2237
/* Inline macros to do direct reads of bytes from the input buffer.
2751
/* Inline macros to do direct reads of bytes from the input buffer.
2238
 * The png_get_int_32() routine assumes we are using two's complement
2752
 * The png_get_int_32() routine assumes we are using two's complement
2239
 * format for negative values, which is almost certainly true.
2753
 * format for negative values, which is almost certainly true.
2240
 */
2754
 */
2241
#  define png_get_uint_32(buf) \
2755
#  define PNG_get_uint_32(buf) \
2242
     (((png_uint_32)(*(buf)) << 24) + \
2756
     (((png_uint_32)(*(buf)) << 24) + \
2243
      ((png_uint_32)(*((buf) + 1)) << 16) + \
2757
      ((png_uint_32)(*((buf) + 1)) << 16) + \
2244
      ((png_uint_32)(*((buf) + 2)) << 8) + \
2758
      ((png_uint_32)(*((buf) + 2)) << 8) + \
2245
      ((png_uint_32)(*((buf) + 3))))
2759
      ((png_uint_32)(*((buf) + 3))))
2246
 
2760
 
Line 2247... Line 2761...
2247
   /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
2761
   /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
2248
    * function) incorrectly returned a value of type png_uint_32.
2762
    * function) incorrectly returned a value of type png_uint_32.
2249
    */
2763
    */
2250
#  define png_get_uint_16(buf) \
2764
#  define PNG_get_uint_16(buf) \
2251
     ((png_uint_16) \
2765
     ((png_uint_16) \
2252
      (((unsigned int)(*(buf)) << 8) + \
2766
      (((unsigned int)(*(buf)) << 8) + \
2253
       ((unsigned int)(*((buf) + 1)))))
2767
       ((unsigned int)(*((buf) + 1)))))
Line 2254... Line 2768...
2254
 
2768
 
2255
#  define png_get_int_32(buf) \
2769
#  define PNG_get_int_32(buf) \
2256
     ((png_int_32)((*(buf) & 0x80) \
2770
     ((png_int_32)((*(buf) & 0x80) \
2257
      ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
2771
      ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
-
 
2772
      : (png_int_32)png_get_uint_32(buf)))
-
 
2773
 
-
 
2774
   /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
-
 
2775
    * but defining a macro name prefixed with PNG_PREFIX.
-
 
2776
    */
-
 
2777
#  ifndef PNG_PREFIX
-
 
2778
#     define png_get_uint_32(buf) PNG_get_uint_32(buf)
-
 
2779
#     define png_get_uint_16(buf) PNG_get_uint_16(buf)
-
 
2780
#     define png_get_int_32(buf)  PNG_get_int_32(buf)
-
 
2781
#  endif
-
 
2782
#else
-
 
2783
#  ifdef PNG_PREFIX
-
 
2784
      /* No macros; revert to the (redefined) function */
-
 
2785
#     define PNG_get_uint_32 (png_get_uint_32)
-
 
2786
#     define PNG_get_uint_16 (png_get_uint_16)
-
 
2787
#     define PNG_get_int_32  (png_get_int_32)
2258
      : (png_int_32)png_get_uint_32(buf)))
2788
#  endif
Line -... Line 2789...
-
 
2789
#endif
-
 
2790
 
-
 
2791
/*******************************************************************************
-
 
2792
 *  SIMPLIFIED API
-
 
2793
 *******************************************************************************
-
 
2794
 *
-
 
2795
 * Please read the documentation in libpng-manual.txt (TODO: write said
-
 
2796
 * documentation) if you don't understand what follows.
-
 
2797
 *
-
 
2798
 * The simplified API hides the details of both libpng and the PNG file format
-
 
2799
 * itself.  It allows PNG files to be read into a very limited number of
-
 
2800
 * in-memory bitmap formats or to be written from the same formats.  If these
-
 
2801
 * formats do not accomodate your needs then you can, and should, use the more
-
 
2802
 * sophisticated APIs above - these support a wide variety of in-memory formats
-
 
2803
 * and a wide variety of sophisticated transformations to those formats as well
-
 
2804
 * as a wide variety of APIs to manipulate ancillary information.
-
 
2805
 *
-
 
2806
 * To read a PNG file using the simplified API:
-
 
2807
 *
-
 
2808
 * 1) Declare a 'png_image' structure (see below) on the stack and set the
-
 
2809
 *    version field to PNG_IMAGE_VERSION.
-
 
2810
 * 2) Call the appropriate png_image_begin_read... function.
-
 
2811
 * 3) Set the png_image 'format' member to the required sample format.
-
 
2812
 * 4) Allocate a buffer for the image and, if required, the color-map.
-
 
2813
 * 5) Call png_image_finish_read to read the image and, if required, the
-
 
2814
 *    color-map into your buffers.
-
 
2815
 *
-
 
2816
 * There are no restrictions on the format of the PNG input itself; all valid
-
 
2817
 * color types, bit depths, and interlace methods are acceptable, and the
-
 
2818
 * input image is transformed as necessary to the requested in-memory format
-
 
2819
 * during the png_image_finish_read() step.  The only caveat is that if you
-
 
2820
 * request a color-mapped image from a PNG that is full-color or makes
-
 
2821
 * complex use of an alpha channel the transformation is extremely lossy and the
-
 
2822
 * result may look terrible.
-
 
2823
 *
-
 
2824
 * To write a PNG file using the simplified API:
-
 
2825
 *
-
 
2826
 * 1) Declare a 'png_image' structure on the stack and memset() it to all zero.
-
 
2827
 * 2) Initialize the members of the structure that describe the image, setting
-
 
2828
 *    the 'format' member to the format of the image samples.
-
 
2829
 * 3) Call the appropriate png_image_write... function with a pointer to the
-
 
2830
 *    image and, if necessary, the color-map to write the PNG data.
-
 
2831
 *
-
 
2832
 * png_image is a structure that describes the in-memory format of an image
-
 
2833
 * when it is being read or defines the in-memory format of an image that you
-
 
2834
 * need to write:
-
 
2835
 */
-
 
2836
#define PNG_IMAGE_VERSION 1
-
 
2837
 
-
 
2838
typedef struct png_control *png_controlp;
-
 
2839
typedef struct
-
 
2840
{
-
 
2841
   png_controlp opaque;    /* Initialize to NULL, free with png_image_free */
-
 
2842
   png_uint_32  version;   /* Set to PNG_IMAGE_VERSION */
-
 
2843
   png_uint_32  width;     /* Image width in pixels (columns) */
-
 
2844
   png_uint_32  height;    /* Image height in pixels (rows) */
-
 
2845
   png_uint_32  format;    /* Image format as defined below */
-
 
2846
   png_uint_32  flags;     /* A bit mask containing informational flags */
-
 
2847
   png_uint_32  colormap_entries;
-
 
2848
                           /* Number of entries in the color-map */
-
 
2849
 
-
 
2850
   /* In the event of an error or warning the following field will be set to a
-
 
2851
    * non-zero value and the 'message' field will contain a '\0' terminated
-
 
2852
    * string with the libpng error or warning message.  If both warnings and
-
 
2853
    * an error were encountered, only the error is recorded.  If there
-
 
2854
    * are multiple warnings, only the first one is recorded.
-
 
2855
    *
-
 
2856
    * The upper 30 bits of this value are reserved, the low two bits contain
-
 
2857
    * a value as follows:
-
 
2858
    */
-
 
2859
#  define PNG_IMAGE_WARNING 1
-
 
2860
#  define PNG_IMAGE_ERROR 2
-
 
2861
   /*
-
 
2862
    * The result is a two bit code such that a value more than 1 indicates
-
 
2863
    * a failure in the API just called:
-
 
2864
    *
-
 
2865
    *    0 - no warning or error
-
 
2866
    *    1 - warning
-
 
2867
    *    2 - error
-
 
2868
    *    3 - error preceded by warning
-
 
2869
    */
-
 
2870
#  define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1)
-
 
2871
 
-
 
2872
   png_uint_32  warning_or_error;
-
 
2873
 
-
 
2874
   char         message[64];
-
 
2875
} png_image, *png_imagep;
-
 
2876
 
-
 
2877
/* The samples of the image have one to four channels whose components have
-
 
2878
 * original values in the range 0 to 1.0:
-
 
2879
 *
-
 
2880
 * 1: A single gray or luminance channel (G).
-
 
2881
 * 2: A gray/luminance channel and an alpha channel (GA).
-
 
2882
 * 3: Three red, green, blue color channels (RGB).
-
 
2883
 * 4: Three color channels and an alpha channel (RGBA).
-
 
2884
 *
-
 
2885
 * The components are encoded in one of two ways:
-
 
2886
 *
-
 
2887
 * a) As a small integer, value 0..255, contained in a single byte.  For the
-
 
2888
 * alpha channel the original value is simply value/255.  For the color or
-
 
2889
 * luminance channels the value is encoded according to the sRGB specification
-
 
2890
 * and matches the 8-bit format expected by typical display devices.
-
 
2891
 *
-
 
2892
 * The color/gray channels are not scaled (pre-multiplied) by the alpha
-
 
2893
 * channel and are suitable for passing to color management software.
-
 
2894
 *
-
 
2895
 * b) As a value in the range 0..65535, contained in a 2-byte integer.  All
-
 
2896
 * channels can be converted to the original value by dividing by 65535; all
-
 
2897
 * channels are linear.  Color channels use the RGB encoding (RGB end-points) of
-
 
2898
 * the sRGB specification.  This encoding is identified by the
-
 
2899
 * PNG_FORMAT_FLAG_LINEAR flag below.
-
 
2900
 *
-
 
2901
 * When the simplified API needs to convert between sRGB and linear colorspaces,
-
 
2902
 * the actual sRGB transfer curve defined in the sRGB specification (see the
-
 
2903
 * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
-
 
2904
 * approximation used elsewhere in libpng.
-
 
2905
 *
-
 
2906
 * When an alpha channel is present it is expected to denote pixel coverage
-
 
2907
 * of the color or luminance channels and is returned as an associated alpha
-
 
2908
 * channel: the color/gray channels are scaled (pre-multiplied) by the alpha
-
 
2909
 * value.
-
 
2910
 *
-
 
2911
 * The samples are either contained directly in the image data, between 1 and 8
-
 
2912
 * bytes per pixel according to the encoding, or are held in a color-map indexed
-
 
2913
 * by bytes in the image data.  In the case of a color-map the color-map entries
-
 
2914
 * are individual samples, encoded as above, and the image data has one byte per
-
 
2915
 * pixel to select the relevant sample from the color-map.
-
 
2916
 */
-
 
2917
 
-
 
2918
/* PNG_FORMAT_*
-
 
2919
 *
-
 
2920
 * #defines to be used in png_image::format.  Each #define identifies a
-
 
2921
 * particular layout of sample data and, if present, alpha values.  There are
-
 
2922
 * separate defines for each of the two component encodings.
-
 
2923
 *
-
 
2924
 * A format is built up using single bit flag values.  All combinations are
-
 
2925
 * valid.  Formats can be built up from the flag values or you can use one of
-
 
2926
 * the predefined values below.  When testing formats always use the FORMAT_FLAG
-
 
2927
 * macros to test for individual features - future versions of the library may
-
 
2928
 * add new flags.
-
 
2929
 *
-
 
2930
 * When reading or writing color-mapped images the format should be set to the
-
 
2931
 * format of the entries in the color-map then png_image_{read,write}_colormap
-
 
2932
 * called to read or write the color-map and set the format correctly for the
-
 
2933
 * image data.  Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!
-
 
2934
 *
-
 
2935
 * NOTE: libpng can be built with particular features disabled, if you see
-
 
2936
 * compiler errors because the definition of one of the following flags has been
-
 
2937
 * compiled out it is because libpng does not have the required support.  It is
-
 
2938
 * possible, however, for the libpng configuration to enable the format on just
-
 
2939
 * read or just write; in that case you may see an error at run time.  You can
-
 
2940
 * guard against this by checking for the definition of the appropriate
-
 
2941
 * "_SUPPORTED" macro, one of:
-
 
2942
 *
-
 
2943
 *    PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED
-
 
2944
 */
-
 
2945
#define PNG_FORMAT_FLAG_ALPHA    0x01U /* format with an alpha channel */
-
 
2946
#define PNG_FORMAT_FLAG_COLOR    0x02U /* color format: otherwise grayscale */
-
 
2947
#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2 byte channels else 1 byte */
-
 
2948
#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */
-
 
2949
 
-
 
2950
#ifdef PNG_FORMAT_BGR_SUPPORTED
-
 
2951
#  define PNG_FORMAT_FLAG_BGR    0x10U /* BGR colors, else order is RGB */
-
 
2952
#endif
-
 
2953
 
-
 
2954
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
-
 
2955
#  define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */
-
 
2956
#endif
-
 
2957
 
-
 
2958
/* Commonly used formats have predefined macros.
-
 
2959
 *
-
 
2960
 * First the single byte (sRGB) formats:
-
 
2961
 */
-
 
2962
#define PNG_FORMAT_GRAY 0
-
 
2963
#define PNG_FORMAT_GA   PNG_FORMAT_FLAG_ALPHA
-
 
2964
#define PNG_FORMAT_AG   (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)
-
 
2965
#define PNG_FORMAT_RGB  PNG_FORMAT_FLAG_COLOR
-
 
2966
#define PNG_FORMAT_BGR  (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)
-
 
2967
#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)
-
 
2968
#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)
-
 
2969
#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)
-
 
2970
#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)
-
 
2971
 
-
 
2972
/* Then the linear 2-byte formats.  When naming these "Y" is used to
-
 
2973
 * indicate a luminance (gray) channel.
-
 
2974
 */
-
 
2975
#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR
-
 
2976
#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)
-
 
2977
#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)
-
 
2978
#define PNG_FORMAT_LINEAR_RGB_ALPHA \
-
 
2979
   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)
-
 
2980
 
-
 
2981
/* With color-mapped formats the image data is one byte for each pixel, the byte
-
 
2982
 * is an index into the color-map which is formatted as above.  To obtain a
-
 
2983
 * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP
-
 
2984
 * to one of the above definitions, or you can use one of the definitions below.
-
 
2985
 */
-
 
2986
#define PNG_FORMAT_RGB_COLORMAP  (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)
-
 
2987
#define PNG_FORMAT_BGR_COLORMAP  (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)
-
 
2988
#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)
-
 
2989
#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)
-
 
2990
#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)
-
 
2991
#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)
-
 
2992
 
-
 
2993
/* PNG_IMAGE macros
-
 
2994
 *
-
 
2995
 * These are convenience macros to derive information from a png_image
-
 
2996
 * structure.  The PNG_IMAGE_SAMPLE_ macros return values appropriate to the
-
 
2997
 * actual image sample values - either the entries in the color-map or the
-
 
2998
 * pixels in the image.  The PNG_IMAGE_PIXEL_ macros return corresponding values
-
 
2999
 * for the pixels and will always return 1 for color-mapped formats.  The
-
 
3000
 * remaining macros return information about the rows in the image and the
-
 
3001
 * complete image.
-
 
3002
 *
-
 
3003
 * NOTE: All the macros that take a png_image::format parameter are compile time
-
 
3004
 * constants if the format parameter is, itself, a constant.  Therefore these
-
 
3005
 * macros can be used in array declarations and case labels where required.
-
 
3006
 * Similarly the macros are also pre-processor constants (sizeof is not used) so
-
 
3007
 * they can be used in #if tests.
-
 
3008
 *
-
 
3009
 * First the information about the samples.
-
 
3010
 */
-
 
3011
#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\
-
 
3012
   (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1)
-
 
3013
   /* Return the total number of channels in a given format: 1..4 */
-
 
3014
 
-
 
3015
#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\
-
 
3016
   ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)
-
 
3017
   /* Return the size in bytes of a single component of a pixel or color-map
-
 
3018
    * entry (as appropriate) in the image: 1 or 2.
-
 
3019
    */
-
 
3020
 
-
 
3021
#define PNG_IMAGE_SAMPLE_SIZE(fmt)\
-
 
3022
   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))
-
 
3023
   /* This is the size of the sample data for one sample.  If the image is
-
 
3024
    * color-mapped it is the size of one color-map entry (and image pixels are
-
 
3025
    * one byte in size), otherwise it is the size of one image pixel.
-
 
3026
    */
-
 
3027
 
-
 
3028
#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\
-
 
3029
   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)
-
 
3030
   /* The maximum size of the color-map required by the format expressed in a
-
 
3031
    * count of components.  This can be used to compile-time allocate a
-
 
3032
    * color-map:
-
 
3033
    *
-
 
3034
    * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)];
-
 
3035
    *
-
 
3036
    * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];
-
 
3037
    *
-
 
3038
    * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
-
 
3039
    * information from one of the png_image_begin_read_ APIs and dynamically
-
 
3040
    * allocate the required memory.
-
 
3041
    */
-
 
3042
 
-
 
3043
/* Corresponding information about the pixels */
-
 
3044
#define PNG_IMAGE_PIXEL_(test,fmt)\
-
 
3045
   (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt))
-
 
3046
 
-
 
3047
#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\
-
 
3048
   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt)
-
 
3049
   /* The number of separate channels (components) in a pixel; 1 for a
-
 
3050
    * color-mapped image.
-
 
3051
    */
-
 
3052
 
-
 
3053
#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\
-
 
3054
   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)
-
 
3055
   /* The size, in bytes, of each component in a pixel; 1 for a color-mapped
-
 
3056
    * image.
-
 
3057
    */
-
 
3058
 
-
 
3059
#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)
-
 
3060
   /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */
-
 
3061
 
-
 
3062
/* Information about the whole row, or whole image */
-
 
3063
#define PNG_IMAGE_ROW_STRIDE(image)\
-
 
3064
   (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)
-
 
3065
   /* Return the total number of components in a single row of the image; this
-
 
3066
    * is the minimum 'row stride', the minimum count of components between each
-
 
3067
    * row.  For a color-mapped image this is the minimum number of bytes in a
-
 
3068
    * row.
-
 
3069
    */
-
 
3070
 
-
 
3071
#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
-
 
3072
   (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))
-
 
3073
   /* Return the size, in bytes, of an image buffer given a png_image and a row
-
 
3074
    * stride - the number of components to leave space for in each row.
-
 
3075
    */
-
 
3076
 
-
 
3077
#define PNG_IMAGE_SIZE(image)\
-
 
3078
   PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))
-
 
3079
   /* Return the size, in bytes, of the image in memory given just a png_image;
-
 
3080
    * the row stride is the minimum stride required for the image.
-
 
3081
    */
-
 
3082
 
-
 
3083
#define PNG_IMAGE_COLORMAP_SIZE(image)\
-
 
3084
   (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)
-
 
3085
   /* Return the size, in bytes, of the color-map of this image.  If the image
-
 
3086
    * format is not a color-map format this will return a size sufficient for
-
 
3087
    * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if
-
 
3088
    * you don't want to allocate a color-map in this case.
-
 
3089
    */
-
 
3090
 
-
 
3091
/* PNG_IMAGE_FLAG_*
-
 
3092
 *
-
 
3093
 * Flags containing additional information about the image are held in the
-
 
3094
 * 'flags' field of png_image.
-
 
3095
 */
-
 
3096
#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01
-
 
3097
   /* This indicates the the RGB values of the in-memory bitmap do not
-
 
3098
    * correspond to the red, green and blue end-points defined by sRGB.
-
 
3099
    */
-
 
3100
 
-
 
3101
#define PNG_IMAGE_FLAG_FAST 0x02
-
 
3102
   /* On write emphasise speed over compression; the resultant PNG file will be
-
 
3103
    * larger but will be produced significantly faster, particular for large
-
 
3104
    * images.  Do not use this option for images which will be distributed, only
-
 
3105
    * used it when producing intermediate files that will be read back in
-
 
3106
    * repeatedly.  For a typical 24-bit image the option will double the read
-
 
3107
    * speed at the cost of increasing the image size by 25%, however for many
-
 
3108
    * more compressible images the PNG file can be 10 times larger with only a
-
 
3109
    * slight speed gain.
-
 
3110
    */
-
 
3111
 
-
 
3112
#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04
-
 
3113
   /* On read if the image is a 16-bit per component image and there is no gAMA
-
 
3114
    * or sRGB chunk assume that the components are sRGB encoded.  Notice that
-
 
3115
    * images output by the simplified API always have gamma information; setting
-
 
3116
    * this flag only affects the interpretation of 16-bit images from an
-
 
3117
    * external source.  It is recommended that the application expose this flag
-
 
3118
    * to the user; the user can normally easily recognize the difference between
-
 
3119
    * linear and sRGB encoding.  This flag has no effect on write - the data
-
 
3120
    * passed to the write APIs must have the correct encoding (as defined
-
 
3121
    * above.)
-
 
3122
    *
-
 
3123
    * If the flag is not set (the default) input 16-bit per component data is
-
 
3124
    * assumed to be linear.
-
 
3125
    *
-
 
3126
    * NOTE: the flag can only be set after the png_image_begin_read_ call,
-
 
3127
    * because that call initializes the 'flags' field.
-
 
3128
    */
-
 
3129
 
-
 
3130
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
-
 
3131
/* READ APIs
-
 
3132
 * ---------
-
 
3133
 *
-
 
3134
 * The png_image passed to the read APIs must have been initialized by setting
-
 
3135
 * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.)
-
 
3136
 */
-
 
3137
#ifdef PNG_STDIO_SUPPORTED
-
 
3138
PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,
-
 
3139
   const char *file_name));
-
 
3140
   /* The named file is opened for read and the image header is filled in
-
 
3141
    * from the PNG header in the file.
-
 
3142
    */
-
 
3143
 
-
 
3144
PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,
-
 
3145
   FILE* file));
-
 
3146
   /* The PNG header is read from the stdio FILE object. */
-
 
3147
#endif /* PNG_STDIO_SUPPORTED */
-
 
3148
 
-
 
3149
PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,
-
 
3150
   png_const_voidp memory, png_size_t size));
-
 
3151
   /* The PNG header is read from the given memory buffer. */
-
 
3152
 
-
 
3153
PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,
-
 
3154
   png_const_colorp background, void *buffer, png_int_32 row_stride,
-
 
3155
   void *colormap));
-
 
3156
   /* Finish reading the image into the supplied buffer and clean up the
-
 
3157
    * png_image structure.
-
 
3158
    *
-
 
3159
    * row_stride is the step, in byte or 2-byte units as appropriate,
-
 
3160
    * between adjacent rows.  A positive stride indicates that the top-most row
-
 
3161
    * is first in the buffer - the normal top-down arrangement.  A negative
-
 
3162
    * stride indicates that the bottom-most row is first in the buffer.
-
 
3163
    *
-
 
3164
    * background need only be supplied if an alpha channel must be removed from
-
 
3165
    * a png_byte format and the removal is to be done by compositing on a solid
-
 
3166
    * color; otherwise it may be NULL and any composition will be done directly
-
 
3167
    * onto the buffer.  The value is an sRGB color to use for the background,
-
 
3168
    * for grayscale output the green channel is used.
-
 
3169
    *
-
 
3170
    * background must be supplied when an alpha channel must be removed from a
-
 
3171
    * single byte color-mapped output format, in other words if:
-
 
3172
    *
-
 
3173
    * 1) The original format from png_image_begin_read_from_* had
-
 
3174
    *    PNG_FORMAT_FLAG_ALPHA set.
-
 
3175
    * 2) The format set by the application does not.
-
 
3176
    * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and
-
 
3177
    *    PNG_FORMAT_FLAG_LINEAR *not* set.
-
 
3178
    *
-
 
3179
    * For linear output removing the alpha channel is always done by compositing
-
 
3180
    * on black and background is ignored.
-
 
3181
    *
-
 
3182
    * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set.  It must
-
 
3183
    * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.
-
 
3184
    * image->colormap_entries will be updated to the actual number of entries
-
 
3185
    * written to the colormap; this may be less than the original value.
-
 
3186
    */
-
 
3187
 
-
 
3188
PNG_EXPORT(238, void, png_image_free, (png_imagep image));
-
 
3189
   /* Free any data allocated by libpng in image->opaque, setting the pointer to
-
 
3190
    * NULL.  May be called at any time after the structure is initialized.
-
 
3191
    */
-
 
3192
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
-
 
3193
 
-
 
3194
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
-
 
3195
#ifdef PNG_STDIO_SUPPORTED
-
 
3196
/* WRITE APIS
-
 
3197
 * ----------
-
 
3198
 * For write you must initialize a png_image structure to describe the image to
-
 
3199
 * be written.  To do this use memset to set the whole structure to 0 then
-
 
3200
 * initialize fields describing your image.
-
 
3201
 *
-
 
3202
 * version: must be set to PNG_IMAGE_VERSION
-
 
3203
 * opaque: must be initialized to NULL
-
 
3204
 * width: image width in pixels
-
 
3205
 * height: image height in rows
-
 
3206
 * format: the format of the data (image and color-map) you wish to write
-
 
3207
 * flags: set to 0 unless one of the defined flags applies; set
-
 
3208
 *    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB
-
 
3209
 *    values do not correspond to the colors in sRGB.
-
 
3210
 * colormap_entries: set to the number of entries in the color-map (0 to 256)
-
 
3211
 */
-
 
3212
PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
-
 
3213
   const char *file, int convert_to_8bit, const void *buffer,
-
 
3214
   png_int_32 row_stride, const void *colormap));
-
 
3215
   /* Write the image to the named file. */
-
 
3216
 
-
 
3217
PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
-
 
3218
   int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
-
 
3219
   const void *colormap));
-
 
3220
   /* Write the image to the given (FILE*). */
-
 
3221
 
-
 
3222
/* With both write APIs if image is in one of the linear formats with 16-bit
-
 
3223
 * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG
-
 
3224
 * gamma encoded according to the sRGB specification, otherwise a 16-bit linear
-
 
3225
 * encoded PNG file is written.
-
 
3226
 *
-
 
3227
 * With color-mapped data formats the colormap parameter point to a color-map
-
 
3228
 * with at least image->colormap_entries encoded in the specified format.  If
-
 
3229
 * the format is linear the written PNG color-map will be converted to sRGB
-
 
3230
 * regardless of the convert_to_8_bit flag.
-
 
3231
 *
-
 
3232
 * With all APIs row_stride is handled as in the read APIs - it is the spacing
-
 
3233
 * from one row to the next in component sized units (1 or 2 bytes) and if
-
 
3234
 * negative indicates a bottom-up row layout in the buffer.
-
 
3235
 *
-
 
3236
 * Note that the write API does not support interlacing or sub-8-bit pixels.
-
 
3237
 */
-
 
3238
#endif /* PNG_STDIO_SUPPORTED */
-
 
3239
#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */
-
 
3240
/*******************************************************************************
-
 
3241
 *  END OF SIMPLIFIED API
-
 
3242
 ******************************************************************************/
-
 
3243
 
-
 
3244
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
-
 
3245
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
-
 
3246
    (png_structrp png_ptr, int allowed));
-
 
3247
#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED
-
 
3248
PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
-
 
3249
    png_const_infop info_ptr));
-
 
3250
#  endif
-
 
3251
#endif /* CHECK_FOR_INVALID_INDEX */
-
 
3252
 
-
 
3253
/*******************************************************************************
-
 
3254
 *  IMPLEMENTATION OPTIONS
-
 
3255
 *******************************************************************************
-
 
3256
 *
-
 
3257
 * Support for arbitrary implementation-specific optimizations.  The API allows
-
 
3258
 * particular options to be turned on or off.  'Option' is the number of the
-
 
3259
 * option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given
-
 
3260
 * by the PNG_OPTION_ defines below.
-
 
3261
 *
-
 
3262
 * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
-
 
3263
 *           are detected at run time, however sometimes it may be impossible
-
 
3264
 *           to do this in user mode, in which case it is necessary to discover
-
 
3265
 *           the capabilities in an OS specific way.  Such capabilities are
-
 
3266
 *           listed here when libpng has support for them and must be turned
-
 
3267
 *           ON by the application if present.
-
 
3268
 *
-
 
3269
 * SOFTWARE: sometimes software optimizations actually result in performance
-
 
3270
 *           decrease on some architectures or systems, or with some sets of
-
 
3271
 *           PNG images.  'Software' options allow such optimizations to be
-
 
3272
 *           selected at run time.
-
 
3273
 */
-
 
3274
#ifdef PNG_SET_OPTION_SUPPORTED
-
 
3275
#ifdef PNG_ARM_NEON_API_SUPPORTED
-
 
3276
#  define PNG_ARM_NEON   0 /* HARDWARE: ARM Neon SIMD instructions supported */
-
 
3277
#endif
-
 
3278
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
-
 
3279
#define PNG_OPTION_NEXT  4 /* Next option - numbers must be even */
-
 
3280
 
-
 
3281
/* Return values: NOTE: there are four values and 'off' is *not* zero */
-
 
3282
#define PNG_OPTION_UNSET   0 /* Unset - defaults to off */
-
 
3283
#define PNG_OPTION_INVALID 1 /* Option number out of range */
-
 
3284
#define PNG_OPTION_OFF     2
-
 
3285
#define PNG_OPTION_ON      3
-
 
3286
 
-
 
3287
PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
-
 
3288
   int onoff));
-
 
3289
#endif
-
 
3290
 
-
 
3291
/*******************************************************************************
-
 
3292
 *  END OF HARDWARE OPTIONS
2259
#endif
3293
 ******************************************************************************/
2260
 
3294
 
2261
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
3295
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
Line 2262... Line 3296...
2262
 * defs
3296
 * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt
2263
 */
3297
 */
2264
 
3298
 
2265
/* The last ordinal number (this is the *last* one already used; the next
3299
/* The last ordinal number (this is the *last* one already used; the next
2266
 * one to use is one more than this.)  Maintainer, remember to add an entry to
3300
 * one to use is one more than this.)  Maintainer, remember to add an entry to
2267
 * scripts/symbols.def as well.
3301
 * scripts/symbols.def as well.
2268
 */
3302
 */
Line 2269... Line 3303...
2269
#ifdef PNG_EXPORT_LAST_ORDINAL
3303
#ifdef PNG_EXPORT_LAST_ORDINAL
2270
  PNG_EXPORT_LAST_ORDINAL(220);
3304
  PNG_EXPORT_LAST_ORDINAL(244);
2271
#endif
3305
#endif