1
2
/* png.h - header file for PNG reference library
3
* libpng version 1.2.8 - December 3, 2004
4
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
4
* libpng version 1.2.13 - November 14, 2006
5
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
5
6
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
6
7
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
8
9
* Authors and maintainers:
9
10
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
10
11
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
11
* libpng versions 0.97, January 1998, through 1.2.8 - December 3, 2004: Glenn
12
* libpng versions 0.97, January 1998, through 1.2.13 - November 14, 2006: Glenn
12
13
* See also "Contributing Authors", below.
14
15
* Note about libpng version numbers:
102
103
* 1.0.16 10 10016 10.so.0.1.0.16
103
104
* 1.2.6 13 10206 12.so.0.1.2.6
104
105
* 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
105
* 1.0.17rc1 10 10017 12.so.0.1.0.17rc1
106
* 1.0.17rc1 10 10017 10.so.0.1.0.17rc1
106
107
* 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
107
* 1.0.17 10 10017 12.so.0.1.0.17
108
* 1.0.17 10 10017 10.so.0.1.0.17
108
109
* 1.2.7 13 10207 12.so.0.1.2.7
109
110
* 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
110
* 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5
111
* 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5
111
112
* 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
112
* 1.0.18 10 10018 12.so.0.1.0.18
113
* 1.0.18 10 10018 10.so.0.1.0.18
113
114
* 1.2.8 13 10208 12.so.0.1.2.8
115
* 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
116
* 1.2.9beta4-11 13 10209 12.so.0.9[.0]
117
* 1.2.9rc1 13 10209 12.so.0.9[.0]
118
* 1.2.9 13 10209 12.so.0.9[.0]
119
* 1.2.10beta1-8 13 10210 12.so.0.10[.0]
120
* 1.2.10rc1-3 13 10210 12.so.0.10[.0]
121
* 1.2.10 13 10210 12.so.0.10[.0]
122
* 1.2.11beta1-4 13 10211 12.so.0.11[.0]
123
* 1.0.19rc1-5 10 10019 10.so.0.19[.0]
124
* 1.2.11rc1-5 13 10211 12.so.0.11[.0]
125
* 1.0.19 10 10019 10.so.0.19[.0]
126
* 1.2.11 13 10211 12.so.0.11[.0]
127
* 1.0.20 10 10020 10.so.0.20[.0]
128
* 1.2.12 13 10212 12.so.0.12[.0]
129
* 1.2.13beta1 13 10211 12.so.0.11[.0]
130
* 1.0.21 10 10021 10.so.0.21[.0]
131
* 1.2.13 13 10213 12.so.0.13[.0]
115
133
* Henceforth the source version will match the shared-library major
116
134
* and minor numbers; the shared-library major version number will be
140
158
* If you modify libpng you may insert additional notices immediately following
143
* libpng versions 1.2.6, August 15, 2004, through 1.2.8, December 3, 2004, are
144
* Copyright (c) 2004 Glenn Randers-Pehrson, and are
161
* libpng versions 1.2.6, August 15, 2004, through 1.2.13, November 14, 2006, are
162
* Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are
145
163
* distributed according to the same disclaimer and license as libpng-1.2.5
146
164
* with the following individual added to the list of Contributing Authors:
252
270
* Y2K compliance in libpng:
253
271
* =========================
257
275
* Since the PNG Development group is an ad-hoc body, we can't make
258
276
* an official declaration.
260
278
* This is your unofficial assurance that libpng from version 0.71 and
261
* upward through 1.2.8 are Y2K compliant. It is my belief that earlier
279
* upward through 1.2.13 are Y2K compliant. It is my belief that earlier
262
280
* versions were also Y2K compliant.
264
282
* Libpng only has three year fields. One is a 2-byte unsigned integer
316
334
/* Version information for png.h - this should match the version in png.c */
317
#define PNG_LIBPNG_VER_STRING "1.2.8"
335
#define PNG_LIBPNG_VER_STRING "1.2.13"
318
336
#define PNG_HEADER_VERSION_STRING \
319
" libpng version 1.2.8 - December 3, 2004 (header)\n"
337
" libpng version 1.2.13 - November 14, 2006 (header)\n"
321
339
#define PNG_LIBPNG_VER_SONUM 0
322
340
#define PNG_LIBPNG_VER_DLLNUM 13
324
342
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
325
343
#define PNG_LIBPNG_VER_MAJOR 1
326
344
#define PNG_LIBPNG_VER_MINOR 2
327
#define PNG_LIBPNG_VER_RELEASE 8
345
#define PNG_LIBPNG_VER_RELEASE 13
328
346
/* This should match the numeric part of the final component of
329
347
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
352
370
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
353
371
* version 1.0.0 was mis-numbered 100 instead of 10000). From
354
372
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
355
#define PNG_LIBPNG_VER 10208 /* 1.2.8 */
373
#define PNG_LIBPNG_VER 10213 /* 1.2.13 */
357
375
#ifndef PNG_VERSION_INFO_ONLY
358
376
/* include the compression library's header */
378
396
#if defined(PNG_USER_PRIVATEBUILD)
379
# define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE | \
380
PNG_LIBPNG_BUILD_PRIVATE
397
# define PNG_LIBPNG_BUILD_TYPE \
398
(PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
382
400
# if defined(PNG_LIBPNG_SPECIALBUILD)
383
# define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE | \
384
PNG_LIBPNG_BUILD_SPECIAL
401
# define PNG_LIBPNG_BUILD_TYPE \
402
(PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
386
# define PNG_LIBPNG_BUILD_TYPE PNG_LIBPNG_BUILD_BASE_TYPE
404
# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
455
473
PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7];
456
474
PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7];
457
475
PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7];
458
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
476
#ifdef PNG_USE_PNGGCCRD
459
477
PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7];
461
479
/* This isn't currently used. If you need it, see png.c for more details.
894
912
#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
895
913
#define PNG_UINT_32_MAX ((png_uint_32)(-1))
896
914
#define PNG_SIZE_MAX ((png_size_t)(-1))
915
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
897
916
/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
898
917
#define PNG_MAX_UINT PNG_UINT_31_MAX
900
920
/* These describe the color_type field in png_info. */
901
921
/* color type masks */
1356
1376
/* This triggers a compiler error in png.c, if png.c and png.h
1357
1377
* do not agree upon the version number.
1359
typedef png_structp version_1_2_8;
1379
typedef png_structp version_1_2_13;
1361
1381
typedef png_struct FAR * FAR * png_structpp;
1442
1462
extern PNG_EXPORT(png_infop,png_create_info_struct)
1443
1463
PNGARG((png_structp png_ptr));
1465
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
1445
1466
/* Initialize the info structure (old interface - DEPRECATED) */
1446
1467
extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr));
1447
1468
#undef png_info_init
1448
1469
#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\
1449
1470
png_sizeof(png_info));
1450
1473
extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
1451
1474
png_size_t png_info_struct_size));
1483
1506
#if defined(PNG_READ_EXPAND_SUPPORTED)
1484
1507
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
1485
1508
extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
1486
extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
1509
#if !defined(PNG_1_0_X)
1510
extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp
1487
1513
extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
1488
1514
extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
1515
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
1517
extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
1491
1521
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
1678
1710
png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
1680
1712
/* free all memory used by the read (old method - NOT DLL EXPORTED) */
1681
extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
1713
/* Debian note: exporting as it is required by legacy applications */
1714
extern PNG_EXPORT(void,png_read_destroy) PNGARG((png_structp png_ptr, png_infop info_ptr,
1682
1715
png_infop end_info_ptr));
1684
1717
/* free any memory associated with the png_struct and the png_info_structs */
1686
1719
PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
1688
1721
/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
1689
extern void png_write_destroy PNGARG((png_structp png_ptr));
1722
/* Debian note: exporting as it is required by legacy applications */
1723
extern PNG_EXPORT(void,png_write_destroy) PNGARG((png_structp png_ptr));
1691
1725
/* set the libpng method of handling chunk CRC errors */
1692
1726
extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
2327
2361
#ifdef PNG_FLOATING_POINT_SUPPORTED
2328
2362
extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
2329
2363
png_infop info_ptr, int unit, double width, double height));
2331
2365
#ifdef PNG_FIXED_POINT_SUPPORTED
2332
2366
extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
2333
2367
png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
2335
2370
#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
2337
2372
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
2427
2462
#define png_debug2(l, m, p1, p2)
2430
2466
extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
2432
2469
extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
2433
2470
extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
2573
2610
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
2612
/* Inline macros to do direct reads of bytes from the input buffer. These
2613
* require that you are using an architecture that uses PNG byte ordering
2614
* (MSB first) and supports unaligned data storage. I think that PowerPC
2615
* in big-endian mode and 680x0 are the only ones that will support this.
2616
* The x86 line of processors definitely do not. The png_get_int_32()
2617
* routine also assumes we are using two's complement format for negative
2618
* values, which is almost certainly true.
2620
#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
2621
# define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
2622
# define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
2623
# define png_get_int_32(buf) ( *((png_int_32p) (buf)))
2625
extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf));
2626
extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf));
2627
extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf));
2628
#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
2629
extern PNG_EXPORT(png_uint_32,png_get_uint_31)
2630
PNGARG((png_structp png_ptr, png_bytep buf));
2631
/* No png_get_int_16 -- may be added if there's a real need for it. */
2633
/* Place a 32-bit number into a buffer in PNG byte order (big-endian).
2635
extern PNG_EXPORT(void,png_save_uint_32)
2636
PNGARG((png_bytep buf, png_uint_32 i));
2637
extern PNG_EXPORT(void,png_save_int_32)
2638
PNGARG((png_bytep buf, png_int_32 i));
2640
/* Place a 16-bit number into a buffer in PNG byte order.
2641
* The parameter is declared unsigned int, not png_uint_16,
2642
* just to avoid potential problems on pre-ANSI C compilers.
2644
extern PNG_EXPORT(void,png_save_uint_16)
2645
PNGARG((png_bytep buf, unsigned int i));
2646
/* No png_save_int_16 -- may be added if there's a real need for it. */
2648
/* ************************************************************************* */
2575
2650
/* These next functions are used internally in the code. They generally
2576
2651
* shouldn't be used unless you are writing code to add or replace some
2577
2652
* functionality in libpng. More information about most functions can
2586
2661
#define PNG_HAVE_IHDR 0x01
2587
2662
#define PNG_HAVE_PLTE 0x02
2588
2663
#define PNG_HAVE_IDAT 0x04
2589
#define PNG_AFTER_IDAT 0x08
2664
#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
2590
2665
#define PNG_HAVE_IEND 0x10
2591
2666
#define PNG_HAVE_gAMA 0x20
2592
2667
#define PNG_HAVE_cHRM 0x40
2596
2671
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
2597
2672
#define PNG_BACKGROUND_IS_GRAY 0x800
2598
2673
#define PNG_HAVE_PNG_SIGNATURE 0x1000
2674
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
2600
2676
/* flags for the transformations the PNG library does on the image data */
2601
2677
#define PNG_BGR 0x0001
2708
2784
#ifdef PNG_USE_GLOBAL_ARRAYS
2709
2785
PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8];
2711
2788
#define png_sig png_sig_bytes(NULL)
2713
2791
#endif /* PNG_NO_EXTERN */
2715
2793
/* Constant strings for known chunk types. If you need to add a chunk,
2762
2840
PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
2763
2841
#endif /* PNG_USE_GLOBAL_ARRAYS */
2766
/* Inline macros to do direct reads of bytes from the input buffer. These
2767
* require that you are using an architecture that uses PNG byte ordering
2768
* (MSB first) and supports unaligned data storage. I think that PowerPC
2769
* in big-endian mode and 680x0 are the only ones that will support this.
2770
* The x86 line of processors definitely do not. The png_get_int_32()
2771
* routine also assumes we are using two's complement format for negative
2772
* values, which is almost certainly true.
2774
#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
2775
# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
2776
# define png_get_int_32(buf) ( *((png_int_32p) (buf)))
2778
# define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
2779
# define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
2781
# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
2782
PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
2784
PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
2785
PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
2786
#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
2787
PNG_EXTERN png_uint_32 png_get_uint_31 PNGARG((png_structp png_ptr,
2843
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
2790
2844
/* Initialize png_ptr struct for reading, and allocate any other memory.
2791
2845
* (old interface - DEPRECATED - use png_create_read_struct instead).
2794
2848
#undef png_read_init
2795
2849
#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
2796
2850
PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
2797
2853
extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
2798
2854
png_const_charp user_png_ver, png_size_t png_struct_size));
2855
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
2799
2856
extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
2800
2857
png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
2801
2858
png_info_size));
2861
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
2803
2862
/* Initialize png_ptr struct for writing, and allocate any other memory.
2804
2863
* (old interface - DEPRECATED - use png_create_write_struct instead).
2807
2866
#undef png_write_init
2808
2867
#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
2809
2868
PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
2810
2871
extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
2811
2872
png_const_charp user_png_ver, png_size_t png_struct_size));
2812
2873
extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr,
2906
2967
PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
2910
/* Place a 32-bit number into a buffer in PNG byte order (big-endian).
2911
* The only currently known PNG chunks that use signed numbers are
2912
* the ancillary extension chunks, oFFs and pCAL.
2914
PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
2916
#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
2917
PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
2920
/* Place a 16-bit number into a buffer in PNG byte order.
2921
* The parameter is declared unsigned int, not png_uint_16,
2922
* just to avoid potential problems on pre-ANSI C compilers.
2924
PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
2926
2970
/* simple function to write the signature */
2927
2971
PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
3406
3450
/* png.c */ /* PRIVATE */
3407
3451
PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr));
3454
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
3455
PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr,
3456
png_infop info_ptr));
3458
PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr,
3459
png_infop info_ptr));
3461
PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr,
3462
png_infop info_ptr));
3464
PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr,
3465
png_infop info_ptr));
3467
PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr,
3468
png_infop info_ptr));
3470
#if defined(PNG_pHYs_SUPPORTED)
3471
PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr,
3472
png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
3473
#endif /* PNG_pHYs_SUPPORTED */
3474
#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
3409
3476
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
3411
3478
#endif /* PNG_INTERNAL */